-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse_hits.pl
executable file
·73 lines (58 loc) · 1.86 KB
/
parse_hits.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
#!/usr/bin/perl
#--INCLUDE PACKAGES-----------------------------------------------------------
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#----SUBROUTINES--------------------------------------------------------------
#-----------------------------------------------------------------------------
sub WriteArrayToFile
{
my ($filename, @in) = @_;
my $a = join (@in, "\n");
open (OUTFILE, ">$filename");
foreach my $a (@in)
{
print OUTFILE $a;
print OUTFILE "\n";
}
close (OUTFILE);
}
#-------------------------------------------
$ResultDirectory = $ARGV[2];
if (not defined $ARGV[2] ) {
$ResultDirectory = cwd();
}
$filenameA = $ResultDirectory."/".$ARGV[0];
$filenameOut = $ResultDirectory."/".$ARGV[1];
my @identarray;
open $FILEA, "< $filenameA";
open $OUTFILE, "> $filenameOut";
open $TEMP, ">".$ResultDirectory."/temp.temp";
while (<$FILEA>)
{
my $a=$_;
$a =~s/-//g;
my @aa = split(//,$a);
my @bb = split(//,$ARGV[0]);
#if ($aa[0] eq ">") { print $TEMP $_ unless $_ eq "\n"; }
#else {print $TEMP $a unless $a eq "\n";}
if ($aa[0] eq ">") {chomp($a);$a = $a.$bb[7]."\n";}
print $TEMP $a unless $a eq "\n";
}
close $TEMP;
open $TEMP, "<".$ResultDirectory."/temp.temp";
while(<$TEMP>) {
print $OUTFILE $_;
my $a=$_; chomp $a; my @aa = split(//,$a); if ($aa[0] eq ">") {$a =~s/>//g; push (@identarray, $a);}
$_ = <$TEMP>;
print $OUTFILE $_;
$a=$_;chomp $a; @aa = split(//,$a); if ($aa[0] eq ">") {$a =~s/>//g; push (@identarray, $a);}
$_ = <$TEMP>;
# print $OUTFILE $_;
$_ = <$TEMP>;
# print $OUTFILE $_;
}
close $TEMP;
system ("rm ".$ResultDirectory."/temp.temp");
close $FILEA;
close $OUTFILE;
#WriteArrayToFile($filenameOut.".tags", @identarray);