Skip to content

Commit

Permalink
orthograph2hamstrad.pl now also accepts summarized directories
Browse files Browse the repository at this point in the history
  • Loading branch information
mptrsen committed Nov 24, 2015
2 parents a9bd70c + a121c13 commit 41cd9cc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
@@ -1,6 +1,13 @@
Changes since release 0.5.7
===========================

* orthograph2hamstrad.pl now also accepts directories that were summarized using summarize_orthograph_results.pl


Changes since release 0.5.6
===========================

* Fixed bug in orthograph2hamstrad.pl that prevented summarized data to be converted
* Moved notification on reftaxon skipping to `verbose`, improved wording on said message
* Alignment files for ortholog set now contain the reference OGS headers, not just database IDs

Expand Down
31 changes: 22 additions & 9 deletions orthograph2hamstrad.pl
Expand Up @@ -20,14 +20,27 @@
__EOT__


my $indir = shift @ARGV or print $usage and exit;
my $indir = shift @ARGV or print $usage and exit;
my $outdir = shift @ARGV or print $usage and exit;

# input and output directories
my $aaind = catdir($indir, 'aa');
my $ntind = catdir($indir, 'nt');
my $ntod = catdir($outdir, 'nt');
my $aaod = catdir($outdir, 'aa');
my $aaind = catdir($indir, 'aa');
my $ntind = catdir($indir, 'nt');
my $ntod = catdir($outdir, 'nt');
my $aaod = catdir($outdir, 'aa');

# see whether we have summarized data or not, change input directory accordingly
if (! -d $aaind) {
if (-d catdir($indir, 'aa_summarized') and -d catdir($indir, 'nt_summarized')) {
$aaind = catdir($indir, 'aa_summarized');
$ntind = catdir($indir, 'nt_summarized');
$ntod = catdir($outdir, 'nt_summarized');
$aaod = catdir($outdir, 'aa_summarized');
}
else {
die "Fatal: could not find aa and nt subdirectories. Is this an Orthograph output directory?\n"
}
}

# create nt output dir unless it exists
create_dir($ntod);
Expand All @@ -45,8 +58,8 @@
next unless $f =~ /\.fa$/;
(my $basename = $f) =~ s/\.aa(\.summarized)?(\.mafft)?\.fa$//;

my $summarized = defined $1 ? '.' . $1 : '';
my $mafft = defined $2 ? '.' . $2 : '';
my $summarized = defined $1 ? $1 : '';
my $mafft = defined $2 ? $2 : '';

my $aafile = catfile($aaind, $f);
my $ntfile = catfile($ntind, $basename . '.nt' . $summarized . $mafft . '.fa');
Expand All @@ -62,8 +75,8 @@
my $ntdata = fasta2arrayref($ntfile);

# open output files
open my $ntofh, '>', catfile($ntod, $basename . '.nt.fa');
open my $aaofh, '>', catfile($aaod, $basename . '.aa.fa');
open my $ntofh, '>', catfile($ntod, $basename . $summarized . $mafft . '.nt.fa');
open my $aaofh, '>', catfile($aaod, $basename . $summarized . $mafft . '.aa.fa');

foreach my $item (@$aadata) {

Expand Down

0 comments on commit 41cd9cc

Please sign in to comment.