X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=samtools.git;a=blobdiff_plain;f=misc%2Fsamtools.pl;h=320e8aaeda8ff2fab7fd91ab5e02073d5f3ba8fe;hp=86b285c5fa6c144a1d60ed61cb48a23bde7f134f;hb=317f5e8dd22cc9e1e5e05fbcaeb3b9aca7447351;hpb=4a17fa7e1f91b2fe04ad334a63fc2b0d5e859d8a diff --git a/misc/samtools.pl b/misc/samtools.pl index 86b285c..320e8aa 100755 --- a/misc/samtools.pl +++ b/misc/samtools.pl @@ -11,7 +11,7 @@ my $version = '0.3.3'; my $command = shift(@ARGV); my %func = (showALEN=>\&showALEN, pileup2fq=>\&pileup2fq, varFilter=>\&varFilter, - unique=>\&unique, uniqcmp=>\&uniqcmp); + unique=>\&unique, uniqcmp=>\&uniqcmp, sra2hdr=>\&sra2hdr); die("Unknown command \"$command\".\n") if (!defined($func{$command})); &{$func{$command}}; @@ -37,6 +37,16 @@ sub showALEN { # varFilter # +# +# Filtration code: +# +# d low depth +# D high depth +# W too many SNPs in a window (SNP only) +# G close to a high-quality indel (SNP only) +# Q low RMS mapping quality (SNP only) +# g close to another indel with higher quality (indel only) + sub varFilter { my %opts = (d=>3, D=>100, l=>30, Q=>25, q=>10, G=>25, s=>100, w=>10, W=>10, N=>2, p=>undef); getopts('pq:d:D:l:Q:w:W:N:G:', \%opts); @@ -216,6 +226,59 @@ sub p2q_print_str { } } +# +# sra2hdr +# + +# This subroutine does not use an XML parser. It requires that the SRA +# XML files are properly formated. +sub sra2hdr { + my %opts = (); + getopts('', \%opts); + die("Usage: samtools.pl sra2hdr \n") if (@ARGV == 0); + my $pre = $ARGV[0]; + my $fh; + # read sample + my $sample = 'UNKNOWN'; + open($fh, "$pre.sample.xml") || die; + while (<$fh>) { + $sample = $1 if (/) { + if (/\s*(\S+)\s*<\/LIBRARY_NAME>/i) { + $exp2lib{$exp} = $1; + } + } + close($fh); + # read run + my ($run, @fn); + open($fh, "$pre.run.xml") || die; + while (<$fh>) { + if (//i) { + if (@fn == 1) { + print STDERR "$fn[0]\t$run\n"; + } else { + for (0 .. $#fn) { + print STDERR "$fn[$_]\t$run", "_", $_+1, "\n"; + } + } + } + } + close($fh); +} + # # unique #