Пример #1
0
def test_monomer_importer(json_importer, independent_importers):
    monomer_importer = importers.MonomerImporter(json_importer)
    ids = monomer_importer.import_data()

    monomer_repo = repo.create_monomer_repository()
    backbone_repo = repo.create_backbone_repository()
    monomer_data = list(monomer_repo.load(ids))
    monomer_docs = json_importer.load(monomer_importer.saver.TYPE.STRING)
    backbone_data = list(backbone_repo.load())
    kekules = [doc['kekule'] for doc in monomer_docs]
    backbones = [mol.to_reduced_dict() for mol in backbone_data]

    assert(len(monomer_data) == 4)
    for mol in monomer_data:
        rdkit_mol = mol.mol
        assert(mol._id != None)
        assert(mol.required == bool(AllChem.CalcNumAromaticRings(rdkit_mol)))
        assert(mol.backbone in backbones)
        assert(mol.sidechain is None)
        assert(mol.connection is None)
        assert(mol.proline == bool(AllChem.CalcNumAliphaticRings(
            rdkit_mol) and rdkit_mol.HasSubstructMatch(PROLINE_N_TERM)))
        assert(mol.imported == True)
        assert(mol.kekule in kekules)
        kekules.remove(mol.kekule)
def test_initialize(initialized_repository):
    assert len(list(repo.create_backbone_repository().load())) == 3
    assert len(list(repo.create_connection_repository().load())) == 2
    assert len(list(repo.create_template_repository().load())) == 3
    assert len(list(repo.create_sidechain_repository().load())) == 3
    assert len(list(repo.create_monomer_repository().load())) == 4
    assert len(list(repo.create_regiosqm_repository().load())) == 3
    assert len(list(repo.create_pka_repository().load())) == 3
Пример #3
0
def test_backbone_repository(backbone_mols, model_sort_key):
    backbone_repo = repo.create_backbone_repository()
    ids = backbone_repo.save(backbone_mols)
    data = list(backbone_repo.load(ids))

    data.sort(key=model_sort_key)

    assert data == backbone_mols
def test_initialize_predictions_only(partial_initialized_repository):
    exporter = RegioSQMExporter()
    exporter.export_regiosqm_smiles_file()

    initializer = CPMGInitializer()
    initializer._initialize_predictions_only()

    assert len(list(repo.create_backbone_repository().load())) == 3
    assert len(list(repo.create_connection_repository().load())) == 2
    assert len(list(repo.create_template_repository().load())) == 3
    assert len(list(repo.create_sidechain_repository().load())) == 3
    assert len(list(repo.create_monomer_repository().load())) == 4
    assert len(list(repo.create_regiosqm_repository().load())) == 3
    assert len(list(repo.create_pka_repository().load())) == 3
Пример #5
0
def test_backbone_importer(json_importer):
    backbone_importer = importers.BackboneImporter(json_importer)
    ids = backbone_importer.import_data()

    backbone_repo = repo.create_backbone_repository()
    data = list(backbone_repo.load(ids))
    docs = json_importer.load(backbone_importer.saver.TYPE.STRING)
    kekules = [doc['kekule'] for doc in docs]

    assert(len(data) == 3)
    for mol in data:
        assert(mol._id != None)
        assert(mol.kekule in kekules)
        kekules.remove(mol.kekule)
def test_initialize_mol_only(partial_initialized_repository):
    assert len(list(repo.create_backbone_repository().load())) == 3
    assert len(list(repo.create_connection_repository().load())) == 2
    assert len(list(repo.create_template_repository().load())) == 3
    assert len(list(repo.create_sidechain_repository().load())) == 3
    assert len(list(repo.create_monomer_repository().load())) == 4
 def __init__(self):
     self.backbone_repo = repo.create_backbone_repository()
     self.sidechain_repo = repo.create_sidechain_repository()
     super().__init__(repo.create_monomer_repository())
 def __init__(self, impl=None):
     self.impl = impl or rxns.create_intermolecular_reactions()
     self.impl = utils.to_list(self.impl)
     self.backbones = list(
         map(lambda x: x.mol,
             repo.create_backbone_repository().load()))
Пример #9
0
def test_backbone_repository_fail():
    backbone_repo = repo.create_backbone_repository()

    _ = backbone_repo.save(['dne'])

    assert len(backbone_repo.failed_instances) == 1
 def __init__(self, loader):
     self.loader = loader
     self.saver = repo.create_backbone_repository()
 def _load_backbones(self):
     for backbone in repo.create_backbone_repository().load():
         self.backbones[backbone.kekule] = backbone