File: filter_coherence.pl

package info (click to toggle)
kissplice 2.6.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 16,752 kB
  • sloc: cpp: 8,783; python: 1,618; perl: 389; sh: 72; makefile: 18
file content (184 lines) | stat: -rw-r--r-- 3,684 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/usr/bin/perl -w


if(@ARGV !=7){
print "format:filter_coherence.pl coherence_condition1.txt coherence_condition2.txt sequences.fa checking.txt updatesequences.fa events_tab_43.txt events_tab_filt_43.txt \n";
print "Please specify the names of the input files and the output file\n"; 
exit 1;
}

$infile1=shift;  #idio me $infile=$ARGV[0]
#idio me $outfile= $ARGV[1]
$infile2=shift;
$infile3=shift;
$outfile=shift;
$outfile1=shift;
$infile4=shift;
$outfile2=shift;
open(IN, "$infile1") || die "Cannot open: $!\n";
open(IN2, "$infile2") || die "Cannot open: $!\n";
open(IN3, "$infile3") || die "Cannot open: $!\n";
open(OUT, ">$outfile") || die "Cannot open: $!\n";
open (OUT1,">$outfile1") || die "Cannot open: $!\n";
open(IN4, "$infile4") || die "Cannot open: $!\n";
open (OUT2,">$outfile2") || die "Cannot open: $!\n";

#>Cycle_10_upper_Length:88_coverage1:20_coverage2:17|UNCOHERENT_CGTCTACGAGGAGGTGCCCGCCTACGGACCATCCCGTGGCTACAGCAGCTATCCCCGCAGCCTGCGATCGGAGGGTAATGGAGGAAGT
$printme=0;
while($line=<IN>){
chomp($line);
if ($line=~m/^>Cycle_(\d+)_(\w+):(.*)\|UNCOHERENT(.*)/){
print $1;
$cyclenum=$1;
print "\t";
print $2;
$path=$2;
print "\t";
if ($path eq "upper_Length"){
$path=0;
}
else{
$path=1;
}
print $path;
print "\n";
$element=$cyclenum.$path;
push(@condition1,$element);
}
}
close(IN);

while($line=<IN2>){
chomp($line);
if ($line=~m/^>Cycle_(\d+)_(\w+):(.*)\|UNCOHERENT(.*)/){
print $1;
$cyclenum=$1;
print "\t";
print $2;
$path=$2;
print "\t";
if ($path eq "upper_Length"){
$path=0;
}
else{
$path=1;
}
print $path;
print "\n";
$element=$cyclenum.$path;
print $element;
print "\n";
push(@condition2,$element);
}
}
close(IN2);
$n1=0;
$n2=0;
@conditions = (@condition1, @condition2);
@conditions=sort{ $a <=> $b } (@conditions);
#while($condition1[$n1]){
#$n1++;
#while($condition2[$n2]){
#print OUT $condition1[$n1];
#print OUT "\n";
#if($condition1[$n1] == $condition2[$n2]){
#push(@cycles,$condition1[$n1]);
#}
#elsif($condition1[$n1] < $condition2[$n2]){
#break;
#}
#$n2++;
#}
#$n1++;
#}
foreach $i(@conditions){
print OUT $i;
print OUT "\n";
}
print OUT "\n\n\n\nDUPLICATES\n\n";
%h = ();
foreach $i (@conditions) {
    if (!exists($h{$i}))  {
        # First time we've seen this one
        $h{$i} = 0
    } elsif ($h{$i}) {
        # We've seen this one before and reported
        $h{$i}++
    } else {
        # Second time, so report the duplicate
        print OUT "\n $i\t";
$thesize=length($i);
$x=substr($i,0,$thesize-1);
push(@duplicates,$x);
print OUT "$x\n";
        $h{$i} = 1
    }
}
%h = (); 

$prev = -1;
               @duplicates = grep($_ ne $prev && ($prev = $_, 1), @duplicates);

foreach $i(@duplicates){
print OUT "$i\n";
}
$dups= join(" ",@duplicates);
print $dups;

while($line=<IN3>){
$found=0;
#>Cycle_0_upper_Length:87_coverage1:7_coverage2:7
#AGAACTGCACCACGAGGGGCTTGTCCTCGTTGGAGAAGCCATCGAACTTGCGGCTGGCCGCGTAGAATCGAGCATCCTGAGAGGTCT
chomp($line);
if ($line=~m/^>Cycle_(\d+)_(\w+):(.*)/){
$number=$1;
#print OUT1 "$number\n";
while($dups =~ m/(\d+)/g) {
	if ($number==$1){ 
$found=1;
}
}
if ($found==0){
print  OUT1 "$line";
print OUT1 "\n";
$line=<IN3>;
print  OUT1 "$line";
}
}
}

$counter=0;
while($line=<IN4>){
chomp($line);
$found=0;
if($counter==0){
print OUT2 $line;
print OUT2 "\n";
}
else{
#0	AGAACTGCACCACGAGGGGCTTGTCCTCGTTGGAGAAGCCATCGAACTTGCGGCTGGCCGCGTAGAATCGAGCATCCTGAGAGGTCT	AGAACTGCACCACGAGGGGCTTGTCCTCGTTGGAGAAGCCATCAAACTTGCGGCTGGCCGCGTAGAATCGAGCATCCTGAGAGGTCT	87	87	7	7	11	15	

if ($line=~m/^(\d+)\t(.*)/){
$number=$1;
#print OUT1 "$number\n";
while($dups =~ m/(\d+)/g) {
	if ($number==$1){ 
$found=1;
}
}
if ($found==0){
print  OUT2 "$line";
print OUT2 "\n";
}
}
}
$counter++;
}




close(IN3);
close(OUT);
close(OUT1);