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

Limit the line length for the command in the top #314

Merged
merged 3 commits into from
Sep 30, 2020

Conversation

jbarnoud
Copy link
Collaborator

Martinize2 writes the command it has been invoked with in
the header of the TOP file it writes. If that command is too
long, then it can pass the maximum line length that grompp
can read.

This commit truncate the command if it passes the limit.

jbarnoud and others added 2 commits September 29, 2020 12:16
Martinize2 writes the command it has been invoked with in
the header of the TOP file it writes. If that command is too
long, then it can pass the maximum line length that grompp
can read.

This commit truncate the command if it passes the limit.
Copy link
Member

@pckroon pckroon left a comment

Choose a reason for hiding this comment

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

...pass the maximum line length that grompp can read.

Are you kidding me? ><

Comment on lines +693 to +696
gromacs_char_limit = 4000 # the limit is actually 4095, but I play safe
command = ' '.join(sys.argv)
if len(command) > gromacs_char_limit:
command = command[:gromacs_char_limit] + ' ...'
Copy link
Member

Choose a reason for hiding this comment

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

Set it to 80, and linebreak properly. Keep printing the complete command, just linewrap it.
Also see: https://docs.python.org/3/library/textwrap.html

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I considered that, but:

  1. it is a fairly rare corner case so it should not affect the general case
  2. the line, once wrapped, will make a header that will be very long and push the relevant information (the topology) far bellow
  3. the line can be easily copy-pasted, which is not the case if it is wrapped because the comment character will pollute the text block; I am fine with if a pathologic line cannot be copied, but I'd rather not affect the legit ones.

Copy link
Member

Choose a reason for hiding this comment

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

Good arguments. Approved.

@jbarnoud
Copy link
Collaborator Author

I individually ignore all the ligands of the PDB for which we do not have a mapping, so it seems that my command line is longer than 4094 characters... Anyway, that odd corner case should not prevent the output file from being read.

@pckroon pckroon merged commit c5f3980 into master Sep 30, 2020
@pckroon pckroon deleted the feature/command-limit branch September 30, 2020 14:03
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.

None yet

2 participants