Skip to content

Commit 908ed9f

Browse files
feat: BMG Mars - Updated parser to support BMG Labtech format (#1126)
Co-authored-by: joshua-benchling <jherna@benchling.com>
1 parent f09f8f7 commit 908ed9f

4 files changed

Lines changed: 4080 additions & 0 deletions

File tree

src/allotropy/parsers/bmg_mars/bmg_mars_reader.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ def _parse_file(self, named_file_contents: NamedFileContents) -> None:
2828
"""Parse the BMG MARS file and populate header and data attributes."""
2929
reader = CsvReader(read_to_lines(named_file_contents))
3030
lines = list(reader.pop_until_inclusive("^,?Raw Data"))
31+
# Some headers may include an extra trailing comma at the end of a line.
32+
# Remove a single trailing comma from any header line before reading.
33+
lines = [
34+
(line[:-1].rstrip() if line.rstrip().endswith(",") else line)
35+
for line in lines
36+
]
3137
# Store the header contents so we can parse some values that don't have key/value
3238
# pairs such as wavelengths and read type.
3339
self.header_content = "\n".join(lines)

src/allotropy/parsers/bmg_mars/bmg_mars_structure.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ class Header:
7474
r"Raw Data \((\d+\.?\d*)/(\d+\.?\d*)\)",
7575
lambda m: (float(m.group(2)), float(m.group(1))),
7676
),
77+
"Raw Data (Ex Em)": (
78+
r"Raw Data \((\d+\.?\d*) (\d+\.?\d*)\)",
79+
lambda m: (float(m.group(2)), float(m.group(1))),
80+
),
7781
"Raw Data (Em)": (
7882
r"Raw Data \((\d+\.?\d*)\)",
7983
lambda m: (float(m.group(1)), None),
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
User: Discovery,Path: C:\Users\Lab user\Documents\Discovery\Data,Test run no.: 445
2+
Test name: xxxxxxxxxxxxx,Date: 5/14/2021,Time: 3:29:50 PM
3+
4+
ID1: xxxxxxxxxxxxx,ID2: Plate 1,ID3: xxxxxxx 11/5/21,
5+
Absorbance
6+
7+
Raw Data (450 1)
8+
9+
,1,2,3,4,5,6,7,8,9,10,11,12,
10+
A,0.073,0.082,0.08,0.107,0.103,0.111,0.199,0.159,0.104,0.096,0.092,0.089
11+
B,0.045,0.067,0.012,0.118,0.1,0.086,0.188,0.112,0.124,0.181,0.218,0.23
12+
C,0.502,0.065,0.012,0.656,0.501,0.132,0.111,0.142,0.71,0.581,0.541,0.596
13+
D,0.121,0.121,0.37,0.634,0.677,0.606,0.069,0.666,0.054,0.836,0.149,0.168
14+
E,0.109,0.06,0.09,0.07,0.072,0.059,0.079,0.073,0.062,0.121,0.112,0.112
15+
F,0.072,0.012,0.064,0.012,0.061,0.06,0.079,0.088,0.082,0.012,0.068,0.1
16+
G,0.314,0.056,0.057,0.376,0.411,0.075,0.081,0.091,0.121,0.41,0.212,0.212
17+
H,0.422,0.224,0.115,0.278,0.377,0.385,0.056,0.377,0.107,0.462,0.116,0.207

0 commit comments

Comments
 (0)