-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcombine.py
31 lines (22 loc) · 1.09 KB
/
combine.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import csv
import sys
import os
from Bio import SeqIO
import pandas as pd
for root, dirs, files in os.walk("/home/edgars.liepa/Becteria result", topdown=False):
for name in dirs:
# os.walk includes .git subdirectories. Only RAPT result folders needed, so rest should be ignored
if ".git" in os.path.join(root, name):
continue
print('parse:',os.path.join(root, name))
contigs = pd.DataFrame()
for record in SeqIO.parse(os.path.join(root, name)+'/annot.gbk', "genbank"):
print(record.id)
products = []
for feature in record.features:
if ('product') in feature.qualifiers:
print(feature.type, feature.qualifiers['product'], feature.location)
product = feature.type + str(feature.qualifiers['product'])+ str(feature.location)
products.append(product)
contigs = pd.concat([contigs, pd.DataFrame({record.id: products})], axis=1)
contigs.to_excel(os.path.join(root, name)+"/geneProducts.xlsx")