-
Notifications
You must be signed in to change notification settings - Fork 30
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
Conversation
There was a problem hiding this 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( |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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...') |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Added prepare_protein_library, which prepares protein topologies and configurations for all snapshots from topology and configuration information about the final snapshot.