def test_csv(): df = opd.read_sdf( input_fname, columns=['mol', 'name', 'chembl_id', 'dude_smiles', 'act']) df['act'] = df['act'].astype(float) df['name'] = df['name'].astype(int) with NamedTemporaryFile(suffix='.csv', mode='w+') as f: for str_buff in (f, f.name): df.to_csv(str_buff, index=False) f.seek(0) df2 = opd.read_csv(f.name, smiles_to_molecule='mol', molecule_column='mol') assert df.shape == df2.shape assert df.columns.tolist() == df2.columns.tolist() assert df.dtypes.tolist() == df2.dtypes.tolist() with NamedTemporaryFile(suffix='.csv', mode='w+') as f: for str_buff in (f, f.name): df.to_csv(str_buff, index=False, columns=['name', 'act']) f.seek(0) df2 = pd.read_csv(f.name) assert df[['name', 'act']].shape == df2.shape assert df[['name', 'act']].columns.tolist() == df2.columns.tolist() assert df[['name', 'act']].dtypes.tolist() == df2.dtypes.tolist()
def test_csv(): df = opd.read_sdf(os.path.join(test_data_dir, 'data/dude/xiap/actives_docked.sdf'), columns=['mol', 'name', 'chembl_id', 'dude_smiles', 'act']) df['act'] = df['act'].astype(float) df['name'] = df['name'].astype(int) with NamedTemporaryFile(suffix='.csv', mode='w+') as f: df.to_csv(f, index=False) f.seek(0) df2 = opd.read_csv(f, smiles_to_molecule='mol', molecule_column='mol') assert_equal(df.shape, df2.shape) assert_equal(df.columns.tolist(), df2.columns.tolist()) assert_equal(df.dtypes.tolist(), df2.dtypes.tolist())
def test_csv(): df = opd.read_sdf(input_fname, columns=['mol', 'name', 'chembl_id', 'dude_smiles', 'act']) df['act'] = df['act'].astype(float) df['name'] = df['name'].astype(int) with NamedTemporaryFile(suffix='.csv', mode='w+') as f: for str_buff in (f, f.name): df.to_csv(str_buff, index=False) f.seek(0) df2 = opd.read_csv(f.name, smiles_to_molecule='mol', molecule_column='mol') assert df.shape == df2.shape assert df.columns.tolist() == df2.columns.tolist() assert df.dtypes.tolist() == df2.dtypes.tolist() with NamedTemporaryFile(suffix='.csv', mode='w+') as f: for str_buff in (f, f.name): df.to_csv(str_buff, index=False, columns=['name', 'act']) f.seek(0) df2 = pd.read_csv(f.name) assert df[['name', 'act']].shape == df2.shape assert df[['name', 'act']].columns.tolist() == df2.columns.tolist() assert df[['name', 'act']].dtypes.tolist() == df2.dtypes.tolist()