Question: Retain Capitalization For Features
0
gravatar for Lee Katz
8.3 years ago by
Lee Katz3.0k
Atlanta, GA
Lee Katz3.0k wrote:

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;
}
genome sequence bioperl • 1.4k views
ADD COMMENTlink written 8.3 years ago by Lee Katz3.0k
1
gravatar for Lee Katz
8.3 years ago by
Lee Katz3.0k
Atlanta, GA
Lee Katz3.0k wrote:

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 COMMENTlink written 8.3 years ago by Lee Katz3.0k
Please log in to add an answer.

Help
Access

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