예제 #1
0

def check_file(filename):
    if (not os.access(filename, os.R_OK)):
        print "%s is not accessible." % filename
        print usage_mesg
        sys.exit(1)


filename_mzXML = sys.argv[1]
filename_hit_list = sys.argv[2]
check_file(filename_mzXML)
check_file(filename_hit_list)

ms1_mz2i = dict()
mzXML = MzXML()
mzXML.parse_file(filename_mzXML)
for tmp_ms1 in mzXML.MS1_list:
    scan_id = tmp_ms1.id
    ms1_mz2i[scan_id] = dict()
    for i in range(0, len(tmp_ms1.mz_list)):
        tmp_mz = tmp_ms1.mz_list[i]
        tmp_i = tmp_ms1.intensity_list[i]
        ms1_mz2i[scan_id][tmp_mz] = tmp_i

ms2_precursor_i = dict()
for tmp_ms2 in mzXML.MS2_list:
    scan_id = tmp_ms2.id
    ms2_precursor_i[scan_id] = tmp_ms2.precursor_intensity

mz2scan = dict()
예제 #2
0
import sys
import os

# from MSScan import MS1Scan, MS2Scan
from MzXML import MzXML

usage_mesg = "mzxml2ms1.py <mzXML file>"

if len(sys.argv) != 2:
    print usage_mesg
    sys.exit(1)

filename_mzXML = sys.argv[1]
if not os.access(filename_mzXML, os.R_OK):
    print "%s is not accessible." % filename_mzXML
    print usage_mesg
    sys.exit(1)

mzXML = MzXML()
mzXML.parse_file(filename_mzXML)

sys.stderr.write("Write %s.ms1 ... " % filename_mzXML)
f_out = open(filename_mzXML + ".ms1", "w")
for tmp_ms1 in mzXML.MS1_list:
    f_out.write("S\t%06d\t%06d\n" % (tmp_ms1.id, tmp_ms1.id))
    f_out.write("I\tRetTime\t%.2f\n" % (tmp_ms1.retention_time))
    for i in range(0, len(tmp_ms1.mz_list)):
        f_out.write("%f\t%.2f\t0\n" % (tmp_ms1.mz_list[i], tmp_ms1.intensity_list[i]))
f_out.close()
sys.stderr.write("Done\n")
예제 #3
0
        t_flag = True
    except:
        threshold_input = raw_input("\nIncorrect input, please enter just a number.\nThreshold: ")

try:
    outputName = str(raw_input("What would you like to call this data set? (No spaces please.) Name: "))
except:
    outputName = raw_input("Enter name: ")

# Sets up book keeping lists and then processes it depending on if it's an mzXML file or mzML file .
neg_pos_mz_sets = [[], []]

# Use correct processing based on filetype
for f in files:
    if ".mzXML" in f:
        mzXML = MzXML()
        mzXML.parse_file(f)
        neg_pos_mz_sets_temp = XML_process(mzXML, threshold=threshold)
        neg_pos_mz_sets[0] = neg_pos_mz_sets[0] + neg_pos_mz_sets_temp[0]
        neg_pos_mz_sets[1] = neg_pos_mz_sets[1] + neg_pos_mz_sets_temp[1]
    elif ".mzML" in f:
        # Use ML processing
        print "Reading %s ..." % f
        neg_pos_mz_sets_temp = ML_process(f, threshold=threshold)
        neg_pos_mz_sets[0] = neg_pos_mz_sets[0] + neg_pos_mz_sets_temp[0]
        neg_pos_mz_sets[1] = neg_pos_mz_sets[1] + neg_pos_mz_sets_temp[1]

# Removes all duplicates from both neg and pos lists
neg_pos_mz_sets[0] = list(set(neg_pos_mz_sets[0]))
neg_pos_mz_sets[1] = list(set(neg_pos_mz_sets[1]))