Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- use Bio::DB::Sam;
- use Data::Dumper;
- use MLDBM qw(DB_File Storable);
- use Fcntl;
- my $foo = $ARGV[0];
- chomp $foo;
- my $idx;
- my $idx2;
- if(-e $foo.".lidx") {
- tie %$idx,'MLDBM', $foo.".lidx", O_RDWR, 0666 or die "$! $foo.lidx";
- }
- else {
- tie %$idx,'MLDBM', $foo.".lidx", O_CREAT|O_RDWR, 0666 or die "$! $foo.lidx";
- my $bam = Bio::DB::Bam->open($foo);
- my $header = $bam->header;
- my $cnt = 0;
- my $pos = $bam->tell;
- while(my $a = $bam->read1()) {
- if( $cnt % 10000 == 0 ) {
- print STDERR "$cnt:". $pos."\n";
- $idx->{$cnt} = $pos;
- }
- $pos = $bam->tell;
- $cnt++;
- }
- }
- my $bam = Bio::DB::Bam->open($foo);
- my $header = $bam->header;
- $bam->seek(int($idx->{$ARGV[1]}),0);
- print STDERR $bam->tell ." $idx->{$ARGV[1]}\n";
- my $aln = $bam->read1();
- print $aln->qname."\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement