Skip to content

Commit

Permalink
fixes #278
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhsmit committed Apr 11, 2022
1 parent ad720df commit bf47636
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 9 additions & 10 deletions pyhdx/fitting_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def __init__(self, hdxm_set, model, losses=None, **metadata):
self.generate_output(hdxm, self.dG[g_column])
for hdxm, g_column in zip(self.hdxm_set, self.dG)
]
df = pd.concat(dfs, keys=self.names, names=["state", "quantity"], axis=1)
df = pd.concat(dfs, keys=self.names, names=["state", "quantity"], axis=1, sort=True)

self.output = df

Expand All @@ -151,7 +151,7 @@ def get_peptide_mse(self):
dfs[hdxm.name] = df

mse_df = pd.concat(
dfs.values(), keys=dfs.keys(), names=["state", "quantity"], axis=1
dfs.values(), keys=dfs.keys(), names=["state", "quantity"], axis=1, sort=True
)

return mse_df
Expand All @@ -174,7 +174,7 @@ def get_residue_mse(self):
residue_mse = pd.Series(residue_mse_values, index=hdxm.coverage.r_number)
residue_mse_list.append(residue_mse)

residue_mse = pd.concat(residue_mse_list, keys=self.hdxm_set.names, axis=1)
residue_mse = pd.concat(residue_mse_list, keys=self.hdxm_set.names, axis=1, sort=True)
columns = pd.MultiIndex.from_tuples(
[(name, "residue_mse") for name in self.hdxm_set.names],
names=["state", "quantity"],
Expand Down Expand Up @@ -374,19 +374,17 @@ def __init__(self, results):
self.results = results

dfs = [result.output for result in self.results]
self.output = pd.concat(dfs, axis=1)
self.output = pd.concat(dfs, axis=1, sort=True)

dfs = [result.losses for result in self.results]
names = ['_'.join(result.hdxm_set.names) for result in self.results]
self.losses = pd.concat(dfs, axis=1, keys=names)
self.losses = pd.concat(dfs, axis=1, keys=names, sort=True)


@property
def metadata(self):
return {'_'.join(result.hdxm_set.names): result.metadata for result in self.results}



def to_file(
self,
file_path,
Expand All @@ -408,13 +406,13 @@ def to_file(

def get_peptide_mse(self):
dfs = [result.get_peptide_mse() for result in self.results]
df = pd.concat(dfs, axis=1)
df = pd.concat(dfs, axis=1, sort=True)

return df

def get_residue_mse(self):
dfs = [result.get_residue_mse() for result in self.results]
df = pd.concat(dfs, axis=1)
df = pd.concat(dfs, axis=1, sort=True)

return df

Expand All @@ -436,9 +434,10 @@ def get_dcalc(self, timepoints=None):

return df

#TODO needs testing and probably the data types are wrong here
def eval(self, timepoints):
dfs = [result(timepoints) for result in self.results]
df = pd.concat(dfs, axis=1)
df = pd.concat(dfs, axis=1) #TODO sort=True?

return df

Expand Down
2 changes: 1 addition & 1 deletion pyhdx/web/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def _add_table(

if table in self.tables:
current = self.tables[table]
new = pd.concat([current, df], axis=1)
new = pd.concat([current, df], axis=1, sort=True)
categories = list(current.columns.unique(level=0)) + list(
df.columns.unique(level=0)
)
Expand Down

0 comments on commit bf47636

Please sign in to comment.