def gnpsexport(input_port, inputFiles_port, ini_file, out_port):
    for input_file, file_count in list(
            wrkflw.parsefolder(input_port, whitelist=['consensusXML'])):
        output = out_port + '/' + out_port + "-" + file_count + ".mgf"

        command = "GNPSExport"
        if ini_file is not None:
            command += " -ini " + ini_file
        command += " -in_cm " + input_file + " -in_mzml"
        # command = "GNPSExport -ini " + ini_file + " -in_cm " + input_file + " -in_mzml "

        file_maps = dict()
        with open(input_file, 'r') as fp:
            params = xtd.parse(fp.read())
            for map in params['consensusXML']['mapList']['map']:
                # print (map['@id'], map['@name'])
                file_maps[int(map['@id'])] = map['@name']

        for input_file, file_count in sorted(
                list(wrkflw.parsefolder(inputFiles_port, whitelist=['mzML']))):
            command += " " + input_file
        command += " -out " + output
        command += '> ' + out_port + '/logfile-00000.txt'
        # command += ' -log ' + out_port+'/logfile-00000.txt'

        print("COMMAND: " + command + "\n")
        os.system(command)
def fix_filenames(out_port, mapping_file):
    print("correcting filenames in featurelinker step...")

    files = dict()
    with open(mapping_file) as f:
        file_dict = xtd.parse(f.read())
        for map_line in file_dict['parameters']['parameter']:
            if "upload_file_mapping" in map_line[
                    '@name'] and "inputFiles" in map_line['#text']:
                map = map_line['#text'].split('|')
                raw_file_path = os.path.splitext(map[0])[0].split('-')[1]

                print("mapping", raw_file_path, "->", map[1])
                files[int(raw_file_path)] = map[1]

    # print(list(wrkflw.parsefolder(out_port)))
    for input_file, file_count in wrkflw.parsefolder(out_port,
                                                     blacklist=['log']):
        with open(input_file) as f:
            file_dict = xtd.parse(f.read())

        for map in file_dict['consensusXML']['mapList']['map']:
            print("\tid:", map['@id'], '\t', map['@name'], '\t-->\t',
                  files[int(map['@id'])])
            map['@name'] = files[int(map['@id'])]

        # export file_dict
        out = xtd.unparse(file_dict, pretty=True)
        with open(input_file, 'w') as file:
            file.write(out)

    print("out port dir:", os.listdir(out_port))
Exemplo n.º 3
0
def featurefindermetabo(input_port, ini_file, out_port):
    commands = []
    for input_file,file_count in wrkflw.parsefolder(input_port, blacklist=['log']):
        cmd = get_exec_cmd(input_file,file_count,ini_file,out_port)
        commands.append(cmd)

    mpl.run_parallel_shellcommands(commands,8)
Exemplo n.º 4
0
def textexporter(input_port, ini_file, out_port):
    for input_file, file_count in list(
            wrkflw.parsefolder(input_port, blacklist=['log'])):
        # command = "TextExporter -ini " + ini_file + " -in " + input_file + " -out " + out_port+'/'+out_port+'-'+file_count+'.csv' + ' >> ' + out_port+'/logfile-00000.txt'
        command = "TextExporter -ini " + ini_file + " -in " + input_file + " -out " + out_port + '/' + out_port + '-' + file_count + '.csv' + ' -log ' + out_port + '/logfile-00000.txt'

        print("COMMAND: " + command + "\n")
        os.system(command)
Exemplo n.º 5
0
def filefilter(input_port, out_port):
    #only one job
    for input_file,file_count in wrkflw.parsefolder(input_port, blacklist=['log']):
        # in_cm = in_port+'/'+get_port_outputs(in_port)[0]
        output = out_port+'/'+out_port+"-"+file_count+".consensusXML"

        command = "FileFilter -id:remove_unannotated_features -in " + input_file + " "
        command += "-out " + output + ' '
        command += '> ' + out_port+'/logfile-00000.txt'
        # command += '-log ' + out_port+'/logfile-00000.txt'

        print("COMMAND: " + command + "\n")
        os.system(command)
