comparison COBRAxy/marea_cluster.py @ 154:49fb0556242f draft

Uploaded
author bimib
date Thu, 07 Nov 2024 10:09:11 +0000
parents a95ac9ae9648
children 3ad3fb730b87
comparison
equal deleted inserted replaced
153:a95ac9ae9648 154:49fb0556242f
133 if len(dataset.columns) < 2: 133 if len(dataset.columns) < 2:
134 sys.exit('Execution aborted: wrong format of dataset\n') 134 sys.exit('Execution aborted: wrong format of dataset\n')
135 return dataset 135 return dataset
136 136
137 ############################ rewrite_input ################################### 137 ############################ rewrite_input ###################################
138 def rewrite_input(dataset :pd.DataFrame) -> Dict[str, List[Optional[float]]]: 138 def rewrite_input(dataset :Dict) -> Dict[str, List[Optional[float]]]:
139 """ 139 """
140 Rewrite the dataset as a dictionary of lists instead of as a dictionary of dictionaries. 140 Rewrite the dataset as a dictionary of lists instead of as a dictionary of dictionaries.
141 141
142 Args: 142 Args:
143 dataset (pandas.DataFrame): The dataset to be rewritten. 143 dataset (pandas.DataFrame): The dataset to be rewritten.
145 Returns: 145 Returns:
146 dict: The rewritten dataset as a dictionary of lists. 146 dict: The rewritten dataset as a dictionary of lists.
147 """ 147 """
148 #Riscrivo il dataset come dizionario di liste, 148 #Riscrivo il dataset come dizionario di liste,
149 #non come dizionario di dizionari 149 #non come dizionario di dizionari
150 dataset = dataset.iloc[:, 1:]
151 #dataset.pop('Reactions', None) 150 #dataset.pop('Reactions', None)
152 151
153 for key, val in dataset.items(): 152 for key, val in dataset.items():
154 l = [] 153 l = []
155 for i in val: 154 for i in val:
504 os.makedirs(args.output_path) 503 os.makedirs(args.output_path)
505 504
506 #Data read 505 #Data read
507 506
508 X = read_dataset(args.input) 507 X = read_dataset(args.input)
508 X = X.iloc[:, 1:]
509 X = pd.DataFrame.to_dict(X, orient='list') 509 X = pd.DataFrame.to_dict(X, orient='list')
510 X = rewrite_input(X) 510 X = rewrite_input(X)
511 X = pd.DataFrame.from_dict(X, orient = 'index') 511 X = pd.DataFrame.from_dict(X, orient = 'index')
512 512
513 for i in X.columns: 513 for i in X.columns: