-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlexStationFormatToCSV.py
More file actions
53 lines (46 loc) · 1.7 KB
/
FlexStationFormatToCSV.py
File metadata and controls
53 lines (46 loc) · 1.7 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
45
46
47
48
49
50
51
52
53
i#!/usr/bin/env python3
#Converts a Molecular Devices FlexStation 3 Microplate Reader .csv file to a easier to use format
#On the command line run: cat "your_file".csv | FlexStationFormatToCSV.py > "your_output".csv
#If you use the wildcard * you can run it on all your files at once
import re
import sys
def pretty_print(start_idx, plate_name, well_co, absorbance, temp, wave):
for i in range(len(well_co)):
print(
f"{start_idx + i},{plate_name},{well_co[i]},{absorbance[i]},{temp},{wave}"
)
n = 0
abs_row = 0
sample = 1
wbool = False
wpos = 0
print("Sample, Plate, Well, Absorbance, Temperature, Wavelenght")
for raw_line in sys.stdin:
line = raw_line.strip()
if re.search(r"##BLOCKS=", line):
block = line.split(",")[0].split(" ")[1]
elif not line.replace(",", "").rstrip():
continue
elif re.search(r"Plate:", line):
plate = line.split(",")[1]
wavelenght = line.split(",")[15].split(" ")
if len(wavelenght) >= 2:
wbool = True
elif re.search(r"Temperature", line):
well = line.split(",")[2:]
abs_row = n + 1
elif abs_row != 0 and abs_row == n:
temperature = line.split(",")[1]
absorbances = line.split(",")[2:]
pretty_print(sample, plate, well, absorbances, temperature, wavelenght[wpos])
sample += len(well)
wpos += 1
elif wbool is True and re.search(re.escape(temperature), line):
temperature = line.split(",")[1]
absorbances = line.split(",")[2:]
pretty_print(sample, plate, well, absorbances, temperature, wavelenght[wpos])
sample += len(well)
wpos += 1
elif re.search(r"~End", line):
wpos = 0
n += 1