编辑:我知道feature.type
将给出gene/CDS,feature.qualifiers
将给出“db_-xref”/“location_-tag”/“推断”等。是否有一个feature.
对象,允许我直接访问该位置(例如:[5240:7267](+)
)?在
这个网址提供了更多的信息,虽然我不知道如何使用它为我的目的。。。http://biopython.org/DIST/docs/api/Bio.SeqFeature.SeqFeature-class.html#location_operator
原文:
我试图修改GenBank文件中特性的位置。基本上,我想修改GenBank文件的以下部分:
gene 5240..7267
/db_xref="GeneID:887081"
/locus_tag="Rv0005"
/gene="gyrB"
CDS 5240..7267
/locus_tag="Rv0005"
/inference="protein motif:PROSITE:PS00177"
...........................
到
^{pr2}$注意从5240到5357
到目前为止,从搜索互联网和Stackoverflow,我已经:
from Bio import SeqIO
gb_file = "mtbtomod.gb"
gb_record = SeqIO.parse(open(gb_file, "r+"), "genbank")
rvnumber = 'Rv0005'
newstart = 5357
final_features = []
for record in gb_record:
for feature in record.features:
if feature.type == "gene":
if feature.qualifiers["locus_tag"][0] == rvnumber:
if feature.location.strand == 1:
feature.qualifiers["amend_position"] = "%s:%s" % (newstart, feature.location.end+1)
else:
# do the reverse for the complementary strand
final_features.append(feature)
record.features = final_features
with open("testest.gb","w") as testest:
SeqIO.write(record, testest, "genbank")
这基本上创建了一个名为“amend_position”的新限定符。。但是,我想做的是直接修改位置(创建或不创建新文件…)
Rv0005只是我需要更新的轨迹标记的一个例子。我还有大约600个位置需要更新,这就解释了脚本的必要性。。救命啊!在
我认为这可以用原生的生物合成纤维来完成,不需要正则表达式 需要的最小工作示例:
所以,你可以试试下面的方法。因为变化的数量将等于在文件中找到的CDS/基因的数量。您可以从csv/text文件中读取位置/位置,并创建一个类似于我手动生成的列表
change_values
。在艾米样品测试.txt文件如下所示:
^{pr2}$希望,这能解决你的问题。干杯!在
好的,我有一些东西现在完全可以用了。我会发布代码,以防有人需要类似的东西
这假设使用
python program.py <genbankfile> <excel spreadsheet>
这也假定电子表格的格式如下:
基因同义词结核患者
Rv0005 gyrB 5240+5357-1.782
Rv0012 Rv0012 14089+14134-1.553
Rv0018c pstP 23181-23172-2.077
Rv0032生物2 34295+34307-0.842
Rv0037c Rv0037c 41202-41163-0.554
相关问题 更多 >
编程相关推荐