Retain Capitalization For Features
1
0
Entering edit mode
12.8 years ago
Lee Katz ★ 3.1k

Hi, I have a GenBank file and am extracting a gene upstream and downstream of a target gene, with everything in between (3 genes + 2 intergenic regions). I am loading the sequence in BioPerl and outputting the sequence to a file.

However, I want to make genes uppercase and intergenic regions lowercase. Is there an easy way to do this? Is there a clean BioPerl way?

sub extractSeq{
  my($file,$start,$end,$settings)=@_;
  my $targetSeq;
  my $seqin=Bio::SeqIO->new(-file=>$file);
  if($$settings{contig}){
    while(my $seq=$seqin->next_seq){
      if($seq->id eq $$settings{contig}){
        $targetSeq=$seq;
        last;
      }
    }
  } else {
    $targetSeq=$seqin->next_seq;
  }

  my $sequence=$targetSeq->subseq($start,$end);

  my $genomeName=basename($file,qw(.gbk .gbk.fna));
  my $extractedSeq=Bio::Seq->new(-id=>join("_",$genomeName,$$settings{contig},$start,$end),-seq=>$sequence);
  $extractedSeq=$extractedSeq->revcom if($$settings{revcom});
  return $extractedSeq;
}
bioperl genome sequence • 1.9k views
ADD COMMENT
1
Entering edit mode
12.8 years ago
Lee Katz ★ 3.1k

sub highlightFeatures{ my($seq,$settings)=@_; my $highlight=$$settings{highlight_type}||"uc"; # TODO return false if not a rich seq for my $feat($seq->get_SeqFeatures){ next if($feat->primary_tag eq 'source'); my($start,$end)=($feat->location->start,$feat->location->end); if($highlight eq 'uc'){ my $firstPartOfTheSequence=($start>1)?$seq->subseq(1,$start-1):""; my $lastPartOfTheSequence=($end<$seq->length)?$seq->subseq($end+1,$seq->length):""; my $sequence=$firstPartOfTheSequence.uc($seq->subseq($start,$end)).$lastPartOfTheSequence; $seq->seq($sequence); } } }

ADD COMMENT

Login before adding your answer.

Traffic: 1787 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