def create_model(target_sequence, target_species_id, require_resnum=None, chosen_template_id=None): target_species_id = target_species_id.upper() sequence_id = model_storage.get_sequence_id(target_sequence) lock_name = "lock_search_%s_%s_%s_%s" % (sequence_id, target_species_id, str(require_resnum), str(chosen_template_id)) if model_storage.model_dir is None: raise InitError("model directory is not set") lock_path = os.path.join(model_storage.model_dir, lock_name) with FileLock(lock_path): model_paths = model_storage.list_models(target_sequence, target_species_id, require_resnum, chosen_template_id) if len(model_paths) > 0: return select_best_model(model_paths, target_sequence, require_resnum) else: ModelLogger.get_current().clear() domain_alignments = \ domain_aligner.get_domain_alignments(target_sequence, require_resnum, chosen_template_id) if len(domain_alignments) <= 0: _log.warn("no domain alignments for target={} resnum={} template={}" .format(target_sequence, require_resnum, chosen_template_id)) return None domain_alignment = select_best_domain_alignment(domain_alignments) return modeler.build_model(target_sequence, target_species_id, domain_alignment, require_resnum)
def create_model(target_sequence, target_species_id, require_resnum=None, chosen_template_id=None): target_species_id = target_species_id.upper() sequence_id = model_storage.get_sequence_id(target_sequence) lock_name = "lock_search_%s_%s_%s_%s" % (sequence_id, target_species_id, str(require_resnum), str(chosen_template_id)) if model_storage.model_dir is None: raise InitError("model directory is not set") lock_path = os.path.join(model_storage.model_dir, lock_name) with FileLock(lock_path): model_paths = model_storage.list_models(target_sequence, target_species_id, require_resnum, chosen_template_id) if len(model_paths) > 0: return select_best_model(model_paths) else: ModelLogger.get_current().clear() domain_alignments = \ domain_aligner.get_domain_alignments(target_sequence, require_resnum, chosen_template_id) if len(domain_alignments) <= 0: _log.warn("no domain alignments for target={} resnum={} template={}" .format(target_sequence, require_resnum, chosen_template_id)) return None domain_alignment = select_best_domain_alignment(domain_alignments) return modeler.build_model(target_sequence, target_species_id, domain_alignment, require_resnum)
def test_align_with_repeats(): sequence = """MRRGRLLEIALGFTVLLASYTSHGADANLEAGNVKETRASRAKRRGGGGHD ALKGPNVCGSRYNAYCCPGWKTLPGGNQCIVPICRHSCGDGFCSRPNMCTCPSGQIAPSCG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 DECLDNREGYCFTEVLQNMCQIGSSNRNPVTKSECCCDGGRGWGPHCEICPFQGTVAFKKLCPHGRGFM TNGADIDECKVIHDVCRNGECVNDRGSYHCICKTGYTPDITGTSCVDLNECNQAPKPCNFICKNTEGSY QCSCPKGYILQEDGRSCKDLDECATKQHNCQFLCVNTIGGFTCKCPPGFTQHHTSCIDNNECTSDINLC GSKGICQNTPGSFTCECQRGFSLDQTGSSCEDVDECEGNHRCQHGCQNIIGGYRCSCPQGYLQHYQWNQ CVDENECLSAHICGGASCHNTLGSYKCMCPAGFQYEQFSGGCQDINECGSAQAPCSYGCSNTEGGYLCG CPPGYFRIGQGHCVSGMGMGRGNPEPPVSGEMDDNSLSPEACYECKINGYPKRGRKRRSTNETDASNIE DQSETEANVSLASWDVEKTAIFAFNISHVSNKVRILELLPALTTLTNHNRYLIESGNEDGFFKINQKEG ISYLHFTKKKPVAGTYSLQISSTPLYKKKELNQLEDKYDKDYLSGELGDNLKMKIQVLLH """.replace('\n','') template_id = TemplateID('2w86', 'A') residue_number = 545 domain_alignments = domain_aligner.get_domain_alignments(sequence, residue_number, template_id) domain_alignment = select_best_domain_alignment(domain_alignments) context = modeler._prepare_context(template_id.pdbid) context.set_main_target(sequence, 'HUMAN', template_id.chain_id) alignments = modeler._make_alignments(sequence, 'HUMAN', domain_alignment, context, residue_number) alignment = alignments[template_id.chain_id] ok_(alignment.is_target_residue_covered(residue_number))
def test_align_filamin(): sequence = """ MSSSHSRAGQSAAGAAPGGGVDTRDAEMPATEKDLAEDAPWKKIQQNTFTRWCNEHLKCVSKRIANLQTDLS DGLRLIALLEVLSQKKMHRKHNQRPTFRQMQLENVSVALEFLDRESIKLVSIDSKAIVDGNLKLILGLIWTL ILHYSISMPMWDEEEDEEAKKQTPKQRLLGWIQNKLPQLPITNFSRDWQSGRALGALVDSCAPGLCPDWDSW DASKPVTNAREAMQQADDWLGIPQVITPEEIVDPNVDEHSVMTYLSQFPKAKLKPGAPLRPKLNPKKARAYG PGIEPT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GAGLEGGVTGNPA EFVVNTSNAGAGALSVTIDGPSKVKMDCQECPEGYRVTYTPMAPGSYLISIKYGGPYHIGGSPFKAKVTGPR LVSNHSLHETSSVFVDSLTKATCAPQHGAPGPGPADASKVVAKGLGLSKAYVGQKSSFTVDCSKAGNNMLLV GVHGPRTPCEEILVKHVGSRLYSVSYLLKDKGEYTLVVKWGDEHIPGSPYRVVVP """.replace('\n','') template_id = TemplateID('4M9P', 'A') residue_number = 429 domain_alignments = domain_aligner.get_domain_alignments(sequence, residue_number, template_id) ok_(len(domain_alignments) > 0) domain_alignment = select_best_domain_alignment(domain_alignments) context = modeler._prepare_context(template_id.pdbid) context.set_main_target(sequence, 'HUMAN', template_id.chain_id) alignments = modeler._make_alignments(sequence, 'HUMAN', domain_alignment, context, residue_number) alignment = alignments[template_id.chain_id] _log.debug("alignment is {}".format(alignment)) ok_(alignment.is_target_residue_covered(residue_number))
def test_align_rab3d(): sequence = "MDEDVLTTLKILIIGESGVGKSSLLLRFTDDTFDPELAATIGVDFKVKTISVDGN" + \ "KAKLAIWVTLHQQTANFFLKSQIGNSPILKWAMWQYDTAGQERFRTLTPSYYRGAQGVILVYDVTRRDTF" + \ "VKLDNWLNELETYCTRNDIVNMLVGNKIDKENREVDRNEGLKFARKHSMLFIEASAKTCDGVQCAFEELV" + \ "EKIIQTPGLWESENQNKGVKLSHREEGQGGGACGGYCSVL" template_id = TemplateID('2GF9', 'A') residue_number = 70 domain_alignments = domain_aligner.get_domain_alignments(sequence, residue_number, template_id) if len(domain_alignments) > 0: domain_alignment = select_best_domain_alignment(domain_alignments) context = modeler._prepare_context(template_id.pdbid) context.set_main_target(sequence, 'HUMAN', template_id.chain_id) alignments = modeler._make_alignments(sequence, 'HUMAN', domain_alignment, context, residue_number) alignment = alignments[template_id.chain_id] ok_(alignment.is_target_residue_covered(residue_number))