[med-svn] [pipasic] 03/03: Fix several issues in upstream code
Andreas Tille
tille at debian.org
Thu Oct 1 19:50:15 UTC 2015
This is an automated email from the git hooks/post-receive script.
tille pushed a commit to branch master
in repository pipasic.
commit c4ba604d13bdb5ba75125ed84aedeafd90468c9d
Author: Andreas Tille <tille at debian.org>
Date: Thu Oct 1 21:49:18 2015 +0200
Fix several issues in upstream code
---
debian/patches/debug.patch | 79 +++++++++++++++++++++-
debian/patches/inspect_files.patch | 16 +++++
debian/patches/safe_path_names.patch | 57 ++++++++++++++++
debian/patches/series | 3 +-
debian/patches/{debug.patch => verbosity.patch} | 25 ++++++-
...README.Debian => pipasic-example.README.Debian} | 0
...-examples.postinst => pipasic-example.postinst} | 0
debian/pipasic.install | 2 +-
debian/pipasic.links | 2 +-
debian/pipasic.postinst | 14 ++++
10 files changed, 191 insertions(+), 7 deletions(-)
diff --git a/debian/patches/debug.patch b/debian/patches/debug.patch
index bd2aa7c..3d4f6e7 100644
--- a/debian/patches/debug.patch
+++ b/debian/patches/debug.patch
@@ -1,6 +1,6 @@
--- a/pipasic.py
+++ b/pipasic.py
-@@ -129,7 +129,7 @@ Note: Pipasic requires two .fasta for ea
+@@ -129,7 +131,7 @@ Note: Pipasic requires two .fasta for ea
sample_counts.append(count)
correction = True
except:
@@ -9,7 +9,7 @@
sample_counts.append(0)
countList.append(sample_counts)
np.array(countList).dump(os.path.splitext(outfile)[0]+"_counts.dat")
-@@ -193,7 +193,7 @@ Note: Pipasic requires two .fasta for ea
+@@ -193,7 +195,7 @@ Note: Pipasic requires two .fasta for ea
count = parseInspect(inpath=inspectOut,fdr_countcut=fdr,silent=False)[1]
sample_counts.append(count)
except:
@@ -29,3 +29,78 @@
continue
else:
inspectOut = os.path.splitext(spectra_name)[0] +"_"+ os.path.splitext(os.path.basename(DBi))[0] +"_InspectOut.txt"
+--- a/simulation_based_similarity.py
++++ b/simulation_based_similarity.py
+@@ -116,10 +116,11 @@ from readMGF import sampleMGF as samplSp
+
+ # 5.a prepare decoyDB input for Inspect (def)
+ def prepDB(fastaDB, path="/usr/share/inspect/"):
+- if not os.path.exists(os.path.join(path,"PrepDB.py")):
+- print "InsPecT files not found, please correct path!"
++ inspectpath=os.path.join(path,"PrepDB.py")
++ if not os.path.exists(inspectpath):
++ print "InsPecT file '%s' not found, please correct path!" % (inspectpath)
+ return 0
+- command = "python {path}PrepDB.py FASTA {db}".format(path=path, db=fastaDB)
++ command = "python {inspectpath} FASTA {db}".format(inspectpath=inspectpath, db=fastaDB)
+ print "Executing: ",command
+ sys.stdout.flush()
+ os.system(command)
+@@ -149,7 +150,7 @@ def calculateSimilarityMatrix(DBs, db_pa
+
+ for i in rng:
+ # 1. sampling from DB (run)
+- prot_path = samplProt(db_path+DBs[i]+".fasta",nProt)
++ prot_path = samplProt(os.path.join(db_path,DBs[i]+".fasta"),nProt)
+ # 2. use OpenMS simulator with sampled proteins (run)
+ out_path = sim_out_path+DBs[i]+"_sampl"+str(nProt)+"MSSim.mzML"
+ run_MSSim(prot_path, out_path, ini=MSSim_ini, param="-threads 4")
+@@ -159,12 +160,15 @@ def calculateSimilarityMatrix(DBs, db_pa
+ spec_path = samplSpecs(sampl_path,nSpec)
+ # (*) with runInspect_user_config.runInspect_config for all DBs
+ # runInspect_config(spectra=spec_path, DBs=DBs, spec_path="", db_path=db_path, inspect_dir=inspect_dir, conf=configfile, user_mods="")
++ print "DEBUG: db_path=%s, inspect_dir=%s" % (db_path, inspect_dir)
+ for j in rng:
+ # 5. calling InSpecT (*)
+- db_j = db_path+DBs[j]+"_decoy.trie"
++ db_j = os.path.join(db_path,DBs[j]+"_decoy.trie")
++ print "DEBUG: db_path=%s, DBs[j]=%s, inspect_dir=%s" % (db_path, DBs[j], inspect_dir)
+ # 5.a create trie if necessary
+ if not os.path.exists(db_j):
+- prepDB(db_path+DBs[j]+"_decoy.fasta",path=inspect_dir)
++ print "DEBUG: path db_j %s does not exist" % (db_j)
++ prepDB(os.path.join(db_path,DBs[j]+"_decoy.fasta"),path=inspect_dir)
+ inspect_out = spec_path[:-4] +"_"+DBs[j]+"_InspectOut.txt" # (!!)
+ # prepare configfile # <-- call runInspect_user_config.runInspect_config instead!! (bei 5. ansetzen, j-Schleife nur mit inspect_out behalten)
+ conf_in = open(inspect_config,'r')
+--- a/runInspect_user_config.py
++++ b/runInspect_user_config.py
+@@ -28,12 +28,14 @@ def runInspect_config(spectra, DBs, spec
+ #simMat = [ [0 for i in rngDB] for j in rngSpc ] # initializing output
+
+ for i in rngSpc:
+- specs = spec_path+spectra[i]+".mgf"
++ specs = os.path.join(spec_path,spectra[i]+".mgf")
+ for j in rngDB:
+- db_j = db_path+DBs[j]+"_decoy.trie"
++ db_j = os.path.join(db_path,DBs[j]+"_decoy.trie")
+ # create trie if necessary
++ print "DEBUG runInspect_config: db_j=%s" % (db_j)
+ if not os.path.exists(db_j):
+- go_on = prepDB(db_path+DBs[j]+"_decoy.fasta", path=inspect_dir)
++ print "DEBUG runInspect_config: db_path=%s, DBs[j]=%s, inspect_dir=%s)"%(db_path, DBs[j], inspect_dir)
++ go_on = prepDB(os.path.join(db_path,DBs[j]+"_decoy.fasta"), path=inspect_dir)
+ if not go_on: return
+ inspect_out = specs[:-4] +"_"+DBs[j]+"_InspectOut.txt"
+
+--- a/TideProcessing.py
++++ b/TideProcessing.py
+@@ -170,7 +170,7 @@ verbose: if True (default), print statu
+ counts = []
+ testout = []
+ for db in db_list:
+- db_fasta = db_path+db+"_decoy.fasta"
++ db_fasta = os.path.join(db_path,db+"_decoy.fasta")
+ succ = runTide(filepath=filepath, nSpec=nSpec, db_fasta=db_fasta, verbose=verbose)
+ if succ[0]: # database not found
+ print succ[0]
diff --git a/debian/patches/inspect_files.patch b/debian/patches/inspect_files.patch
index 3430900..2dd42d1 100644
--- a/debian/patches/inspect_files.patch
+++ b/debian/patches/inspect_files.patch
@@ -98,3 +98,19 @@ Description: Upstream code contains a lot of private dirs as
f.write(pep + "\tfrom\t" + line.split(sep)[2] + "\n")'''
# calculate weights from counts
if verbose: print "not found: %i of %i"%(notfound,sum(counts)+notfound)
+--- a/pipasic.py
++++ b/pipasic.py
+@@ -47,10 +47,10 @@ Note: Pipasic requires two .fasta for ea
+
+ # input parameters:
+ optparser.add_option('-o', '--outfile', type='string', dest='outfile', default="results.txt", help='Output filename for results. Also serves as trunk for other result files (graphics, data). [default: %default]')
+- optparser.add_option('-s', '--spec_dir', type='string', dest='spec_dir', default=None, help='Directory of SPECTRA (mgf) files. Search in current directory, if not given. [default: %default]')
+- optparser.add_option('-d', '--db_dir', type='string', dest='db_dir', default=None, help='Directory of proteinDBs. Search for DB files current directory, if not given. [default: %default]')
++ optparser.add_option('-s', '--spec_dir', type='string', dest='spec_dir', default="/var/lib/pipasic/spectra", help='Directory of SPECTRA (mgf) files. Search in current directory, if not given. [default: %default]')
++ optparser.add_option('-d', '--db_dir', type='string', dest='db_dir', default="/var/lib/pipasic/proteome", help='Directory of proteinDBs. Search for DB files current directory, if not given. [default: %default]')
+ optparser.add_option('-m', '--mods', type='string', dest='mods', default=None, help='A string containing all modifications in question, modification choice by filename if not given. [default: %default]')
+- optparser.add_option('-i', '--inspect_dir', type='string', dest='insp_dir', default=None, help='Inspect directory. [default: %default]')
++ optparser.add_option('-i', '--inspect_dir', type='string', dest='insp_dir', default="/usr/share/inspect", help='Inspect directory. [default: %default]')
+ optparser.add_option('-f', '--fdr_cutoff', type='float', dest='fdr', default=0.05, help='False discovery rate cut-off for identification lists. [default: %default]')# -l : list_fdr_cutoff ??
+ optparser.add_option('-t', '--decoy_tag', type='str', dest='decoy_tag', default="REVERSED|DECOY", help='Tag to identify decoy sequences in the database. Regular expressions may be used. This tag must be used in the name of all decoy sequences in the file "<DB>_decoy.fasta". [default: %default]')
+ #optparser.add_option('-n', '--numberspectra', type='int', dest='nspec', default=1000, help='number of samples from simulated spectra. [default: %default]')
diff --git a/debian/patches/safe_path_names.patch b/debian/patches/safe_path_names.patch
new file mode 100644
index 0000000..02c17ff
--- /dev/null
+++ b/debian/patches/safe_path_names.patch
@@ -0,0 +1,57 @@
+Author: Andreas Tille <tille at debian.org>
+Last-update: Tue, 29 Sep 2015 15:21:50 +0200
+Description: Make sure directory and file are properly separated
+
+--- a/simulation_based_similarity.py
++++ b/simulation_based_similarity.py
+@@ -150,7 +150,7 @@ def calculateSimilarityMatrix(DBs, db_pa
+
+ for i in rng:
+ # 1. sampling from DB (run)
+- prot_path = samplProt(db_path+DBs[i]+".fasta",nProt)
++ prot_path = samplProt(os.path.join(db_path,DBs[i]+".fasta"),nProt)
+ # 2. use OpenMS simulator with sampled proteins (run)
+ out_path = sim_out_path+DBs[i]+"_sampl"+str(nProt)+"MSSim.mzML"
+ run_MSSim(prot_path, out_path, ini=MSSim_ini, param="-threads 4")
+@@ -162,10 +162,10 @@ def calculateSimilarityMatrix(DBs, db_pa
+ # runInspect_config(spectra=spec_path, DBs=DBs, spec_path="", db_path=db_path, inspect_dir=inspect_dir, conf=configfile, user_mods="")
+ for j in rng:
+ # 5. calling InSpecT (*)
+- db_j = db_path+DBs[j]+"_decoy.trie"
++ db_j = os.path.join(db_path,DBs[j]+"_decoy.trie")
+ # 5.a create trie if necessary
+ if not os.path.exists(db_j):
+- prepDB(db_path+DBs[j]+"_decoy.fasta",path=inspect_dir)
++ prepDB(os.path.join(db_path,DBs[j]+"_decoy.fasta"),path=inspect_dir)
+ inspect_out = spec_path[:-4] +"_"+DBs[j]+"_InspectOut.txt" # (!!)
+ # prepare configfile # <-- call runInspect_user_config.runInspect_config instead!! (bei 5. ansetzen, j-Schleife nur mit inspect_out behalten)
+ conf_in = open(inspect_config,'r')
+--- a/runInspect_user_config.py
++++ b/runInspect_user_config.py
+@@ -28,12 +28,12 @@ def runInspect_config(spectra, DBs, spec
+ #simMat = [ [0 for i in rngDB] for j in rngSpc ] # initializing output
+
+ for i in rngSpc:
+- specs = spec_path+spectra[i]+".mgf"
++ specs = os.path.join(spec_path,spectra[i]+".mgf")
+ for j in rngDB:
+- db_j = db_path+DBs[j]+"_decoy.trie"
++ db_j = os.path.join(db_path,DBs[j]+"_decoy.trie")
+ # create trie if necessary
+ if not os.path.exists(db_j):
+- go_on = prepDB(db_path+DBs[j]+"_decoy.fasta", path=inspect_dir)
++ go_on = prepDB(os.path.join(db_path,DBs[j]+"_decoy.fasta"), path=inspect_dir)
+ if not go_on: return
+ inspect_out = specs[:-4] +"_"+DBs[j]+"_InspectOut.txt"
+
+--- a/TideProcessing.py
++++ b/TideProcessing.py
+@@ -170,7 +170,7 @@ verbose: if True (default), print statu
+ counts = []
+ testout = []
+ for db in db_list:
+- db_fasta = db_path+db+"_decoy.fasta"
++ db_fasta = os.path.join(db_path,db+"_decoy.fasta")
+ succ = runTide(filepath=filepath, nSpec=nSpec, db_fasta=db_fasta, verbose=verbose)
+ if succ[0]: # database not found
+ print succ[0]
diff --git a/debian/patches/series b/debian/patches/series
index 9ab31c7..b806743 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
inspect_files.patch
-debug.patch
+verbosity.patch
+safe_path_names.patch
diff --git a/debian/patches/debug.patch b/debian/patches/verbosity.patch
similarity index 57%
copy from debian/patches/debug.patch
copy to debian/patches/verbosity.patch
index bd2aa7c..b296c69 100644
--- a/debian/patches/debug.patch
+++ b/debian/patches/verbosity.patch
@@ -1,6 +1,10 @@
+Author: Andreas Tille <tille at debian.org>
+Last-update: Tue, 29 Sep 2015 15:21:50 +0200
+Description: More verbose output
+
--- a/pipasic.py
+++ b/pipasic.py
-@@ -129,7 +129,7 @@ Note: Pipasic requires two .fasta for ea
+@@ -129,7 +131,7 @@ Note: Pipasic requires two .fasta for ea
sample_counts.append(count)
correction = True
except:
@@ -9,7 +13,7 @@
sample_counts.append(0)
countList.append(sample_counts)
np.array(countList).dump(os.path.splitext(outfile)[0]+"_counts.dat")
-@@ -193,7 +193,7 @@ Note: Pipasic requires two .fasta for ea
+@@ -193,7 +195,7 @@ Note: Pipasic requires two .fasta for ea
count = parseInspect(inpath=inspectOut,fdr_countcut=fdr,silent=False)[1]
sample_counts.append(count)
except:
@@ -29,3 +33,20 @@
continue
else:
inspectOut = os.path.splitext(spectra_name)[0] +"_"+ os.path.splitext(os.path.basename(DBi))[0] +"_InspectOut.txt"
+--- a/simulation_based_similarity.py
++++ b/simulation_based_similarity.py
+@@ -116,10 +116,11 @@ from readMGF import sampleMGF as samplSp
+
+ # 5.a prepare decoyDB input for Inspect (def)
+ def prepDB(fastaDB, path="/usr/share/inspect/"):
+- if not os.path.exists(os.path.join(path,"PrepDB.py")):
+- print "InsPecT files not found, please correct path!"
++ inspectpath=os.path.join(path,"PrepDB.py")
++ if not os.path.exists(inspectpath):
++ print "InsPecT file '%s' not found, please correct path!" % (inspectpath)
+ return 0
+- command = "python {path}PrepDB.py FASTA {db}".format(path=path, db=fastaDB)
++ command = "python {inspectpath} FASTA {db}".format(inspectpath=inspectpath, db=fastaDB)
+ print "Executing: ",command
+ sys.stdout.flush()
+ os.system(command)
diff --git a/debian/pipasic-examples.README.Debian b/debian/pipasic-example.README.Debian
similarity index 100%
rename from debian/pipasic-examples.README.Debian
rename to debian/pipasic-example.README.Debian
diff --git a/debian/pipasic-examples.postinst b/debian/pipasic-example.postinst
similarity index 100%
rename from debian/pipasic-examples.postinst
rename to debian/pipasic-example.postinst
diff --git a/debian/pipasic.install b/debian/pipasic.install
index 4a780e8..8264350 100644
--- a/debian/pipasic.install
+++ b/debian/pipasic.install
@@ -1,3 +1,3 @@
*.py usr/share/pipasic
-config_files/* etc/pipasic
+config_files/* var/lib/pipasic/config_files
debian/bin usr
diff --git a/debian/pipasic.links b/debian/pipasic.links
index 723bfd4..5f427e5 100644
--- a/debian/pipasic.links
+++ b/debian/pipasic.links
@@ -1 +1 @@
-etc/pipasic usr/share/pipasic/config_files
+var/lib/pipasic/config_files usr/share/pipasic/config_files
diff --git a/debian/pipasic.postinst b/debian/pipasic.postinst
new file mode 100644
index 0000000..b9865cd
--- /dev/null
+++ b/debian/pipasic.postinst
@@ -0,0 +1,14 @@
+#!/bin/sh
+set -e
+
+pipasicconfigdir=/var/lib/pipasic/config_files
+
+case "$1" in
+ configure)
+ # enable write permission to everybody in pipasic config dir
+ chmod 777 ${pipasicconfigdir}
+ find ${pipasicconfigdir} -type f -exec chmod 666 \{\} \;
+ ;;
+esac
+
+#DEBHELPER#
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/pipasic.git
More information about the debian-med-commit
mailing list