Commit 71a010bb by peastman

Merge pull request #84 from jchodera/test-data

Reorganize tests; simplify doctests.
parents 23ebf586 c96b2440
...@@ -45,6 +45,8 @@ import os ...@@ -45,6 +45,8 @@ import os
import os.path import os.path
import math import math
from pkg_resources import resource_filename
# Imports for urlopen # Imports for urlopen
if sys.version_info >= (3,0): if sys.version_info >= (3,0):
from urllib.request import urlopen from urllib.request import urlopen
...@@ -156,29 +158,23 @@ class PDBFixer(object): ...@@ -156,29 +158,23 @@ class PDBFixer(object):
Examples Examples
-------- --------
Start from a file object.
>>> pdbid = '1VII'
>>> url = 'http://www.rcsb.org/pdb/files/%s.pdb' % pdbid
>>> file = urlopen(url)
>>> fixer = PDBFixer(pdbfile=file)
Start from a filename. Start from a filename.
>>> filename = 'test.pdb' >>> filename = resource_filename('pdbfixer', 'tests/data/test.pdb')
>>> file = urlopen(url)
>>> outfile = open(filename, 'w')
>>> outfile.write(file.read())
>>> outfile.close()
>>> fixer = PDBFixer(filename=filename) >>> fixer = PDBFixer(filename=filename)
Start from a file object.
>>> with open(filename) as f:
... fixer = PDBFixer(pdbfile=f)
Start from a URL. Start from a URL.
>>> fixer = PDBFixer(url=url) >>> fixer = PDBFixer(url='http://www.rcsb.org/pdb/files/1VII.pdb')
Start from a PDB code. Start from a PDB code.
>>> fixer = PDBFixer(pdbid=pdbid) >>> fixer = PDBFixer(pdbid='1VII')
""" """
......
from nose.tools import ok_, eq_, raises, assert_items_equal from nose.tools import ok_, eq_, raises, assert_list_equal
import simtk.openmm.app as app import simtk.openmm.app as app
import pdbfixer import pdbfixer
import tempfile import tempfile
...@@ -10,7 +10,7 @@ def remove_chain_ids_and_verify(pdbid, chain_ids_to_remove, expected_chain_ids_r ...@@ -10,7 +10,7 @@ def remove_chain_ids_and_verify(pdbid, chain_ids_to_remove, expected_chain_ids_r
fixer.removeChains(chainIds=chain_ids_to_remove) fixer.removeChains(chainIds=chain_ids_to_remove)
# Check to make sure asserted chains remain. # Check to make sure asserted chains remain.
chain_ids_remaining = [c.id for c in fixer.topology.chains()] chain_ids_remaining = [c.id for c in fixer.topology.chains()]
assert_items_equal(chain_ids_remaining, expected_chain_ids_remaining) assert_list_equal(chain_ids_remaining, expected_chain_ids_remaining)
def test_removechain_ids(): def test_removechain_ids():
remove_chain_ids_and_verify('4JSV', [], ['B', 'D', 'A', 'C', 'B', 'A']) remove_chain_ids_and_verify('4JSV', [], ['B', 'D', 'A', 'C', 'B', 'A'])
...@@ -26,7 +26,7 @@ def remove_chain_indices_and_verify(pdbid, chain_indices_to_remove, expected_cha ...@@ -26,7 +26,7 @@ def remove_chain_indices_and_verify(pdbid, chain_indices_to_remove, expected_cha
fixer.removeChains(chainIndices=chain_indices_to_remove) fixer.removeChains(chainIndices=chain_indices_to_remove)
# Check to make sure asserted chains remain. # Check to make sure asserted chains remain.
chain_ids_remaining = [c.id for c in fixer.topology.chains()] chain_ids_remaining = [c.id for c in fixer.topology.chains()]
assert_items_equal(chain_ids_remaining, expected_chain_ids_remaining) assert_list_equal(chain_ids_remaining, expected_chain_ids_remaining)
def test_removechain_indices(): def test_removechain_indices():
remove_chain_indices_and_verify('4JSV', [], ['B', 'D', 'A', 'C', 'B', 'A']) remove_chain_indices_and_verify('4JSV', [], ['B', 'D', 'A', 'C', 'B', 'A'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment