def test_set_value(self): import operator from IMP.pmi.io.crosslink import FilterOperator as FO cldb1=self.setup_cldb("xl_dataset_test.dat") cldb2=self.setup_cldb("xl_dataset_test.dat") cldb1.set_value(cldb1.protein1_key,'FFF',FO(cldb1.protein1_key,operator.eq,"AAA")) cldb1.set_value(cldb1.protein2_key,'HHH',FO(cldb1.protein2_key,operator.eq,"AAA")) protein_names_1=[] for xl in cldb1: protein_names_1.append((xl[cldb1.protein1_key],xl[cldb1.protein2_key])) protein_names_2=[] for xl in cldb2: protein_names_2.append((xl[cldb1.protein1_key],xl[cldb1.protein2_key])) new_protein_names=[] for n,p in enumerate(protein_names_2): p1=p[0] p2=p[1] if p1 == 'AAA': p1 = 'FFF' if p2 == 'AAA': p2 = 'HHH' new_protein_names.append((p1,p2)) self.assertEqual(protein_names_1,new_protein_names)
def test_FilterOperator(self): import operator from IMP.pmi.io.crosslink import FilterOperator as FO cldb=self.setup_cldb("xl_dataset_test.dat") fo=FO(cldb.protein1_key,operator.eq,"AAA") for xl in cldb: self.assertEqual(fo.evaluate(xl),xl[cldb.protein1_key]=="AAA") fo=FO(cldb.protein1_key,operator.eq,"AAA")|FO(cldb.protein2_key,operator.eq,"BBB") for xl in cldb: self.assertEqual(fo.evaluate(xl),((xl[cldb.protein1_key]=="AAA")|(xl[cldb.protein2_key]=="BBB") )) fo=(FO(cldb.protein1_key,operator.eq,"AAA")|FO(cldb.protein2_key,operator.eq,"BBB"))&FO("sample",operator.eq,"human") for xl in cldb: self.assertEqual(fo.evaluate(xl),((xl[cldb.protein1_key]=="AAA")|(xl[cldb.protein2_key]=="BBB") )&(xl["sample"]=="human")) fo=(FO(cldb.residue1_key,operator.gt,30)|FO(cldb.protein2_key,operator.eq,"BBB")) for xl in cldb: self.assertEqual(fo.evaluate(xl),((xl[cldb.residue1_key]>30)|(xl[cldb.protein2_key]=="BBB") )) fo=~(FO(cldb.residue1_key,operator.gt,30)|FO(cldb.protein2_key,operator.eq,"BBB")) for xl in cldb: self.assertEqual(fo.evaluate(xl),((xl[cldb.residue1_key]<=30)&(xl[cldb.protein2_key]!="BBB") ))
def test_filter_cldbkc(self): import operator from IMP.pmi.io.crosslink import FilterOperator as FO cldb=self.setup_cldb("xl_dataset_test.dat") fo=FO(cldb.protein1_key,operator.eq,"AAA") cldb1=cldb.filter(fo) nentry=len([xl for xl in cldb if (xl[cldb.protein1_key]=="AAA")]) self.assertEqual(len(cldb1),nentry)
"../../../crosslinks/Exp3-KFG-081016-3.csv", "../../../crosslinks/Exp1-BP-CXMS-12aout16-KFGVE.csv", "../../../crosslinks/Exp3-KFGE-081016-3.csv", "../../../crosslinks/Vgrg-Tle1.csv", "../../../crosslinks/Vgrg-Tle1-2-1008.csv" ]: cldb_tmp = IMP.pmi.io.crosslink.CrossLinkDataBase(cldbkc) cldb_tmp.create_set_from_file(csv) cldb_tmp.rename_proteins({"TssKHis6": "TssK"}) cldb_tmp.set_name(csv) cldb.append_database(cldb_tmp) fo = FO("Decision", operator.eq, "Accepted") fcldb = cldb.filter(fo) prots = ["TssK"] protx = prots proty = prots suffix = "TssK" conversion_fastanames_name = {"TssKHis6": "TssK"} inv_conversion_fastanames_name = { v: k for k, v in conversion_fastanames_name.items()
cldb_tmp.create_set_from_file(csv) cldb_tmp.rename_proteins({"TssKHis6":"TssK","StrepTssF":"TssF","TssGFlag":"TssG"}) cldb_tmp.set_name(csv) cldb.append_database(cldb_tmp) for xl in cldb: xl[cldb.id_score_key]=-math.log(xl[cldb.id_score_key]) cldb.create_new_keyword(cldb.sigma1_key) cldb.create_new_keyword(cldb.sigma2_key) cldb.set_value(cldb.sigma1_key,'SIGMA') cldb.set_value(cldb.sigma2_key,'SIGMA') cldb.set_value(cldb.sigma1_key,'FLEXIBLE-1',FO(cldb.residue1_links_number_key,operator.gt,5)) cldb.set_value(cldb.sigma2_key,'FLEXIBLE-1',FO(cldb.residue2_links_number_key,operator.gt,5)) cldb.set_value(cldb.sigma1_key,'FLEXIBLE-2',FO(cldb.residue1_links_number_key,operator.gt,30)) cldb.set_value(cldb.sigma2_key,'FLEXIBLE-2',FO(cldb.residue2_links_number_key,operator.gt,30)) #for xl in cldb: # print xl[cldb.sigma1_key],xl[cldb.residue1_links_number_key],xl[cldb.sigma2_key],xl[cldb.residue2_links_number_key] fo=FO("Decision",operator.eq,"Accepted") fcldb=cldb.filter(fo) data=IMP.crosslinkms.DataFixedLength("/Bis/home/rpellari/imp-projects/imp-050517/imp/modules/crosslinkms/data/data.21.10000.gaussian.1.rmf") xlmovers=[]
]: cldb_tmp.offset_residue_index("VgrG-II", -8) cldb_tmp.clone_protein("VgrG-II", "VgrG.2") cldb_tmp.clone_protein("VgrG-II", "VgrG.3") cldb_tmp.rename_proteins({"VgrG-II": "VgrG.1"}) cldb_tmp.set_name(csv) cldb.append_database(cldb_tmp) else: cldb_tmp.clone_protein("VgrGHA", "VgrG.2") cldb_tmp.clone_protein("VgrGHA", "VgrG.3") cldb_tmp.rename_proteins({"VgrGHA": "VgrG.1"}) cldb_tmp.set_name(csv) cldb.append_database(cldb_tmp) fo = FO("Decision", operator.eq, "Accepted") & FO(cldb.redundancy_key, operator.gt, 2) fcldb = cldb.filter(fo) prots = ["VgrG.1", "VgrG.2", "VgrG.3"] protx = prots proty = prots suffix = "VgrG" conversion_fastanames_name = { "VgrGHA.1": "VgrG.1", "VgrGHA.2": "VgrG.2", "VgrGHA.3": "VgrG.3"
for csv in [ "../../crosslinks/Vgrg-Tle1.csv", "../../crosslinks/Vgrg-Tle1-2-1008.csv" ]: cldb_tmp = IMP.pmi.io.crosslink.CrossLinkDataBase(cldbkc) cldb_tmp.create_set_from_file(csv) cldb_tmp.clone_protein("VgrG-II", "VgrGB") cldb_tmp.clone_protein("VgrG-II", "VgrGC") cldb_tmp.rename_proteins({"VgrG-II": "VgrGA"}) cldb_tmp.rename_proteins({"Tle1-His": "Tle1"}) cldb_tmp.set_name(csv) cldb.append_database(cldb_tmp) cldb.create_new_keyword("Redundancy_for_filter", values_from_keyword="Redundancy") fo = FO("Decision", operator.eq, "Accepted") & FO("Redundancy_for_filter", operator.gt, 2) fcldb = cldb.filter(fo) xl = IMP.pmi.restraints.crosslinking.CrossLinkingMassSpectrometryRestraint( root_hier=hier, CrossLinkDataBase=fcldb, length=21.0, slope=0.01, resolution=1.0, label="XL") xl.add_to_model() sigma = xl.sigma_dictionary["SIGMA"][0] psi = xl.psi_dictionary["PSI"][0] sigma.set_scale(11.0) psi.set_scale(0.05)
"../data/crosslinks/old/Vgrg-Tle1-2-1008.csv" ]: cldb_tmp = IMP.pmi.io.crosslink.CrossLinkDataBase(cldbkc) cldb_tmp.create_set_from_file(csv) cldb_tmp.rename_proteins({ "TssKHis6": "TssK", "StrepTssF": "TssF", "TssGFlag": "TssG" }) cldb_tmp.set_name(csv) cldb.append_database(cldb_tmp) fo = FO("Decision", operator.eq, "Accepted") fcldb = cldb.filter(fo) for xl in fcldb: xl[cldbkc.id_score_key] = -math.log(xl[cldbkc.id_score_key]) prots = ["TssK"] protx = prots proty = prots suffix = "TssK" conversion_fastanames_name = {"TssKHis6": "TssK"}