# Path: conkit/io/pdb.py
# class PdbParser(GenericStructureParser):
#     """
#     Class to parse a PDB file and extract distance restraints
#     as residue-residue contacts
#     """
# 
#     def __init__(self):
#         super(PdbParser, self).__init__()
# 
#     def read(self, f_handle, f_id="pdb", distance_cutoff=8, atom_type="CB"):
#         """Read a contact file
# 
#         Parameters
#         ----------
#         f_handle
#            Open file handle [read permissions]
#         f_id : str, optional
#            Unique contact file identifier
#         distance_cutoff : int, optional
#            Distance cutoff for which to determine contacts [default: 8]
#         atom_type : str, optional
#            Atom type between which distances are calculated [default: CB]
# 
#         Returns
#         -------
#         :obj:`~conkit.core.contactfile.ContactFile`
# 
#         """
#         structure = PDBParser(QUIET=True).get_structure("pdb", f_handle)
#         return self._read(structure, f_id, distance_cutoff, atom_type)
# 
#     def write(self, f_handle, hierarchy):
#         """Write a contact file instance to to file
# 
#         Parameters
#         ----------
#         f_handle
#            Open file handle [write permissions]
#         hierarchy : :obj:`~conkit.core.contactfile.ContactFile`, :obj:`~conkit.core.contactmap.ContactMap`
#                     or :obj:`~conkit.core.contact.Contact`
# 
#         Raises
#         ------
#         :exc:`NotImplementedError`
#            Write function not available
# 
#         """
#         self._write(f_handle, hierarchy)


import os
import unittest
from conkit.io.pdb import PdbParser
from conkit.io.tests.helpers import ParserTestCase
            contact_file = PdbParser().read(f_in, distance_cutoff=7, atom_type="CB")
        contact_map1 = contact_file.top_map
        self.assertEqual(1, len(contact_file))
        self.assertEqual(6, len(contact_map1))
        self.assertEqual([36], [c.res1_seq for c in contact_map1 if c.true_positive])
        self.assertEqual([86], [c.res2_seq for c in contact_map1 if c.true_positive])
        self.assertEqual([0.934108], [c.raw_score for c in contact_map1 if c.true_positive])

    def test_read_4(self):
        content = """ATOM      1  N   TYR A  36      39.107  51.628   3.103  0.50 43.13           N
ATOM      2  CA  TYR A  36      38.300  50.814   2.204  0.50 41.80           C
ATOM      3  O   TYR A  36      38.712  48.587   1.405  0.50 41.03           O
ATOM      4  CB  TYR A  36      37.586  51.694   1.175  0.50 41.61           C
ATOM      5  N   PHE A  86      32.465  47.498   5.487  0.50 25.81           N
ATOM      6  CA  PHE A  86      32.670  48.303   4.288  0.50 26.45           C
ATOM      7  O   PHE A  86      31.469  50.326   3.758  0.50 28.47           O
ATOM      8  CB  PHE A  86      32.977  47.392   3.090  0.50 25.35           C
TER
ATOM      9  N   TRP B 171      23.397  37.507  -1.161  0.50 18.04           N
ATOM     10  CA  TRP B 171      23.458  36.846   0.143  0.50 20.46           C
ATOM     11  O   TRP B 171      22.235  34.954   0.951  0.50 22.45           O
ATOM     12  CB  TRP B 171      23.647  37.866   1.275  0.50 18.83           C
ATOM     13  N   PHE B 208      32.221  42.624  -5.829  0.50 19.96           N
ATOM     14  CA  PHE B 208      31.905  43.710  -4.909  0.50 20.31           C
ATOM     15  O   PHE B 208      32.852  45.936  -5.051  0.50 17.69           O
ATOM     16  CB  PHE B 208      31.726  43.102  -3.518  0.50 19.90           C
END
"""
        f_name = self.tempfile(content=content)
        with open(f_name, "r") as f_in:

