-
Notifications
You must be signed in to change notification settings - Fork 38
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
Drop class name analogies favoring technical names #21
Conversation
haddock/defaults.py
Outdated
"trans_vector_48": data_path / "toppar/initial_positions/trans_vector_48", | ||
"trans_vector_49": data_path / "toppar/initial_positions/trans_vector_49", | ||
"trans_vector_50": data_path / "toppar/initial_positions/trans_vector_50" | ||
"trans_vector_0": (data_path / |
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.
This is a classic example where I would not personally follow strict 80-lenght line except if committing a major number of lines is intended in order to inflate statistics.
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.
agreed. it actually reads better with single lines despite going over 80 chars which I like so much. Nonetheless what about:
- use
Path
and not/
. - Don't overload operators 😉
TRANSLATION_VECTORS = {
f"trans_vector_{i}": Path(data_path, 'toppar', 'initial_positions', f'trans_vector_{i}')
for i in range(51)
}
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.
ooh this is great @joaomcteixeira, thanks!
@@ -27,34 +27,43 @@ def run(self, module_information): | |||
self.patch_defaults(module_information) | |||
|
|||
# Get the models generated in previous step | |||
models_to_score = [p for p in self.previous_io.output if p.file_type == Format.PDB] |
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.
List comprehension is faster and IMHO more readable 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.
I agree. please keep the list comprehension.
|
||
# Check if multiple models are provided | ||
if len(models_to_score) > 1: | ||
self.finish_with_error("Only one model allowed in LightDock sampling module") | ||
self.finish_with_error("Only one model allowed in LightDock" |
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.
Same non-sense 80-length limitation. Luckily, not using old screens anymore.
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.
in these cases if you really don't wanna go over 80 I advise writing:
_msg = "blablabla"
self.finish_with_error(_msg)
or
self.finish_with_error(
"blablablabla 1"
"blablabbla 2"
)
expected = [] | ||
not_found = [] | ||
for model in models: | ||
model_name = model.stem | ||
if not (processed_pdb := self.path / f"{model_name}_haddock.{Format.PDB}").is_file(): |
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.
Why this? Using modern Python and walrus operator is not a crime...
@@ -29,7 +30,9 @@ def __init__(self, file_name, file_type, path='.'): | |||
self.path = str(Path(path).parent.absolute()) | |||
|
|||
def __repr__(self): | |||
return f"[{self.file_type}|{self.created}] {Path(self.path) / self.file_name}" | |||
rep = (f"[{self.file_type}|{self.created}] " |
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.
Less efficient and unnecessary.
step.execute() | ||
|
||
|
||
class Recipe: |
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.
If not using metaphors anymore, maybe there is a better name for this class too?
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.
Boring review too. I am not a fan of strict linting, specially of line-length rules, but your call. List comprehensions and walrus operator are more pythonic options though.
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.
Just made general comments. Nothing critical. Somethings I personally dislike, but they are not mistakes either.
haddock/defaults.py
Outdated
"trans_vector_48": data_path / "toppar/initial_positions/trans_vector_48", | ||
"trans_vector_49": data_path / "toppar/initial_positions/trans_vector_49", | ||
"trans_vector_50": data_path / "toppar/initial_positions/trans_vector_50" | ||
"trans_vector_0": (data_path / |
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.
agreed. it actually reads better with single lines despite going over 80 chars which I like so much. Nonetheless what about:
- use
Path
and not/
. - Don't overload operators 😉
TRANSLATION_VECTORS = {
f"trans_vector_{i}": Path(data_path, 'toppar', 'initial_positions', f'trans_vector_{i}')
for i in range(51)
}
@@ -27,34 +27,43 @@ def run(self, module_information): | |||
self.patch_defaults(module_information) | |||
|
|||
# Get the models generated in previous step | |||
models_to_score = [p for p in self.previous_io.output if p.file_type == Format.PDB] |
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.
I agree. please keep the list comprehension.
|
||
# Check if multiple models are provided | ||
if len(models_to_score) > 1: | ||
self.finish_with_error("Only one model allowed in LightDock sampling module") | ||
self.finish_with_error("Only one model allowed in LightDock" |
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.
in these cases if you really don't wanna go over 80 I advise writing:
_msg = "blablabla"
self.finish_with_error(_msg)
or
self.finish_with_error(
"blablablabla 1"
"blablabbla 2"
)
|
||
model = models_to_score[0] | ||
# Check if chain IDs are present | ||
segids, chains = PDBFactory.identify_chainseg(Path(model.path) / model.file_name) | ||
segids, chains = PDBFactory.identify_chainseg(Path(model.path) / |
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.
humble suggestion since you are refactoring enforcing 80 chars
_path = Path(model.path, model.file_name)
PDBFactory.indentify_chainseg(_path)
same everywhere. in my opinion. mixing operator overload with line breaks is difficult to read
haddock/modules/scoring/default.py
Outdated
@@ -51,11 +56,21 @@ def run(self, module_information): | |||
jobs = [] | |||
|
|||
# Get the models generated in previous step | |||
models_to_score = [p for p in self.previous_io.output if p.file_type == Format.PDB] | |||
models_to_score = [] |
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.
same as before.
if you want to be purist, these logic should be some kind of method of function. but for now just keep the list comprehension
raise HaddockError from re | ||
|
||
|
||
class Step: |
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.
Needs documentation
However, despite we change the class names to more technical ones we should keep the nice HADDOCK-related interface for the users. Phrases of sailors are nice ⛵ |
Some names `flavour` remained after haddocking#21. This broke any runs where flavour was not the "default", for example in lightdock.
Update installation instructions after #21
This is a boring PR to make the code more accessible.
I do believe analogy is a great technique to match unrelated objects in order facilitate understanding and it is seen in many large projects out there in the wild. However me and @joaomcteixeira are getting lost in the ones that were present here since they were often actually quite metaphoric.
Additionally, since we aim the project to have a wide reach, we need to also consider code accessibility and making it more boring can increase its readability. There will still be plenty of room for creative expression later on :)
With this PR I also linted to code to comply with E501.
In this branch there are no tests yet, so I tested it by running the examples and checking if things were working.