-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathfasta2hmm.pl
executable file
·65 lines (60 loc) · 1.71 KB
/
fasta2hmm.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
#!/usr/bin/perl
# Script: fasta2hmm.pl
# Description: Pipeline for converting unaligned fasta files to hmm files
# Author: Steven Ahrendt
# email: [email protected]
# Date: 1.22.13
#######################################
# Cluster w/ uclust at 85%
# Align w/ Tcoffee
# Convert from Clustalw to aligned Fasta
# Build HMM
#######################################
# Usage: perl fasta2hmm.pl fastafile [-c] [-s]
#######################################
use strict;
use warnings;
use Getopt::Long;
use Cwd;
my $input;
my $shell; # Make a shell script instead of running
my ($help,$verb,$clust);
GetOptions ('i|input=s' => \$input,
'h|help' => \$help,
'v|verbose' => \$verb,
'c|cluster' => \$clust,
's|shell' => \$shell);
my $usage = "Usage: perl fasta2hmm.pl -i fastafile [-c] [-s]\n";
die $usage if $help;
die "No input file: $!\n$usage" if (!$input);
my $fasta = $input;
my $fasta_name = (split(/\./,$fasta))[0];
print $fasta,"\n";
## Display Steps
my $tc_in = $fasta;
if($shell)
{
open(SH,">fas2hmm.sh");
print SH "module load usearch\n";
if($clust)
{
$tc_in = "$fasta_name\.cluster";
print SH "usearch -cluster_fast $fasta -id 0.85 -centroids $tc_in\n";
}
print SH "t_coffee $tc_in -n_core=4 -output=fasta_aln\n";
print SH "hmmbuild --cpu 4 --informat afa $fasta_name.hmm $fasta_name\.fasta_aln\n";
print SH "hmmpress $fasta_name.hmm\n";
close(SH);
print `chmod 744 fas2hmm.sh`;
}
else
{
## Run Steps
if($clust)
{
print `usearch -cluster_fast $fasta -id 0.85 -centroids $tc_in`;
}
print `t_coffee $tc_in -n_core=4 -output=fasta_aln`;
print `hmmbuild --cpu 4 --informat afa $fasta_name.hmm $fasta_name\.fasta_aln`;
print `hmmpress $fasta_name.hmm`;
}