Mercurial > repos > greg > snpeff_v2_from_pablo
comparison snpEff_2_1a/scripts/fastaSample.pl @ 0:f8eaa3f8194b default tip
Uploaded snpEff_v2_1a_core.tgz from Pablo Cingolani
| author | greg |
|---|---|
| date | Fri, 20 Apr 2012 14:47:09 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:f8eaa3f8194b |
|---|---|
| 1 #!/usr/bin/perl | |
| 2 | |
| 3 #--- | |
| 4 # Initialize parameters | |
| 5 #--- | |
| 6 $sampleStart = $ARGV[0]; | |
| 7 $sampleEnd = $ARGV[1]; | |
| 8 if(( $ARGV[0] eq '' ) || ($ARGV[1] eq '')) { die "Usage: fastaSample sampleStart sampleEnd\n"; } | |
| 9 | |
| 10 $sampleStart--; | |
| 11 $sampleEnd--; | |
| 12 $sampleLen = $sampleEnd - $sampleStart + 1; | |
| 13 | |
| 14 #--- | |
| 15 # Read fasta file | |
| 16 #--- | |
| 17 for($lineNum=0 ; $l = <STDIN> ; $lineNum++ ) { | |
| 18 if( $l =~/^>/ ) { | |
| 19 # Sample if not empty | |
| 20 if( $seq ne "" ) { | |
| 21 $s = substr( $seq, $sampleStart, $sampleLen); | |
| 22 print "$s\n"; | |
| 23 } | |
| 24 # New sequence | |
| 25 $seq = ""; | |
| 26 } else { | |
| 27 chomp($l); | |
| 28 $seq .= $l; | |
| 29 } | |
| 30 } | |
| 31 | |
| 32 # Sample if not empty | |
| 33 if( $seq ne "" ) { | |
| 34 $s = substr( $seq, $sampleStart, $sampleLen); | |
| 35 print "$s\n"; | |
| 36 } | |
| 37 | |
| 38 $len = length($seq); | |
| 39 print STDERR "Lines: $lineNum\n"; | |
| 40 print STDERR "Sequence size: $len\n"; | |
| 41 print STDERR "Sample size: $sampleLen\n"; |
