-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
64 changed files
with
88,103 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from .plugin_setup import plugin | ||
from ._semantics import TSVMolecules | ||
import pandas as pd | ||
|
||
|
||
def _read_dataframe(fh): | ||
# Using `dtype=object` and `set_index` to avoid type casting/inference | ||
# of any columns or the index. | ||
df = pd.read_csv(fh, sep='\t', header=0, dtype='str') | ||
df.set_index(df.columns[0], drop=True, append=False, inplace=True) | ||
df.index.name = 'id' | ||
return df | ||
|
||
# define a transformer from pd.DataFrame to -> TSVMolecules | ||
@plugin.register_transformer | ||
def _1(data: pd.DataFrame) -> TSVMolecules: | ||
ff = TSVMolecules() | ||
with ff.open() as fh: | ||
data.to_csv(fh, sep='\t', header=True) | ||
return ff | ||
|
||
# define a transformer from TSVMolecules -> pd.DataFrame | ||
@plugin.register_transformer | ||
def _2(ff: TSVMolecules) -> pd.DataFrame: | ||
with ff.open() as fh: | ||
df = _read_dataframe(fh) | ||
return df |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.