Commit 8ec6db1f authored by Martino Bertoni's avatar Martino Bertoni 🌋
Browse files

added method to dump molrepos's molecules to csv file

parent 536a3254
Pipeline #2512 failed with stages
in 61 minutes and 49 seconds
...@@ -132,6 +132,21 @@ class Molrepo(Base): ...@@ -132,6 +132,21 @@ class Molrepo(Base):
session.close() session.close()
return res return res
def to_csv(staticmethod, filename):
"""Write molecules InChI-Key, source_id, InChI and SMILES to CSV file.
filename(str): Path to a CSV file.
import pandas as pd
molecules = Molrepo.get_by_molrepo_name(molrepo_name)
df = pd.DataFrame(molecules, columns=['molrepo','source_id','SMILES','InChIKey','InChI'])
df.sort_values('InChIKey', inplace=True)
df[['InChIKey', 'source_id', 'SMILES','InChI']].to_csv(filename, index=False)
@staticmethod @staticmethod
def from_csv(filename): def from_csv(filename):
"""Add entries from CSV file. """Add entries from CSV file.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment