summaryrefslogtreecommitdiff
path: root/lib/qmrf-report.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/qmrf-report.rb')
-rw-r--r--lib/qmrf-report.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/qmrf-report.rb b/lib/qmrf-report.rb
index 3ec1fdd..a83bf6d 100644
--- a/lib/qmrf-report.rb
+++ b/lib/qmrf-report.rb
@@ -11,6 +11,7 @@ module OpenTox
# require "qsar-report"
# report = OpenTox::QMRFReport.new
# report.value "QSAR_title", "My QSAR Title"
+ # report.change_attributes "training_set_data", {:inchi => "Yes", :smiles => "Yes"}
# report.change_catalog :publications_catalog, :publications_catalog_1, {:title => "MyName M (2016) My Publication Title, QSAR News, 10, 14-22", :url => "http://myqsarnewsmag.dom"}
# report.ref_catalog :bibliography, :publications_catalog, :publications_catalog_1
# puts report.to_xml
@@ -20,6 +21,8 @@ module OpenTox
SCHEMA_FILE = File.join(File.dirname(__FILE__),"template/qmrf.xsd")
# QMRF XML Template file
TEMPLATE_FILE = File.join(File.dirname(__FILE__),"template/qmrf.xml")
+ # QMRF XML tags with attributes to edit
+ ATTRIBUTE_TAGS = ["training_set_availability", "training_set_data", "training_set_descriptors", "dependent_var_availability", "validation_set_availability", "validation_set_data", "validation_set_descriptors", "validation_dependent_var_availability"]
attr_accessor :xml, :report
@@ -55,6 +58,21 @@ module OpenTox
t.content
end
+ # Set attributes of an report XML tag
+ # e.G.: <training_set_data cas="Yes" chapter="6.2" chemname="Yes" formula="Yes" help="" inchi="Yes" mol="Yes" name="Available information for the training set" smiles="Yes"/>
+ #@example change_attributes
+ # report.change_attributes "training_set_data", {:inchi => "Yes", :smiles => "Yes"}
+ # @param [String] key Nodename e.g.: "training_set_data"
+ # @param [Hash] valuehash Key-Value Hash of tag attributes to change.
+ # @return [Error] returns Error message if fails
+ def change_attributes tagname, valuehash
+ raise "Can not edit the attributes of tag: #{tagname}." unless ATTRIBUTE_TAGS.include? tagname
+ tag = @report.at_css tagname
+ valuehash.each do |key, value|
+ tag.attributes["#{key}"].value = value
+ end
+ end
+
# Change a catalog
# @param [String] catalog Name of the catalog - One of "software_catalog", "algorithms_catalog", "descriptors_catalog", "endpoints_catalog", "publications_catalog", "authors_catalog" in QMRF v1.3
# @param [String] id Single entry node in the catalog e.G.: "<software contact='mycontact@mydomain.dom' description="My QSAR Software " id="software_catalog_2" name="MySoftware" number="" url="https://mydomain.dom"/>