forked from benedictpaten/cPecan
-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.py
66 lines (61 loc) · 3.15 KB
/
common.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
#Copyright (C) 2009-2011 by Benedict Paten (benedictpaten@gmail.com)
#
#Released under the MIT license, see LICENSE.txt
"""Wrapper functions for assisting in running the various programs
"""
import os
import random
import sys
from sonLib.bioio import logger
from sonLib.bioio import system
from sonLib.bioio import nameValue
from sonLib.bioio import getLogLevelString
def getLogLevelString2(logLevelString):
"""Gets the log level string for the binary
"""
if logLevelString == None:
return getLogLevelString()
return logLevelString
def runCPecanEm(sequenceFiles, alignmentsFile, outputModelFile,
inputModelFile=None,
modelType=None,
jobStore=None,
iterations=None, randomStart=None,
trials=None,
optionsToRealign=None,
logLevel=None,
updateTheBand=None,
maxAlignmentLengthPerJob=None,
maxAlignmentLengthToSample=None,
useDefaultModelAsStart=None,
setJukesCantorStartingEmissions=None,
trainEmissions=None,
tieEmissions=None,
outputTrialHmms = None,
outputXMLModelFile = None,
blastScoringMatrixFile=None):
assert(jobStore is not None)
logLevel = getLogLevelString2(logLevel)
inputModelFile= nameValue("inputModel", inputModelFile, str)
modelType = nameValue("modelType", modelType, str)
iterations = nameValue("iterations", iterations, int)
trials = nameValue("trials", trials, int)
randomStart = nameValue("randomStart", randomStart, bool)
updateTheBand = nameValue("updateTheBand", updateTheBand, bool)
maxAlignmentLengthPerJob = nameValue("maxAlignmentLengthPerJob", maxAlignmentLengthPerJob, int)
maxAlignmentLengthToSample = nameValue("maxAlignmentLengthToSample", maxAlignmentLengthToSample, int)
optionsToRealign = nameValue("optionsToRealign", optionsToRealign, quotes=True)
useDefaultModelAsStart = nameValue("useDefaultModelAsStart", useDefaultModelAsStart, bool)
trainEmissions = nameValue("trainEmissions", trainEmissions, bool)
tieEmissions = nameValue("tieEmissions", tieEmissions, bool)
setJukesCantorStartingEmissions = nameValue("setJukesCantorStartingEmissions", setJukesCantorStartingEmissions, float)
outputTrialHmms = nameValue("outputTrialHmms", outputTrialHmms, bool)
outputXMLModelFile = nameValue("outputXMLModelFile", outputXMLModelFile, str)
blastScoringMatrixFile = nameValue("blastScoringMatrixFile", blastScoringMatrixFile, str)
system("cPecanEm --sequences '%s' --alignments %s --outputModel %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s" % \
(" ".join(sequenceFiles), alignmentsFile, outputModelFile, iterations, trials, randomStart,
inputModelFile, optionsToRealign, modelType,
maxAlignmentLengthPerJob, maxAlignmentLengthToSample, updateTheBand, useDefaultModelAsStart,
trainEmissions, tieEmissions, setJukesCantorStartingEmissions, outputTrialHmms,
outputXMLModelFile, blastScoringMatrixFile, jobStore))