Skip to content

Commit

Permalink
Modify ipython notebook script to be compatible with createKineticsLi…
Browse files Browse the repository at this point in the history
…brary

Specifically changed the way it reads comments, so that it can copy shortDesc and longDesc from the library entry. This is needed in the case where we make the library as an intermediate to making training reactions.
  • Loading branch information
nyee committed Jun 1, 2017
1 parent 925fdba commit 0381ce9
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions scripts/convertKineticsLibraryToTrainingReactions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"outputs": [],
"source": [
"reactionDict = {}\n",
"commentsDict = {} #key is a :class:Reaction object, value is a list of entry attributes [reference, referenceType, shortDesc, longDesc]\n",
"kineticLibrary = database.kinetics.libraries[libraryName]\n",
"\n",
"# html table settings\n",
Expand All @@ -102,6 +103,7 @@
" lib_rxn.kinetics = entry.data \n",
" lib_rxn.index = entry.index\n",
" lib_rxn.kinetics.comment = entry.label # Assign the entry's label to the comment\n",
" commentsDict[lib_rxn] = [entry.reference, entry.referenceType, entry.shortDesc, entry.longDesc] #save comments to add to training\n",
" # Let's make RMG try to generate this reaction from the families!\n",
" fam_rxn_list = []\n",
" rxt_mol_mutation_num = 1\n",
Expand Down Expand Up @@ -343,7 +345,18 @@
" reactions = reactionDict[familyName]\n",
" print 'reactions.py previously has {} rxns. Now adding {} new rxn(s).'.format(len(trainingDatabase.entries.values()), len(reactions))\n",
" print '================='\n",
" kineticFamily.saveTrainingReactions(reactions, shortDesc='Training reaction from kinetics library: {0}'.format(libraryName))"
" for reaction in reactions:\n",
" shortDesc = ''\n",
" #If the library entry has a shortDesc and longDesc to the training reaction \n",
" if commentsDict[reaction][2]:\n",
" shortDesc = commentsDict[reaction][2]\n",
" reaction.kinetics.comment = str(commentsDict[reaction][3])\n",
" else:\n",
" shortDesc = 'Training reaction from kinetics library: {0}'.format(libraryName)\n",
" kineticFamily.saveTrainingReactions([reaction],\n",
" reference = commentsDict[reaction][0],\n",
" referenceType = commentsDict[reaction][1],\n",
" shortDesc=shortDesc)"
]
},
{
Expand Down Expand Up @@ -530,7 +543,7 @@
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python [default]",
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
Expand All @@ -544,7 +557,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
"version": "2.7.13"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 0381ce9

Please sign in to comment.