Skip to content

Add Protparam #168

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

Merged
merged 1 commit into from
Jul 9, 2025
Merged

Add Protparam #168

merged 1 commit into from
Jul 9, 2025

Conversation

e-osipov
Copy link

@e-osipov e-osipov commented Jul 7, 2025

Created protparam script to calculate common properties for a model.

Depends on Biopython. Since it might be missing from standard PyMOL installation, the script installs it if import fails.

@e-osipov
Copy link
Author

e-osipov commented Jul 8, 2025

Hi @speleo3 , I have updated the code according to the proposed changes. I also removed a test because it was failing😁

@speleo3
Copy link
Contributor

speleo3 commented Jul 8, 2025

I also removed a test because it was failing

How about a test that works?

def test_protparam(capsys):
    cmd.reinitialize()
    cmd.fab("A// ACD B// EFG", "m1")
    cmd.fab("HIKL", "m2")
    cmd.alter("resn CYS", "resn='UNK'")
    protparam()
    captured = capsys.readouterr()
    assert "Protein name: m1" in captured.out
    assert "Protein name: m2" in captured.out
    assert "Sequence: ADEFG\n" in captured.out
    assert "Sequence: HIKL\n" in captured.out
    assert "Protein length: 2 aa" not in captured.out
    assert "Protein length: 3 aa" not in captured.out
    assert "Protein length: 4 aa" in captured.out
    assert "Protein length: 5 aa" in captured.out
    assert "Count of aminoacids: {'A': 1," in captured.out
    protparam(bychain=1)
    captured = capsys.readouterr()
    assert "Protein name: m1" in captured.out
    assert "Protein name: m2" in captured.out
    assert "Sequence: AD\n" in captured.out
    assert "Sequence: EFG\n" in captured.out
    assert "Protein length: 2 aa" in captured.out
    assert "Protein length: 3 aa" in captured.out
    assert "Protein length: 4 aa" in captured.out
    assert "Protein length: 5 aa" not in captured.out
    assert "Molecular Weight: 204.2 Da" in captured.out
    protparam("resn LYS")
    captured = capsys.readouterr()
    assert "Protein name: m1" not in captured.out
    assert "Protein name: m2" in captured.out
    assert "Protein length: 1 aa" in captured.out
    assert "Isoelectric point: 8.75" in captured.out

@e-osipov
Copy link
Author

e-osipov commented Jul 9, 2025

Thanks! I've updated the code with this test. I added extra test for "empty" output. I am not very familiar with pytests so it might fail. In that case, I will try to fix and push it again.

Update: since ci.yml doesn't install biopython, tests fail with an error:

NameError: name 'SeqIO' is not defined

I could "fix" it by adding biopython to ci.yml but perhaps there is better way to handle this error?

@speleo3
Copy link
Contributor

speleo3 commented Jul 9, 2025

I could "fix" it by adding biopython to ci.yml but perhaps there is better way to handle this error?

That's the correct solution, please add biopython to ci.yml, thanks.

…tent

Correcting for PR comments 1

Correcting for PR comments 2. Added test and biopython import for github actions
Copy link
Contributor

@speleo3 speleo3 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 now, thank you

@speleo3 speleo3 merged commit 1269bf0 into Pymol-Scripts:master Jul 9, 2025
1 check 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