extractor
db_to_dataframe(session, prefix='CHEBI')
Convert a semsql database to a DataFrame
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
Session
|
|
required |
prefix
|
|
'CHEBI'
|
Returns:
Source code in c3p/extractor.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
eav_to_df(eav_df, value_column='value')
Convert an EAV DataFrame to a wide-format DataFrame.
Example:
>>> test_eav_df = pd.DataFrame({
... 'subject': ['a', 'a', 'b', 'b', 'b', 'c'],
... 'predicate': ['p1', 'p1', 'p1', 'p1', 'p2', 'p3'],
... 'value': ['v1', 'v2', 'v3', 'v4', 'v4', '']
... })
>>> eav_to_df(test_eav_df)
predicate subject p1 p2 p3
0 a [v1, v2] None None
1 b [v3, v4] v4 None
2 c None None
Parameters:
Name | Type | Description | Default |
---|---|---|---|
eav_df
|
DataFrame
|
|
required |
value_column
|
|
'value'
|
Returns:
Source code in c3p/extractor.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
sanitize_smiles(smiles_string)
Sanitizes a SMILES string by: 1. Removing whitespace 2. Removing invalid characters 3. Preserving valid SMILES characters including brackets, numbers, and symbols
Parameters:
Name | Type | Description | Default |
---|---|---|---|
smiles_string
|
str
|
Input SMILES string |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
Sanitized SMILES string |
Source code in c3p/extractor.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
split_instances_for_class(cc, all_smiles, validation_proportion=0.2, max_validation_negative=1000)
Split instances for a chemical class into training and validation sets.
We assume that cc is already loaded with all positive instances as train_positive
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cc
|
ChemicalClass
|
|
required |
validation_proportion
|
|
0.2
|
Returns:
Source code in c3p/extractor.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
|
validate_dataset(dataset)
Validate a dataset
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset
|
Dataset
|
|
required |
Returns:
Source code in c3p/extractor.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
|