File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -522,6 +522,36 @@ def format(
522522 f"'data_type' { data_type } is currently not implemented"
523523 )
524524
525+ elif data_type == "drug_descriptor" :
526+ if data .drug_descriptors is None :
527+ raise ValueError (
528+ f"'{ data_type } ' attribute of Dataset cannot be 'None'"
529+ )
530+ shape = kwargs .get ('shape' , 'long' )
531+ legal_shapes = ['long' , 'wide' ]
532+ if shape not in legal_shapes :
533+ raise ValueError (
534+ f"'shape' has to be one of '{ legal_shapes } '"
535+ )
536+ type = kwargs .get ('type' , None )
537+
538+ if type is None :
539+ tmp = data .drug_descriptors
540+ else :
541+ # TODO: potentially allow for list of columns to retain
542+ tmp = data .drug_descriptors [
543+ data .drug_descriptors ['structural_descriptor' ] == type
544+ ]
545+ if shape == 'long' :
546+ ret = tmp
547+ else :
548+ ret = tmp .pivot (
549+ index = 'improve_drug_id' ,
550+ columns = 'structural_descriptor' ,
551+ values = 'descriptor_value'
552+ )
553+
554+
525555 elif data_type == "drugs" :
526556 if data .drugs is None :
527557 raise ValueError (
You can’t perform that action at this time.
0 commit comments