forked from vinuesa/get_phylomarkers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert_aln_format_batch_bp.pl
executable file
·61 lines (47 loc) · 2.09 KB
/
convert_aln_format_batch_bp.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
#!/usr/bin/perl -w
# Use BioPerl's Bio::AlignIO to convert between multiple sequence alignment formats
# Pablo Vinuesa July 2007. [email protected]
use strict;
chomp(my $HOSTNAME = `hostname`);
if ($HOSTNAME =~ /kayab/){use lib '/state/partition1/space12/PIG/vinuesa/marfil/CVS_code/BioPerl-1.6.1'};
use Bio::AlignIO;
# 1) Declare variable, get input arguments from the command line and print help if needed
if ($#ARGV < 3)
{
print "Usage: $0 inputformat infile_ext outputformat outputfile_ext\n
Supported formats include:
bl2seq Bl2seq Blast output
clustalw clustalw (.aln) format
emboss EMBOSS water and needle format
fasta FASTA format
maf Multiple Alignment Format
mase mase (seaview) format
mega MEGA format
meme MEME format
msf msf (GCG) format
nexus Swofford et al NEXUS format
pfam Pfam sequence alignment format
phylip Felsenstein PHYLIP format
prodom prodom (protein domain) format
psi PSI?BLAST format
selex selex (hmmer) format
stockholm stockholm format\n\n\n";
exit;
}
my($inputformat, $infile_ext, $outputformat, $outputfile_ext)=@ARGV;
my @infiles = <*$infile_ext>;
my($basename,$counter);
# 2) Process all files in cwd having infile_ext, converting them from inputformat to outputformat
# with the outputfile_ext provided at the command line
foreach my $infile ( @infiles )
{
$basename = (split(/\./, $infile))[0];
my $in = Bio::AlignIO->new(-file => $basename . ".$infile_ext", -format => $inputformat);
my $out = Bio::AlignIO->new(-file => ">$basename.$outputfile_ext", -format => $outputformat);
while ( my $aln = $in->next_aln() )
{
$out->write_aln($aln);
}
$counter++;
}
print "\n\t# I'm done: $counter $inputformat input files with $infile_ext extension were converted to $outputformat format with $outputfile_ext extension\n\n";