Reverse Complement A Genbank File
1
0
Entering edit mode
12.6 years ago
Lee Katz ★ 3.2k

Hi all, is there an easy way to reverse-complement a genbank file? I tried it with bioperl, and all the features disappeared.

I am trying to revcom certain contigs to visualize a region in a genome, across several genomes, so that I can view them all at once in MAUVE, and some contigs need to be revcom'd.

genbank • 6.2k views
ADD COMMENT
1
Entering edit mode

You don't want to write a script yourself right? This pdf http://www.bsi.umn.edu/resources/perl2.pdf has a nice demo, if you are willing to script it up.

ADD REPLY
0
Entering edit mode

I can script it up if there's help! I'm not sure if the tutorial you attached addresses features though.

ADD REPLY
0
Entering edit mode

No it doesn't. Were you throwing any errors in bioperl? In my limited bioperl experience it is usually something trivial that screws up the script.

ADD REPLY
0
Entering edit mode

Doing a richseq->revcom removes the features. Or maybe it's the truncation step. But, I think I got the answer on my own.

ADD REPLY
4
Entering edit mode
12.6 years ago
Lee Katz ★ 3.2k

I think I basically got it right, after I thought about the math. Here is the relevant snippet of code. There are certain variables that are defined somewhere else like $start and $end (start/end of the contig), but the idea is there.

  my @feat=$targetSeq->get_SeqFeatures();
  my $truncSeq=$targetSeq->trunc($start,$end);
  $truncSeq=$truncSeq->revcom if($revcom);

  for my $feat(@feat){
    my $subseqFeatStart=$feat->location->start-$start+1;
    my $subseqFeatEnd=$feat->location->end-$start+1;
    my $strand=$feat->strand;
    next if( ($subseqFeatStart<1 && $subseqFeatEnd<1) || ($subseqFeatStart>$seqLength && $subseqFeatEnd>$seqLength) );

    if($revcom){
      $subseqFeatStart=$end-($subseqFeatStart-$start)+1;
      $subseqFeatEnd=$end-($subseqFeatEnd-$start)+1;
      ($subseqFeatStart,$subseqFeatEnd)=($subseqFeatEnd,$subseqFeatStart);
      $strand=$strand*-1;
    }

    next if(ref($feat->location) ne "Bio::Location::Simple");
    $subseqFeatStart=1 if($subseqFeatStart<1);
    $subseqFeatEnd=$seqLength if($subseqFeatEnd>$seqLength);

    $feat->location->start($subseqFeatStart);
    $feat->location->end($subseqFeatEnd);
    $feat->strand($strand);
    $truncSeq->add_SeqFeature($feat);
  }
ADD COMMENT
2
Entering edit mode

up vote for self answer :)

ADD REPLY

Login before adding your answer.

Traffic: 1427 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6