You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've used pandas df.to_csv() to write out a custom codon table codon_table.csv
reading this table gives an error when reading the last line. adding the length check ( if len(line)>3:) solves this problem.
def csv_string_to_codons_dict(csv_string):
"""Transform a CSV string of a codon table to a dict."""
result = {}
for line in csv_string.split("\n")[1:]:
if len(line)>3: # new check
aa, codon, freq = line.split(",")
if aa not in result:
result[aa] = {}
result[aa][codon] = float(freq)
return result
The text was updated successfully, but these errors were encountered:
Thank you. The issue seems to arise when the csv is terminated with an empty line, which is common and probably a preferable format as well. I'll address this later this month together with DNA Chisel; the function may be replaced with something from the csv package. But in any case perhaps it's better to remove all trailing newlines from the string.
I've used pandas df.to_csv() to write out a custom codon table
codon_table.csv
reading this table gives an error when reading the last line. adding the length check (
if len(line)>3:
) solves this problem.The text was updated successfully, but these errors were encountered: