-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRenameQueryHits.pl
More file actions
59 lines (58 loc) · 1.36 KB
/
RenameQueryHits.pl
File metadata and controls
59 lines (58 loc) · 1.36 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
#latest version modified by Pablo Cruz-Morales Sept 2022
#renames hits file
use strict;
use lib './';
use experimental 'smartmatch';
open (NAMES,"GENOMES.IDs") or die "Couldn't open NAMES file $!";
open (SEQUENCE,"QUERY_HITS.txt") or die "Couldn't open QUERY_HITS.txt file $!";
open (OUT,">>QUERY_HITS.faa") or die "Couldn't open QUERY_HITS.faa file $!";
my %SEQUENCES;
my %NAMES;
my$name;
#########################################################################
readNames(\%NAMES);
readSequence(\%SEQUENCES,\%NAMES);
close NAMES;
close SEQUENCE;
close OUT;
##########################################################################
sub readNames{
my $refNAMES=shift;
my $count=1;
foreach my $line (<NAMES>){
chomp $line;
my @st=split("\t",$line);
my $org=$count;
$count++;
my $name=$st[2];
$name=~s/\[\)\(\,\.\-\]\=/\_/g;
$name=~s/\s/\_/g;
$name=~s/\_\_/\_/g;
$refNAMES->{$org}=$name;
print "$org¡$refNAMES->{$org}!\n";
}
}
sub readSequence{
my $refSEQUENCES=shift;
my $refNAMES=shift;
my $Org="Empty";
foreach my $line (<SEQUENCE>){
chomp $line;
print "LINE $line\n";
if ($line=~m/>/){
$Org=$line;
my $peg="";
if($Org=~/peg/){
$Org=~s/peg_(\d*)//;
$peg=$1;
}
$Org=~s/>_org//;
print "¡$Org!\n";
my $name=$refNAMES->{$Org}."_peg_".$peg."_org_"."$Org";
print OUT ">$name\n";
}
else{#
print OUT "$line\n";
}
}
}