Author: Andreas Tille <tille@debian.org>
Last-Update: Wed, 20 Apr 2016 10:31:32 +0200
Description: Some plain debugging was helpful to understand how parsnp works
 leave this as a deactivated patch

--- a/Parsnp.py
+++ b/Parsnp.py
@@ -936,6 +936,7 @@ if __name__ == "__main__":
     #3)run parsnp (cores, grid?)
     print "-->Running Parsnp multi-MUM search and libMUSCLE aligner.."
     if not os.path.exists(outputDir+os.sep+"blocks"):
+        print "DEBUG: mkdir", outputDir+os.sep+"blocks"
         os.mkdir(outputDir+os.sep+"blocks")
     command = ""
     run_parsnp = 1
@@ -951,14 +952,16 @@ if __name__ == "__main__":
                     command = "/usr/lib/parsnp/parsnp %sparsnpAligner.ini"%(outputDir+os.sep)
                 else:
                     command = "/usr/lib/parsnp/parsnp %spsnn.ini"%(outputDir+os.sep)
+                print "DEBUG not inifile_exists -> command:", command
             else:
                 if not os.path.exists(inifile):
                     sys.stderr.write("Error: ini file %s does not exist!\n"%(inifile))
                     sys.exit(1)
                 command = "/usr/lib/parsnp/parsnp %s"%(inifile)
+                print "DEBUG inifile_exists -> command:", command
             run_command(command)
         
-
+            print "DEBUG command successful:", command
             if not os.path.exists(outputDir+os.sep+"parsnpAligner.xmfa"):
 
                 successful_run = False
@@ -971,6 +974,7 @@ if __name__ == "__main__":
                 runcnt +=1
                 break
         os.system("mv "+outputDir+os.sep+"parsnpAligner.xmfa "+outputDir+os.sep+"parsnp.xmfa")
+    print "DEBUG 'if run_parsnp' is done"
     xmfafile = open(outputDir+os.sep+"parsnp.xmfa",'r')
         
     file2hdr_dict = {}
@@ -995,6 +999,7 @@ if __name__ == "__main__":
         sys.exit(1)
 
     #update thresholds
+    print "DEBUG update thresholds"
     if coverage <= 0.01:
         sys.stderr.write( "  |->["+ERROR_RED+"ERROR"+ENDC+"]"+": aligned regions cover less than 1% of reference genome, something is not right.. please adjust params and rerun. If problem persists please contact developers (treangen@gmail.com)"+ENDC)
         sys.exit(1)
--- a/src/parsnp.cpp
+++ b/src/parsnp.cpp
@@ -517,6 +517,7 @@ void Aligner::writeOutput(string psnp,ve
     test.append("/parsnpAligner.log");
     lcbdir.append("/blocks/");
     lcbprefix.append("/blocks/b");
+cerr << "DEBUG: Try to create testfile " << test.c_str() << endl;
     try
     {
         ofstream testfile ( test.c_str() );
@@ -525,12 +526,13 @@ void Aligner::writeOutput(string psnp,ve
     }
     catch ( char const * str )
     {
-        string command = "mkdir ";
+cerr << "DEBUG: Opening testfile " << test.c_str() << " failed - try to create directory " << this->outdir << endl;
+        string command = "mkdir -p ";
         command.append(this->outdir);
         int result = system(command.c_str());
         if ( result )
         {
-            cerr << "ParSNP:: error creating output directory, exiting.." << endl;
+            cerr << "ParSNP:: error creating output directory" << this->outdir << ", exiting.." << endl;
             exit(1);
         }
     }
