[Bioperl-l] multi ID indexing Bio::DB::Fasta

Jason Stajich jason at bioperl.org
Wed Oct 22 20:20:27 UTC 2008


Any reason I should avoid making this change which allows a custom  
makeid to return a list of IDs that can be indexed per sequence?   
There is the issue that they need to be unique but that is always the  
case.  DBFasta tests pass fine after the change.

This would allow indexing by GI and Accession and LOCUS all from the  
same file.  This is the behavior for Bio::Index::Fasta and other  
Bio::Index not sure if there was any reason to not support it in  
Bio::DB::Fasta.

Basically it is as follows.  I did some code indenting so there are  
actually less changes than showing when I do a diff.

-		  if ($id) {
-			  my $seqlength    = $pos - $offset - length($_);
-			  $seqlength      -= $termination_length * $seq_lines;
-			  $offsets->{$id}  = &{$self->{packmeth}}($offset,$seqlength,
-																	$linelength,$firstline,
-																	$type,$base);
-		  }
-		  $id = ref($self->{makeid}) eq 'CODE' ? $self->{makeid}->($_) : $1;


+      if (@id) {
+	my $seqlength    = $pos - $offset - length($_);
+	$seqlength      -= $termination_length * $seq_lines;
+	my $ppos = &{$self->{packmeth}}($offset,$seqlength,
+				       $linelength,$firstline,
+				       $type,$base);
+	for my $id (@id) { $offsets->{$id}  = $ppos }
+      }
+      @id = ref($self->{makeid}) eq 'CODE' ? $self->{makeid}->($_) :  
$1;



-jason
--
Jason Stajich
jason at bioperl.org






More information about the Bioperl-l mailing list