Esempio n. 1
0
def init():
    if len(sys.argv) != 7:
        print(''.join(["Usage: ", os.path.basename(__file__), ' params.ctd jobname.txt registername.txt user.txt filestostage.ctd workflow.ctd' ]))
        sys.exit(-1)
    params = {}
    ctd = args_from_file(sys.argv[1])
    params["duration"] = ctd['duration']
    params['filesystem'] = ctd['filesystem']

    params['wfname'] = ctd['wfname']
    params['wfrepo'] = ctd['wf_repo']
    params['wf']= os.path.join(params['wfrepo'],params['wfname'])
    params['jobname'] = read_firstline(sys.argv[2])
    params['registername'] = read_firstline(sys.argv[3])
    params['user'] = read_firstline(sys.argv[4])
    params['group'] = None

    ctdmodel = CTDModel(from_file=sys.argv[5])
    params['inputfiles'] = get_filestostage(ctdmodel,"input")
    params['db'] = get_filestostage(ctdmodel, "db")

    #wfdir = ws_allocate("cfc", "init_works_qbic_dw", 1)
    print("allocating work space " + params['registername'])
    params['wfspace'] = ws_allocate(params['filesystem'], params['registername'], params['duration'])
    params['params'] = sys.argv[6]
    return params
def test_args_from_file():
    ctd = args_from_file("inputs/INIT-CTD")
    duration = ctd['duration']
    filesystem = ctd['filesystem']

    snakemake_wf_name = ctd['wfname']
    wf_repo = ctd['wf_repo']

    assert (duration == 5 or duration == '5')
    assert snakemake_wf_name == "qcprot"
    assert wf_repo == "/lustre_cfc/qbic/workflow_repos"
    assert filesystem == "cfc"
from CTDopts.CTDopts import _InFile, CTDModel, args_from_file
import sys
import os
import subprocess

wf_dir = sys.argv[1]
ctd_files = args_from_file(wf_dir + '/IN-FILESTOSTAGE')


command = './annotateVariants.sh '

data_path = '%s/data/' % wf_dir
result_path = '%s/result/' % wf_dir

files = []

for f in ctd_files["input"]:
	fileName = f.split('/')[-1]
        command += ('%s' % (data_path, fileName))

command += '%s ' % wf_dir 
command += '%s ' fileName

subprocess.call(command.split())
from CTDopts.CTDopts import _InFile, CTDModel, args_from_file
import sys
import os
import subprocess

wf_dir = sys.argv[1]
ctd_params = args_from_file(wf_dir + '/WORKFLOW-CTD')
ctd_files = args_from_file(wf_dir + '/IN-FILESTOSTAGE')

#TODO: define parameters using flags (input files, pheno.txt and var of interest)
command = 'python prepare_r.py '

data_path = '%s/data/' % wf_dir
result_path = '%s/result/' % wf_dir
log_path = '%s/logs/' % wf_dir

command += " -d " + wf_dir

files = []

for f in ctd_files["input"]:
    fileName = f.split('/')[-1]
    files.append('%s%s' % (data_path, fileName))

#command += '%s' % ' '.join(files)

for param in ctd_params.keys():
    command += ' -%s %s' % (param, ctd_params[param])

log = open("qclogs.txt", 'w')
subprocess.call(command.split(), stderr=log, stdout=log)
Esempio n. 5
0
pout2mzidparams.add(
    'validate',
    type=bool,
    description='This is a flag: Type 1 to set flag. Sets that validation of XML schema should not be performed. Faster parsing.'
)

pout2mzidparams.add(
    'warning',
    type=bool,
    description='This is a flag: Type 1 to set flag. Sets that upon warning the software should terminate'
)

args = msgf_percolator_model.parse_cl_args()

try:
    args = args_from_file(args['ctd'])
    print "try to load ctd"

    ### MZID2PIN Parameter ###
    try:
        args['mzid2pin']['mzid2pin_path']
        args['mzid2pin']['target_input']
        args['mzid2pin']['decoy_input']
    except:
        print "Path or decoy/target-files missing!"
    str = ''
    try:
        if args['mzid2pin']['outputXML'] != '':
            str += ' --outputXML \'%s\'' % args['mzid2pin']['outputXML']
    except:
        pass
Esempio n. 6
0
print ("We can validate these arguments against the model, and get a dictionary with parameter types correctly casted "
"and defaults set. Note that subparams:param_1 was casted from string to a floating point number because that's how it "
"was defined in the model.")
validated = model.validate_args(new_values)
pretty_print(validated)
print()

print ('We can write a CTD file containing these validated argument values. Just call CTDModel.write_ctd() with an extra '
    'parameter: the nested argument dictionary containing the actual values.')
model.write_ctd('exampleTool_preset_params.ctd', validated)
print()

print ('As mentioned earlier, CTDopts can load argument values from CTD files. Feel free to change some values in '
    "exampleTool_preset_params.ctd you've just written, and load it back.")
args_from_ctd = args_from_file('exampleTool_preset_params.ctd')
pretty_print(args_from_ctd)
print()
print ("Notice that all the argument values are strings now. This is because we didn't validate them against the model, "
    "just loaded some stuff from a file into a dictionary. If you want to cast them, call CTDModel.validate_args():")
validated_2 = model.validate_args(args_from_ctd)
pretty_print(validated_2)
print()

print ("Now certain parameters may have restrictions that we might want to validate for as well. Let's set the parameter "
    "positive_int to a negative value, and try to validate it with a strictness level enforce_restrictions=1. This "
    "will register a warning, but still accept the value.")
validated_2['positive_int'] = -5
_ = model.validate_args(validated_2, enforce_restrictions=1)
print()
Esempio n. 7
0
    "and defaults set. Note that subparams:param_1 was casted from string to a floating point number because that's how it "
    "was defined in the model.")
validated = model.validate_args(new_values)
pretty_print(validated)
print()

print(
    'We can write a CTD file containing these validated argument values. Just call CTDModel.write_ctd() with an extra '
    'parameter: the nested argument dictionary containing the actual values.')
model.write_ctd('exampleTool_preset_params.ctd', validated)
print()

print(
    'As mentioned earlier, CTDopts can load argument values from CTD files. Feel free to change some values in '
    "exampleTool_preset_params.ctd you've just written, and load it back.")
args_from_ctd = args_from_file('exampleTool_preset_params.ctd')
pretty_print(args_from_ctd)
print()
print(
    "Notice that all the argument values are strings now. This is because we didn't validate them against the model, "
    "just loaded some stuff from a file into a dictionary. If you want to cast them, call CTDModel.validate_args():"
)
validated_2 = model.validate_args(args_from_ctd)
pretty_print(validated_2)
print()

print(
    "Now certain parameters may have restrictions that we might want to validate for as well. Let's set the parameter "
    "positive_int to a negative value, and try to validate it with a strictness level enforce_restrictions=1. This "
    "will register a warning, but still accept the value.")
validated_2['positive_int'] = -5