def showvirtualAtoms(filename): sm = get_sm(filename) cg = sm.bg clash_energy = fbe.StemVirtualResClashEnergy() clash_energy.eval_energy(sm) forJson = {"virtual_atoms": []} virtualAtoms = ftug.virtual_atoms(sm.bg, sidechain=True) for residuePos in virtualAtoms.keys(): stem = cg.get_node_from_residue_num(residuePos) if stem[0] != "s": continue #Only virtual res for stems! residue = virtualAtoms[residuePos] for aname in residue.keys(): isClashing = False if stem in clash_energy.bad_bulges: for clashing in clash_energy.bad_atoms[stem]: if np.allclose(residue[aname], clashing): isClashing = True break atomInfo = { "atomname": aname, "center": residue[aname].tolist(), "is_clashing": isClashing, "loop": stem } forJson["virtual_atoms"].append(atomInfo) return jsonify(forJson)
def setUp(self): self.cg = ftmc.CoarseGrainRNA.from_bg_file( 'test/fess/data/1GID_A-structure1.coord') self.cg_copy = ftmc.CoarseGrainRNA.from_bg_file( 'test/fess/data/1GID_A-structure1.coord') self.sm = fbm.SpatialModel(self.cg) self.cg2 = ftmc.CoarseGrainRNA.from_bg_file( 'test/fess/data/1GID_A-clash.coord') self.sm2 = fbm.SpatialModel(self.cg2) real_stats_fn = 'fess/stats/all_nr3.36.stats' self.stat_source = stat_container.StatStorage(real_stats_fn) self.sm.constraint_energy = fbe.StemVirtualResClashEnergy() self.sm2.constraint_energy = fbe.StemVirtualResClashEnergy() e1 = fbe.RoughJunctionClosureEnergy() e2 = fbe.RoughJunctionClosureEnergy() for e, sm in [(e1, self.sm), (e2, self.sm2)]: for ml in sm.bg.defines: if ml[0] == "m": sm.junction_constraint_energy[ml] = e self.builder = fbb.Builder(self.stat_source)
def setUp(self): self.cg = ftmc.CoarseGrainRNA.from_bg_file( 'test/fess/data/1GID_A-structure1.coord') self.cg2 = ftmc.CoarseGrainRNA.from_bg_file( 'test/fess/data/1GID_A-structure2.coord') self.cg_clash = ftmc.CoarseGrainRNA.from_bg_file( 'test/fess/data/1GID_A-clash.coord') self.cg.add_all_virtual_residues() self.cg2.add_all_virtual_residues() self.cg_clash.add_all_virtual_residues() #self.sm = fbm.SpatialModel(cg) #self.sm.load_sampled_elems() #self.sm2 = fbm.SpatialModel(cg2) #self.sm2.load_sampled_elems() #self.sm_clash= fbm.SpatialModel(cg_clash) #self.sm_clash.load_sampled_elems() self.energy = fbe.StemVirtualResClashEnergy()
def getStructureJson(sm): clash_energy = fbe.StemVirtualResClashEnergy() try: clash_energy.eval_energy(sm) except KeyError: sm.bg.add_all_virtual_residues() clash_energy.eval_energy(sm) forJson = {"loops": [], "bad_bulges": [], "status": "OK"} for element in sm.bg.coords: forJson["loops"].append(cylinderToThree(sm.bg.coords[element], element)) if clash_energy.bad_bulges: forJson["bad_bulges"] = list(set(clash_energy.bad_bulges)) forJson["dotbracket"] = sm.bg.to_dotbracket_string() forJson["sequence"] = sm.bg.seq return jsonify(forJson)
def structureStats(filename): sm = get_sm(filename) cg = sm.bg clash_energy = fbe.StemVirtualResClashEnergy() clash_energy.eval_energy(sm) numclashes = sum( len(clash_energy.bad_atoms[x]) for x in clash_energy.bad_atoms) junction_energy = fbe.RoughJunctionClosureEnergy() j = junction_energy.eval_energy(sm) print("J Energy is ", j) return render_template("structureinfo.html", cg=cg, numclashes=numclashes, clashbulges=", ".join( sorted(set(clash_energy.bad_bulges), key=lambda x: int(x[1:]))), bad_junctions=", ".join( sorted(set(junction_energy.bad_bulges), key=lambda x: int(x[1:]))))