-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathFM_ZygoAnalysis.pl
executable file
·76 lines (70 loc) · 1.52 KB
/
FM_ZygoAnalysis.pl
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
#!/usr/bin/perl
# Script: FM_ZygoAnalysis.pl
# Description: Specific script for analysis of Zygomycete run
# Author: Steven Ahrendt
# email: [email protected]
# Date: 03.11.2014
##################################
use warnings;
use strict;
use Getopt::Long;
#####-----Global Variables-----#####
my $input;
my $textfile;
my %fm_data;
my ($help,$verb);
GetOptions ('i|input=s' => \$input,
't|text=s' => \$textfile,
'h|help' => \$help,
'v|verbose' => \$verb);
my $usage = "Usage: FM_ZygoAnalysis.pl -i input -t textfile\n";
die $usage if $help;
die "No input.\n$usage" if (!$input);
die "No textfile.\n$usage" if (!$textfile);
#####-----Main-----#####
open(HASH,"<$textfile") or die "Can't open $textfile: $!\n";
while(my $line = <HASH>)
{
chomp $line;
my ($key,$val) = split(/\t/,$line);
$fm_data{$key} = $val;
}
close(HASH);
open(IN,"<$input") or die "Can't open $input: $!\n";
while(my $line = <IN>)
{
chomp $line;
if($line =~ /^Org/)
{
my $new_line = reformatLine($line);
print $new_line,"\n";
}
else
{
print $line,"\n";
}
}
close(IN);
warn "Done.\n";
exit(0);
#####-----Subroutines-----#####
sub reformatLine
{
my $line = shift @_;
my @data = split(/\t/,$line);
my @new_data;
#my $d=0;
foreach my $dat (@data)
{
if($dat ne "Org")
{
$dat = (split(/\|/,$dat))[2];
if(exists $fm_data{$dat}){$dat = $fm_data{$dat};}
}
#print "$d: $dat\n";
#$d++;
push @new_data,$dat;
}
my $new_line = join("\t",@new_data);
return $new_line;
}