-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
importlib-resources
to load data in older Python versions
- Loading branch information
Showing
4 changed files
with
78 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,65 @@ | ||
import unittest | ||
|
||
import numpy | ||
import Bio.PDB | ||
from mini3di import Encoder | ||
|
||
import mini3di | ||
try: | ||
from importlib.resources import files as resource_files | ||
except ImportError: | ||
from importlib_resources import files as resource_files | ||
|
||
|
||
class TestEncoder(unittest.TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
cls.encoder = Encoder() | ||
cls.parser = Bio.PDB.PDBParser(QUIET=True) | ||
|
||
@classmethod | ||
def get_structure(cls, name): | ||
path = resource_files(__package__).joinpath("data", name).with_suffix(".pdb") | ||
return cls.parser.get_structure(name, path) | ||
|
||
def test_encode_3bww(self): | ||
structure = self.get_structure("3bww") | ||
states = self.encoder.encode_chain(structure[0]["A"]) | ||
sequence = self.encoder.build_sequence(states) | ||
self.assertEqual( | ||
sequence, | ||
"DKDFFEAAEDDLVCLVVLLPPPACPQRQAYEDALVVQVPDDPVSVVSVVNSLVHHAYAYEYEAQQL" | ||
"LDDPQGDVVSLVSVLVCCVVSVPQEYEYENDPPDADALDVVSLVSSLVSQLVSCVSSVGAYAYEDA" | ||
"ADQDHDPRHPDDVLVSRQSNCVSNVHAHAYELVRLVRCCVRPVPDDSLVSLVRHPLQRHQHYEYQV" | ||
"VSVVSVLVNLVDHQAHHYYYHDYPDDVVVNSVVRVVSRVSNVVSCVVVVHYIDMD", | ||
) | ||
|
||
def test_encode_8crb(self): | ||
structure = self.get_structure("8crb") | ||
|
||
states = self.encoder.encode_chain(structure[0]["A"]) | ||
sequence = self.encoder.build_sequence(states) | ||
self.assertEqual( | ||
sequence, | ||
"DWAKDKDWADEDAAQAKTKIKMATPPDLLQDFFKFKWFDAPPDDIDGQAPGACPSPPLADDVHHHH" | ||
"GKGWHDDSVRRMIMIMGGNDDQVVFGKMKMFTADDADPQVVVPDGDDTDDMHDIDTYGHPPDDFFA" | ||
"WDKDKDQDDPVPCPVQKPKIKMKTDDGDDDDKDKAWLVNPGDPQKDDFDWDADPVRGIIDMIIGMD" | ||
"GNVCFQVGFTKIWMAGVVVRDIDIDGGHD", | ||
) | ||
|
||
states = self.encoder.encode_chain(structure[0]["B"]) | ||
sequence = self.encoder.build_sequence(states) | ||
self.assertEqual( | ||
sequence, | ||
"DAAKDFDQQEEEAAQAKDKGWIFAADVPPVPDAFWKWWDAPPDDIDTAADPNQAGDPVDHSQKGWD" | ||
"ADHGITIIMGGRDDNSRQGFIWRAQPDDPDHNGHTDDTHGYYHCPDDQDDKDKDWDDAAVVVLVVL" | ||
"FGKTKIKIDDGDDPPKDKFKDLQNHTDDAQWDWDDWDLDPVRTIMTMIIRRDGVVSCVVSQKMKMW" | ||
"IDDDVHTDIDMDGNVVHD", | ||
) | ||
|
||
states = self.encoder.encode_chain(structure[0]["C"]) | ||
sequence = self.encoder.build_sequence(states) | ||
self.assertEqual( | ||
sequence, | ||
"DPCVLVVLVLQLVLVVLLLVVVVVVLVVCVVVLFKDWQDPVHDWQLACVSPDHDCPDCCSVPGSNN" | ||
"VQQCPKPLDDVTATNQSVQQIDDGDLDHDDDDDTIQGCPPPVRCSVVVVVVSVVSVVVSVVSCVVS" | ||
"VVVVVVD", | ||
) |