Skip to content

add a feature for a user-defined config folder #272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: v1.5rc3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/assemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ def Assemble(input,output):
matedString = "-mean %d -stddev %d -m %s/Preprocess/out/lib%d.seq.mates"%(lib.mean, lib.stdev, _settings.rundir, lib.id)
run_process(_settings, "%s/convert-fasta-to-v2.pl -l %s %s -s %s/Preprocess/out/lib%d.seq -q %s/Preprocess/out/lib%d.seq.qual > %s/Preprocess/out/lib%d.frg"%(_settings.CA, lib.sid, matedString, _settings.rundir, lib.id, _settings.rundir, lib.id, _settings.rundir, lib.id),"Assemble")
frglist += "%s/Preprocess/out/lib%d.frg "%(_settings.rundir, lib.id)

run_process(_settings, "%s/runCA -p %s -d %s/Assemble/out/ -s %s/config/asm.spec %s %s"%(_settings.CA,_settings.PREFIX,_settings.rundir,_settings.METAMOS_UTILS,"stopAfter=terminator" if _settings.doscaffolding else "stopAfter=utgcns", frglist),"Assemble")
asm_path=getProgramParamsFile(_settings.METAMOS_UTILS, 'asm.spec')
run_process(_settings, "%s/runCA -p %s -d %s/Assemble/out/ -s %s %s %s"%(_settings.CA,_settings.PREFIX,_settings.rundir,asm_path,"stopAfter=terminator" if _settings.doscaffolding else "stopAfter=utgcns", frglist),"Assemble")
#convert CA to AMOS
run_process(_settings, "%s/gatekeeper -dumpfrg -allreads %s.gkpStore > %s.frg"%(_settings.CA, _settings.PREFIX, _settings.PREFIX),"Assemble")
if _settings.doscaffolding:
Expand Down
5 changes: 3 additions & 2 deletions src/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ def Preprocess(input,output):

reads = rf.read().split(">")[1:]
quals = rq.read().split(">")[1:]


readcnt = 1
for currIndex, rd in enumerate(reads):
Expand Down Expand Up @@ -684,8 +685,8 @@ def Preprocess(input,output):

oldPath = os.environ["PATH"]
os.environ["PATH"] = _settings.AMOS + os.pathsep + _settings.BLASR + os.pathsep + oldPath

run_process(_settings, "%s/pacBioToCA -l lib%d -s %s/config/pacbio.blasr.spec -t %d -partitions 100 fastqFile=%s genomeSize=%s longReads=1 ovlThreads=%d merylThreads=%d cnsConcurrency=%d merylMemory=%s ovlStoreMemory=%s"%(_settings.CA, lib.id, _settings.METAMOS_UTILS, _settings.threads, lib.f1.path, genomeSize, _settings.threads, _settings.threads, _settings.threads, availableMem, availableMem), "Preprocess")
pacbio_path = getProgramParamsFile(_settings.METAMOS_UTILS, 'pacbio.blasr.spec')
run_process(_settings, "%s/pacBioToCA -l lib%d -s %s -t %d -partitions 100 fastqFile=%s genomeSize=%s longReads=1 ovlThreads=%d merylThreads=%d cnsConcurrency=%d merylMemory=%s ovlStoreMemory=%s"%(_settings.CA, lib.id, pacbio_path, _settings.threads, lib.f1.path, genomeSize, _settings.threads, _settings.threads, _settings.threads, availableMem, availableMem), "Preprocess")
# subset longest 25X?
# update library format and file names
lib.f1.path = "%s/Preprocess/out/lib%d.fastq"%(_settings.rundir, lib.id)
Expand Down
15 changes: 10 additions & 5 deletions src/runPipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def printConfiguration(fileName=None):
conf.write(''.join(configurationText))
conf.close()

