Skip to content
Snippets Groups Projects
Commit 165df59d authored by Bienchen's avatar Bienchen
Browse files

Removed obsoletet ligand test

parent 87175141
No related branches found
No related tags found
No related merge requests found
'''
SWISS-MODEL 2.0
doc at: "firefox file:///import/bc2/home/schwede/gallo/swissmodel/doc/build/html/index.html"
use: ./TESTS --verbose meld
'''
import os, sys, math
import shutil
from ost import *
from sm.core.test import *
from sm.core import *
from sm.meld import *
from sm import smtl, config, tplsearch
from sm.pipeline import project
from sm.pipeline.model import HomologyModel
from sm.pipeline.addligands import *
class TestAddLigands(unittest.TestCase):
def setUp(self):
if os.path.exists('data/ligands/SMTL'):
shutil.rmtree('data/ligands/SMTL')
if os.path.exists('data/ligands/test.sm'):
shutil.rmtree('data/ligands/test.sm')
def tearDown(self):
# using the same path for each test SMTL, we have to clear the cache
smtl.SMTL.LOADED_SMTLS = {}
if os.path.exists('data/ligands/SMTL'):
shutil.rmtree('data/ligands/SMTL')
if os.path.exists('data/ligands/test.sm'):
shutil.rmtree('data/ligands/test.sm')
def fastIsLigandInContact(self):
in_contact = []
bound = IsLigandInContact(in_contact)
self.assertEqual(bound, False)
in_contact = ['_.12','-.2']
bound = IsLigandInContact(in_contact)
self.assertEqual(bound, False)
in_contact = ['_.12', 'T.1']
bound = IsLigandInContact(in_contact)
self.assertEqual(bound, False)
in_contact = ['_.12', 'T.1','S.2']
bound = IsLigandInContact(in_contact)
self.assertEqual(bound, True)
def fastIsLigandBound(self):
target_seq = io.LoadSequence('data/ligands/3G04C.fasta')
seq1 = io.LoadSequence('data/ligands/3G04C.fasta')
templates = tplsearch.TemplateList()
tem = tplsearch.Template.Create('3G04',1,'A',seq.CreateAlignment(target_seq, seq1))
templates.append(tem)
lib = smtl.SMTL.Create('data/ligands/SMTL')
lib.Update(add=('3G04', ), mmcif_dir='data/ligands/', calc_profiles=False)
prj = project.Project.Create('test', target_seq, lib, output_dir='./data/ligands',
pdb_storage='external', split=False)
prj.ImportTemplates(templates, lib, pdb_storage='default', tolerant=False, found_by=None)
model = io.LoadPDB('data/ligands/3G04_model_no_lig.pdb')
bio_unit = prj.smtl.Get(tem.pdb_id,tem.assembly_id)
lig = bio_unit.ligands[0].chains[0]
is_bound = IsLigandBound(lig, model)
self.assertEqual(is_bound,False)
lig = bio_unit.ligands[0].chains[1]
is_bound = IsLigandBound(lig, model)
self.assertEqual(is_bound,True)
lig = bio_unit.ligands[0].chains[2]
is_bound = IsLigandBound(lig, model)
self.assertEqual(is_bound,True)
lig = bio_unit.ligands[0].chains[3]
is_bound = IsLigandBound(lig, model)
self.assertEqual(is_bound,True)
lig = bio_unit.ligands[0].chains[4]
is_bound = IsLigandBound(lig, model)
self.assertEqual(is_bound,True)
lig = bio_unit.ligands[0].chains[5]
is_bound = IsLigandBound(lig, model)
self.assertEqual(is_bound,True)
lig = bio_unit.ligands[1].chains[0]
is_bound = IsLigandBound(lig, model)
self.assertEqual(is_bound,False)
lig = bio_unit.ligands[1].chains[1]
is_bound = IsLigandBound(lig, model)
self.assertEqual(is_bound,False)
lig = bio_unit.ligands[1].chains[2]
is_bound = IsLigandBound(lig, model)
self.assertEqual(is_bound,True)
lig = bio_unit.ligands[1].chains[3]
is_bound = IsLigandBound(lig, model)
self.assertEqual(is_bound,True)
lig = bio_unit.ligands[1].chains[4]
is_bound = IsLigandBound(lig, model)
self.assertEqual(is_bound,True)
def fastAssignResiduesConservation(self):
# perfect aln
mod_seq = seq.CreateSequence('M', 'AAAAA')
tem_seq = seq.CreateSequence('T', 'AAAAA')
aln = seq.CreateAlignment(mod_seq, tem_seq)
in_contact = ['_.12', 'T.1','T.3','T.4','C.23']
is_cons = AssignResiduesConservation(in_contact, aln)
self.assertEqual(is_cons, True)
# bad aln
mod_seq = seq.CreateSequence('M', 'TA--A')
tem_seq = seq.CreateSequence('T', 'TSAAS')
aln = seq.CreateAlignment(mod_seq, tem_seq)
in_contact = ['_.12', 'T.1','T.3','T.4','C.23']
is_cons = AssignResiduesConservation(in_contact, aln)
self.assertEqual(is_cons, False)
def fastCopyLigand(self):
tem = io.LoadPDB('data/ligands/3IIJ.pdb')
ligand = tem.Select('rname=ADP')
model = io.LoadPDB('data/ligands/3IIJ_no_ligands.pdb')
add_lig, no_overlaps, new_model = CopyLigand(ligand, model)
self.assertEqual(add_lig, True)
self.assertEqual(no_overlaps, True)
adp = new_model.Select('rname=ADP')
self.assertEqual(adp.residues[0].name, 'ADP')
ligands = new_model.Select('protein=false and water=false')
self.assertEqual(ligands.residue_count, 1)
def fastRunAddLigands(self):
mod_seq = io.LoadSequence('data/ligands/3IIJ.fasta')
tem_seq = io.LoadSequence('data/ligands/3IIJ.fasta')
aln = seq.CreateAlignment(mod_seq, tem_seq)
tem = tplsearch.Template.Create('3iij', 1, 'A', aln)
model = io.LoadPDB('data/ligands/3IIJ_no_ligands.pdb')
lib = smtl.SMTL.Create('data/ligands/SMTL')
lib.Update(add=('3IIJ', ), mmcif_dir='data/ligands/', calc_profiles=False)
bio_unit = lib.Get(tem.pdb_id,tem.assembly_id)
chain = bio_unit.GetChainByName(tem.chain_name)
new_aln = chain.ToAtomSeqAlignment(tem.alignment)
rep, new_model = RunAddLigands(bio_unit, model, aln)
lig_rep = rep[0]
self.assertEqual(lig_rep['description'], "ADENOSINE-5'-DIPHOSPHATE")
self.assertEqual(lig_rep['name'][0], 'ADP')
self.assertEqual(lig_rep['number'], '1')
self.assertEqual(lig_rep['included'], True)
self.assertEqual(lig_rep['reason']['bound'], True)
self.assertEqual(lig_rep['reason']['relevant'], True)
self.assertEqual(lig_rep['reason']['conserved_residues'], True)
self.assertEqual(lig_rep['reason']['sterically_valid'], True)
lig_rep = rep[1]
# self.assertEqual(lig_rep['description'], "SULFATE ION")
# self.assertEqual(lig_rep['name'][0], 'SO4')
# self.assertEqual(lig_rep['number'], '2')
# self.assertEqual(lig_rep['included'], False)
# self.assertEqual(lig_rep['reason']['bound'], True)
# self.assertEqual(lig_rep['reason']['relevant'], False)
# self.assertEqual(len(rep), 5)
# ligands = new_model.Select('protein=false and water=false')
# self.assertEqual(ligands.residues[0].name, 'ADP')
# self.assertEqual(ligands.residue_count, 1)
if __name__ == "__main__":
run()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment