-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathunalign.pl
More file actions
executable file
·54 lines (47 loc) · 1.25 KB
/
unalign.pl
File metadata and controls
executable file
·54 lines (47 loc) · 1.25 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
#!/usr/bin/perl -w
# Script: unalign.pl
# Description: Un-aligns a fasta-formatted alignment
# Author: Steven Ahrendt
# email: sahrendt0@gmail.com
# Date: 6.23.11
####################
use strict;
use Bio::Seq;
use Bio::SeqIO;
use Getopt::Long;
#####-----Global Variables-----#####
my $input;
my ($help,$verb);
GetOptions ('i|input=s' => \$input,
'h|help' => \$help,
'v|verbose' => \$verb);
my $usage = "unalign.pl -i alignfile\nUn-aligns a fasta-formatted alignment\n";
die $usage if $help;
die "No input.\n$usage" if (!$input);
#####-----Main-----#####
my $name = getName($input);
my $alignmentfile = new Bio::SeqIO(-file=>$input,
-format=>'fasta');
while (my $seq = $alignmentfile->next_seq)
{
my $dealseq = $seq->seq();
$dealseq =~ s/-//g;
$dealseq =~ s/\.//g;
$seq->seq($dealseq);
my $dealignmentfile = new Bio::SeqIO(-file=>">>$name\_unal.fa",
-format=>'fasta');
$dealignmentfile->write_seq($seq);
}
warn "Done.\n";
exit(0);
#####-----Subroutines-----#####
sub getName {
my $in = shift @_;
my @infilename = split(/\./,$in);
my $name = $infilename[0];
if(scalar(@infilename) > 2)
{
pop(@infilename);
$name = join(".",@infilename);
}
}