method, anfrac = method.split(':') else: anfrac = None tgs = defaultdict(set) allspec = set() lccal = defaultdict(dict) for specfile in sys.argv[3:]: dirname = specfile.rsplit('.', 2)[0] if dirname.endswith('.centroid'): dirname = dirname.rsplit('.', 1)[0] spectra = os.path.split(dirname)[1] allspec.add(spectra) w.addacquisition(name=spectra, method=method, anfrac=anfrac, sample=sample, xicmmu=50, type="DIA") for jsonfile in glob.glob(dirname + '/*.json'): # spectra = os.path.split(os.path.split(jsonfile)[0])[1] data = json.loads(open(jsonfile).read()) rt = data['rt'] nrt = data.get('nrt') trans = [] for s in data['series']: trid = s['name'].split('/')[-2] it = float(s['obs_relint']) / 10.0 if it <= 0: continue trans.append((trid, it)) trans.sort(key=lambda t: -t[1])
w = GPTWiki() spectra2tg = defaultdict(set) for tgpage in w.iterpages(include_categories=['TransitionGroup']): tg = w.get(tgpage.name) spectra = tg.get('spectra') spectra2tg[spectra].add(tg.get('id')) allspectra = set() for transfile in sys.argv[1:]: spectra, sample, method, index, extn = transfile.rsplit('.', 4) spectra = os.path.split(spectra)[1] allspectra.add(spectra) w.addacquisition(name=spectra, method=method, sample=sample) tgroup = defaultdict(dict) for l in csv.DictReader(open(transfile), dialect='excel-tab'): seq = l['PeptideSequence'] glyspec = l['Glycans'] modspec = l['Mods'] glycan = [] if glyspec != "-": glycan = map(lambda t: (t[1], seq[int(t[0]) - 1] + str(t[0])), map(lambda s: s.split(':'), glyspec.split(','))) mods = [] if modspec != "-": for mstr in modspec.split(','): pos, delta = mstr.split(':') delta, site, sym = mod_mw(float(delta), int(pos), seq) mods.append((delta, site))