-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path16Ssubstractive.pl
More file actions
70 lines (62 loc) · 1.34 KB
/
16Ssubstractive.pl
File metadata and controls
70 lines (62 loc) · 1.34 KB
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
#! /usr/bin/perl -w
use POSIX;
use Math::Combinatorics;
#Author: Fiona J. Whelan
#Date: May 23rd 2017
#Usage: 16Ssubstractive.pl otu_table plate_list
#Check usage
if (($#ARGV+1) < 2) {
print "\nError: give me the parameters I need!\n";
print "Usage: 16Ssubstractive.pl otu_table plate_list\n";
exit;
}
#Save var input
$otu_table = $ARGV[0];
$plate_list = $ARGV[1];
$relAbundCutoff = 0.01;
#Translate plate names to otu table column positions
open (LIST, "<", $plate_list) or die "$!";
@plates = ();
foreach $line (<LIST>) {
chomp($line);
push @plates, "$line";
}
close LIST;
open (TABLE, "<", $otu_table) or die "$!";
$firstline = <TABLE>;
close TABLE;
@first = split /\t/, $firstline;
@platePos = ();
$count = 0;
%plate_pos = ();
foreach $i (@first) {
if ( grep(/$i/, @plates)) {
push @platePos, $count;
$plate_pos{$count} = $i;
}
$count++;
}
#Union x
my @c;
for ($a = $#platePos+1; $a >= 1; $a--) {
push @c, combine($a+1,@platePos);
}
for $c_ele ( 0 .. $#c ) {
open (TABLE, "<", $otu_table) or die "$!";
#skip first line
<TABLE>;
foreach $woline (<TABLE>) {
@line = split /\t/, $woline;
$FLAG = 0;
for $element (0 .. $#{ $c[$c_ele] } ) {
if ($line[$c[$c_ele][$element]] <= $relAbundCutoff) {
$FLAG = 1;
last;
}
}
if ($FLAG == 0) {
foreach $e (@{ $c[$c_ele] }) { print $plate_pos{$e}." ";} print "\n";
last;
}
}
}