解析GenBank文件

时间:2014-02-19 18:15:15

标签: perl awk biopython bioperl

基本上,GenBank文件包含基因条目('基因'后面跟着相应的' CDS'条目(每个基因只有一个),就像我在下面显示的两个一样。我想在制表符分隔的两列文件中获取locus_tag vs product。'基因' CDS'总是先后跟空格。如果这个任务可以很容易地使用一个已经可用的工具,请告诉我。

输入文件:

 gene            complement(8972..9094)
                 /locus_tag="HAPS_0004"
                 /db_xref="GeneID:7278619"
 CDS             complement(8972..9094)
                 /locus_tag="HAPS_0004"
                 /codon_start=1
                 /transl_table=11
                 /product="hypothetical protein"
                 /protein_id="YP_002474657.1"
                 /db_xref="GI:219870282"
                 /db_xref="GeneID:7278619"
                 /translation="MYYKALAHFLPTLSTMQNILSKSPLSLDFRLLFLAFIDKR"
 gene            9632..11416
                 /gene="frdA"
                 /locus_tag="HAPS_0005"
                 /db_xref="GeneID:7278620"
 CDS             9632..11416
                 /gene="frdA"
                 /locus_tag="HAPS_0005"
                 /note="part of four member fumarate reductase enzyme
                 complex FrdABCD which catalyzes the reduction of fumarate
                 to succinate during anaerobic respiration; FrdAB are the
                 catalytic subcomplex consisting of a flavoprotein subunit
                 and an iron-sulfur subunit, respectively; FrdCD are the
                 membrane components which interact with quinone and are
                 involved in electron transfer; the catalytic subunits are
                 similar to succinate dehydrogenase SdhAB"
                 /codon_start=1
                 /transl_table=11
                 /product="fumarate reductase flavoprotein subunit"
                 /protein_id="YP_002474658.1"
                 /db_xref="GI:219870283"
                 /db_xref="GeneID:7278620"
                 /translation="MQTVNVDVAIVGAGGGGLRAAIAAAEANPNLKIALISKVYPMRS
                 HTVAAEGGAAAVAKEEDSYDKHFHDTVAGGDWLCEQDVVEYFVEHSPVEMTQLERWGC
                 PWSRKADGDVNVRRFGGMKIERTWFAADKTGFHLLHTLFQTSIKYPQIIRFDEHFVVD
                 ILVDDGQVRGCVAMNMMEGTFVQINANAVVIATGGGCRAYRFNTNGGIVTGDGLSMAY
                 RHGVPLRDMEFVQYHPTGLPNTGILMTEGCRGEGGILVNKDGYRYLQDYGLGPETPVG
                 KPENKYMELGPRDKVSQAFWQEWRKGNTLKTAKGVDVVHLDLRHLGEKYLHERLPFIC
                 ELAQAYEGVDPAKAPIPVRPVVHYTMGGIEVDQHAETCIKGLFAVGECASSGLHGANR
                 LGSNSLAELVVFGKVAGEMAAKRAVEATARNQAVIDAQAKDVLERVYALARQEGEESW
                 SQIRNEMGDSMEEGCGIYRTQESMEKTVAKIAELKERYKRIKVKDSSSVFNTDLLYKI
                 ELGYILDVAQSISSSAVERKESRGAHQRLDYVERDDVNYLKHTLAFYNADGTPTIKYS
                 DVKITKSQPAKRVYGAEAEAQEAAAKKE"

所需的输出(locus_tag与制表符分隔的两列文件中的产品):

HAPS_0004 hypothetical protein
HAPS_0005 fumarate reductase flavoprotein subunit

事实上,这个输出是理想的,每个基因一行(仅显示一个基因):

 locus_tag="HAPS_0004" db_xref="GeneID:7278619" complement(8972..9094) codon_start=1 transl_table=11 product="hypothetical protein" protein_id="YP_002474657.1" db_xref="GI:219870282" db_xref="GeneID:7278619" translation="MYYKALAHFLPTLSTMQNILSKSPLSLDFRLLFLAFIDKR"

1 个答案:

答案 0 :(得分:3)

perl -nE'
  BEGIN{ ($/, $") = ("CDS", "\t") }
  say "@r[0,1]" if @r= m!/(?:locus_tag|product)="(.+?)"!g and @r>1
' file

输出

HAPS_0004       hypothetical protein
HAPS_0005       fumarate reductase flavoprotein subunit