Skip to content

Instantly share code, notes, and snippets.

@mhan008
Created October 31, 2012 05:27
Show Gist options
  • Save mhan008/3984996 to your computer and use it in GitHub Desktop.
Save mhan008/3984996 to your computer and use it in GitHub Desktop.
Week5
#!/usr/bin/perl -w
use strict;
use Bio::SearchIO;
my $cutoff = '0.001';
my $file = 'actin-vs-basidio.BLASTP';
my $in = Bio::SearchIO->new(-format => 'blast',
-file => $file);
while( my $r = $in->next_result ) {
print "Query is: ", $r->query_name, " ",
$r->query_description," ",$r->query_length," aa\n";
print " Matrix was ", $r->get_parameter('matrix'), "\n";
while( my $h = $r->next_hit ) {
last if $h->significance > $cutoff;
print "Hit is ", $h->name, "\n";
while( my $hsp = $h->next_hsp ) {
print " HSP Len is ", $hsp->length('total'), " ",
" E-value is ", $hsp->evalue, " Bit score ",
$hsp->score, " \n",
" Query loc: ",$hsp->query->start, " ",
$hsp->query->end," ",
" Sbject loc: ",$hsp->hit->start, " ",
$hsp->hit->end,"\n";
}
}
}
#!/usr/bin/perl -w
use strict;
use warnings;
use Bio::SeqIO;
my $file = 'sample_seqs.gbk';
my $in = Bio::SeqIO->new(-format => 'genbank',
-file => $file);
my ($seqcount);
while ( my $seq = $in->next_seq) {
$seqcount++; # count the number of sequences
print $seq->display_id, " sequence:\n"; #prints seq accession
my $cds = 0; #this works better out here
for my $feature ( $seq->get_SeqFeatures ) {
if ( $feature->primary_tag eq 'CDS') {
my $length = $feature->end - $feature->start;
print "CDS identified! Length is $length.\n";
$cds++;
}
}
print "Total CDS features: $cds.\n";
}
printf "In db %s there are %d sequences\n",
$file, $seqcount;
#!/usr/bin/perl -w
use strict;
use warnings;
use Bio::SeqIO;
my $file = 'sample_seqs.gbk';
my $in = Bio::SeqIO->new(-format => 'genbank',
-file => $file);
my ($seqcount);
while ( my $seq = $in->next_seq) {
$seqcount++; # count the number of sequences
print $seq->display_id, " sequence:\n"; #prints seq accession
my $cds = 0; #this works better out here
for my $feature ( $seq->get_SeqFeatures ) {
if ( $feature->primary_tag eq 'CDS') {
my $length = $feature->end - $feature->start;
print "CDS identified! Length is $length.\n";
$cds++;
}
}
print "Total CDS features: $cds.\n";
}
printf "In db %s there are %d sequences\n",
$file, $seqcount;
#!/usr/bin/perl -w
use strict;
use warnings;
use Bio::SeqIO;
my $file = 'sample_seqs.gbk';
my $in = Bio::SeqIO->new(-format => 'genbank',
-file => $file);
my %species;
my $count = 0;
while ( my $seq = $in->next_seq) {
for my $feature ( $seq->get_SeqFeatures ) {
if ( $feature->primary_tag eq 'source') { #organism under source primary tag
my @values = $feature->get_tag_values("organism") if ($feature->has_tag("organism"));
# print "@values\n"; #convert array to hash to enforce unique
$count++; #this just counts up to 20
$species{$values[0]} = "$count";
}
}
}
print join(",",sort keys %species), "\n";
print join(",",values %species), "\n";
#!/usr/bin/perl -w
use strict;
use warnings;
use Bio::DB::Fasta;
use Bio::Seq;
use Bio::SeqIO;
my $dbfile = 'sacharomyces_cerevisiae_S288C.fa';
my $db = Bio::DB::Fasta->new($dbfile);
my $piece = $db->seq('chrI',54584 => 54913);
print "This is a mystery yeast DNA sequence:\n", "$piece\n";
my $seq = Bio::Seq->new(-seq =>$piece); #have to load into bioseq!
print "Translation is:\n", $seq->translate->seq, "\n";
#!/usr/bin/perl -w
use strict;
use warnings;
use Bio::DB::Fasta;
use Bio::Seq;
use Bio::SeqIO;
my $dbfile = 'sacharomyces_cerevisiae_S288C.fa';
my $db = Bio::DB::Fasta->new($dbfile);
my $piece = $db->seq('chrI',54584 => 54913);
print "This is a mystery yeast DNA sequence:\n", "$piece\n";
my $seq = Bio::Seq->new(-seq =>$piece); #have to load into bioseq!
print "Translation is:\n", $seq->translate->seq, "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment