Commit c869718d authored by mirandaa's avatar mirandaa

source is the copy paste from excalubur

parent f8c0d40a
'''
Created on 29.05.2018
@author: mirandaa
'''
import sys
import pandas as pd
def dataframe_slope(peaksDF):
max = peaksDF.Intensity.max()
tenPC = max / 10
selected_peaks = peaksDF.loc[peaksDF.Intensity > tenPC]
selected_peaks.sort_values('mz', inplace=True)
# selected_peaks.plot.scatter('mz', 'resolution')
idx_lowMZ = selected_peaks.head(10)['Resolution'].max() == selected_peaks['Resolution']
idx_highMZ = selected_peaks.tail(10)['Resolution'].min() == selected_peaks['Resolution']
print 'selected points are :'
print selected_peaks[idx_lowMZ]
print selected_peaks[idx_highMZ]
slope = (selected_peaks[idx_highMZ].Resolution.values[-1] - selected_peaks[idx_lowMZ].Resolution.values[0]) / (selected_peaks[idx_highMZ].mz.values[-1] - selected_peaks[idx_lowMZ].mz.values[0])
print ('slope of (res.highMZ - res.lowMZ ) / (highMZ - lowMZ ) is {}'.format(slope))
return slope
def rcc(filename):
print ('clean csv')
df = pd.read_csv(filename)
df.dropna(inplace=True)
df.head()
df.columns = df.iloc[0]
df.rename(index=str, columns={"m/z": "mz"},inplace =True)
df = df.iloc[1:]
df.reset_index(inplace=True)
df = df.apply(pd.to_numeric)
slope = dataframe_slope(df)
print('----')
print('slope: {}'.format(slope))
if __name__ == '__main__':
print ('provide *.csv file, copy/paste from excalibur with masses in the range expected for the slope')
if len(sys.argv) <= 1:
print ('provide *.csv file, copy/paste from excalibur')
sys.exit(1)
filename = ' '.join(sys.argv[1:])
if str(filename[-4:]).lower() != '.csv':
print ('provideded {}r'.format(filename))
print ('provide *.csv file, copy/paste from excalibur')
sys.exit(1)
try:
rcc(filename)
except Exception as e:
print(e)
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment