Skip to content

Instantly share code, notes, and snippets.

@canimus
Created February 9, 2023 14:10
Show Gist options
  • Save canimus/1b23464a40d900361410fde5e6e71c69 to your computer and use it in GitHub Desktop.
Save canimus/1b23464a40d900361410fde5e6e71c69 to your computer and use it in GitHub Desktop.
Conversion of gene to frame
series = []
d = {}
for row in raw:
try:
if len(row) == 0:
continue
if row.startswith("!sample_table_end"):
for k in arr:
if k in d:
d[k] = [d[k]]
series.append(d)
d = {}
continue
if row.startswith("#") or row.startswith("ID_REF") or ("sample_table_begin" in row):
continue
if row.startswith("^") or row.startswith("!"):
x = row.split(" ")
a,b = x[0].strip(), " ".join(x[1:]).strip()
if a in arr:
if a not in d:
d[a] = []
else:
d[a] = d[a] + [b[2:]]
else:
d[a] = [b[2:]]
else:
a,b = row.split("\t")
d[a.strip()] = [b.strip()]
except Exception as e:
print(row, e)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment