Mercurial > repos > bioitcore > splicetrap
comparison bin/scan_nomt.pl @ 1:adc0f7765d85 draft
planemo upload
| author | bioitcore |
|---|---|
| date | Thu, 07 Sep 2017 15:06:58 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:d4ca551ca300 | 1:adc0f7765d85 |
|---|---|
| 1 use strict; | |
| 2 use FileHandle; | |
| 3 | |
| 4 | |
| 5 my $File1Name=$ARGV[0]; | |
| 6 my $File2Name=$ARGV[1]; | |
| 7 | |
| 8 my %FileHandle1; | |
| 9 my %FileHandle2; | |
| 10 my %chrlist; | |
| 11 | |
| 12 open(File1,$File1Name); | |
| 13 open(File2,$File2Name); | |
| 14 | |
| 15 while(my $line1=<File1>) | |
| 16 { | |
| 17 my $line2=<File2>; | |
| 18 chomp($line1); | |
| 19 chomp($line2); | |
| 20 my $read1status=substr($line1,length($line1)-2,2); | |
| 21 my $read2status=substr($line2,length($line2)-2,2); | |
| 22 #next if( ($read1status eq "NM" or $read1status eq "MT") and ($read2status eq "NM" or $read2status eq "MT"); | |
| 23 my @array1=split("\t",$line1); | |
| 24 my @array2=split("\t",$line2); | |
| 25 my $chr1=""; | |
| 26 my $chr2=""; | |
| 27 if(scalar(@array1) eq 4) | |
| 28 { | |
| 29 if($array1[3]=~/(chr\S*?)\|/) | |
| 30 {$chr1=$1;} | |
| 31 } | |
| 32 if(scalar(@array2) eq 4) | |
| 33 { | |
| 34 if($array2[3]=~/(chr\S*?)\|/) | |
| 35 {$chr2=$1;} | |
| 36 } | |
| 37 my $chr=$chr1; | |
| 38 if ($chr eq "") | |
| 39 { | |
| 40 next if($chr2 eq ""); | |
| 41 $chr=$chr2; | |
| 42 } | |
| 43 else | |
| 44 { | |
| 45 next if($chr2 ne "" and $chr2 ne $chr); | |
| 46 | |
| 47 } | |
| 48 next if $chr eq ""; | |
| 49 if(exists $chrlist{$chr}) | |
| 50 { | |
| 51 my $fout1= $FileHandle1{$chr}; | |
| 52 my $fout2= $FileHandle2{$chr}; | |
| 53 if($read1status eq "MT") | |
| 54 { | |
| 55 print $fout1 $array1[0],"\t",$array1[1],"\tMT\n"; | |
| 56 } | |
| 57 else | |
| 58 { | |
| 59 print $fout1 $line1,"\n"; | |
| 60 } | |
| 61 if($read2status eq "MT") | |
| 62 { | |
| 63 print $fout2 $array2[0],"\t",$array2[1],"\tMT\n"; | |
| 64 } | |
| 65 else | |
| 66 { | |
| 67 print $fout2 $line2,"\n"; | |
| 68 } | |
| 69 | |
| 70 | |
| 71 | |
| 72 } | |
| 73 else | |
| 74 { | |
| 75 $chrlist{$chr}=1; | |
| 76 my $fout1= new FileHandle; | |
| 77 open($fout1, ">".$File1Name.".".$chr); | |
| 78 $FileHandle1{$chr}=$fout1; | |
| 79 | |
| 80 my $fout2= new FileHandle; | |
| 81 open($fout2, ">".$File2Name.".".$chr); | |
| 82 $FileHandle2{$chr}=$fout2; | |
| 83 | |
| 84 } | |
| 85 | |
| 86 } | |
| 87 | |
| 88 foreach my $fout1 (keys %FileHandle1) | |
| 89 { | |
| 90 close($fout1); | |
| 91 } | |
| 92 foreach my $fout2 (keys %FileHandle2) | |
| 93 { | |
| 94 close($fout2); | |
| 95 } | |
| 96 | |
| 97 close(File1); | |
| 98 close(File2); |
