Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use Bio::DB::GenBank;
- use Bio::SeqIO;
- use Error qw(:try); ##for the try catch
- ##@lines comes from a file with the accesion numbers
- for($i=0; $i<$nlines; $i++){
- chomp(@lines[$i]);
- print @lines[$i], " ->"; #this is the accesion number or gen_id
- $acc_num = @lines[$i];
- #so we create a genbank object first
- #and we get the report by the accesion number or gen_id
- #if we get an error, like connection error we try again
- $ok = 0;
- ##the try catch is because my connection sometimes is sucky
- do{
- try{
- $gb = new Bio::DB::GenBank();
- $seq = $gb->get_Seq_by_version($acc_num);
- $ok=0;
- }
- catch Bio::Root::Exception with{
- my $err = shift;
- print "Connection error again, argh, try once more with $acc_num\n";
- $ok=1;
- };
- }while($ok==1);
- for my $result($seq->get_SeqFeatures){
- ##here we get te taxon of each seq
- push @ids, $result->get_tag_values("db_xref") if ($result->has_tag("db_xref"));
- }
- #print it to a file
- for $taxon(@ids){
- ##but first there is to check if we have a taxon or an ATCC
- @aux = split(":",$taxon);
- if(@aux[0] eq "taxon"){
- print {$out} $taxon, "\n";
- last;
- }
- }
- @ids = ();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement