[med-svn] [prank] 03/08: New upstream version 0.0.170427+dfsg
Andreas Tille
tille at debian.org
Tue Sep 12 09:41:32 UTC 2017
This is an automated email from the git hooks/post-receive script.
tille pushed a commit to branch master
in repository prank.
commit 0acd6a36772c16be9130de888b911feca81c2fef
Author: Andreas Tille <tille at debian.org>
Date: Tue Sep 12 11:22:04 2017 +0200
New upstream version 0.0.170427+dfsg
---
VERSION_HISTORY | 7 ++++++
src/bppancestors.cpp | 57 ++++++++++++------------------------------------
src/bppancestors.h | 15 -------------
src/config.h | 6 +++++
src/exonerate_reads.cpp | 40 +++++++++++-----------------------
src/exonerate_reads.h | 14 ------------
src/hirschberg.cpp | 4 ++--
src/hmmodel.cpp | 3 ++-
src/mafft_alignment.cpp | 32 +++++++++------------------
src/mafft_alignment.h | 13 -----------
src/prank.1 | 41 ++++++++++++++++++++--------------
src/prank.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++-
src/readalignment.cpp | 4 ++--
13 files changed, 138 insertions(+), 156 deletions(-)
diff --git a/VERSION_HISTORY b/VERSION_HISTORY
index 8dfb25d..ab22fb7 100644
--- a/VERSION_HISTORY
+++ b/VERSION_HISTORY
@@ -1,3 +1,10 @@
+v.170427
+Changes by Nikolai Hecker
+- make the temp files thread safe
+- fix a compile issue with GCC 6.2.0
+- reduce the information written to stdout; disable with "-verbose"
+
+
v.150803
- force linear order of alignment anchors
- convert multifurcating trees to bifurcating ones
diff --git a/src/bppancestors.cpp b/src/bppancestors.cpp
index 62c6218..60c5b95 100644
--- a/src/bppancestors.cpp
+++ b/src/bppancestors.cpp
@@ -44,7 +44,7 @@ bool BppAncestors::testExecutable()
{
#if defined (__CYGWIN__)
- char path[200];
+ char path[200] = "";
int length = readlink("/proc/self/exe",path,200-1);
string epath = string(path).substr(0,length);
@@ -58,7 +58,7 @@ bool BppAncestors::testExecutable()
# else
- char path[200];
+ char path[200] = "";
string epath;
#if defined (__APPLE__)
@@ -94,13 +94,9 @@ bool BppAncestors::testExecutable()
bool BppAncestors::inferAncestors(AncestralNode *root,map<string,string> *aseqs,string *atree,bool isDna)
{
-
- string tmp_dir = this->get_temp_dir();
-
stringstream f_name;
stringstream t_name;
stringstream o_name;
- stringstream m_name;
int r = rand();
while(true)
@@ -109,21 +105,18 @@ bool BppAncestors::inferAncestors(AncestralNode *root,map<string,string> *aseqs,
f_name.str("");
t_name.str("");
o_name.str("");
- m_name.str("");
- f_name <<tmp_dir<<"f"<<r<<".fas";
+ f_name <<tmp_dir<<"/f"<<r<<".fas";
ifstream f_file(f_name.str().c_str());
- t_name <<tmp_dir<<"t"<<r<<".tre";
+ t_name <<tmp_dir<<"/t"<<r<<".tre";
ifstream t_file(t_name.str().c_str());
- o_name <<tmp_dir<<"o"<<r<<".fas";
+ o_name <<tmp_dir<<"/o"<<r<<".fas";
ifstream o_file(t_name.str().c_str());
- m_name <<tmp_dir<<"m"<<r<<".tre";
- ifstream m_file(t_name.str().c_str());
- if(!f_file && !t_file && !o_file && !m_file)
+ if(!f_file && !t_file && !o_file )
{
ofstream f_tmp;
f_tmp.open(f_name.str().c_str(), (ios::out) );
@@ -263,35 +256,13 @@ bool BppAncestors::inferAncestors(AncestralNode *root,map<string,string> *aseqs,
aseqs->insert(aseqs->begin(),pair<string,string>("#"+n.at(i)+"#",s.at(i)));
}
- this->delete_files(r);
-
+ //delete files
+ if ( remove( f_name.str().c_str() ) != 0)
+ perror("Error deleting temporary file in BppAncestors::inferAncestors");
+ if ( remove( t_name.str().c_str()) != 0 )
+ perror("Error deleting temporary file in BppAncestors::inferAncestors");
+ if ( remove( o_name.str().c_str()) != 0 )
+ perror("Error deleting temporary file in BppAncestors::inferAncestors");
+
return (rv>0);
}
-
-void BppAncestors::delete_files(int r)
-{
-
- string tmp_dir = this->get_temp_dir();
-
- stringstream t_name;
- t_name <<tmp_dir<<"t"<<r<<".tre";
-
- stringstream f_name;
- f_name <<tmp_dir<<"f"<<r<<".fas";
-
- stringstream o_name;
- o_name <<tmp_dir<<"o"<<r<<".fas";
-
-// stringstream m_name;
-// m_name <<tmp_dir<<"m"<<r<<".tre";
-
- if ( remove( t_name.str().c_str() ) != 0 )
- perror( "Error deleting file" );
- if ( remove( f_name.str().c_str() ) != 0 )
- perror( "Error deleting file");
- if ( remove( o_name.str().c_str() ) != 0 )
- perror( "Error deleting file");
-// if ( remove( m_name.str().c_str() ) != 0 )
-// perror( "Error deleting file");
-
-}
diff --git a/src/bppancestors.h b/src/bppancestors.h
index d66dd96..f25a620 100644
--- a/src/bppancestors.h
+++ b/src/bppancestors.h
@@ -29,21 +29,6 @@ class BppAncestors
{
std::string bppdistpath;
- std::string get_temp_dir()
- {
- std::string tmp_dir = "/tmp/";
- if(tempdir != "")
- tmp_dir = tempdir+"/";
-
- struct stat st;
- if(stat(tmp_dir.c_str(),&st) != 0)
- tmp_dir = "";
-
- return tmp_dir;
- }
-
- void delete_files(int r);
-
public:
BppAncestors();
bool testExecutable();
diff --git a/src/config.h b/src/config.h
index bde30ed..36d1012 100644
--- a/src/config.h
+++ b/src/config.h
@@ -181,4 +181,10 @@ extern float pwInitialMatrixSize;
extern double sumLogs(double a, double b);
extern std::string itos(int i);
+//global variable for temporary directory
+extern char tmp_dir[1000];
+
+//global variable for verbose flag
+extern bool verbose;
+
#endif
diff --git a/src/exonerate_reads.cpp b/src/exonerate_reads.cpp
index 564cb4f..e2a2a7c 100644
--- a/src/exonerate_reads.cpp
+++ b/src/exonerate_reads.cpp
@@ -28,7 +28,7 @@ bool Exonerate_reads::test_executable()
int status = -1;
#if defined (__CYGWIN__)
- char path[200];
+ char path[200] = "";
int length = readlink("/proc/self/exe",path,200-1);
string epath = string(path).substr(0,length);
@@ -42,7 +42,7 @@ bool Exonerate_reads::test_executable()
if(WEXITSTATUS(status) != 1)
{
- char path[200];
+ char path[200] = "";
string epath;
#if defined (__APPLE__)
@@ -117,17 +117,15 @@ void Exonerate_reads::local_alignment(string* ls,string* rs, vector<hit> *hits,
ofstream q_output;
ofstream t_output;
- string tmp_dir = this->get_temp_dir();
+ stringstream q_name;
+ stringstream t_name;
int r = rand();
while(true)
{
-
- stringstream q_name;
- stringstream t_name;
-
- q_name <<tmp_dir<<"q"<<r<<".fas";
- t_name <<tmp_dir<<"t"<<r<<".fas";
+
+ q_name <<tmp_dir<<"/q"<<r<<".fas";
+ t_name <<tmp_dir<<"/t"<<r<<".fas";
ifstream q_file(q_name.str().c_str());
ifstream t_file(t_name.str().c_str());
@@ -200,7 +198,7 @@ void Exonerate_reads::local_alignment(string* ls,string* rs, vector<hit> *hits,
// # else
// command<<"exonerate ";
// #endif
- command << " -q "+tmp_dir+"q"<<r<<".fas -t "+tmp_dir+"t"<<r<<".fas --showalignment no --showsugar yes --showvulgar no 2>&1";
+ command << " -q " <<tmp_dir<<"/q"<<r<<".fas -t "<<tmp_dir<<"/t"<<r<<".fas --showalignment no --showsugar yes --showvulgar no 2>&1";
if(NOISE>0)
cout<<"cmd: "<<command.str()<<endl;
@@ -406,22 +404,10 @@ void Exonerate_reads::local_alignment(string* ls,string* rs, vector<hit> *hits,
iter2++;
}
- this->delete_files(r);
-}
-
-void Exonerate_reads::delete_files(int r)
-{
-
- string tmp_dir = this->get_temp_dir();
-
- stringstream q_name;
- q_name <<tmp_dir<<"q"<<r<<".fas";
-
- stringstream t_name;
- t_name <<tmp_dir<<"t"<<r<<".fas";
+ //delete files
+ if( remove( q_name.str().c_str() ) != 0 )
+ perror("Error deleting temporary file in Exonerate_reads::local_alignment");
+ if( remove( t_name.str().c_str() ) != 0 )
+ perror("Error deleting temporary file in Exonerate_reads::local_alignment");
- if ( remove( q_name.str().c_str() ) != 0 )
- perror( "Error deleting file" );
- if ( remove( t_name.str().c_str() ) != 0 )
- perror( "Error deleting file");
}
diff --git a/src/exonerate_reads.h b/src/exonerate_reads.h
index 8d614f1..7d59c05 100644
--- a/src/exonerate_reads.h
+++ b/src/exonerate_reads.h
@@ -34,20 +34,6 @@ class Exonerate_reads
}
bool split_sugar_string(const std::string& row,hit *h);
- void delete_files(int r);
-
- std::string get_temp_dir()
- {
- std::string tmp_dir = "/tmp/";
- if(tempdir != "")
- tmp_dir = tempdir+"/";
-
- struct stat st;
- if(stat(tmp_dir.c_str(),&st) != 0)
- tmp_dir = "";
-
- return tmp_dir;
- }
public:
Exonerate_reads();
diff --git a/src/hirschberg.cpp b/src/hirschberg.cpp
index 0698e87..e04f656 100644
--- a/src/hirschberg.cpp
+++ b/src/hirschberg.cpp
@@ -431,7 +431,7 @@ void Hirschberg::alignSeqs(Sequence* s1,Sequence* s2,PhyloMatchScore *pms)
defineEnd();
unsigned int ii = 0;
- if (SCREEN && totalSites>0)
+ if (SCREEN && totalSites>0 && verbose == true)
{
FOR( ii,message.length())
{
@@ -859,7 +859,7 @@ void Hirschberg::divideSeq()
if (newsite->index()%reportLimit==0)
{
- if (SCREEN)
+ if (SCREEN && verbose == true)
{
unsigned int ii;
FOR(ii,message.length())
diff --git a/src/hmmodel.cpp b/src/hmmodel.cpp
index 79d0912..48cb628 100644
--- a/src/hmmodel.cpp
+++ b/src/hmmodel.cpp
@@ -22,6 +22,7 @@
#include <cmath>
#include <ctime>
#include <fstream>
+#include <iostream>
#include "hmmodel.h"
#include "eigen.h"
@@ -1510,7 +1511,7 @@ void HMModel::alignmentModel(AncestralNode *tn)
}
else
{
- cout<<"HMModel::alignmentModel: impossible 'as'"<<cout;
+ std::cout << "HMModel::alignmentModel: impossible 'as'";
exit(-1);
}
diff --git a/src/mafft_alignment.cpp b/src/mafft_alignment.cpp
index 4888bac..8c9bd0d 100644
--- a/src/mafft_alignment.cpp
+++ b/src/mafft_alignment.cpp
@@ -20,7 +20,7 @@ Mafft_alignment::Mafft_alignment()
bool Mafft_alignment::test_executable()
{
#if defined (__CYGWIN__)
- char path[200];
+ char path[200] = "";
int length = readlink("/proc/self/exe",path,200-1);
string epath = string(path).substr(0,length);
@@ -33,7 +33,7 @@ bool Mafft_alignment::test_executable()
# else
- char path[200];
+ char path[200] = "";
string epath;
#if defined (__APPLE__)
@@ -70,14 +70,13 @@ bool Mafft_alignment::test_executable()
void Mafft_alignment::align_sequences(vector<string> *names,vector<string> *sequences)
{
ofstream m_output;
- string tmp_dir = this->get_temp_dir();
+
+ stringstream m_name;
int r = rand();
while(true)
{
-
- stringstream m_name;
- m_name <<tmp_dir<<"m"<<r<<".fas";
+ m_name <<tmp_dir<<"/m"<<r<<".fas";
ifstream m_file(m_name.str().c_str());
if(!m_file)
@@ -98,7 +97,7 @@ void Mafft_alignment::align_sequences(vector<string> *names,vector<string> *sequ
m_output.close();
stringstream command;
- command << mafftpath<<"mafft "+tmp_dir+"m"<<r<<".fas 2> /dev/null";
+ command << mafftpath<<"mafft "<<tmp_dir<<"/m"<<r<<".fas 2> /dev/null";
if(NOISE>0)
cout<<"cmd: "<<command.str()<<endl;
@@ -173,7 +172,7 @@ void Mafft_alignment::align_sequences(vector<string> *names,vector<string> *sequ
cout<<"\nError: Initial alignment with Mafft failed. The output generated was:\n";
command.str("");
- command << mafftpath<<"mafft "+tmp_dir+"m"<<r<<".fas 2>&1";
+ command << mafftpath<<"mafft "<<tmp_dir<<"/m"<<r<<".fas 2>&1";
int i = system(command.str().c_str());
@@ -181,19 +180,8 @@ void Mafft_alignment::align_sequences(vector<string> *names,vector<string> *sequ
exit(0);
}
- this->delete_files(r);
-
-}
-
-void Mafft_alignment::delete_files(int r)
-{
-
-string tmp_dir = this->get_temp_dir();
-
-stringstream m_name;
-m_name <<tmp_dir<<"m"<<r<<".fas";
-
+ //remove file
+ if( remove( m_name.str().c_str() ) != 0)
+ perror("Error deleting temporary file in Mafft_alignment::align_sequences");
-if ( remove( m_name.str().c_str() ) != 0 )
- perror( "Error deleting file" );
}
diff --git a/src/mafft_alignment.h b/src/mafft_alignment.h
index 9b2e046..9ca2ed1 100644
--- a/src/mafft_alignment.h
+++ b/src/mafft_alignment.h
@@ -11,18 +11,6 @@ extern std::string tempdir;
class Mafft_alignment
{
- std::string get_temp_dir()
- {
- std::string tmp_dir = "/tmp/";
- if(tempdir != "")
- tmp_dir = tempdir+"/";
-
- struct stat st;
- if(stat(tmp_dir.c_str(),&st) != 0)
- tmp_dir = "";
-
- return tmp_dir;
- }
std::string remove_last_whitespaces(const std::string & s)
{
@@ -61,7 +49,6 @@ class Mafft_alignment
|| (c == '\f');
}
- void delete_files(int r);
public:
Mafft_alignment();
diff --git a/src/prank.1 b/src/prank.1
index 45afc96..6580099 100644
--- a/src/prank.1
+++ b/src/prank.1
@@ -1,4 +1,4 @@
-.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16)
+.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29)
.\"
.\" Standard preamble:
.\" ========================================================================
@@ -38,6 +38,8 @@
. ds PI \(*p
. ds L" ``
. ds R" ''
+. ds C`
+. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
@@ -48,21 +50,28 @@
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
-.ie \nF \{\
-. de IX
-. tm Index:\\$1\t\\n%\t"\\$2"
+.\"
+.\" Avoid warning from groff about undefined register 'F'.
+.de IX
..
-. nr % 0
-. rr F
-.\}
-.el \{\
-. de IX
+.nr rF 0
+.if \n(.g .if rF .nr rF 1
+.if (\n(rF:(\n(.g==0)) \{
+. if \nF \{
+. de IX
+. tm Index:\\$1\t\\n%\t"\\$2"
..
+. if !\nF==2 \{
+. nr % 0
+. nr F 2
+. \}
+. \}
.\}
+.rr rF
.\" ========================================================================
.\"
.IX Title "PRANK 1"
-.TH PRANK 1 "2013-04-10" "v.130410" "The Probabilistic Alignment Kit"
+.TH PRANK 1 "2017-04-27" "v.121211" "The Probabilistic Alignment Kit"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
@@ -77,7 +86,7 @@ prank \- Computes probabilistic multiple sequence alignments
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
The Probabilistic Alignment Kit (\s-1PRANK\s0) is a probabilistic multiple alignment
-program for \s-1DNA\s0, codon and amino-acid sequences. It's based on a novel algorithm
+program for \s-1DNA,\s0 codon and amino-acid sequences. It's based on a novel algorithm
that treats insertions correctly and avoids over-estimation of the number of
deletion events.
.PP
@@ -88,7 +97,7 @@ sequences to be aligned and then, simultaneously with the alignment, predicts
the locations of structural units in the sequences.
.SH "OPTIONS"
.IX Header "OPTIONS"
-.SS "\s-1INPUT/OUTPUT\s0 \s-1PARAMETERS\s0"
+.SS "\s-1INPUT/OUTPUT PARAMETERS\s0"
.IX Subsection "INPUT/OUTPUT PARAMETERS"
.IP "\fB\-d=\f(BIsequence_file\fB\fR" 8
.IX Item "-d=sequence_file"
@@ -136,7 +145,7 @@ Truncate names at first space character.
.IP "\fB\-quiet\fR" 8
.IX Item "-quiet"
Reduce output.
-.SS "\s-1ALIGNMENT\s0 \s-1MERGE\s0"
+.SS "\s-1ALIGNMENT MERGE\s0"
.IX Subsection "ALIGNMENT MERGE"
.IP "\fB\-d1=\f(BIalignment_file\fB\fR" 8
.IX Item "-d1=alignment_file"
@@ -150,7 +159,7 @@ The tree file for the first alignment. If unset, an appriximated \s-1NJ\s0 tree
.IP "\fB\-t2=\f(BItree_file\fB\fR" 8
.IX Item "-t2=tree_file"
The tree file for the second alignment. If unset, an appriximated \s-1NJ\s0 tree is generated.
-.SS "\s-1MODEL\s0 \s-1PARAMETERS\s0"
+.SS "\s-1MODEL PARAMETERS\s0"
.IX Subsection "MODEL PARAMETERS"
.IP "\fB\-F\fR, \fB+F\fR" 8
.IX Item "-F, +F"
@@ -165,7 +174,7 @@ Set the gap extension probability. The default is \fB0.75\fR for \s-1DNA\s0 and
proteins.
.IP "\fB\-codon\fR" 8
.IX Item "-codon"
-Use empirical codon model for coding \s-1DNA\s0.
+Use empirical codon model for coding \s-1DNA.\s0
.IP "\fB\-DNA\fR, \fB\-protein\fR" 8
.IX Item "-DNA, -protein"
Use \s-1DNA\s0 or protein model, respectively. Disables auto-detection of model.
@@ -178,7 +187,7 @@ No missing data. Use \fB\-F\fR for terminal gaps.
.IP "\fB\-keep\fR" 8
.IX Item "-keep"
Do not remove gaps from pre-aligned sequences.
-.SS "\s-1OTHER\s0 \s-1PARAMETERS\s0"
+.SS "\s-1OTHER PARAMETERS\s0"
.IX Subsection "OTHER PARAMETERS"
.IP "\fB\-iterate=#\fR" 8
.IX Item "-iterate=#"
diff --git a/src/prank.cpp b/src/prank.cpp
index a262af1..7cef15a 100644
--- a/src/prank.cpp
+++ b/src/prank.cpp
@@ -24,19 +24,61 @@
#include <iostream>
#include <string>
#include <sstream>
+#include <unistd.h>
#include "progressivealignment.h"
#include "check_version.h"
#include "prank.h"
using namespace std;
+// stores current temporary directory will be created and removed in main
+char tmp_dir[1000] = "";
+bool verbose = false;
+
+//main
int main(int argc, char *argv[])
{
- version = 150803;
+ version = 170427;
readArguments(argc, argv);
int time1 = time(0);
+ // character array for assigning system tmp path
+ char* tmpPath = NULL;
+ //mkdtemp template
+ const char* mktemplate = "tmpdirprankmsaXXXXXX";
+
+ //create temporary directory
+ //get tmpPath from environment or assign tmpPath to NULL (if last getenv fails)
+ if( (tmpPath = getenv("TMPDIR")) == NULL)
+ {
+ if( (tmpPath = getenv("TMP")) == NULL)
+ {
+ if( (tmpPath = getenv("TEMPDIR")) == NULL)
+ {
+ tmpPath = getenv("TEMP");
+ }
+ }
+ }
+
+ // define temp dir based on whether tmpPath was found
+ if(tmpPath == NULL)
+ {
+ sprintf(tmp_dir, "%s", mktemplate);
+ }
+ else
+ {
+ sprintf(tmp_dir, "%s/%s", tmpPath, mktemplate);
+ }
+
+ // call mkdtemp
+ if( (mkdtemp(tmp_dir) == NULL) )
+ {
+ perror("'mkdtemp' failed to generate temporary directory while creating ProgressiveAlignbment object.\n");
+ exit(EXIT_FAILURE);
+ }
+
+
ProgressiveAlignment* pa = new ProgressiveAlignment(treefile,seqfile,dnafile);
if (NOISE>=0)
cout<<endl<<"Analysis done. Total time "<<(time(0)-time1)<<"s"<<endl;
@@ -44,6 +86,12 @@ int main(int argc, char *argv[])
delete pa;
delete hmm;
+ //unlink temporary directory
+ if( rmdir(tmp_dir) != 0)
+ {
+ perror("ERROR! failed removing temporary directory.");
+ }
+
cout<<endl;
exit(0);
}
@@ -112,6 +160,13 @@ void readArguments(int argc, char *argv[])
exit(0);
}
+
+ else if (s=="-verbose")
+ {
+ verbose = true;
+ }
+
+
/********* input/output: **********/
// sequence data file
@@ -845,6 +900,7 @@ void printHelp(bool complete)
if (complete)
cout<<" -dna=dna_sequence_file [DNA sequence file for backtranslation of protein alignment]"<<endl;
cout<<" -version [check for updates]"<<endl;
+ cout<<" -verbose [print progress etc. during runtime]"<<endl;
cout<<"\n -help [show more options]"<<endl;
cout<<""<<endl;
diff --git a/src/readalignment.cpp b/src/readalignment.cpp
index 2155bdb..6d3d0a6 100644
--- a/src/readalignment.cpp
+++ b/src/readalignment.cpp
@@ -184,7 +184,7 @@ bool ReadAlignment::readSeqs(Sequence* s1,Sequence* s2,PhyloMatchScore *pms,Tree
for (;; s++)
{
- if (SCREEN && totalSites>0 && countSites%reportLimit==0)
+ if (SCREEN && totalSites>0 && countSites%reportLimit==0 && verbose == true)
{
FOR(ii,message.length())
{
@@ -1114,7 +1114,7 @@ bool ReadAlignment::readSeqs(Sequence* s1,Sequence* s2,PhyloMatchScore *pms,Tree
newsite->setNeighbours(beg,end);
end->prev();
- if (SCREEN && totalSites>0 && countSites%reportLimit==0)
+ if (SCREEN && totalSites>0 && countSites%reportLimit==0 && verbose == true)
{
FOR(ii,message.length())
{
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/prank.git
More information about the debian-med-commit
mailing list