def featurelinkerunlabeledqt(input_port, ini_file, out_port):
    command = "FeatureLinkerUnlabeledQT "
    if ini_file is not None:
        command += "-ini " + ini_file + " "
    command += "-in "
    for input_file, file_count in wrkflw.parsefolder(input_port,
                                                     whitelist=["featureXML"]):
        command += input_file + " "
    command += "-out " + out_port + "/" + out_port + "-00000.consensusXML "
    command += '-log ' + out_port + '/logfile-00000.txt'

    print("COMMAND: " + command + "\n")
    os.system(command)
def fileconverter(input_port, out_port):
    commands = []
    for input_file,file_count in wrkflw.parsefolder(input_port, blacklist=["log"]):
        if any([ext.lower() in input_file.lower() for ext in ['mzData', 'mzXML',\
                'cachedMzML', 'dta', 'dta2d', 'mgf', 'featureXML',\
                'consensusXML', 'ms2', 'fid', 'tsv', 'peplist', 'kroenik',\
                'edta']]):
          cmd = get_exec_cmd(input_file,file_count,out_port)
          commands.append(cmd)
        elif "mzml" in input_file.lower():
          shutil.copyfile(input_file, out_port+"/"+out_port+"-"+file_count+".mzML")
          os.system("echo \"original file format for {} is mzml\" >> {}".format(input_file,out_port+"/logfile-"+file_count+".txt"))
        else:
          continue
    mpl.run_parallel_shellcommands(commands,8)
Exemplo n.º 8
0
def idmapper(input_port, ini_file, idxml_path, featurefinder_port, out_port):
    commands = []
    for input_file, file_count in wrkflw.parsefolder(featurefinder_port,
                                                     blacklist=['log']):
        cmd = get_exec_cmd( \
          input_file, \
          file_count, \
          ini_file, \
          idxml_path, \
          input_port, \
          out_port
        )
        commands.append(cmd)

    mpl.run_parallel_shellcommands(commands, 8)
def mapalignerposeclustering(input_port, ini_file, out_port):
    command = "MapAlignerPoseClustering "
    if ini_file is not None:
        command += "-ini " + ini_file + " "
    command += "-in "

    outputs = []
    for input_file, file_count in wrkflw.parsefolder(input_port,
                                                     blacklist=['log']):
        command += '{} '.format(input_file)
        outputs.append("{out}/{out}-{filec}.featureXML ".format(
            out=out_port, filec=file_count))
        # command += input_file + ' '
    command += '-out '
    command += ' '.join(outputs)
    # for input_file,file_count in wrkflw.parsefolder(input_port, blacklist=['log']):
    # command += out_port+"/"+out_port+"-"+file_count+".featureXML" + ' '
    command += '> ' + out_port + '/logfile-00000.txt'
    # command += '-log ' + out_port+'/logfile-00000.txt'

    print("COMMAND: " + command + "\n")
    os.system(command)
Exemplo n.º 10
0
#6 module: text export
'''


def textexporter(input_port, ini_file, out_port):
    for input_file, file_count in list(
            wrkflw.parsefolder(input_port, blacklist=['log'])):
        # command = "TextExporter -ini " + ini_file + " -in " + input_file + " -out " + out_port+'/'+out_port+'-'+file_count+'.csv' + ' >> ' + out_port+'/logfile-00000.txt'
        command = "TextExporter -ini " + ini_file + " -in " + input_file + " -out " + out_port + '/' + out_port + '-' + file_count + '.csv' + ' -log ' + out_port + '/logfile-00000.txt'

        print("COMMAND: " + command + "\n")
        os.system(command)


if __name__ == '__main__':
    print("===TEXT EXPORTER===")

    # set env
    os.environ["LD_LIBRARY_PATH"] = sys.argv[1]
    os.environ["PATH"] = sys.argv[2]
    os.environ["OPENMS_DATA_PATH"] = os.path.abspath(sys.argv[3])

    # ini file
    ini_file = None
    if os.path.exists('iniFiles'):
        ini_dir = list(wrkflw.parsefolder('iniFiles'))
        if len(ini_dir) > 0:
            ini_file = ini_dir[0][0]

    textexporter(sys.argv[4], ini_file, sys.argv[6])