[Bio] / FigKernelPackages / FIGV.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/FIGV.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.34, Thu Jun 28 22:04:24 2007 UTC revision 1.35, Fri Jul 6 21:55:20 2007 UTC
# Line 1194  Line 1194 
1194      }      }
1195  }  }
1196    
1197    ####################################################
1198    #
1199    # Following are some MG-RAST specific features. FIGV seems a good a place as any to include them.#
1200    #
1201    #
1202    
1203    =head3 taxa_to_seed_ids
1204    
1205    Given a prefix of a taxonomy string, return the list of metagenome fids that
1206    mapped to SEED organisms in that taxonomy.
1207    
1208    =cut
1209    
1210    sub taxa_to_seed_ids
1211    {
1212        my($self, $tax) = @_;
1213    
1214        my $btree_file = "$self->{_orgdir}/taxa_summary_by_blast.btree";
1215        my %btree;
1216    
1217        my $btree_tie = tie %btree, 'DB_File', $btree_file, O_RDONLY, 0666, $DB_BTREE;
1218    
1219        if (!$btree_tie)
1220        {
1221            warn "Cannot tie $btree_file: $!\n";
1222            return undef;
1223        }
1224    
1225        my $key = $tax;
1226        my ($res, $value);
1227        my @vals;
1228        my %seen;
1229    
1230        for ($res = $btree_tie->seq($key, $value, R_CURSOR);
1231             $res == 0 and $key =~ /^$tax/;
1232             $res = $btree_tie->seq($key, $value, R_NEXT))
1233        {
1234            print "$key\n";
1235            push(@vals, map { [$key, $_] } grep { not $seen{$_}++ } split(/$;/, $value));
1236        }
1237        return @vals;
1238    }
1239    
1240  sub load_pseq {  sub load_pseq {
1241      my($self) = @_;      my($self) = @_;
1242    

Legend:
Removed from v.1.34  
changed lines
  Added in v.1.35

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3