Example #1
0
 def setUp(self):
     super().setUp()
     populate_cutoff()
     populate_atlas(graph_list=AtlasHandler().atlas_graphs)
     self.codes = ['2ebo', '10gs']
     self.cta = UpdateCodes(codes=self.codes, store_files=False)
     self.cta.run_update(mode=_mode)
Example #2
0
 def setUp(self):
     super().setUp()
     populate_cutoff()
     populate_atlas(graph_list=AtlasHandler().atlas_graphs)
     self.code = '2ebo'
     # add pdb code
     UpdateCodes(codes=[self.code], store_files=False).run_update(mode=_mode)
     remove_pdb_code(code=self.code)
Example #3
0
class AtlasHandlerTestCase(unittest.TestCase):
    def setUp(self):
        self.atlas_handler = AtlasHandler(mode=mode)
        self.g1 = complete_graph(8)
        self.g2 = complete_graph(9)
        self.g1_name = 'U1'
        self.g2_name = 'jack_test_graph'

    def clear_unknown_graphs(self):
        with open(unknown_graphs, 'wb') as foo:
            pickle.dump([], foo)

    def tearDown(self):
        self.clear_unknown_graphs()

    def test_atlas_graphs(self):
        self.assertEqual(len(self.atlas_handler.atlas_graphs), 1253)

    def test_cyclic_graphs(self):
        self.assertEqual(len(self.atlas_handler.cyclic_graphs(max_nodes=88)),
                         81)

    def test_path_graphs(self):
        self.assertEqual(len(self.atlas_handler.path_graphs(max_nodes=88)), 81)
Example #4
0
def name_against_unknowns(knob_graphs):
    """ Checks each unnamed graph for isomorphism against list of 'unknown' (large) graphs.

    Parameters
    ----------
    knob_graphs: list(networkx.Graph)

    Returns
    -------
    None
    """
    large_graph_list = AtlasHandler().get_graph_list(atlas=False,
                                                     cyclics=False,
                                                     paths=False,
                                                     unknowns=True)
    for g in knob_graphs:
        if g.graph['name'] is None:
            name = isomorphism_checker(g, graph_list=large_graph_list)
            if name is not None:
                g.graph['name'] = name
    return
Example #5
0
def add_unknowns(knob_graphs, mode):
    """ Name all new unknown graphs, add them to unknown_pickle and to database.

    Parameters
    ----------
    knob_graphs: list(networkx.Graph)
    mode: str
        Allowed values: 'production' or 'testing'.

    Returns
    -------
    None
    """
    large_graph_list = AtlasHandler().get_graph_list(atlas=False,
                                                     cyclics=False,
                                                     paths=False,
                                                     unknowns=True)
    assert not all_graphs_named(knob_graphs=knob_graphs)
    assert all(
        isomorphism_checker(x, graph_list=large_graph_list)
        for x in knob_graphs)
    next_number_to_add = max([int(x.name[1:]) for x in large_graph_list]) + 1
    to_add_to_atlas = []
    for i, g in enumerate(knob_graphs):
        n = isomorphism_checker(g, graph_list=knob_graphs[:i])
        if n is None:
            h = graph_to_plain_graph(g)
            n = 'U{}'.format(next_number_to_add)
            h.name = n
            to_add_to_atlas.append(h)
            next_number_to_add += 1
        g.graph['name'] = n
    large_graph_list += to_add_to_atlas
    unknown_pickle = global_settings["unknown_graphs"][mode]
    with open(unknown_pickle, 'wb') as foo:
        pickle.dump(large_graph_list, foo)
    populate_atlas(graph_list=to_add_to_atlas)
    return
Example #6
0
 def setUp(self):
     super().setUp()
     self.graph_list = AtlasHandler().atlas_graphs
Example #7
0
import networkx
import numpy
from isambard.add_ons.filesystem import FileSystem, preferred_mmol, get_cif, get_mmol
from isambard.add_ons.knobs_into_holes import KnobGroup
from isambard.add_ons.parmed_to_ampal import convert_cif_to_ampal
from isambard.ampal.pdb_parser import convert_pdb_to_ampal

from isocket.graph_theory import graph_to_plain_graph, AtlasHandler, isomorphism_checker
from isocket_settings import global_settings

try:
    data_dir = global_settings['structural_database']['path']
except KeyError:
    data_dir = None
_graph_list = AtlasHandler().get_graph_list(atlas=True,
                                            paths=True,
                                            cyclics=True,
                                            unknowns=False)


class StructureHandler:
    """ Class for parsing pdb/cif files into KIH graphs """
    def __init__(self, assembly):
        self.assembly = assembly
        self.is_preferred = False
        self.code = self.assembly.id
        self.mmol = None

    def __repr__(self):
        return '<StructureHandler(code={0}, mmol={1})>'.format(
            self.code, self.mmol)
Example #8
0
 def setUp(self):
     self.graph_list = AtlasHandler(mode=mode).get_graph_list()
Example #9
0
 def setUp(self):
     self.atlas_handler = AtlasHandler(mode=mode)
     self.g1 = complete_graph(8)
     self.g2 = complete_graph(9)
     self.g1_name = 'U1'
     self.g2_name = 'jack_test_graph'