ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/gclib/scripts/sam2reads.pl
Revision: 24
Committed: Tue Jul 26 21:46:39 2011 UTC (8 years, 1 month ago) by gpertea
File size: 809 byte(s)
Log Message:
Line File contents
1 #!/usr/bin/perl
2 use strict;
3 use Getopt::Std;
4 use FindBin;use lib $FindBin::Bin;
5
6 my $usage = q/Usage:
7 samtools view <in.bam> | sam2reads.pl
8 sam2reads.pl <in.sam>
9
10 Rebuild the raw read names (for paired reads) from the input
11 SAM\/BAM file and list them.
12 /;
13 umask 0002;
14 getopts('o:') || die($usage."\n");
15 my $outfile=$Getopt::Std::opt_o;
16 if ($outfile) {
17 open(OUTF, '>'.$outfile) || die("Error creating output file $outfile\n");
18 select(OUTF);
19 }
20 # --
21
22 while (<>) {
23 my @t=split(/\t/);
24 my $name=$t[0];
25 my $num=0;
26 $num+=1 if ($t[1] & 0x40) == 0x40;
27 $num+=2 if ($t[1] & 0x80) == 0x80;
28 if ($num<1 || $num>2) {
29 print STDERR "Warning: $name without mate info:\n$_";
30 }
31 print $name.'/'.$num."\n";
32 }
33
34 # --
35 if ($outfile) {
36 select(STDOUT);
37 close(OUTF);
38 }
39
40 #************ Subroutines **************

Properties

Name Value
svn:executable *