Mercurial > repos > cstrittmatter > test_galtrakr_eurl_vtec_wgs_pt_23
comparison scripts/MultifastaFromBlast.pl @ 0:8be2feb96994
"planemo upload commit cb65588391944306ff3cb32a23e1c28f65122014"
author | cstrittmatter |
---|---|
date | Fri, 11 Mar 2022 15:50:35 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:8be2feb96994 |
---|---|
1 #!/usr/bin/env perl | |
2 use strict; | |
3 use warnings; | |
4 use English; | |
5 | |
6 # Parse arguments | |
7 my ($inputs, $output) = @ARGV; | |
8 # Run program | |
9 unlink $output; | |
10 my @infiles = split( /,/, $inputs ); | |
11 foreach(@infiles) { | |
12 transformFileContent($_, $output); | |
13 } | |
14 | |
15 # read input file and write multifasta with sequence (forward or reverse complement) | |
16 sub transformFileContent { | |
17 my ($infile, $outfile) = @_; | |
18 open my $if, '<', $infile or die "Cannot open : $infile!"; | |
19 open my $of, '>>', $outfile or die "Cannot open : $outfile!"; | |
20 my @lines = <$if>; | |
21 close $if; | |
22 foreach(@lines) { | |
23 my @elems = split( /\t/, $_ ); | |
24 print $of ">$elems[0]\n"; | |
25 chomp $elems[2]; | |
26 if ($elems[1] == 1) { | |
27 print $of "$elems[2]\n"; | |
28 } | |
29 else { | |
30 my $revcomp = reverseComplement($elems[2]); | |
31 print $of "$revcomp\n"; | |
32 } | |
33 } | |
34 close $of; | |
35 return 0; | |
36 } | |
37 | |
38 # calculate reverse complement | |
39 sub reverseComplement { | |
40 my ($DNA) = @_; | |
41 my $revcom = reverse $DNA; | |
42 $revcom =~ tr/ACGTacgt/TGCAtgca/; | |
43 return $revcom; | |
44 } |