def _getInterconversionEnergy(self, request, uri, interconversion_uuid): graph = graphstore.graph() try: route = grrm2.Interconversion.get( graph, utils.uuidToUri(interconversion_uuid)) except: raise http.Http404 output = {} start = grrm2.interconversionStart(route).get()[0] end = grrm2.interconversionEnd(route).get()[0] energies = {} for step in grrm2.interconversionStep(route).getAll(): step = step[0] energies[grrm2.stepNumber(step).get()] = grrm2.energy(step).get() energies[0] = grrm2.energy(start).get() energies[max(energies.keys()) + 1] = grrm2.energy(end).get() output["energies"] = energies return http.HttpResponse(simplejson.dumps(output), mimetype='application/javascript')
def _parseUDCTokenList(self): tokenizer = grrm.ListOutputTokenizer() tokens = tokenizer.tokenize(self._filename) current_molecule = None header_found = False for t in tokens: if t.__class__ == tokentypes.HeaderDissociatedToken: header_found = True if t.__class__ == tokentypes.StructureHeaderToken: if not header_found: raise Exception("Header not found") current_molecule = grrm2.BarrierlessDissociated.new( self._graph, rdflib.URIRef("urn:uuid:" + str(uuid.uuid4()))) self._molecules.append(current_molecule) grrm2.structureNumber(current_molecule).set(int(t.number())) self._struct_label_to_molecule_mapper[( "uDC", t.number())] = current_molecule if t.__class__ == tokentypes.GeometryToken: if not header_found: raise Exception("Header not found") grrm2.geometry(current_molecule).set( helperfuncs.parseGeometryToken(t)) if t.__class__ == tokentypes.EnergyToken: if not header_found: raise Exception("Header not found") grrm2.energy(current_molecule).set( helperfuncs.parseEnergyToken(t)) if t.__class__ == tokentypes.SpinToken: if not header_found: raise Exception("Header not found") grrm2.spin(current_molecule).set( int(t.spin().rescale(units.hbar).magnitude)) if t.__class__ == tokentypes.ZPVEToken: if not header_found: raise Exception("Header not found") grrm2.zeroPointVibrationalEnergy(current_molecule).set( helperfuncs.parseZPVEToken(t)) if t.__class__ == tokentypes.NormalModesToken: if not header_found: raise Exception("Header not found") grrm2.normalModesEigenvalues(current_molecule).set( helperfuncs.parseNormalModesEigenvalues(t)) if t.__class__ == tokentypes.ConnectionToken: if not header_found: raise Exception("Header not found") self._connections.append( (("uDC", grrm2.structureNumber(current_molecule).get()), ("EQ", t.first()))) if t.__class__ == tokentypes.DissociationFragmentsToken: if not header_found: raise Exception("Header not found") grrm2.fragments(current_molecule).set(t.fragments())
def dispatch(self, request, **args): current_uri = args["uri"] graph = graphstore.graph() try: iconv = grrm2.Interconversion.get(graph, current_uri) except: return None ctx = {} ctx["steps"] = [] ctx["start"] = ResultInfo() ctx["end"] = ResultInfo() start = grrm2.interconversionStart(iconv).get()[0] ctx["start"].uri = start.uri() ctx["start"].link = "/resources/%7B" + utils.uriToUuid( start.uri()) + "%7D" iconstorage = filestorage.ResourceIcon( start, settings=settings.filestorage_settings) ctx["start"].icon = iconstorage.url(filestorage.ResourceIcon.STATIC) ctx["start"].energy = grrm2.energy(start).get() ctx["start"].label = _getLabel(start) end = grrm2.interconversionEnd(iconv).get()[0] ctx["end"].uri = end.uri() ctx["end"].link = "/resources/%7B" + utils.uriToUuid(end.uri()) + "%7D" iconstorage = filestorage.ResourceIcon( end, settings=settings.filestorage_settings) ctx["end"].icon = iconstorage.url(filestorage.ResourceIcon.STATIC) ctx["end"].energy = grrm2.energy(end).get() ctx["end"].label = _getLabel(end) for s in grrm2.interconversionStep(iconv).getAll(): step = s[0] iconstorage = filestorage.ResourceIcon( step, settings=settings.filestorage_settings) info = StepInfo() info.link = "/resources/%7B" + utils.uriToUuid(step.uri()) + "%7D" info.icon = iconstorage.url(filestorage.ResourceIcon.STATIC) info.uri = step.uri() info.energy = grrm2.energy(step).get() info.number = grrm2.stepNumber(step).get() ctx["steps"].append(info) def cmpFunc(x, y): return cmp(x.number, y.number) ctx["steps"] = sorted(ctx["steps"], cmp=cmpFunc) return ctx
def dispatch(self, request, **args): current_uri = args["uri"] graph = graphstore.graph() try: route = grrm2.Interconversion.get(graph, current_uri) except: return None start = grrm2.interconversionStart(route).get()[0] end = grrm2.interconversionEnd(route).get()[0] iconstorage_start = filestorage.ResourceIcon(start, settings=settings.filestorage_settings) iconstorage_end = filestorage.ResourceIcon(end, settings=settings.filestorage_settings) iconstorage_route = filestorage.ResourceIcon(route, settings=settings.filestorage_settings) ctx = {} ctx["startUrl"] = "/resources/%7B"+utils.uriToUuid(start.uri())+"%7D" ctx["endUrl"] = "/resources/%7B"+utils.uriToUuid(end.uri())+"%7D" ctx["startIcon"] = iconstorage_start.url(filestorage.ResourceIcon.STATIC) ctx["endIcon"] = iconstorage_end.url(filestorage.ResourceIcon.STATIC) ctx["connectionRouteIcon"] = iconstorage_route.url(filestorage.ResourceIcon.ANIMATED) ctx["startStructureLabel"] = _getLabel(start) ctx["endStructureLabel"] = _getLabel(end) energies = {} for step in grrm2.interconversionStep(route).getAll(): step = step[0] energies[grrm2.stepNumber(step).get()] = grrm2.energy(step).get() energies[0] = grrm2.energy(start).get() energies[max(energies.keys())+1] = grrm2.energy(end).get() chart_query = http.QueryDict("").copy() chart_query.update( { "cht": "lxy", "chs": "400x400", "chd": "t:"+",".join([ str(x) for x in energies.keys()])+"|"+",".join( [str(x) for x in energies.values()]), "chds": str(min(energies.keys()))+","+str(max(energies.keys()))+","+str(min(energies.values()))+","+str(max(energies.values())), "chco": "3072F3,ff0000,00aaaa", "chls": "2,4,1", "chf": "bg,s,F0F0FF", "chm": "s,FF0000,0,-1,5|s,0000ff,1,-1,5|s,00aa00,2,-1,5", "chxt": "x,y", "chxr": "0,"+str(min(energies.keys()))+","+str(max(energies.keys()))+"|1,"+str(min(energies.values()))+","+str(max(energies.values())), } ) ctx["chartUrl"] = "http://chart.apis.google.com/chart?"+chart_query.urlencode() return ctx
def _indexEnergy(graph, indexer): indexer.addIndex("grrm__energy", "VARCHAR(255)") for m in grrm2.Molecule.all(graph): energy = grrm2.energy(m).get() if energy: indexer.store(m.uri(), { "grrm__energy" : float(energy)})
def _getEnergies(iconv): energies = {} for step in grrm2.interconversionStep(iconv).getAll(): step = step[0] energies[grrm2.stepNumber(step).get()] = grrm2.energy(step).get() return energies
def grrmMoleculeInfoFilter(thing, data_list): if not grrm2.Molecule.tryCast(thing): return (thing, data_list) mol = grrm2.Molecule.tryCast(thing) energy = grrm2.energy(mol).get() if energy: for data in data_list: data.grrm__energy = float(energy) mass = grrm2.mass(mol).get() if mass: for data in data_list: data.grrm__mass = float(mass) geometry = grrm2.geometry(mol).get() if geometry: for data in data_list: all_symbols = geometry["symbols"] data.grrm__carbons = len(filter(lambda x: x == "C", all_symbols)) data.grrm__oxygens = len(filter(lambda x: x == "O", all_symbols)) data.grrm__hydrogens = len(filter(lambda x: x == "H", all_symbols)) data.grrm__nitrogens = len(filter(lambda x: x == "N", all_symbols)) smiles = grrm2.smiles(mol).get() if smiles: for data in data_list: data.grrm__smiles_md5 = md5.md5(smiles).hexdigest() inchi = grrm2.inchi(mol).get() if inchi: for data in data_list: data.grrm__inchi_md5 = md5.md5(inchi).hexdigest() return (thing, data_list)
def _getFromRoutesContext(self, molecule): icres = grrm2.InterconversionResult.tryCast(molecule) context = [] iconvs = grrm2.interconversionEndOf(icres).getAll() if iconvs is None: return context for iconv in iconvs: iconv = iconv[0] start = grrm2.interconversionStart(iconv).get()[0] route_info = RouteInfo() route_info.link = "/resources/%7B" + utils.uriToUuid( iconv.uri()) + "%7D" route_info.targetLink = "/resources/%7B" + utils.uriToUuid( start.uri()) + "%7D" route_info.targetIcon = filestorage.ResourceIcon( start, settings=settings.filestorage_settings).url( filestorage.ResourceIcon.STATIC) struct_number = grrm2.structureNumber(start).get() if grrm2.EquilibriumStructure.tryCast(start): struct_type = "EQ" elif grrm2.TransitionState.tryCast(start): struct_type = "TS" elif grrm2.BarrierlessDissociated.tryCast(start): struct_type = "DDC" elif grrm2.BarrierDissociated.tryCast(start): struct_type = "UDC" route_info.targetStructureLabel = struct_type + str(struct_number) route_info.targetEnergy = grrm2.energy(start).get() route_info.energyDifference = grrm2.energy( start).get() - grrm2.energy(molecule).get() route_info.icon = filestorage.ResourceIcon( iconv, settings=settings.filestorage_settings).url( filestorage.ResourceIcon.ANIMATED) context.append(route_info) return context
def _parseUDCAnalysis(self): tokenizer = grrm.UDCAnalysisOutputTokenizer() tokens = tokenizer.tokenize(self._filename) steepest_header_found = False m_uDC = re.search("_uDC(\d+)\.log", self._filename) route = grrm2.Interconversion.new( self._graph, rdflib.URIRef("urn:uuid:" + str(uuid.uuid4()))) self._route = route self._route_additional_infos = InterconversionAdditionalInfo.InterconversionAdditionalInfo( route) self._route_additional_infos.setStartStructureLabel( ("uDC", int(m_uDC.group(1)))) steps = {} for t in tokens: if t.__class__ == tokentypes.SteepestDescentHeaderToken: steepest_header_found = True if t.__class__ == tokentypes.IRCStepToken: if not steepest_header_found: raise Exception("Steepest Header not found") molecule = grrm2.InterconversionStep.new( self._graph, rdflib.URIRef("urn:uuid:" + str(uuid.uuid4()))) self._route_steps.append(molecule) grrm2.energy(molecule).set(t.energy().rescale( units.hartree).magnitude) grrm2.spin(molecule).set(t.spin().rescale( units.hbar).magnitude) grrm2.geometry(molecule).set(helperfuncs.parseGeometryToken(t)) grrm2.stepNumber(molecule).set(t.step()) grrm2.interconversionStep(route).add(molecule) steps[t.step()] = molecule if t.step() != 1: grrm2.prevInterconversionStep(molecule).set( steps[t.step() - 1]) if t.__class__ == tokentypes.DownhillWalkingResultToken: self._route_additional_infos.setEndStructureLabel(t.result())
def testDataProperty(self): graph = rdflib.ConjunctiveGraph(getStore()) eq1 = grrm2.EquilibriumStructure.new(graph, "http://example.com/eq1") ts1 = grrm2.TransitionState.new(graph, "http://example.com/ts1") blessdiss1 = grrm2.BarrierlessDissociated.new( graph, "http://example.com/blessdiss1") bdiss1 = grrm2.BarrierDissociated.new(graph, "http://example.com/bdiss1") ic1 = grrm2.InterconversionStep.new(graph, "http://example.com/ic1") iconv1 = grrm2.Interconversion.new(graph, "http://example.com/iconv1") rundata1 = grrm2.RunData.new(graph, "http://example.com/rundata1") run1 = grrm2.Run.new(graph, "http://example.com/run1") mol1 = grrm2.Molecule.new(graph, "http://example.com/mol1") runin1 = grrm2.RunInput.new(graph, "http://example.com/runin1") runout1 = grrm2.RunOutput.new(graph, "http://example.com/runout1") icres1 = grrm2.InterconversionResult.new(graph, "http://example.com/icres1") all_results = [eq1, ts1, blessdiss1, bdiss1, icres1] all_not_results = [iconv1, rundata1, run1, runin1, ic1, mol1, runout1] all_molecules = all_results + [ic1, mol1] all_not_molecules = [iconv1, rundata1, run1, runin1, runout1] all_runin = [runin1] + all_molecules all_runout = [runout1] + all_molecules for r in all_results: grrm2.zeroPointVibrationalEnergy(r).set(12.3) self.assertRaises(Exception, grrm2.zeroPointVibrationalEnergy(r).set, "hello") for r in all_not_results: self.assertRaises(Exception, grrm2.zeroPointVibrationalEnergy, r) for r in all_results: grrm2.structureNumber(r).set(1) self.assertRaises(Exception, grrm2.structureNumber(r).set, "hello") for r in all_not_results: self.assertRaises(Exception, grrm2.structureNumber, r) for r in [ic1]: grrm2.stepNumber(r).set(1) self.assertRaises(Exception, grrm2.stepNumber(r).set, "hello") for r in [ eq1, ts1, blessdiss1, bdiss1, icres1, iconv1, rundata1, run1, runin1, mol1, runout1 ]: self.assertRaises(Exception, grrm2.stepNumber, r) for r in all_molecules: grrm2.spinMultiplicity(r).set(1) self.assertRaises(Exception, grrm2.spinMultiplicity(r).set, "hello") for r in all_not_molecules: self.assertRaises(Exception, grrm2.spinMultiplicity, r) for r in all_molecules: grrm2.spin(r).set(1.4) self.assertRaises(Exception, grrm2.spin(r).set, "hello") for r in all_not_molecules: self.assertRaises(Exception, grrm2.spin, r) for r in all_molecules: grrm2.smiles(r).set("hello") for r in all_not_molecules: self.assertRaises(Exception, grrm2.smiles, r) for r in all_molecules: grrm2.normalModesEigenvalues(r).set([1, 2, 3]) for r in all_not_molecules: self.assertRaises(Exception, grrm2.normalModesEigenvalues, r) for r in [rundata1]: grrm2.method(r).set("hello") for r in [ eq1, ts1, blessdiss1, bdiss1, ic1, iconv1, run1, mol1, runin1, runout1, icres1 ]: self.assertRaises(Exception, grrm2.method, r) for r in all_molecules: grrm2.mass(r).set(1.4) self.assertRaises(Exception, grrm2.mass(r).set, "hello") for r in all_not_molecules: self.assertRaises(Exception, grrm2.mass, r) for r in [rundata1]: grrm2.job(r).set("hello") for r in [ eq1, ts1, blessdiss1, bdiss1, ic1, iconv1, run1, mol1, runin1, runout1, icres1 ]: self.assertRaises(Exception, grrm2.job, r) for r in all_molecules: grrm2.inchi(r).set("hello") for r in all_not_molecules: self.assertRaises(Exception, grrm2.inchi, r) for r in all_molecules: grrm2.hillFormula(r).set("hello") for r in all_not_molecules: self.assertRaises(Exception, grrm2.hillFormula, r) for r in all_molecules: grrm2.geometry(r).set({}) for r in all_not_molecules: self.assertRaises(Exception, grrm2.geometry, r) for r in all_molecules: grrm2.energy(r).set(1.4) self.assertRaises(Exception, grrm2.energy(r).set, "hello") for r in all_not_molecules: self.assertRaises(Exception, grrm2.energy, r) for r in all_molecules: grrm2.charge(r).set(1.4) self.assertRaises(Exception, grrm2.charge(r).set, "hello") for r in all_not_molecules: self.assertRaises(Exception, grrm2.charge, r) for r in all_molecules: grrm2.canostSerial(r).set(["foo"]) for r in all_not_molecules: self.assertRaises(Exception, grrm2.canostSerial, r) for r in all_molecules: grrm2.canostPlanar(r).set(["foo"]) for r in all_not_molecules: self.assertRaises(Exception, grrm2.canostPlanar, r) for r in [rundata1]: grrm2.basisSet(r).set("hello") for r in [ eq1, ts1, blessdiss1, bdiss1, ic1, iconv1, run1, mol1, runin1, runout1, icres1 ]: self.assertRaises(Exception, grrm2.basisSet, r)
def dispatch(self, request, uri): context = {} graph = graphstore.graph() try: molecule = grrm2.Molecule.get(graph, uri) except: return None context["moleculeInfo"] = [] context["moleculeInfo"].append( ("Formula", grrm2.hillFormula(molecule).get(), None)) context["moleculeInfo"].append( ("Molecular Mass", grrm2.mass(molecule).get(), None)) context["moleculeInfo"].append( ("InChi", grrm2.inchi(molecule).get(), None)) context["moleculeInfo"].append( ("SMILES", grrm2.smiles(molecule).get(), None)) context["moleculeInfo"].append( ("Energy", grrm2.energy(molecule).get(), None)) context["moleculeInfo"].append( ("Charge", grrm2.charge(molecule).get(), None)) context["moleculeInfo"].append( ("Spin", grrm2.spin(molecule).get(), None)) context["moleculeInfo"].append( ("Structure Type", _getStructureType(molecule), None)) result = grrm2.InterconversionResult.tryCast(molecule) if result: context["moleculeInfo"].append( ("Structure Number", grrm2.structureNumber(result).get(), None)) context["moleculeInfo"].append( ("Zero Point Vibrational Energy", grrm2.zeroPointVibrationalEnergy(result).get(), None)) step = grrm2.InterconversionStep.tryCast(molecule) if step: context["moleculeInfo"].append( ("Interconversion Step", grrm2.stepNumber(step).get(), None)) context["moleculeInfo"].append( ("Belongs to interconversion", grrm2.interconversionStepOf(step).get()[0].uri(), "/resources/%7B" + utils.uriToUuid( grrm2.interconversionStepOf(step).get()[0].uri()) + "%7D")) context["moleculeInfo"].append( ("CANOST canonical planar", grrm2.canostSerialCanonical(molecule).get(), None)) context["moleculeInfo"].append( ("CANOST canonical serial", grrm2.canostPlanarCanonical(molecule).get(), None)) context["moleculeInfo"].append( ("CANOST planar codes", grrm2.canostPlanar(molecule).get(), None)) context["moleculeInfo"].append( ("CANOST serial codes", grrm2.canostSerial(molecule).get(), None)) fragment_strings = [] if grrm2.fragments(molecule).get() is not None: geometry = grrm2.geometry(molecule).get() for fragment in grrm2.fragments(molecule).get(): symbols = [geometry["symbols"][i - 1] for i in fragment] fragment_strings.append(chemistry.hillFormula(symbols)) context["moleculeInfo"].append( ("Fragments", "/".join(fragment_strings), None)) try: run = grrm2.runOutputOf(molecule).get()[0] context["moleculeInfo"].append( ("Run", run.uri(), "/resources/%7B" + utils.uriToUuid(run.uri()) + "%7D")) except Exception, e: pass
def dispatch(self, request, **args): current_uri = args["uri"] graph = graphstore.graph() try: transition_state = grrm2.TransitionState.get(graph, current_uri) except: return None ctx = {} iconv_start_tuple_list = grrm2.interconversionStartOf( transition_state).getAll() or [] iconv_end_tuple_list = grrm2.interconversionEndOf( transition_state).getAll() or [] if len(iconv_start_tuple_list) + len(iconv_end_tuple_list) != 2: return None # we have a problem... a transition state must have two links if len(iconv_start_tuple_list) == 2: iconv_left = iconv_start_tuple_list[0][0] iconv_right = iconv_start_tuple_list[1][0] energies_left = _getEnergies(iconv_left) energies_right = _getEnergies(iconv_right) energies = {} energies[0] = grrm2.energy(transition_state).get() for k, v in sorted(map(lambda x: (-x[0], x[1]), energies_left.items()) + energies_right.items(), key=lambda x: x[0]): print k energies[k] = v end_left = grrm2.interconversionEnd(iconv_left).get()[0] end_right = grrm2.interconversionEnd(iconv_right).get()[0] energies[min(energies.keys()) - 1] = grrm2.energy(end_left).get() energies[max(energies.keys()) + 1] = grrm2.energy(end_right).get() else: return None chart_query = http.QueryDict("").copy() chart_query.update({ "cht": "lxy", "chs": "400x400", "chd": "t:" + ",".join([ str(x[0]) for x in sorted(energies.items(), key=lambda x: x[0]) ]) + "|" + ",".join([ str(x[1]) for x in sorted(energies.items(), key=lambda x: x[0]) ]), "chds": str(min(energies.keys())) + "," + str(max(energies.keys())) + "," + str(min(energies.values())) + "," + str(max(energies.values())), "chco": "3072F3,ff0000,00aaaa", "chls": "2,4,1", "chf": "bg,s,F0F0FF", "chm": "s,FF0000,0,-1,5|s,0000ff,1,-1,5|s,00aa00,2,-1,5", "chxt": "x,y", "chxr": "0," + str(min(energies.keys())) + "," + str(max(energies.keys())) + "|1," + str(min(energies.values())) + "," + str(max(energies.values())), }) ctx["chartUrl"] = "http://chart.apis.google.com/chart?" + chart_query.urlencode( ) iconstorage = filestorage.ResourceIcon( transition_state, settings=settings.filestorage_settings) if iconstorage.readable(filestorage.ResourceIcon.STATIC): icon_url = iconstorage.url(filestorage.ResourceIcon.STATIC) elif iconstorage.readable(filestorage.ResourceIcon.ANIMATED): icon_url = iconstorage.url(filestorage.ResourceIcon.ANIMATED) else: icon_url = None ctx["transitionStateIcon"] = icon_url iconstorage = filestorage.ResourceIcon( end_left, settings=settings.filestorage_settings) if iconstorage.readable(filestorage.ResourceIcon.STATIC): icon_url = iconstorage.url(filestorage.ResourceIcon.STATIC) elif iconstorage.readable(filestorage.ResourceIcon.ANIMATED): icon_url = iconstorage.url(filestorage.ResourceIcon.ANIMATED) else: icon_url = None ctx["leftEndIcon"] = icon_url iconstorage = filestorage.ResourceIcon( end_right, settings=settings.filestorage_settings) if iconstorage.readable(filestorage.ResourceIcon.STATIC): icon_url = iconstorage.url(filestorage.ResourceIcon.STATIC) elif iconstorage.readable(filestorage.ResourceIcon.ANIMATED): icon_url = iconstorage.url(filestorage.ResourceIcon.ANIMATED) else: icon_url = None ctx["rightEndIcon"] = icon_url ctx["leftEndUrl"] = "/resources/%7B" + utils.uriToUuid( end_left.uri()) + "%7D" ctx["rightEndUrl"] = "/resources/%7B" + utils.uriToUuid( end_right.uri()) + "%7D" return ctx
if len(runs) != 1: raise Exception("Run length != 1") storage = filestorage.ResourceStorage(runs[0], web_accessible=True, settings=settings.filestorage_settings) print "writing file : "+storage.path("connectivity","csv") f=file(storage.path("connectivity","csv"),"w") for icresult in grrm2.InterconversionResult.all(graph): label=_getLabel(icresult) f.write("v,"+label+","+utils.uriToUuid(icresult.uri())+"\n") for iconv in grrm2.Interconversion.all(graph): start = grrm2.interconversionStart(iconv).get()[0] if grrm2.interconversionStart(iconv).get() is not None: start = grrm2.interconversionStart(iconv).get()[0] else: continue if grrm2.interconversionEnd(iconv).get() is not None: end = grrm2.interconversionEnd(iconv).get()[0] else: continue start_energy = grrm2.energy(start).get() end_energy = grrm2.energy(end).get() f.write("e,"+str(end_energy-start_energy)+","+_getLabel(start)+","+_getLabel(end)+","+utils.uriToUuid(iconv.uri())+"\n") f.close()
def _parseTSAnalysis(self): tokenizer = grrm.TSAnalysisOutputTokenizer() tokens = tokenizer.tokenize(self._filename) status = Anon() status.header_found = False status.doing_forward = False status.doing_backward = False m_TS = re.search("_TS(\d+)\.log", self._filename) forward_route = grrm2.Interconversion.new(self._graph,rdflib.URIRef("urn:uuid:"+str(uuid.uuid4()))) backward_route = grrm2.Interconversion.new(self._graph,rdflib.URIRef("urn:uuid:"+str(uuid.uuid4()))) self._forward_route = forward_route self._backward_route = backward_route forward_steps = {} backward_steps = {} self._forward_route_additional_infos = InterconversionAdditionalInfo.InterconversionAdditionalInfo(forward_route) self._forward_route_additional_infos.setStartStructureLabel( ( "TS", int(m_TS.group(1)) ) ) self._backward_route_additional_infos = InterconversionAdditionalInfo.InterconversionAdditionalInfo(backward_route) self._backward_route_additional_infos.setStartStructureLabel( ( "TS", int(m_TS.group(1)) ) ) for t in tokens: if t.__class__ == tokentypes.IRCHeaderToken: status.header_found = True if t.__class__ == tokentypes.ForwardIRCHeaderToken: if not status.header_found: raise Exception("Header not found") status.doing_forward = True status.doing_backward = False if t.__class__ == tokentypes.BackwardIRCHeaderToken: if not status.header_found: raise Exception("Header not found") status.doing_forward = False status.doing_backward = True if t.__class__ == tokentypes.IRCStepToken: molecule = grrm2.InterconversionStep.new(self._graph, rdflib.URIRef("urn:uuid:"+str(uuid.uuid4()))) grrm2.energy(molecule).set(t.energy().rescale(units.hartree).magnitude) grrm2.spin(molecule).set(t.spin().rescale(units.hbar).magnitude) grrm2.geometry(molecule).set(helperfuncs.parseGeometryToken(t)) grrm2.stepNumber(molecule).set(t.step()) if status.doing_forward: grrm2.interconversionStep(forward_route).add(molecule) self._forward_steps.append(molecule) forward_steps[t.step()] = molecule if t.step() != 1: grrm2.prevInterconversionStep(molecule).set(forward_steps[t.step()-1]) elif status.doing_backward: grrm2.interconversionStep(backward_route).add(molecule) self._backward_steps.append(molecule) backward_steps[t.step()] = molecule if t.step() != 1: grrm2.prevInterconversionStep(molecule).set(backward_steps[t.step()-1]) else: raise Exception("found IRCStepToken but no idea who it belongs to") if t.__class__ == tokentypes.IRCFollowingResultsToken: self._forward_route_additional_infos.setEndStructureLabel(_properNaming(t.forward())) self._backward_route_additional_infos.setEndStructureLabel(_properNaming(t.backward()))