File: FilterGoodClass.pl

package info (click to toggle)
ampliconnoise 1.29-10
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 6,040 kB
  • sloc: ansic: 18,080; sh: 2,899; perl: 2,089; makefile: 235
file content (68 lines) | stat: -rwxr-xr-x 896 bytes parent folder | download | duplicates (9)
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
#!/usr/bin/perl

my $fastaFile = shift;
my $distFile = shift;

my $cutoff = shift;

my @Seq = ();
my $total = 0;
my @id = ();

open(FILE, $fastaFile) or die "Can't open $fastaFile\n";

my $seq = "";

while($line = <FILE>){ 
    chomp($line);
    
    if($line =~ />(.*)/){
	
	$id[$count] = $1;
	
	if($seq ne ""){
	    $Seq[$count - 1] = $seq;

	    $seq = "";
	}

	$count++;
    }
    else{
	$seq .= $line;
    }
}

$Seq[$count - 1] = $seq;

$total = $count;

open(FILE, $distFile) or die "Can't open $distFile\n";

for($i = 0; $i < $total; $i++){
    $line = <FILE>;
    
    chomp($line);

    @tokens = split(/ /,$line);

    $id = $tokens[0];

    $id =~ /.*_(.*)/;

    $freq = $1;
    
    $x = $tokens[1]; 
    $y = $tokens[2];

    $p = $tokens[4];

    if($p < $cutoff){
	printf STDERR ">$id[$i]\n$Seq[$i]\n";
    }
    else{
	printf STDOUT ">$id[$i]\n$Seq[$i]\n";
    }
}

close(FILE);