shortOptions = "hM:IR:rjwbd:s:e:o:k:c:a:n:p:qt:f:vm:4g:iu1l:x:yz:LBVX:S:"
shortOptions = "hM:IR:rjwbd:s:e:o:k:c:a:n:p:qt:f:vm:4g:iu1l:x:yz:LBVX:S:U:"
longOptions = ["help", \
"multialigner",\
"isolate",\
Expand Down Expand Up @@ -234,7 +234,7 @@ def printConfiguration(fileName=None):
"noblastdb",\
"version",\
"validator",\
"asmscore"]
"asmscore", "user_config_dir"]
try:
opts, args = getopt.getopt(sys.argv[1:], shortOptions, longOptions)
except getopt.GetoptError, err:
Expand All @@ -252,14 +252,14 @@ def printConfiguration(fileName=None):
supported_genecallers = ["fraggenescan","metagenemark","glimmermg"]
supported_assemblers = ["newbler", "soapdenovo","soapdenovo2","ca","velvet","velvet-sc","metavelvet",\
"metaidba","sparseassembler","minimus"]
supported_assemblers.extend(generic.getSupportedList(utils.INITIAL_UTILS, utils.STEP_NAMES.ASSEMBLE))
#supported_assemblers.extend(generic.getSupportedList(utils.INITIAL_UTILS, utils.STEP_NAMES.ASSEMBLE))

supported_mappers = ["bowtie","bowtie2"]
supported_abundance = ["metaphyler"]
supported_aligners = ["mgcat"]
supported_classifiers = ["fcp","phylosift","phmmer","blast",\
"metaphyler", "phymm"]
supported_classifiers.extend(generic.getSupportedList(utils.INITIAL_UTILS, utils.STEP_NAMES.ANNOTATE))
#supported_classifiers.extend(generic.getSupportedList(utils.INITIAL_UTILS, utils.STEP_NAMES.ANNOTATE))
supported_validators = ["reapr", "orf", "lap", "ale", "quast", "frcbam", "freebayes", "cgal", "n50"]
supported_fannotate = ["blast"]
supported_scaffolders = ["bambus2"]
Expand Down Expand Up @@ -343,7 +343,10 @@ def printConfiguration(fileName=None):
print "project dir %s does not exist!"%(settings.rundir)
usage()
sys.exit(1)

elif o in ("-U","--user_config_dir"):
utils.user_config_dir = a
supported_assemblers.extend(generic.getSupportedList(utils.INITIAL_UTILS, utils.STEP_NAMES.ASSEMBLE))
supported_classifiers.extend(generic.getSupportedList(utils.INITIAL_UTILS, utils.STEP_NAMES.ANNOTATE))
if not os.path.exists(settings.rundir) or settings.rundir == "":
print "project dir %s does not exist!"%(settings.rundir)
usage()
Expand Down Expand Up @@ -684,6 +687,8 @@ def printConfiguration(fileName=None):
savebtidx = True
elif o in ("-L", "--localKrona"):
utils.Settings.local_krona = True
elif o in ("-U","--user_config_dir"):
utils.user_config_dir = a
else:
assert False, "unhandled option"

Expand Down
33 changes: 27 additions & 6 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def resource_path(relative_path):
base_path = os.path.abspath(".")

return os.path.join(base_path, relative_path)

user_config_dir =""
application_path = ""
if getattr(sys, 'frozen', False):
application_path = os.path.dirname(sys.executable)
Expand Down Expand Up @@ -1224,11 +1224,12 @@ def getProgramCitations(settings, programName, comment="#"):

def getProgramParams(configDir, fileName, module="", prefix="", comment="#", separator=""):
# we process parameters in the following priority:
# first: current directory
# second: user home directory
# third: metAMOS directory
# a parameter specifeid in the current directory takes priority over all others, and so on down the line
dirs = [configDir + os.sep + "config", os.path.expanduser('~') + os.sep + ".metAMOS", os.getcwd()]
# first: user_config_dir
# second: current directory
# third: user home directory
# fourth: metAMOS directory
# a parameter specifeid in user_config_dir takes priority over all others, and so on down the line
dirs = [configDir + os.sep + "config", os.path.expanduser('~') + os.sep + ".metAMOS", os.getcwd(), user_config_dir]
optDict = {}

cmdOptions = ""
Expand Down Expand Up @@ -1424,3 +1425,23 @@ def translateToSRAURL(settings, name):
if oldDyLD != "":
os.environ["DYLD_FALLBACK_LIBRARY_PATH"] = oldDyLD
return result

def getProgramParamsFile(configDir, fileName):
# we process parameters in the following priority:
# first: user_config_dir
# second: current directory
# third: user home directory
# fourth: metAMOS directory
# a parameter specifeid in user_config_dir takes priority over all others, and so on down the line

dirs = [configDir + os.sep + "config", os.path.expanduser('~') + os.sep + ".metAMOS", os.getcwd(), user_config_dir]

result_path = ''
for curDir in dirs:
curFile = curDir + os.sep + fileName
print curFile
if os.path.exists(curFile):
result_path = curFile

return result_path