comparison COBRAxy/flux_to_map.py @ 243:5aaf15260ca6 draft

Uploaded
author francesco_lapi
date Wed, 15 Jan 2025 10:41:57 +0000
parents c6d78b0d324d
children ccb4ae0e01b3
comparison
equal deleted inserted replaced
242:c6d78b0d324d 243:5aaf15260ca6
867 np.clip(dataset.loc['EX_gln__L_e'].to_numpy(), a_min=None, a_max=0), 867 np.clip(dataset.loc['EX_gln__L_e'].to_numpy(), a_min=None, a_max=0),
868 out=np.full_like(dataset.loc['EX_lac__L_e'].to_numpy(), np.nan), 868 out=np.full_like(dataset.loc['EX_lac__L_e'].to_numpy(), np.nan),
869 where=dataset.loc['EX_gln__L_e'].to_numpy() != 0 869 where=dataset.loc['EX_gln__L_e'].to_numpy() != 0
870 ) 870 )
871 871
872 # Controllo e sostituzione dei NaN con 0 se necessario
873 vectors = {'lact_glc': lact_glc, 'lact_gln': lact_gln, 'lact_o2': lact_o2, 'glu_gln': glu_gln}
874
875 for name, vector in vectors.items():
876 if np.all(np.isnan(vector)): # Controlla se tutti i valori sono NaN
877 vectors[name] = np.zeros_like(vector) # Sostituisci con un vettore di zeri
878
879 # Riassegna i vettori aggiornati
880 lact_glc, lact_gln, lact_o2, glu_gln = vectors['lact_glc'], vectors['lact_gln'], vectors['lact_o2'], vectors['glu_gln']
881
872 # Create a DataFrame for the new rows 882 # Create a DataFrame for the new rows
873 new_rows = pd.DataFrame({ 883 new_rows = pd.DataFrame({
874 dataset.index.name: ['LactGlc', 'LactGln','LactO2', 'GluGln'], 884 dataset.index.name: ['LactGlc', 'LactGln','LactO2', 'GluGln'],
875 **{col: [lact_glc[i], lact_gln[i],lact_o2[i], glu_gln[i]] for i, col in enumerate(dataset.columns)} 885 **{col: [lact_glc[i], lact_gln[i],lact_o2[i], glu_gln[i]] for i, col in enumerate(dataset.columns)}
876 }) 886 })