-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGCMS_CholesterolQuantification.py
More file actions
44 lines (34 loc) · 1.59 KB
/
GCMS_CholesterolQuantification.py
File metadata and controls
44 lines (34 loc) · 1.59 KB
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
42
43
44
""" This program extracts peak area values from csv result-files created in GC-MS analysis with Agilent 5973 GC/MS system for quantification of cholesterol """
# File created on 13 Mar 2015.
# author__ = "Johannes Holert"
# usage: python GCMS_CholesterolQuantification.py <resultfile.csv>
# 0 1
import sys
import csv
import re
filein = open(sys.argv[1], 'r')
shortname = re.sub('.csv$','', sys.argv[1], re.I)
# finds file format removes extension, case insensitive search
output = shortname + ".quant.csv"
fileout = open(output, 'w')
reader = csv.reader(filein) # read lines in input file
for row in reader:
if len(row) < 3:
continue # identify header rows by length and skip these rows
else:
area = row[8] # read out peak areas
if area == "Area": # skip string Area
continue
else:
ret_time = float(row[2]) # read out retention times and convert into flowting numbers
area = float(area) # convert areas into flowting numbers
if (ret_time < 16.7) and (ret_time > 16.4): # set time frame for detection of 5alpha-cholestane standard peak
fileout.write ("%s,%s,Standard,%s\n" %(ret_time, area, output)) # write retention time and peak area for internal standard
elif (ret_time < 19.85) and (ret_time > 19.25): # set time frame for detection of cholesterol peak
fileout.write ("%s,%s,Cholesterol\n" %(ret_time, area)) # write retention time and peak area for cholesterol
else:
continue
filein.close()
fileout.close()
""" To Do:
"""