Created
January 15, 2013 16:44
-
-
Save graingert/4540012 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Bio::DB::Sam; | |
# high level API | |
my $sam = Bio::DB::Sam->new(-bam =>"data/ex1.bam", | |
-fasta=>"data/ex1.fa", | |
); | |
my @targets = $sam->seq_ids; | |
my @alignments = $sam->get_features_by_location(-seq_id => 'seq2', | |
-start => 500, | |
-end => 800); | |
for my $a (@alignments) { | |
# where does the alignment start in the reference sequence | |
my $seqid = $a->seq_id; | |
my $start = $a->start; | |
my $end = $a->end; | |
my $strand = $a->strand; | |
my $cigar = $a->cigar_str; | |
my $paired = $a->get_tag_values('PAIRED'); | |
# where does the alignment start in the query sequence | |
my $query_start = $a->query->start; | |
my $query_end = $a->query->end; | |
my $ref_dna = $a->dna; # reference sequence bases | |
my $query_dna = $a->query->dna; # query sequence bases | |
my @scores = $a->qscore; # per-base quality scores | |
my $match_qual= $a->qual; # quality of the match | |
} | |
my @pairs = $sam->get_features_by_location(-type => 'read_pair', | |
-seq_id => 'seq2', | |
-start => 500, | |
-end => 800); | |
for my $pair (@pairs) { | |
my $length = $pair->length; # insert length | |
my ($first_mate,$second_mate) = $pair->get_SeqFeatures; | |
my $f_start = $first_mate->start; | |
# my $s_start = $second_mate->start; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment