Question: Adding Feature To Genbank In Biopython
gravatar for Gorysko
7.7 years ago by
Gorysko100 wrote:

Dear all now I'm writing small script for adding feature to genbank file


from Bio import SeqIO

from Bio.SeqFeature import SeqFeature, FeatureLocation

record ="mirum.gbk", "genbank")

for sub_feature in record.features:

    for  seq_record in SeqIO.parse("mirum_ort.fasta", "fasta"):

      dbxref = sub_feature.qualifiers.get("db_xref")

          if dbxref == seq.record:



But in general it's working without appending new feature in bioperl I've written such script which is looking like


use Bio::SeqIO;

$| = 1;

my $seqio_object = Bio::SeqIO->new(-file => "mirum.gbk" );

my $seq_object = $seqio_object->next_seq;

for my $feat_object ($seq_object->get_SeqFeatures)


    for my $tag ($feat_object->get_all_tags)


            if ($tag eq "db_xref")


                    for my $value ($feat_object->get_tag_values($tag))


                            if ($value =~ m/^([0-9]+)/)


                                    my $gi_gbk = "$1";

                                    my $seqio_object_fasta = Bio::SeqIO->new(-file =>"mirum_ort.fasta" );

                                    while (my $seq_object_fasta = $seqio_object_fasta->next_seq)


                                            my $gi_fasta = $seq_object_fasta->id();

                                            $gi_fasta =~ s/^gi\|([0-9]+)\|ref.*$/$1/;

                                            if ($gi_gbk eq $gi_fasta)


                                                    my $misc_feat = new Bio::SeqFeature::Generic(-start => $feat_object->location->start(), -end => $feat_object->location->end(), -strand => $feat_object->location->strand(), -primary$









my $seqio_object_out = Bio::SeqIO->new(-file => ">mirum_ort.gbk" );



But my interest is to write it in Biopython

What could You advice me to change in this script

Thank You

biopython genbank • 2.6k views
ADD COMMENTlink modified 6.3 years ago by Biostar ♦♦ 20 • written 7.7 years ago by Gorysko100

If you want to add a new feature, make a SeqFeature object. instead it looks like you are trying to add a database cross reference.

ADD REPLYlink written 7.7 years ago by Peter5.8k

I really cannot answer, but I'm curious: why are you doing this? Thx

ADD REPLYlink written 7.7 years ago by Manu Prestat3.9k

thnx you Peter ,you comment auiqte good in this situation

ADD REPLYlink written 7.7 years ago by Gorysko100
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1589 users visited in the last hour