擅长:python、mysql、java
<p>要将GTF文件中的多个分隔符更改为单个制表符分隔符。一旦你这样做,文件就不再是一个GTF文件。在</p>
<p>下面的代码将把GTF文件的内容转换成文本文件</p>
<pre><code>import gffutils
try:
db = gffutils.create_db("sample.gtf", dbfn='sample.db')
except:
pass
db = gffutils.FeatureDB('sample.db', keep_order=True)
with open('sample.txt', 'w') as fout:
for line in db.all_features():
line = str(line)
line = line.split(";") #make your parsing changes here
fout.write(str(line) + '\n')
</code></pre>
<p>请注意,您只能使用<code>create_db()</code>方法一次。所以我才把它评论出来。在</p>
<p><strong>编辑</strong></p>
<p>添加了try语句</p>