From 39d8ac5175497b9443b0c24ebb289c451c94ab9c Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Fri, 18 May 2018 16:42:33 -0400 Subject: [PATCH 1/2] allow list inputs to saveTrainingReactions --- rmgpy/data/kinetics/family.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/rmgpy/data/kinetics/family.py b/rmgpy/data/kinetics/family.py index fbede8b0f8..adab1d66e6 100644 --- a/rmgpy/data/kinetics/family.py +++ b/rmgpy/data/kinetics/family.py @@ -743,7 +743,7 @@ def saveEntry(self, f, entry): """ return saveEntry(f, entry) - def saveTrainingReactions(self, reactions, reference=None, referenceType='', shortDesc='', rank=3): + def saveTrainingReactions(self, reactions, reference='', referenceType='', shortDesc='', rank=3): """ This function takes a list of reactions appends it to the training reactions file. It ignores the existence of duplicate reactions. @@ -754,6 +754,15 @@ def saveTrainingReactions(self, reactions, reference=None, referenceType='', sho For each entry, the long description is imported from the kinetics comment. """ from rmgpy import settings + + if not isinstance(reference,list): + reference = [reference]*len(reactions) + if not isinstance(referenceType,list): + referenceType = [referenceType]*len(reactions) + if not isinstance(shortDesc,list): + shortDesc = [shortDesc]*len(reactions) + if not isinstance(rank,list): + rank = [rank]*len(reactions) training_path = os.path.join(settings['database.directory'], 'kinetics', 'families', \ self.label, 'training') @@ -822,11 +831,11 @@ def saveTrainingReactions(self, reactions, reference=None, referenceType='', sho label = str(reaction), item = reaction, data = reaction.kinetics, - reference = reference, - referenceType = referenceType, - shortDesc = unicode(shortDesc), + reference = reference[i], + referenceType = referenceType[i], + shortDesc = unicode(shortDesc[i]), longDesc = unicode(longDesc), - rank = rank, + rank = rank[i], ) self.saveEntry(training_file, entry) From 571a966073cd5d19bc2807eeb0fb8ff6a77270f4 Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Sat, 19 May 2018 18:00:58 -0400 Subject: [PATCH 2/2] prevent undesired default behavior --- rmgpy/data/kinetics/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rmgpy/data/kinetics/common.py b/rmgpy/data/kinetics/common.py index 9af9a296af..e487b73a55 100644 --- a/rmgpy/data/kinetics/common.py +++ b/rmgpy/data/kinetics/common.py @@ -115,7 +115,7 @@ def sortEfficiencies(efficiencies0): f.write(' kinetics = None,\n') # Write reference - if entry.reference is not None: + if entry.reference is not None and entry.reference != '': reference = entry.reference.toPrettyRepr() lines = reference.splitlines() f.write(' reference = {0}\n'.format(lines[0]))