-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3-HitCollator-Radical2.py
41 lines (32 loc) · 1.18 KB
/
3-HitCollator-Radical2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 2 17:43:28 2018
@author: Will Kew
"""
import pandas as pd
import os
#import re
import progressbar
path = "F:/Will/Dropbox/Documents/University/Edinburgh/FTICRMS/MixedIonisation3-formularity/"
#path = "C:/Users/Will/Dropbox/Documents/University/Edinburgh/FTICRMS/MixedIonisation3-formularity/"
inputdata = path +"ReformAssignments/"
outputdata = path
files = os.listdir(inputdata)
mode = None
#mode = "normalise"
df = pd.DataFrame(index=files,columns=['Total','Deprotonated','Radical','De-Duplicated'])
bar = progressbar.ProgressBar()
for x in bar(files):
sample = x[:-5]
df1 = pd.read_excel(inputdata+x,sheet_name="Hits")
totallength = len(df1)
deprotonatedlength = len(df1[df1['State']=="H-"])
radicallength = len(df1[df1['State']==".-"])
df1=df1.groupby('Formula',as_index=False).mean() #This clever line averages the values for duplicated formula, i.e. radicals found.
dedupedlength = len(df1)
df.loc[x,'Total']=totallength
df.loc[x,'Deprotonated']=deprotonatedlength
df.loc[x,'Radical']=radicallength
df.loc[x,'De-Duplicated']=dedupedlength
df.to_excel(outputdata+"RadicalStats.xlsx")