def script_wizard(self, script='new', output_directory='./'): """ The script_wizard is designed to build a Dragon script file. The name and the functionality of this function is the same as available Script wizard in the Dragon Graphic User Interface. Note: All reported nodes are mandatory, except the <EXTERNAL> tag Note: Script for version 7 doesn't support fingerprints block Parameters ---------- script : string, optional (default="new") If "new" start creating a new script from scratch. If you want to load an existing script, pass the filename with drs format. output_directory : string, optional (default = './') the path to the working directory to store output files. dragon : xml element Dragon script in xml format. drs : string Dragon script file name data_path : string The path+name of saved data file in any format. If saveType is 'block' or 'subblock' data_path is just the path to the directory that all data files have been saved. """ self.output_directory = output_directory if not os.path.exists(self.output_directory): os.makedirs(self.output_directory) if script == 'new': if self.version == 6: self.dragon = objectify.Element( "DRAGON", version="%i.0.0" % self.version, script_version="1", generation_date=std_datetime_str('date').replace('-', '/')) OPTIONS = objectify.SubElement(self.dragon, "OPTIONS") OPTIONS.append( objectify.Element("CheckUpdates", value=bool_formatter(self.CheckUpdates))) OPTIONS.append( objectify.Element("SaveLayout", value=bool_formatter(self.SaveLayout))) OPTIONS.append( objectify.Element("ShowWorksheet", value=bool_formatter( self.ShowWorksheet))) OPTIONS.append( objectify.Element("Decimal_Separator", value=self.Decimal_Separator)) OPTIONS.append( objectify.Element("Missing_String", value=self.Missing_String)) OPTIONS.append( objectify.Element("DefaultMolFormat", value=self.DefaultMolFormat)) OPTIONS.append( objectify.Element("HelpBrowser", value=self.HelpBrowser)) OPTIONS.append( objectify.Element("RejectUnusualValence", value=bool_formatter( self.RejectUnusualValence))) OPTIONS.append( objectify.Element("Add2DHydrogens", value=bool_formatter( self.Add2DHydrogens))) OPTIONS.append( objectify.Element("MaxSRforAllCircuit", value=self.MaxSRforAllCircuit)) OPTIONS.append(objectify.Element("MaxSR", value=self.MaxSR)) OPTIONS.append( objectify.Element("MaxSRDetour", value=self.MaxSRDetour)) OPTIONS.append( objectify.Element("MaxAtomWalkPath", value=self.MaxAtomWalkPath)) OPTIONS.append( objectify.Element("LogPathWalk", value=bool_formatter(self.LogPathWalk))) OPTIONS.append( objectify.Element("LogEdge", value=bool_formatter(self.LogEdge))) Weights = objectify.SubElement(OPTIONS, "Weights") for weight in self.Weights: if weight not in [ "Mass", "VdWVolume", "Electronegativity", "Polarizability", "Ionization", "I-State" ]: msg = "'%s' is not a valid weight type." % weight raise ValueError(msg) Weights.append(objectify.Element('weight', name=weight)) OPTIONS.append( objectify.Element("SaveOnlyData", value=bool_formatter(self.SaveOnlyData))) OPTIONS.append( objectify.Element("SaveLabelsOnSeparateFile", value=bool_formatter( self.SaveLabelsOnSeparateFile))) OPTIONS.append( objectify.Element("SaveFormatBlock", value=self.SaveFormatBlock)) OPTIONS.append( objectify.Element("SaveFormatSubBlock", value=self.SaveFormatSubBlock)) OPTIONS.append( objectify.Element("SaveExcludeMisVal", value=bool_formatter( self.SaveExcludeMisVal))) OPTIONS.append( objectify.Element("SaveExcludeAllMisVal", value=bool_formatter( self.SaveExcludeAllMisVal))) OPTIONS.append( objectify.Element("SaveExcludeConst", value=bool_formatter( self.SaveExcludeConst))) OPTIONS.append( objectify.Element("SaveExcludeNearConst", value=bool_formatter( self.SaveExcludeNearConst))) OPTIONS.append( objectify.Element("SaveExcludeStdDev", value=bool_formatter( self.SaveExcludeStdDev))) OPTIONS.append( objectify.Element("SaveStdDevThreshold", value=self.SaveStdDevThreshold)) OPTIONS.append( objectify.Element("SaveExcludeCorrelated", value=bool_formatter( self.SaveExcludeCorrelated))) OPTIONS.append( objectify.Element("SaveCorrThreshold", value=self.SaveCorrThreshold)) OPTIONS.append( objectify.Element( "SaveExclusionOptionsToVariables", value=bool_formatter( self.SaveExclusionOptionsToVariables))) OPTIONS.append( objectify.Element("SaveExcludeMisMolecules", value=bool_formatter( self.SaveExcludeMisMolecules))) OPTIONS.append( objectify.Element("SaveExcludeRejectedMolecules", value=bool_formatter( self.SaveExcludeRejectedMolecules))) DESCRIPTORS = objectify.SubElement(self.dragon, "DESCRIPTORS") for i in self.blocks: if i < 1 or i > 29: msg = "block id must be in range 1 to 29." raise ValueError(msg) DESCRIPTORS.append( objectify.Element('block', id="%i" % i, SelectAll="true")) MOLFILES = objectify.SubElement(self.dragon, "MOLFILES") MOLFILES.append( objectify.Element("molInput", value=self.molInput)) # if self.molInput == "stdin": # if self.molInputFormat not in ['SYBYL', 'MDL', 'HYPERCHEM', 'SMILES', 'MACROMODEL']: # msg = "'%s' is not a valid molInputFormat. Formats:['SYBYL','MDL','HYPERCHEM','SMILES','MACROMODEL']" % self.molInputFormat # raise ValueError(msg) # MOLFILES.append(objectify.Element("molInputFormat", value=self.molInputFormat)) if self.molInput == "file": if isinstance(self.molFile, dict): for f in range(1, len(self.molFile) + 1): MOLFILES.append( objectify.Element( "molFile", value=self.molFile[f]['file'])) elif isinstance(self.molFile, str): MOLFILES.append( objectify.Element("molFile", value=self.molFile)) else: msg = 'Variable molInput can be either a string or a list' raise ValueError(msg) else: msg = "The molInput value must be 'file'. 'stdin' is not supported through ChemML" raise ValueError(msg) OUTPUT = objectify.SubElement(self.dragon, "OUTPUT") OUTPUT.append( objectify.Element("SaveStdOut", value=bool_formatter(self.SaveStdOut))) OUTPUT.append( objectify.Element("SaveProject", value=bool_formatter(self.SaveProject))) if self.SaveProject: OUTPUT.append( objectify.Element("SaveProjectFile", value=self.SaveProjectFile)) OUTPUT.append( objectify.Element("SaveFile", value=bool_formatter(self.SaveFile))) if self.SaveFile: OUTPUT.append( objectify.Element("SaveType", value=self.SaveType) ) # value = "[singlefile/block/subblock]" OUTPUT.append( objectify.Element("SaveFilePath", value=self.output_directory + self.SaveFilePath) ) #Specifies the file name for saving results as a plan text file(s), if the "singlefile" option is set; if "block" or "subblock" are set, specifies the path in which results files will be saved. OUTPUT.append(objectify.Element( "logMode", value=self.logMode)) # value = [none/stderr/file] if self.logMode == "file": OUTPUT.append( objectify.Element("logFile", value=self.output_directory + self.logFile)) if self.external: EXTERNAL = objectify.SubElement(self.dragon, "EXTERNAL") EXTERNAL.append( objectify.Element("fileName", value=self.fileName)) EXTERNAL.append( objectify.Element("delimiter", value=self.delimiter)) EXTERNAL.append( objectify.Element("consecutiveDelimiter", value=bool_formatter( self.consecutiveDelimiter))) EXTERNAL.append( objectify.Element("MissingValue", value=self.MissingValue)) self._save_script() elif self.version == 7: self.dragon = objectify.Element( "DRAGON", version="%i.0.0" % self.version, description="Dragon7 - FP1 - MD5270", script_version="1", generation_date=std_datetime_str('date').replace('-', '/')) OPTIONS = objectify.SubElement(self.dragon, "OPTIONS") OPTIONS.append( objectify.Element("CheckUpdates", value=bool_formatter(self.CheckUpdates))) OPTIONS.append( objectify.Element("PreserveTemporaryProjects", value=bool_formatter( self.PreserveTemporaryProjects))) OPTIONS.append( objectify.Element("SaveLayout", value=bool_formatter(self.SaveLayout))) # OPTIONS.append(objectify.Element("ShowWorksheet", value = bool_formatter(self.ShowWorksheet))) OPTIONS.append( objectify.Element("Decimal_Separator", value=self.Decimal_Separator)) if self.Missing_String == "NaN": self.Missing_String = "na" OPTIONS.append( objectify.Element("Missing_String", value=self.Missing_String)) OPTIONS.append( objectify.Element("DefaultMolFormat", value=self.DefaultMolFormat)) # OPTIONS.append(objectify.Element("HelpBrowser", value = self.HelpBrowser)) OPTIONS.append( objectify.Element("RejectDisconnectedStrucuture", value=bool_formatter( self.RejectDisconnectedStrucuture))) OPTIONS.append( objectify.Element("RetainBiggestFragment", value=bool_formatter( self.RetainBiggestFragment))) OPTIONS.append( objectify.Element("RejectUnusualValence", value=bool_formatter( self.RejectUnusualValence))) OPTIONS.append( objectify.Element("Add2DHydrogens", value=bool_formatter( self.Add2DHydrogens))) OPTIONS.append( objectify.Element( "DisconnectedCalculationOption", value=self.DisconnectedCalculationOption)) OPTIONS.append( objectify.Element("MaxSRforAllCircuit", value=self.MaxSRforAllCircuit)) # OPTIONS.appendm(objectify.Element("MaxSR", value = self.MaxSR)) OPTIONS.append( objectify.Element("MaxSRDetour", value=self.MaxSRDetour)) OPTIONS.append( objectify.Element("MaxAtomWalkPath", value=self.MaxAtomWalkPath)) OPTIONS.append( objectify.Element("RoundCoordinates", value=bool_formatter( self.RoundCoordinates))) OPTIONS.append( objectify.Element("RoundWeights", value=bool_formatter(self.RoundWeights))) OPTIONS.append( objectify.Element("LogPathWalk", value=bool_formatter(self.LogPathWalk))) OPTIONS.append( objectify.Element("LogEdge", value=bool_formatter(self.LogEdge))) Weights = objectify.SubElement(OPTIONS, "Weights") for weight in self.Weights: if weight not in [ "Mass", "VdWVolume", "Electronegativity", "Polarizability", "Ionization", "I-State" ]: msg = "'%s' is not a valid weight type." % weight raise ValueError(msg) Weights.append(objectify.Element('weight', name=weight)) OPTIONS.append( objectify.Element("SaveOnlyData", value=bool_formatter(self.SaveOnlyData))) OPTIONS.append( objectify.Element("SaveLabelsOnSeparateFile", value=bool_formatter( self.SaveLabelsOnSeparateFile))) OPTIONS.append( objectify.Element("SaveFormatBlock", value=self.SaveFormatBlock)) OPTIONS.append( objectify.Element("SaveFormatSubBlock", value=self.SaveFormatSubBlock)) OPTIONS.append( objectify.Element("SaveExcludeMisVal", value=bool_formatter( self.SaveExcludeMisVal))) OPTIONS.append( objectify.Element("SaveExcludeAllMisVal", value=bool_formatter( self.SaveExcludeAllMisVal))) OPTIONS.append( objectify.Element("SaveExcludeConst", value=bool_formatter( self.SaveExcludeConst))) OPTIONS.append( objectify.Element("SaveExcludeNearConst", value=bool_formatter( self.SaveExcludeNearConst))) OPTIONS.append( objectify.Element("SaveExcludeStdDev", value=bool_formatter( self.SaveExcludeStdDev))) OPTIONS.append( objectify.Element("SaveStdDevThreshold", value=self.SaveStdDevThreshold)) OPTIONS.append( objectify.Element("SaveExcludeCorrelated", value=bool_formatter( self.SaveExcludeCorrelated))) OPTIONS.append( objectify.Element("SaveCorrThreshold", value=self.SaveCorrThreshold)) OPTIONS.append( objectify.Element( "SaveExclusionOptionsToVariables", value=bool_formatter( self.SaveExclusionOptionsToVariables))) OPTIONS.append( objectify.Element("SaveExcludeMisMolecules", value=bool_formatter( self.SaveExcludeMisMolecules))) OPTIONS.append( objectify.Element("SaveExcludeRejectedMolecules", value=bool_formatter( self.SaveExcludeRejectedMolecules))) OPTIONS.append( objectify.Element("RoundDescriptorValues", value=bool_formatter( self.RoundDescriptorValues))) DESCRIPTORS = objectify.SubElement(self.dragon, "DESCRIPTORS") for i in self.blocks: if i < 1 or i > 30: msg = "block id must be in range 1 to 30." raise ValueError(msg) DESCRIPTORS.append( objectify.Element('block', id="%i" % i, SelectAll="true")) MOLFILES = objectify.SubElement(self.dragon, "MOLFILES") MOLFILES.append( objectify.Element("molInput", value=self.molInput)) # if self.molInput == "stdin": # if self.molInputFormat not in [ # 'SYBYL', 'MDL', 'HYPERCHEM', 'SMILES', 'CML', 'MACROMODEL' # ]: # msg = "'%s' is not a valid molInputFormat. Formats:['SYBYL','MDL','HYPERCHEM','SMILES','CML','MACROMODEL']" % self.molInputFormat # raise ValueError(msg) # MOLFILES.append(objectify.Element("molInputFormat", value=self.molInputFormat)) if self.molInput == "file": if isinstance(self.molFile, dict): for f in range(1, len(self.molFile) + 1): MOLFILES.append( objectify.Element( "molFile", value=self.molFile[f]['file'])) elif isinstance(self.molFile, str): MOLFILES.append( objectify.Element("molFile", value=self.molFile)) else: msg = 'Variable molFile can be either a string or a list' raise ValueError(msg) else: msg = "The molInput value must be 'file'. 'stdin' is not supported through ChemML" raise ValueError(msg) OUTPUT = objectify.SubElement(self.dragon, "OUTPUT") OUTPUT.append( objectify.Element("knimemode", value=bool_formatter(self.knimemode))) OUTPUT.append( objectify.Element("SaveStdOut", value=bool_formatter(self.SaveStdOut))) OUTPUT.append( objectify.Element("SaveProject", value=bool_formatter(self.SaveProject))) if self.SaveProject: OUTPUT.append( objectify.Element("SaveProjectFile", value=self.SaveProjectFile)) OUTPUT.append( objectify.Element("SaveFile", value=bool_formatter(self.SaveFile))) if self.SaveFile: OUTPUT.append( objectify.Element("SaveType", value=self.SaveType) ) # value = "[singlefile/block/subblock]" OUTPUT.append( objectify.Element("SaveFilePath", value=self.output_directory + self.SaveFilePath) ) #Specifies the file name for saving results as a plan text file(s), if the "singlefile" option is set; if "block" or "subblock" are set, specifies the path in which results files will be saved. OUTPUT.append(objectify.Element( "logMode", value=self.logMode)) # value = [none/stderr/file] if self.logMode == "file": OUTPUT.append( objectify.Element("logFile", value=self.output_directory + self.logFile)) if self.external: EXTERNAL = objectify.SubElement(self.dragon, "EXTERNAL") EXTERNAL.append( objectify.Element("fileName", value=self.fileName)) EXTERNAL.append( objectify.Element("delimiter", value=self.delimiter)) EXTERNAL.append( objectify.Element("consecutiveDelimiter", value=bool_formatter( self.consecutiveDelimiter))) EXTERNAL.append( objectify.Element("MissingValue", value=self.MissingValue)) self._save_script() else: doc = etree.parse(script) self.dragon = etree.tostring(doc) # dragon script : dragon self.dragon = objectify.fromstring(self.dragon) objectify.deannotate(self.dragon) etree.cleanup_namespaces(self.dragon) if self.dragon.attrib['version'][0] not in ['6', '7']: msg = "Dragon script is not labeled to the newest vesions of Dragon, 6 or 7. This may causes some problems." warnings.warn(msg, RuntimeWarning) mandatory_nodes = ['OPTIONS', 'DESCRIPTORS', 'MOLFILES', 'OUTPUT'] reported_nodes = [ element.tag for element in self.dragon.iterchildren() ] if not set(reported_nodes).issuperset(set(mandatory_nodes)): msg = "Dragon script doesn't contain all required nodes, which are:%s" % str( mandatory_nodes) raise ValueError(msg) self.drs = script self.data_path = self.dragon.OUTPUT.SaveFilePath.attrib['value'] return self
def test_bool_formatter(): bf_true = bool_formatter(True) bf_false = bool_formatter(False) assert bf_true == 'true' assert bf_false == 'false'
def test_bool_formatter_exception(): with pytest.raises(ValueError): bool_formatter('true')
def _script_wizard(self, input_mol_list, input_mol_type): """ The script_wizard is designed to build a Dragon script file. The name and the functionality of this function is the same as available Script wizard in the Dragon Graphic User Interface. Note: All reported nodes are mandatory, except the <EXTERNAL> tag Note: Script for version 7 doesn't support fingerprints block Parameters ---------- input_mol_list : list if SMILES, list contains only 1 element -- path to one SMILES file if mol2, list of '.mol2' file paths input_mol_type: str Input molecule type: either 'mol2' or 'smiles' output_directory : string, optional (default = './') the path to the working directory to store output files. """ self.dragon = objectify.Element( "DRAGON", version="%i.0.0" % self.version, description="Dragon7 - FP1 - MD5270", script_version="1", generation_date=std_datetime_str('date').replace('-', '/')) OPTIONS = objectify.SubElement(self.dragon, "OPTIONS") OPTIONS.append( objectify.Element("CheckUpdates", value=bool_formatter(self.CheckUpdates))) OPTIONS.append( objectify.Element("PreserveTemporaryProjects", value=bool_formatter( self.PreserveTemporaryProjects))) OPTIONS.append( objectify.Element("SaveLayout", value=bool_formatter(self.SaveLayout))) # OPTIONS.append(objectify.Element("ShowWorksheet", value = bool_formatter(self.ShowWorksheet))) OPTIONS.append( objectify.Element("Decimal_Separator", value=self.Decimal_Separator)) if self.Missing_String == "NaN": self.Missing_String = "na" OPTIONS.append( objectify.Element("Missing_String", value=self.Missing_String)) OPTIONS.append( objectify.Element("DefaultMolFormat", value=self.DefaultMolFormat)) # OPTIONS.append(objectify.Element("HelpBrowser", value = self.HelpBrowser)) OPTIONS.append( objectify.Element("RejectDisconnectedStrucuture", value=bool_formatter( self.RejectDisconnectedStrucuture))) OPTIONS.append( objectify.Element("RetainBiggestFragment", value=bool_formatter( self.RetainBiggestFragment))) OPTIONS.append( objectify.Element("RejectUnusualValence", value=bool_formatter(self.RejectUnusualValence))) OPTIONS.append( objectify.Element("Add2DHydrogens", value=bool_formatter(self.Add2DHydrogens))) OPTIONS.append( objectify.Element("DisconnectedCalculationOption", value=self.DisconnectedCalculationOption)) OPTIONS.append( objectify.Element("MaxSRforAllCircuit", value=self.MaxSRforAllCircuit)) # OPTIONS.appendm(objectify.Element("MaxSR", value = self.MaxSR)) OPTIONS.append(objectify.Element("MaxSRDetour", value=self.MaxSRDetour)) OPTIONS.append( objectify.Element("MaxAtomWalkPath", value=self.MaxAtomWalkPath)) OPTIONS.append( objectify.Element("RoundCoordinates", value=bool_formatter(self.RoundCoordinates))) OPTIONS.append( objectify.Element("RoundWeights", value=bool_formatter(self.RoundWeights))) OPTIONS.append( objectify.Element("LogPathWalk", value=bool_formatter(self.LogPathWalk))) OPTIONS.append( objectify.Element("LogEdge", value=bool_formatter(self.LogEdge))) Weights = objectify.SubElement(OPTIONS, "Weights") for weight in self.Weights: if weight not in [ "Mass", "VdWVolume", "Electronegativity", "Polarizability", "Ionization", "I-State" ]: msg = "'%s' is not a valid weight type." % weight raise ValueError(msg) Weights.append(objectify.Element('weight', name=weight)) OPTIONS.append( objectify.Element("SaveOnlyData", value=bool_formatter(self.SaveOnlyData))) OPTIONS.append( objectify.Element("SaveLabelsOnSeparateFile", value=bool_formatter( self.SaveLabelsOnSeparateFile))) OPTIONS.append( objectify.Element("SaveFormatBlock", value=self.SaveFormatBlock)) OPTIONS.append( objectify.Element("SaveFormatSubBlock", value=self.SaveFormatSubBlock)) OPTIONS.append( objectify.Element("SaveExcludeMisVal", value=bool_formatter(self.SaveExcludeMisVal))) OPTIONS.append( objectify.Element("SaveExcludeAllMisVal", value=bool_formatter(self.SaveExcludeAllMisVal))) OPTIONS.append( objectify.Element("SaveExcludeConst", value=bool_formatter(self.SaveExcludeConst))) OPTIONS.append( objectify.Element("SaveExcludeNearConst", value=bool_formatter(self.SaveExcludeNearConst))) OPTIONS.append( objectify.Element("SaveExcludeStdDev", value=bool_formatter(self.SaveExcludeStdDev))) OPTIONS.append( objectify.Element("SaveStdDevThreshold", value=self.SaveStdDevThreshold)) OPTIONS.append( objectify.Element("SaveExcludeCorrelated", value=bool_formatter( self.SaveExcludeCorrelated))) OPTIONS.append( objectify.Element("SaveCorrThreshold", value=self.SaveCorrThreshold)) OPTIONS.append( objectify.Element("SaveExclusionOptionsToVariables", value=bool_formatter( self.SaveExclusionOptionsToVariables))) OPTIONS.append( objectify.Element("SaveExcludeMisMolecules", value=bool_formatter( self.SaveExcludeMisMolecules))) OPTIONS.append( objectify.Element("SaveExcludeRejectedMolecules", value=bool_formatter( self.SaveExcludeRejectedMolecules))) OPTIONS.append( objectify.Element("RoundDescriptorValues", value=bool_formatter( self.RoundDescriptorValues))) DESCRIPTORS = objectify.SubElement(self.dragon, "DESCRIPTORS") for i in self.blocks: if i < 1 or i > 30: msg = "block id must be in range 1 to 30." raise ValueError(msg) DESCRIPTORS.append( objectify.Element('block', id="%i" % i, SelectAll="true")) MOLFILES = objectify.SubElement(self.dragon, "MOLFILES") MOLFILES.append(objectify.Element("molInput", value="file")) # if self.molInput == "stdin": # if self.molInputFormat not in [ # 'SYBYL', 'MDL', 'HYPERCHEM', 'SMILES', 'CML', 'MACROMODEL' # ]: # msg = "'%s' is not a valid molInputFormat. Formats:['SYBYL','MDL','HYPERCHEM','SMILES','CML','MACROMODEL']" % self.molInputFormat # raise ValueError(msg) # MOLFILES.append(objectify.Element("molInputFormat", value=self.molInputFormat)) if input_mol_type == 'mol2': for mol2 in input_mol_list: MOLFILES.append(objectify.Element("molFile", value=mol2)) else: MOLFILES.append( objectify.Element("molFile", value=input_mol_list[0])) # if isinstance(self.molFile, dict): # for f in range(1, len(self.molFile) + 1): # if os.path.exists(self.molFile[f]['file']): # MOLFILES.append(objectify.Element("molFile", value=self.molFile[f]['file'])) # else: # msg = "file not found at "+ self.molFile[f]['file'] # raise FileNotFoundError(msg) # elif isinstance(self.molFile, str): # MOLFILES.append(objectify.Element("molFile", value=self.molFile)) # else: # msg = 'Variable molFile can be either a string or a list' # raise ValueError(msg) OUTPUT = objectify.SubElement(self.dragon, "OUTPUT") OUTPUT.append( objectify.Element("knimemode", value=bool_formatter(self.knimemode))) OUTPUT.append( objectify.Element("SaveStdOut", value=bool_formatter(self.SaveStdOut))) OUTPUT.append( objectify.Element("SaveProject", value=bool_formatter(self.SaveProject))) if self.SaveProject: OUTPUT.append( objectify.Element("SaveProjectFile", value=self.SaveProjectFile)) OUTPUT.append( objectify.Element("SaveFile", value=bool_formatter(self.SaveFile))) if self.SaveFile: OUTPUT.append(objectify.Element( "SaveType", value=self.SaveType)) # value = "[singlefile/block/subblock]" OUTPUT.append( objectify.Element("SaveFilePath", value=self.output_directory + self.SaveFilePath) ) #Specifies the file name for saving results as a plan text file(s), if the "singlefile" option is set; if "block" or "subblock" are set, specifies the path in which results files will be saved. OUTPUT.append(objectify.Element( "logMode", value=self.logMode)) # value = [none/stderr/file] if self.logMode == "file": OUTPUT.append( objectify.Element("logFile", value=self.output_directory + self.logFile)) if self.external: EXTERNAL = objectify.SubElement(self.dragon, "EXTERNAL") EXTERNAL.append(objectify.Element("fileName", value=self.fileName)) EXTERNAL.append( objectify.Element("delimiter", value=self.delimiter)) EXTERNAL.append( objectify.Element("consecutiveDelimiter", value=bool_formatter( self.consecutiveDelimiter))) EXTERNAL.append( objectify.Element("MissingValue", value=self.MissingValue)) # objectify.deannotate(self.dragon) etree.cleanup_namespaces(self.dragon) self.drs_name = 'Dragon_script.drs' with open(os.path.join(self.output_directory, self.drs_name), 'w') as outfile: outfile.write( etree.tostring(self.dragon, pretty_print=True).decode()) self.data_path = self.dragon.OUTPUT.SaveFilePath.attrib['value'] return self