Exemplo n.º 1
0
    def test_write(self, tmpdir):
        yaml_conf = tmpdir / "conf.yml"
        yaml_conf.write(r"""
        numThreads: 4
        fastaFiles: [test1.fasta,test2.fasta]
        parseRules:
          identifierParseRule: ^>.*\|(.*)\|.*$
        paramGroups:
          - files: [Test1.mzXML,Test2.mzXML] # paramGroup 0
            fixedModifications: [mod1]
            variableModifications: [mod2,mod3]
            maxMissedCleavages: 1
        """)
        mqpar_out = tmpdir / "mqpar.xml"

        t = MQParam(TEMPLATE_PATH, yaml=str(yaml_conf))
        t.write(str(mqpar_out))

        test = ET.parse(str(mqpar_out)).getroot()
        assert test.find('numThreads').text == '4'
        assert test.find('fastaFiles')[1].find(
            'identifierParseRule').text == '^>.*\\|(.*)\\|.*$'
        assert [
            el.text for el in test.find('parameterGroups')[0].find(
                'variableModifications')
        ] == ['mod2', 'mod3']
Exemplo n.º 2
0
parser.add_argument('--version', '-v', help="""A version number. Raises exception if it doesn't
match the MaxQuant version of the template. For usage in the Galaxy tool.""")

# in case numThreads is a environment variable, otherwise it can be specified in the yaml file as well
parser.add_argument('--num_threads', '-t', help="Number of threads to specify in mqpar.")
args = parser.parse_args()

# edit file names, working dir is unknown at the time of galaxy tool configfile creation
if args.yaml:
    with open(args.yaml) as f:
        conf_dict = yaml.safe_load(f.read())

        for n, pg in enumerate(conf_dict['paramGroups']):
            for num, fl in enumerate(pg['files']):
                if not fl.startswith('/'):
                    conf_dict['paramGroups'][n]['files'][num] = os.path.join(os.getcwd(), fl)
    with open('yaml', 'w') as f:
        yaml.safe_dump(conf_dict, stream=f)
        args.yaml = 'yaml'

kwargs = dict(yaml=args.yaml)
if args.substitution_rx:
    kwargs['substitution_rx'] = args.substitution_rx
mqparam = MQParam(args.template, args.exp_design, **kwargs)
if args.version and mqparam.version != args.version:
    raise Exception('mqpar version is ' + mqparam.version + '. Tool uses version {}.'.format(args.version))
mqparam.set_simple_param('numThreads', args.num_threads)

mqparam.write(args.mqpar_out if args.mqpar_out else 'mqpar.xml')
Exemplo n.º 3
0
from mqparam import MQParam

parser = argparse.ArgumentParser()

arguments = ('--infiles',
             '--version',
             '--num_threads',
             '--substitution_rx',
             '--fasta_files',
             '--description_parse_rule',
             '--identifier_parse_rule',
             'mqpar')

for arg in arguments:
    parser.add_argument(arg)

args = parser.parse_args()

mqpar_out = os.path.join(os.getcwd(), 'mqpar.xml')
infiles = [os.path.join(os.getcwd(), f) for f in args.infiles.split(',')]
mqparam = MQParam(args.mqpar, None, substitution_rx=args.substitution_rx)
if mqparam.version != args.version:
    raise Exception('mqpar version is ' + mqparam.version + '. Tool uses version {}.'.format(args.version))
mqparam.translate(infiles)
mqparam.add_fasta_files(args.fasta_files.split(','),
                        {'identifierParseRule': args.identifier_parse_rule,
                         'descriptionParseRule': args.description_parse_rule})
mqparam.set_simple_param('numThreads', args.num_threads)
mqparam.write('mqpar.xml')