[Bioperl-l] Parsing the CDS join or complement statements to get the sub-locations

Chris Fields cjfields at uiuc.edu
Wed Nov 15 21:33:25 EST 2006


On Nov 15, 2006, at 8:11 PM, Joanne Chen wrote:

> Hi,
> I am a new user to BioPerl and am encountering some problems while  
> parsing
> location statements.
>
> I have read the link
> http://www.bioperl.org/wiki/ 
> FAQ#How_do_I_parse_the_CDS_join_or_complement_statements_in_GenBank_or 
> _EMBL_files_to_get_the_sub-locations.3F
> and tried to implement this.
>
> However I am encountering some problems.
>
> Given a testcase:
>
> CDS     join(752472..752685,752752..753298,753335..754039)
>
>
> CDS     complement(637431..639525)
>
>
> CDS    741745..741781
>
>
> This means that my file has join, complement and simple location  
> statements.
>
> Using Bio::Location::SplitLocationI object to get the coordinates,  
> my output is:
>
> CDS     752472..752685,752752..753298,753335..754039
>
> CDS
>
> CDS
>
>
> The complement and simple location statements were not parsed  
> properly. Am I
> using the right BioPerl module to parse? Kindly assist on the  
> appropriate steps
> to retrieve all 3 different location types. Thanks!
>
>
> Joanne
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l

If you are using the loop as shown in the FAQ:

foreach my $feature ($seqobj->top_SeqFeatures){
   if ( $feature->location->isa('Bio::Location::SplitLocationI') and  
$feature->primary_tag eq 'CDS' ) {
      foreach my $location ( $feature->location->sub_Location ) {
        print $location->start , ".." , $location->end, "\n";
      }
   }
}

it will skip over simple locations, so the last two are passed over.   
You probably should use:

foreach my $feature ($seqobj->top_SeqFeatures){
   if ( $feature->primary_tag eq 'CDS' ) {
      foreach my $location ( $feature->location->each_Location ) {
        print $location->start , ".." , $location->end, "\n";
      }
   }
}


Christopher Fields
Postdoctoral Researcher
Lab of Dr. Robert Switzer
Dept of Biochemistry
University of Illinois Urbana-Champaign





More information about the Bioperl-l mailing list