script/extract-mcl-out.pl untested

filter: Statementstmt 0.0% 0 / 50 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 11 Podpod n/a totaltotal 0.0% 0 / 68 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/env perl
2 # PODNAME: extract-mcl-out.pl
3 # ABSTRACT: Extract orthogroups (FASTA files) from MCL clusters
4  
5 use Modern::Perl '2011';
6 use autodie;
7  
8 use File::Basename;
9 use Getopt::Euclid qw(:vars);
10 use Path::Class qw(dir file);
11 use Smart::Comments;
12  
13 use Bio::MUST::Core;
14 use Bio::MUST::Core::Constants qw(:files);
15 use Bio::MUST::Core::Utils qw(change_suffix);
16 use aliased 'Bio::MUST::Core::Ali::Stash';
17 use aliased 'Bio::MUST::Core::IdList';
18  
19  
20 my $db = Stash->load($ARGV_database);
21  
22 for my $infile (@ARGV_infiles) {
23  
24 ### Processing: $infile
25  
26 # create directory named after filename
27 my ($filename) = fileparse($infile, qr{\.[^.]*}xms);
28 my $dir = dir($filename)->relative;
29 $dir->mkpath();
30  
31 # TODO: move this part to some object returning a ordered hash of IdList
32  
33 open my $in, '<', $infile;
34  
35 LINE:
36 while (my $line = <$in>) {
37 chomp $line;
38  
39 # skip empty lines and other comment lines
40 next LINE if $line =~ $EMPTY_LINE
41 || $line =~ $COMMENT_LINE;
42  
43 # extract id list for current group
44 my ($group, @ids) = split /\s+/xms, $line;
45 $group =~ s/:\z//xms; # remove trailing colon (:)
46 my $list = IdList->new( ids => \@ids );
47  
48 # assemble Ali and store it as FASTA file
49 my $ali = $list->reordered_ali($db);
50 $ali->dont_guess;
51 my $outfile = file($dir, change_suffix($group, '.fasta') )->stringify;
52 $ali->store_fasta($outfile);
53 }
54 }
55  
56 __END__