File: Map.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 (54 lines) | stat: -rwxr-xr-x 789 bytes parent folder | download | duplicates (8)
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
#!/usr/bin/perl

use strict;

my $mapFile = $ARGV[0];

open(MAPFILE, $mapFile) or die "Can't open $mapFile\n";

my @map = ();

while(my $line = <MAPFILE>){
    chomp($line);
    my @tokens = split(/:/,$line);
    push(@map, $tokens[2]);
}

close(MAPFILE);


my $nOTUs  = 0;

while(my $line = <STDIN>){
    chomp($line);
    my @tokens = split(/ /,$line);
    my $d = shift(@tokens);

    $nOTUs = shift(@tokens);
    
    print "$d $nOTUs ";

    for(my $i = 0; $i < $nOTUs; $i++){
	my @tokens2 = split(/,/,$tokens[$i]);
	my $size = scalar(@tokens2);

	for(my $j = 0; $j < $size - 1; $j++){
	    print "$map[$tokens2[$j]],";
	}
	print "$map[$tokens2[$size - 1]] ";
    }
    print "\n";
}


sub min
{
    my ($x, $y) = @_;

    if($x < $y){
	return $x;
    }
    else{
	return $y;
    }
}