Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added functionality to spatiotemporal #1096

Merged
merged 5 commits into from
Jun 25, 2024
Merged

Conversation

alatham13
Copy link
Contributor

Added prepare_protein_library, which prepares protein topologies and configurations for all snapshots from topology and configuration information about the final snapshot.

Copy link
Member

@benmwebb benmwebb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I added a few minor suggestions but it looks to me like it should work as-is. You just need to address the issues that flake8 noted to pass the standards checks, and then we can merge.

if os.path.exists(exp_comp_map[prot]):
exp = pd.read_csv(exp_comp_map[prot])
else:
raise Exception(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I wouldn't bother with this check (since Python will raise an exception anyway if the file does not exist, or is unreadable) but if you want to, I would recommend catching the original exception rather than using os.path.exists (as this avoids race conditions). Certainly use a more specific exception like IOError or FileNotFoundError instead of Exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if not isinstance(match_final_state, bool):
raise TypeError("match_final_state should be of type bool")
# make output_dir if necessary
if len(output_dir) > 0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified to simply if output_dir:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because if len(output_dir) == 0, uses cwd

os.chdir(output_dir)
else:
os.mkdir(output_dir)
os.chdir(output_dir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little inelegant since you chdir in both branches. Would be cleaner if the chdir were outside the if.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if prot in template_dict.keys():
keep_prots.extend(template_dict[prot])
else:
raise Exception("Protein " + prot + ' does not exist in template_dict\nClosing...')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KeyError would be more appropriate here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@alatham13 alatham13 merged commit f0e76b4 into salilab:develop Jun 25, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants