Skip to content

Commit 0491870

Browse files
committed
fix bug on macos, h1s works with fas >= 1.4
1 parent e95c25f commit 0491870

File tree

5 files changed

+52
-29
lines changed

5 files changed

+52
-29
lines changed

h1s/bin/hamstr.pl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ sub checkInput {
12541254

12551255
## 13) setting up the directories where the output files will be put into.
12561256
$fa_dir_neu = $outpath . '/fa_dir_' . $dbfile_short . '_' . $hmmset . '_' . $refspec[0];
1257-
$tmpdir = $outpath . '/' . $tmpdir;
1257+
# $tmpdir = $tmpdir;
12581258
if (!$strict) {
12591259
$fa_dir_neu = $outpath . '/fa_dir_' . $dbfile_short . '_' . $hmmset . '_' . $refspec[0];
12601260
}
@@ -1281,10 +1281,10 @@ sub checkInput {
12811281
`rm -rf "$fa_dir_neu"`;
12821282
`mkdir "$fa_dir_neu"`;
12831283
}
1284-
if (!(-e "$tmpdir")) {
1284+
if (!(-d "$tmpdir")) {
12851285
`mkdir "$tmpdir"`;
12861286
}
1287-
elsif (-e "$tmpdir" and $cleartmp) {
1287+
elsif (-d "$tmpdir" and $cleartmp) {
12881288
`rm -rf "$tmpdir"`;
12891289
`mkdir "$tmpdir"`;
12901290
}

h1s/bin/oneSeq.pl

+46-23
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@
169169
my $annotation_prog = "annoFAS";
170170
my $fas_prog = "calcFAS";
171171
my $hamstrFAS_prog = "hamstrFAS";
172+
if (check_exists_command("fdogFAS")) {
173+
$hamstrFAS_prog = "fdogFAS";
174+
}
172175

173176
##### ublast Baustelle: not implemented yet
174177
my $runublast = 0;
@@ -607,6 +610,7 @@
607610
my $final_eval_blast = $eval_blast*$eval_relaxfac;
608611
my $final_eval_hmmer = $eval_hmmer*$eval_relaxfac;
609612

613+
$taxaPath = $genome_dir;
610614
my @searchTaxa;
611615
unless($groupNode) {
612616
@searchTaxa = keys %taxa;
@@ -643,14 +647,16 @@
643647
foreach (sort @searchTaxa) {
644648
chomp(my $searchTaxon = $_);
645649
my $pid = $pm->start and next;
646-
my $doneTaxon = runHamstr($searchTaxon, $seqName, $finalOutput, $refSpec, $hitlimit, $representative, $strict, $coremode, $final_eval_blast, $final_eval_hmmer, $aln);
647-
unless ($silent) {
648-
print $doneTaxon,"\t";
649-
}
650-
my $doneTaxonName = getTaxonName($doneTaxon);
651-
if (defined($doneTaxonName)) {
652-
print $doneTaxonName, " DONE\n";
650+
651+
my $searchTaxonName = getTaxonName($searchTaxon);
652+
if (defined($searchTaxonName)) {
653+
unless ($silent) {
654+
print $searchTaxon, "\t", $searchTaxonName, "\n";
655+
} else {
656+
print $searchTaxonName, "\n";
657+
}
653658
}
659+
runHamstr($searchTaxon, $seqName, $finalOutput, $refSpec, $hitlimit, $representative, $strict, $coremode, $final_eval_blast, $final_eval_hmmer, $aln);
654660
$pm->finish;
655661
}
656662
$pm->wait_all_children;
@@ -1568,14 +1574,16 @@ sub getBestOrtholog {
15681574
unless ($silent) {
15691575
print "Hamstr species: " . $key->scientific_name . " - " . @{$key->name('supplied')}[0] . "\n";
15701576
}
1571-
my $doneTaxon = runHamstr(@{$key->name('supplied')}[0], $seqName, $outputFa, $refSpec, $core_hitlimit, $core_rep, $corestrict, $coremode, $eval_blast, $eval_hmmer, $aln);
1572-
unless ($silent) {
1573-
print $doneTaxon,"\t";
1574-
}
1575-
my $doneTaxonName = getTaxonName($doneTaxon);
1576-
if (defined($doneTaxonName)) {
1577-
print $doneTaxonName, " DONE\n";
1577+
my $coreTaxon = @{$key->name('supplied')}[0];
1578+
my $coreTaxonName = getTaxonName($coreTaxon);
1579+
if (defined($coreTaxonName)) {
1580+
unless ($silent) {
1581+
print $coreTaxon, "\t", $coreTaxonName, "\n";
1582+
} else {
1583+
print $coreTaxonName, "\n";
1584+
}
15781585
}
1586+
runHamstr($coreTaxon, $seqName, $outputFa, $refSpec, $core_hitlimit, $core_rep, $corestrict, $coremode, $eval_blast, $eval_hmmer, $aln);
15791587
## check weather a candidate was found in the searched taxon
15801588
if(-e $candidatesFile) {
15811589

@@ -1900,11 +1908,11 @@ sub getRefTree {
19001908
sub getTaxonName {
19011909
my $taxAbbr = $_[0];
19021910
my @tmp = split(/@/,$taxAbbr);
1903-
my $taxon = $db_bkp->get_taxon($tmp[1]);
1911+
my $taxon = $db_bkp->get_taxon(-taxonid => $tmp[1]);
19041912
if (defined($taxon)) {
19051913
return($taxon->scientific_name);
19061914
} else {
1907-
return("Unk NCBI taxon");
1915+
return("Unk NCBI taxon for $taxAbbr");
19081916
}
19091917
}
19101918

@@ -2043,7 +2051,6 @@ sub runHamstr {
20432051
else {
20442052
print "No protein set available for $taxon. Failed to fetch it from database and nothing at $taxaDir. Skipping!\n";
20452053
}
2046-
return($taxon);
20472054
}
20482055

20492056
# add seed sequence to output file if not exists
@@ -2062,19 +2069,30 @@ sub addSeedSeq {
20622069
}
20632070
}
20642071
}
2065-
# get seed seq
2072+
# get seed sequence and add to be beginning of the fasta output
2073+
open(TEMP, ">$outputFa.temp") or die "Cannot create $outputFa.temp!\n";
2074+
my $seedFa = "";
20662075
if ($flag == 1) {
2076+
# first, write the seed to TEMP
20672077
my $seqio = Bio::SeqIO->new(-file => "$coreOrthologsPath/$seqName/$seqName.fa", '-format' => 'Fasta');
20682078
while(my $seq = $seqio->next_seq) {
20692079
my $id = $seq->id;
20702080
if ($id =~ /$refSpec/) {
2071-
my $seedFa = ">".$id."|1\n".$seq->seq;
2072-
# append to begining of outputFa
2073-
my $headCommand = "sed -i \'1s/^/". ">".$id."|1\\n".$seq->seq . "\\n/\' " . $outputFa;
2074-
system($headCommand);
2081+
print TEMP ">$id|1\n", $seq->seq, "\n";
2082+
last;
2083+
}
2084+
}
2085+
# then write other sequences
2086+
my $seqio2 = Bio::SeqIO->new(-file => "$outputFa", '-format' => 'Fasta');
2087+
while(my $seq = $seqio2->next_seq) {
2088+
my $id = $seq->id;
2089+
if ($id !~ /$refSpec/) {
2090+
print TEMP ">$id\n", $seq->seq, "\n";
20752091
}
20762092
}
20772093
}
2094+
close(TEMP);
2095+
system("mv $outputFa.temp $outputFa")
20782096
}
20792097

20802098
##########################
@@ -2549,7 +2567,7 @@ sub initialCheck {
25492567
}
25502568

25512569
# check executable FAS
2552-
my $fasCheckMsg = `prepareFAS -t ./ -c 2>&1`;
2570+
my $fasCheckMsg = `$hamstrFAS_prog -t ./ -c 2>&1`;
25532571
if ($fasoff != 1 && $fasCheckMsg =~ /ERROR/) {
25542572
die "ERROR: greedyFAS not ready to use! Please check https://github.com/BIONF/FAS/wiki/prepareFAS\n";
25552573
}
@@ -2642,6 +2660,11 @@ sub checkValidFolderName {
26422660
sub gettime { sprintf"%d.%03d",Time::HiRes::gettimeofday }
26432661
sub roundtime { sprintf("%.2f", $_[0]); }
26442662

2663+
sub check_exists_command {
2664+
my $check = `sh -c 'command -v $_[0]'`;
2665+
return $check;
2666+
}
2667+
26452668
###########################
26462669
sub helpMessage {
26472670
my $helpmessage = "

h1s/h1s.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def h1s(args):
161161
sys.exit('Problem running\n%s' % (cmd))
162162

163163
def main():
164-
version = '2.2.17'
164+
version = '2.2.18'
165165
parser = argparse.ArgumentParser(description='You are running h1s version ' + str(version) + '.')
166166
parser.add_argument('--version', action='version', version=str(version))
167167
required = parser.add_argument_group('Required arguments')

h1s/hms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def calcFAS (outpath, extendedFa, weightpath, cpu):
178178
sys.exit('Problem running\n%s' % (fasCmd))
179179

180180
def main():
181-
version = '2.2.17'
181+
version = '2.2.18'
182182
parser = argparse.ArgumentParser(description='You are running h1s version ' + str(version) + '.')
183183
parser.add_argument('--version', action='version', version=str(version))
184184
required = parser.add_argument_group('Required arguments')

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
setup(
2828
name="h1s",
29-
version="2.2.17",
29+
version="2.2.18",
3030
python_requires='>=3.7.0',
3131
description="Feature-aware orthology prediction tool",
3232
long_description=long_description,

0 commit comments

Comments
 (0)