mirror of
https://github.com/biopython/biopython.git
synced 2025-10-20 13:43:47 +08:00
Move self-tests for Bio.PDB.PSEA to unit tests (#3980)
Authored-by: Valentin Vareskic <valentin.vareskic@gmail.com>
This commit is contained in:
committed by
GitHub
parent
257143be91
commit
a8d2647a88
1
.gitignore
vendored
1
.gitignore
vendored
@ -125,3 +125,4 @@ Doc/api/*.rst
|
||||
|
||||
#Ignore virtual environment file
|
||||
.env
|
||||
venv/
|
||||
|
@ -103,16 +103,3 @@ class PSEA:
|
||||
def get_seq(self):
|
||||
"""Return secondary structure string."""
|
||||
return self.ss_seq
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
import sys
|
||||
from Bio.PDB import PDBParser
|
||||
|
||||
# Parse PDB file
|
||||
p = PDBParser()
|
||||
s = p.get_structure("X", sys.argv[1])
|
||||
|
||||
# Annotate structure with PSEA secondary structure info
|
||||
PSEA(s[0], sys.argv[1])
|
||||
|
126
Tests/test_PDB_PSEA.py
Normal file
126
Tests/test_PDB_PSEA.py
Normal file
@ -0,0 +1,126 @@
|
||||
# Copyright 2022 by Valentin Vareskic (valentin.vareskic@gmail.com).
|
||||
# All rights reserved. This code is part of the Biopython distribution
|
||||
# and governed by its license. Please see the LICENSE file that should
|
||||
# have been included as part of this package.
|
||||
|
||||
"""Tests for PDB PSEA."""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
from subprocess import getoutput
|
||||
|
||||
from Bio import MissingExternalDependencyError
|
||||
from Bio.PDB import PDBParser
|
||||
from Bio.PDB.PSEA import run_psea, psea, psea2HEC, PSEA
|
||||
|
||||
|
||||
os.environ["LANG"] = "C"
|
||||
|
||||
|
||||
cmd_output = getoutput("psea -h")
|
||||
if not cmd_output.startswith("o---"):
|
||||
raise MissingExternalDependencyError(
|
||||
"Download and install psea from "
|
||||
"ftp://ftp.lmcp.jussieu.fr/pub/sincris/software/protein/p-sea/. "
|
||||
"Make sure that psea is on path"
|
||||
)
|
||||
|
||||
|
||||
def remove_sea_files():
|
||||
for file in os.listdir():
|
||||
if file.endswith(".sea"):
|
||||
os.remove(file)
|
||||
|
||||
|
||||
class TestPDBPSEA(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
remove_sea_files()
|
||||
|
||||
def test_run_psea(self):
|
||||
psae_run = run_psea("PDB/1A8O.pdb")
|
||||
self.assertEqual(psae_run, "1A8O.sea")
|
||||
|
||||
def test_psea(self):
|
||||
psae_run = psea("PDB/2BEG.pdb")
|
||||
self.assertEqual(psae_run, "ccccbbbbbbbccccbbbbbbbbbbc")
|
||||
|
||||
def test_psea_2HEC(self):
|
||||
seq = psea("PDB/2BEG.pdb")
|
||||
psae_run = psea2HEC(seq)
|
||||
self.assertEqual(
|
||||
psae_run,
|
||||
[
|
||||
"C",
|
||||
"C",
|
||||
"C",
|
||||
"C",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"C",
|
||||
"C",
|
||||
"C",
|
||||
"C",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"C",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
class TestPSEA(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
remove_sea_files()
|
||||
|
||||
def test_get_seq(self):
|
||||
p = PDBParser()
|
||||
s = p.get_structure("X", "PDB/2BEG.pdb")
|
||||
psea_class = PSEA(s[0], "PDB/2BEG.pdb")
|
||||
self.assertEqual(
|
||||
psea_class.get_seq(),
|
||||
[
|
||||
"C",
|
||||
"C",
|
||||
"C",
|
||||
"C",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"C",
|
||||
"C",
|
||||
"C",
|
||||
"C",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"E",
|
||||
"C",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
runner = unittest.TextTestRunner(verbosity=2)
|
||||
unittest.main(testRunner=runner)
|
Reference in New Issue
Block a user