Beispiel #1
0
    def calc_RT(self, calibrate_coeff=(1, 0, 0, 0), RTtype='achrom'):
        self.RT_predicted = []
        if RTtype == 'ssrcalc':
            if SSRCalc is None:
                logger.critical('SSRCalc not available. Make sure that mechanize is installed.')
                sys.exit(1)
            ps = list(set([peptide.sequence for peptide in self.peptideslist]))
            SSRCalc_RTs = SSRCalc.calculate_RH(ps[:], pore_size=100, ion_pairing_agent='FA')

        for peptide in self.peptideslist:
            if RTtype == 'achrom':
                RT_predicted = achrom.calculate_RT(peptide.modified_sequence, self.RC, raise_no_mod=False)
                if np.isinf(RT_predicted):
                    elems = peptide.modified_sequence.split('-')
                    if len(elems) > 1:
                        if not all(el in parser.std_amino_acids for el in elems[0]) and str(elems[0] + '-') not in self.RC['aa']:
                            self.RC['aa'][str(elems[0] + '-')] = self.RC['aa']['H-']
                        elif not all(el in parser.std_amino_acids for el in elems[-1]) and str('-' + elems[-1]) not in self.RC['aa']:
                            self.RC['aa'][str('-' + elems[-1])] = self.RC['aa']['-OH']
                    RT_predicted = achrom.calculate_RT(peptide.modified_sequence, self.RC, raise_no_mod=False)

            elif RTtype == 'ssrcalc':
                SSRCalc_RT = SSRCalc_RTs[peptide.sequence]
                if SSRCalc_RT is not None:
                    RT_predicted = float(SSRCalc_RT) * calibrate_coeff[0] + calibrate_coeff[1]
                else:
                    RT_predicted = 0
                    logger.error('SSRCalc error')
            elif RTtype == 'biolccc':
                RT_predicted = biolccc.calculateRT(peptide.sequence, biolccc.rpAcnTfaChain, biolccc.standardChromoConditions)
            else:
                logger.error('RT_type error')
            self.RT_predicted.append(RT_predicted)
        self.check_arrays()
Beispiel #2
0
def pyteomcis_snippets(traindf, trainy, testdf, nomod=True):
    """
    """
    #pyteomics
    clf = achrom.get_RCs_vary_lcp([str(i).replace("U", "C") for i in traindf],
                                  trainy)
    print("Pyteomics LCP: {}".format(clf["lcp"]))
    yhat_train = [
        achrom.calculate_RT(i, clf, raise_no_mod=nomod) for i in traindf
    ]
    yhat_test = [
        achrom.calculate_RT(i, clf, raise_no_mod=nomod) for i in testdf
    ]
    return (yhat_train, yhat_test)
Beispiel #3
0
def rt_prediction(calib_file, finalMS1_df):
    print ' from:', calib_file
    calib_df = pd.read_excel(calib_file)
    reten_seq = [str(x) for x in calib_df['Sequence']]
    reten_peak = calib_df['PepRtimePeak'].tolist()
    np.warnings.filterwarnings('ignore')
    RCs = achrom.get_RCs_vary_lcp(reten_seq, reten_peak)
    initRT_tuple = []
    for idx, row in finalMS1_df.iterrows():
        pept = str(row['pept'])
        rt = achrom.calculate_RT(pept, RCs)
        initRT_tuple.append((idx, pept, rt))

    reten_start = calib_df['PepRtimeStart']
    reten_end = calib_df['PepRtimeEnd']
    initRT_width = np.mean((reten_end - reten_start).values)

    reten_validate = []
    for seq in reten_seq:
        rt_v = achrom.calculate_RT(seq, RCs)
        reten_validate.append(rt_v)

    predict_coef = np.corrcoef(reten_peak, reten_validate)
    return initRT_tuple, initRT_width
Beispiel #4
0
print 'Done!'

peptides = [peptide for peptide in peptides if peptide['length'] <= 100]

print 'Calculating the mass, charge and m/z...'
for peptide in peptides:
    peptide['charge'] = int(
        round(electrochem.charge(peptide['parsed_sequence'], pH=2.0)))
    peptide['mass'] = mass.calculate_mass(peptide['parsed_sequence'])
    peptide['m/z'] = mass.calculate_mass(peptide['parsed_sequence'],
                                         charge=peptide['charge'])
print 'Done!'

print 'Calculating the retention time...'
for peptide in peptides:
    peptide['RT_RP'] = achrom.calculate_RT(peptide['parsed_sequence'],
                                           achrom.RCs_zubarev)
    peptide['RT_normal'] = achrom.calculate_RT(peptide['parsed_sequence'],
                                               achrom.RCs_yoshida_lc)
print 'Done!'

plt.figure()
plt.hist([peptide['m/z'] for peptide in peptides], bins=2000, range=(0, 4000))
plt.xlabel('m/z, Th')
plt.ylabel('# of peptides within 2 Th bin')

plt.figure()
plt.hist([peptide['charge'] for peptide in peptides], bins=20, range=(0, 10))
plt.xlabel('charge, e')
plt.ylabel('# of peptides')

x = [peptide['RT_RP'] for peptide in peptides]
Beispiel #5
0
def calc_RT(seq, RC):
    try:
        return achrom.calculate_RT(seq, RC)
    except Exception:
        return 0