# Path: conkit/io/pdb.py
# class PdbParser(GenericStructureParser):
#     """
#     Class to parse a PDB file and extract distance restraints
#     as residue-residue contacts
#     """
# 
#     def __init__(self):
#         super(PdbParser, self).__init__()
# 
#     def read(self, f_handle, f_id="pdb", distance_cutoff=8, atom_type="CB"):
#         """Read a contact file
# 
#         Parameters
#         ----------
#         f_handle
#            Open file handle [read permissions]
#         f_id : str, optional
#            Unique contact file identifier
#         distance_cutoff : int, optional
#            Distance cutoff for which to determine contacts [default: 8]
#         atom_type : str, optional
#            Atom type between which distances are calculated [default: CB]
# 
#         Returns
#         -------
#         :obj:`~conkit.core.contactfile.ContactFile`
# 
#         """
#         structure = PDBParser(QUIET=True).get_structure("pdb", f_handle)
#         return self._read(structure, f_id, distance_cutoff, atom_type)
# 
#     def write(self, f_handle, hierarchy):
#         """Write a contact file instance to to file
# 
#         Parameters
#         ----------
#         f_handle
#            Open file handle [write permissions]
#         hierarchy : :obj:`~conkit.core.contactfile.ContactFile`, :obj:`~conkit.core.contactmap.ContactMap`
#                     or :obj:`~conkit.core.contact.Contact`
# 
#         Raises
#         ------
#         :exc:`NotImplementedError`
#            Write function not available
# 
#         """
#         self._write(f_handle, hierarchy)


# Path: conkit/io/tests/test_pdb.py
import os
import unittest
from conkit.io.pdb import PdbParser
from conkit.io.tests.helpers import ParserTestCase

            contact_file = PdbParser().read(f_in, distance_cutoff=7, atom_type="CB")
        contact_map1 = contact_file.top_map
        self.assertEqual(1, len(contact_file))
        self.assertEqual(6, len(contact_map1))
        self.assertEqual([36], [c.res1_seq for c in contact_map1 if c.true_positive])
        self.assertEqual([86], [c.res2_seq for c in contact_map1 if c.true_positive])
        self.assertEqual([0.934108], [c.raw_score for c in contact_map1 if c.true_positive])

    def test_read_4(self):
        content = """ATOM      1  N   TYR A  36      39.107  51.628   3.103  0.50 43.13           N
ATOM      2  CA  TYR A  36      38.300  50.814   2.204  0.50 41.80           C
ATOM      3  O   TYR A  36      38.712  48.587   1.405  0.50 41.03           O
ATOM      4  CB  TYR A  36      37.586  51.694   1.175  0.50 41.61           C
ATOM      5  N   PHE A  86      32.465  47.498   5.487  0.50 25.81           N
ATOM      6  CA  PHE A  86      32.670  48.303   4.288  0.50 26.45           C
ATOM      7  O   PHE A  86      31.469  50.326   3.758  0.50 28.47           O
ATOM      8  CB  PHE A  86      32.977  47.392   3.090  0.50 25.35           C
TER
ATOM      9  N   TRP B 171      23.397  37.507  -1.161  0.50 18.04           N
ATOM     10  CA  TRP B 171      23.458  36.846   0.143  0.50 20.46           C
ATOM     11  O   TRP B 171      22.235  34.954   0.951  0.50 22.45           O
ATOM     12  CB  TRP B 171      23.647  37.866   1.275  0.50 18.83           C
ATOM     13  N   PHE B 208      32.221  42.624  -5.829  0.50 19.96           N
ATOM     14  CA  PHE B 208      31.905  43.710  -4.909  0.50 20.31           C
ATOM     15  O   PHE B 208      32.852  45.936  -5.051  0.50 17.69           O
ATOM     16  CB  PHE B 208      31.726  43.102  -3.518  0.50 19.90           C
END
"""
        f_name = self.tempfile(content=content)
        with open(f_name, "r") as f_in:

            contact_file = PdbParser().read(f_in, distance_cutoff=8, atom_type="CB")