summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrautenberg <rautenberg@in-silico.ch>2016-08-23 18:28:57 +0200
committerrautenberg <rautenberg@in-silico.ch>2016-08-23 18:28:57 +0200
commit0ebf1ea8978344ec5f69e081e3ee7c8ff41602c2 (patch)
tree01b9881af66336e41198eb1e111bf7a30723ebdf
parentc8adcd3fb21de20c5d66bf069e8a11b41eeaaceb (diff)
Add QPRF reporting and change name to qsar-report
-rw-r--r--.yardopts2
-rw-r--r--ChangeLog3
-rw-r--r--Gemfile4
-rw-r--r--README.md51
-rw-r--r--VERSION2
-rw-r--r--lib/qmrf-report.rb22
-rw-r--r--lib/qprf-report.rb92
-rw-r--r--lib/qsar-report.rb6
-rw-r--r--lib/template/qprf.haml25
-rw-r--r--lib/template/qprf.json198
-rw-r--r--qsar-report.gemspec (renamed from qmrf-report.gemspec)12
-rw-r--r--test/all.rb3
-rw-r--r--test/data/qprf-t6.json197
-rw-r--r--test/qmrf-report.rb (renamed from test/report.rb)20
-rw-r--r--test/qprf-report.rb52
-rw-r--r--test/setup.rb3
16 files changed, 648 insertions, 44 deletions
diff --git a/.yardopts b/.yardopts
index f4a7b90..9187a58 100644
--- a/.yardopts
+++ b/.yardopts
@@ -1,4 +1,4 @@
--readme README.md
---title 'QMRF reporting class for opentox'
+--title 'QMRF reporting class for OpenTox'
--charset utf-8
yardoc lib/*.rb - README.md ChangeLog VERSION LICENSE
diff --git a/ChangeLog b/ChangeLog
index 7b71772..99778df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+v0.0.2
+* add QPRF reporting
+* rename gem qmrf-report to qsar-report
v0.0.1
* initial version
diff --git a/Gemfile b/Gemfile
index 6109aa6..a5ba459 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,3 +1,5 @@
source "https://rubygems.org"
gemspec
-gem "nokogiri" \ No newline at end of file
+gem "nokogiri"
+gem "haml"
+gem "json" \ No newline at end of file
diff --git a/README.md b/README.md
index 655a8d4..1b71cbc 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,18 @@
-# lazar-report
-QMRF reporting extension to OpenTox ruby modules and lazar
+# QSAR-Report
+QMRF and QPRF reporting extension to OpenTox ruby modules and lazar
## About
-Class for QMRF reporting.
-Provides a ruby OpenTox class to prepare an initial version of a QMRF report.
-The XML output is in QMRF version 1.3 and can be finalized with the QMRF editor 2.0 (https://sourceforge.net/projects/qmrf/)
-
-
+Class for QMRF and QPRF reporting.
+* QMRF:
+ Provides a ruby OpenTox class to prepare an initial version of a QMRF report.
+ The XML output is in QMRF version 1.3 and can be finalized with the QMRF editor 2.0 (https://sourceforge.net/projects/qmrf/)
+* QPRF:
+ Provides a ruby OpenTox class to prepare an initial version of a QPRF report in JSON or HTML.
## Usage
-create a new report, add some content and show output:
-```ruby
-require "qmrf-report"
+### QMRF
+create a new QMRF report, add some content and show output:
+```ruby
+require "qsar-report"
# create a new report
report = OpenTox::QMRFReport.new
@@ -30,3 +32,32 @@ puts report.to_xml
# validate a report (as created above) against qmrf.xsd
report.validate
```
+### QPRF
+create a new QPRF report, add some content and show output:
+```ruby
+require "qsar-report"
+
+# create a new QPRF report instance
+report = OpenTox::QPRFReport.new
+
+# Set Title of the report
+report.Title = "My QPRF Report"
+
+# Set Version
+report.Version = "1"
+
+# Set Date
+report.Date = Time.now.strftime("%Y/%m/%d")
+
+# Set the CAS number in chapter 1.1
+report.Value "1.1", "7732-18-5" # set CAS number for H²O
+
+# print HTML version
+puts report.to_html
+
+# print formated JSON version
+puts report.pretty_json
+
+```
+
+
diff --git a/VERSION b/VERSION
index 8a9ecc2..7bcd0e3 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.0.1 \ No newline at end of file
+0.0.2 \ No newline at end of file
diff --git a/lib/qmrf-report.rb b/lib/qmrf-report.rb
index 88c6c86..df102d9 100644
--- a/lib/qmrf-report.rb
+++ b/lib/qmrf-report.rb
@@ -8,7 +8,7 @@ module OpenTox
#Provides a ruby OpenTox class to prepare an initial version of a QMRF report.
#The XML output is in QMRF version 1.3 and can be finalized with the QMRF editor 2.0 (https://sourceforge.net/projects/qmrf/)
#@example Report
- # require "qmrf-report"
+ # require "qsar-report"
# report = OpenTox::QMRFReport.new
# report.change_qmrf_tag "QSAR_title", "My QSAR Title"
# report.change_catalog :publications_catalog, :publications_catalog_1, {:title => "MyName M (2016) My Publication Title, QSAR News, 10, 14-22", :url => "http://myqsarnewsmag.dom"}
@@ -42,15 +42,17 @@ module OpenTox
@report.to_xml
end
- # Change a value
+ # Get or Set a value
# e.G.: <QSAR_title chapter="1.1" help="" name="QSAR identifier (title)">Title of My QSAR</QSAR_title>
- # @param [String] key Name of the node
- # @param [String] value Value to change
+ # @param [String] key Nodename e.g.: "QSAR_title"
+ # @param [String] value Value to change. If not set the function returns the current value
# @return [Error] returns Error message if fails
- def change_qmrf_tag key, value
+ # @return [String] returns value
+ def Value key, value=nil
raise "Can not edit attribute #{key} directly. Edit the catalog with 'report.change_catalog(catalog, key, value)'." if ["QSAR_software","QSAR_Algorithm", ""].include? key
t = @report.at_css key
- t.content = value
+ t.content = value unless value.nil?
+ t.content
end
# Change a catalog
@@ -96,14 +98,6 @@ module OpenTox
end
end
- # get value of a QMRF node
- # @param [String] key Nodename e.g.: "QSAR_title"
- # @return [String] returns value
- def get_qmrf_tag key
- t = @report.at_css key
- t.content
- end
-
# get an attribute from a catalog entry
# @param [String] catalog Name of the catalog
# @param [String] id entry id in the catalog
diff --git a/lib/qprf-report.rb b/lib/qprf-report.rb
new file mode 100644
index 0000000..c87e12b
--- /dev/null
+++ b/lib/qprf-report.rb
@@ -0,0 +1,92 @@
+require "json"
+require "haml"
+
+# OpenTox module
+module OpenTox
+
+ #Class for QPRF reporting.
+ #
+ #Provides a ruby OpenTox class to prepare an initial version of a QPRF report.
+ #The QPRF output is in QPRF version 1.1 from May 2008
+ #@example Report
+ # require "qsar-report"
+ # report = OpenTox::QPRFReport.new
+ # report.Title = "My QPRF Report"
+ # report.Version = "1"
+ # report.Date = Time.now.strftime("%Y/%m/%d")
+ # report.Value "1.1", "7732-18-5" # set CAS number for H²O
+ # puts report.to_html
+
+ class QPRFReport
+ # QPRF JSON Template file
+ TEMPLATE_FILE = File.join(File.dirname(__FILE__),"template/qprf.json")
+
+ # QPRF MarkDown Template file
+ MD_TEMPLATE_FILE = File.join(File.dirname(__FILE__),"template/qprf.haml")
+
+ attr_accessor :json, :report
+
+ # Open an existing QPRF json report
+ # @param [String] file Name of the file
+ def open file
+ json = File.read("#{file}")
+ @report = JSON.parse(json)
+ end
+
+ # Initialize a new report instance from QPRF template. With helper functions for Title, Version and Date
+ def initialize
+ json = File.read(TEMPLATE_FILE)
+ @report = JSON.parse(json)
+
+ attr_hash = {self.report['singleCalculations'] => ["Title", "Version", "Date"] }
+ attr_hash.each_pair do |block, attributes|
+ attributes.each do |attribute|
+ define_singleton_method "#{attribute}" do
+ return block[attribute]
+ end
+ define_singleton_method "#{attribute}=" do |val=nil|
+ block[attribute] = val unless val.nil?
+ return block[attribute]
+ end
+ end
+ end
+
+ end
+
+ # Set or Get a value in the QPRF report
+ #@example for CAS Number
+ # report = OpenTox::QPRFReport.new
+ # report.Value "1.1", "7732-18-5"
+ #
+ # @param [String] chapter Name of the chapter - e.g.: "1.1", "1.2", "1.3", "1.4", "1.5 General", "1.5 a.", "1.5 b.", "1.5 c.", "1.5 d.", "2.1" ...
+ # @param [String] value Value to set. If not set the function returns the current value
+ # @return [String] returns Value
+ def Value chapter, value=nil
+ case chapter
+ when /^1\.\d*/
+ block = "1. Substance"
+ when /^2\.\d*/
+ block = "2. General information"
+ when /^3\.\d*/
+ block = "3. Prediction"
+ when /^4\.\d*/
+ block = "4. Adequacy (Optional)"
+ end
+ @report["arrayCalculations"][block]['values'][chapter][1] = value unless value.nil?
+ @report["arrayCalculations"][block]['values'][chapter][1]
+ end
+
+ # returns prettified JSON representation (QPRF JSON report) of report instance
+ # @return [String] returns JSON
+ def pretty_json
+ JSON.pretty_generate(@report)
+ end
+
+ # Creates a HTML representation of the QPRF report
+ # @return [String] returns HTML
+ def to_html
+ Haml::Engine.new(File.read(MD_TEMPLATE_FILE)).render @report
+ end
+
+ end
+end \ No newline at end of file
diff --git a/lib/qsar-report.rb b/lib/qsar-report.rb
new file mode 100644
index 0000000..9e3060e
--- /dev/null
+++ b/lib/qsar-report.rb
@@ -0,0 +1,6 @@
+
+
+[
+ "qmrf-report.rb",
+ "qprf-report.rb"
+].each{ |f| require_relative f } \ No newline at end of file
diff --git a/lib/template/qprf.haml b/lib/template/qprf.haml
new file mode 100644
index 0000000..1634a0d
--- /dev/null
+++ b/lib/template/qprf.haml
@@ -0,0 +1,25 @@
+!!!
+%html{:xmlns => "http://www.w3.org/1999/xhtml", "xml:lang" => "en", :lang => "en"}
+ %body
+ %h1= self["singleCalculations"]["Title"]
+ %p
+ = self["singleCalculations"]["Disclaimer and Instructions"]
+ %ul
+ %li
+ Date: #{self["singleCalculations"]["Date"]}
+ %li
+ Version: #{self["singleCalculations"]["Version"]}
+ - self["arrayCalculations"].each do |block|
+ %h2= block[0]
+ - block[1]["values"].each do |val|
+ - if val[0] == "General" && val[1][0] == "Instructions"
+ %p #{val[1][1]}
+ - else
+ - if val[0].match(/\d\.\d \w\./)
+ %h4
+ #{val[0]} #{val[1][0]}
+ -else
+ %h3
+ #{val[0]} #{val[1][0]}
+ %p #{val[1][1]}
+
diff --git a/lib/template/qprf.json b/lib/template/qprf.json
new file mode 100644
index 0000000..b0e3c57
--- /dev/null
+++ b/lib/template/qprf.json
@@ -0,0 +1,198 @@
+{
+ "meta": {
+ "description": "qprf report",
+ "title": "qprf report",
+ "qprf_version": "1.1",
+ "date": ""
+ },
+ "visible": true,
+ "singleCalculations": {
+ "Date": "",
+ "Disclaimer and Instructions": "Please fill in the fields of the QPRF with information about the prediction and the substance for which the prediction is made. The information that you provide will be used to facilitate considerations on the adequacy of the prediction (model result) in relation to a defined regulatory purpose. The adequacy of a prediction depends on the following conditions: a) the (Q)SAR model is scientifically valid: the scientific validity is established according to the OECD principles for (Q)SAR validation; b) the (Q)SAR model is applicable to the query chemical: a (Q)SAR is applicable if the query chemical falls within the defined applicability domain of the model; c) the (Q)SAR result is reliable: a valid (Q)SAR that is applied to a chemical falling within its applicability domain provides a reliable result; d) the (Q)SAR model is relevant for the regulatory purpose: the predicted endpoint can be used directly or following an extrapolation, possibly in combination with other information, for a particular regulatory purpose. A (Q)SAR prediction (model result) may be considered adequate if it is reliable and relevant, and depending on the totality of information available in a weight-of-evidence assessment (see Section 4 of the QPRF).",
+ "Time": "",
+ "Title": "QSAR Prediction Reporting Format (QPRF)",
+ "Version": 1
+ },
+ "arrayCalculations": {
+ "1. Substance": {
+ "colNames": [
+ "Title",
+ "Value"
+ ],
+ "values": {
+ "General": [
+ "Instructions",
+ "This section is aimed at defining the substance for which the (Q)SAR prediction is made."
+ ],
+ "1.1": [
+ "CAS number",
+ ""
+ ],
+ "1.2": [
+ "EC number",
+ "Report the EC number."
+ ],
+ "1.3": [
+ "Chemical name",
+ "Report the chemical names (IUPAC and CAS names)."
+ ],
+ "1.4": [
+ "Structural formula",
+ "Report the structural formula."
+ ],
+ "1.5 General": [
+ "Structure codes",
+ "Report available structural information for the substance, including the structure code used to run the model. If you used a SMILES or InChI code, report the code in the corresponding field below. If you have used any another format (e.g. mol file), please include the corresponding structural representation as supporting information."
+ ],
+ "1.5 a.": [
+ "SMILES",
+ "Report the SMILES of the substance (indicate if this is the one used for the model prediction)."
+ ],
+ "1.5 b.": [
+ "InChI",
+ "Report the InChI code of the substance (indicate if this is the one used for the model prediction)."
+ ],
+ "1.5 c.": [
+ "Other structural representation",
+ "Indicate if another structural representation was used to generate the prediction. Indicate whether this information is included as supporting information. Example: 'mol file used and included in the supporting information'."
+ ],
+ "1.5 d.": [
+ "Stereochemical features",
+ "Indicate whether the substance is a stereo-isomer and consequently may have properties that depend on the orientation of its atoms in space. Identify the stereochemical features that may affect the reliability of predictions for the substance, e.g. cis-trans isomerism, chiral centres. Are these features encoded in the structural representations mentioned above?"
+ ]
+ }
+ },
+ "2. General information": {
+ "colNames": [
+ "Title",
+ "Value"
+ ],
+ "values": {
+ "General": [
+ "Instructions",
+ "General information about the compilation of the current QPRF is provided in this section."
+ ],
+ "2.1": [
+ "Date of QPRF",
+ "Report the date of compilation of the QPRF. Example: “01 January 2007”."
+ ],
+ "2.2": [
+ "QPRF author and contact details",
+ "Report the contact details of the author of the QPRF."
+ ]
+ }
+ },
+ "3. Prediction": {
+ "colNames": [
+ "Title",
+ "Value"
+ ],
+ "values": {
+ "General": [
+ "Instructions",
+ "The information provided in this section will help to facilitate considerations on the scientific validity of the model (as defined in the OECD Principles for the validation of (Q)SAR models) and the reliability of the prediction. Detailed information on the model are stored in the corresponding QMRF which is devised to reflect as much as possible the OECD principles. Remember that the QMRF and the QPRF are complementary, and a QPRF should always be associated with a defined QMRF."
+ ],
+ "3.1 General": [
+ "Endpoint",
+ "(OECD Principle 1)"
+ ],
+ "3.1 a.": [
+ "Endpoint",
+ "Define the endpoint for which the model provides predictions (this information should correspond to the information provided in the QMRF under fields 3.2 and 3.3). Example: 'Nitrate radical degradation rate constant KNO3'."
+ ],
+ "3.1 b.": [
+ "Dependent variable",
+ "Report the dependent variable for which the model provides predictions including any transformations introduced for modelling purposes (note that this information should correspond to the information provided in the QMRF under field 3.5). Example: '-log (KNO3)'."
+ ],
+ "3.2 General": [
+ "Algorithm",
+ "(OECD Principle 2)"
+ ],
+ "3.2 a.": [
+ "Model or submodel name",
+ "Identify the model used to make the prediction and possibly report its name as stored in the corresponding QMRF; in the QMRF the model name is reported in the field QSAR identifier. Examples: “BIOWIN for Biodegradation”; “TOPKAT Developmental Toxicity Potential”. If applicable identify the specific submodel or algorithm applicable to the specific chemical Examples: 'BIOWIN '; 'TOPKAT Skin Irritation Acyclics (Acids, Amines, Esters) MOD v SEV Model'; 'ECOSAR esters model'."
+ ],
+ "3.2 b.": [
+ "Model version",
+ "Identify, where relevant, the version number and/or date of the model and submodel."
+ ],
+ "3.2 c.": [
+ "Reference to QMRF",
+ "Provide relevant information about the QMRF that stores information about the model used to make the prediction. Possible useful pieces of information are: availability, source, reference number (if any) of the QMRF. Examples: 'The corresponding QMRF named -BIOWIN for Biodegradation- has been downloaded from the JRC QSAR Model Database'; 'The corresponding QMRF named -TOPKAT Skin Irritation Acyclics (Acids, Amines, Esters) MOD v SEV Model- has been newly compiled'."
+ ],
+ "3.2 d.": [
+ "Predicted value (model result)",
+ "Report the predicted value (including units) obtained from the application of the model to the query chemical. For an expert system such as Derek for Windows, report the alert triggered together with the reasoning. Example: ' aromatic amine - mutagenicity, plausible'."
+ ],
+ "3.2 e.": [
+ "Predicted value (comments)",
+ "If the result is qualitative (e.g. yes/no) or semi-quantitative (e.g. low/medium/high), explain the cut-off values that were used as the basis for classification. In reporting the predicted value, pay attention to the transformations (e.g. if the prediction is made in log units, apply anti-logarithm function)."
+ ],
+ "3.2 f.": [
+ "Input for prediction",
+ "Specify what kind of input was used to generate the prediction (SMILES, mol file, graphical interface etc). Please provide the structure code used to generate the prediction (unless already provided in section 1.5)."
+ ],
+ "3.2 g.": [
+ "Descriptor values",
+ "Where appropriate, report the values (experimental or calculated data) for numerical descriptors and indicate which values were used for making the prediction."
+ ],
+ "3.3 General": [
+ "Applicability domain",
+ "(OECD principle 3)"
+ ],
+ "3.3 a.": [
+ "Domains",
+ "Discuss whether the query chemical falls in the applicability domain of the model as defined in the corresponding QMRF (section 5 of QMRF, Defining the applicability domain - OECD Principle 3). If additional software/methods were used to assess the applicability domain then they should also be documented in this section. Include a discussion about: i. descriptor domain ii. structural fragment domain (e.g., discuss whether the chemical contains fragments that are not represented in the model training set) iii. mechanism domain (discuss whether the chemical is known or considered to act according to the mechanism of action associated with the used model) iv. metabolic domain, if relevant"
+ ],
+ "3.3 b.": [
+ "Structural analogues",
+ "List the structural analogues that are present in the training or test sets, or accessible from other sources (in this case you should explain how the structural analogue was retrieved1) and why they are considered analogues). For each analogue, report the CAS number, the structural formula, the SMILES code, and the source (e.g., training set, test set or other source). For an expert system (like Derek for Windows or TOPKAT), the example compounds or structurally related analogues with their experimental data should be provided here."
+ ],
+ "3.3 c.": [
+ "Considerations on structural analogues",
+ "Discuss how predicted and experimental data for analogues support the prediction of the chemical under consideration. "
+ ],
+ "3.4": [
+ "The uncertainty of the prediction (OECD principle 4)",
+ "If possible, comment on the uncertainty of the prediction for this chemical, taking into account relevant information (e.g. variability of the experimental results). "
+ ],
+ "3.5": [
+ "The chemical and biological mechanisms according to the model underpinning the predicted result (OECD principle 5)",
+ "Discuss the mechanistic interpretation of the model prediction for this specific chemical. For an expert system based on structural alerts (e.g. Derek for Windows, OncologicTM) the rationale for the structural alert fired should be provided."
+ ]
+ }
+ },
+ "4. Adequacy (Optional)": {
+ "colNames": [
+ "Title",
+ "Value"
+ ],
+ "values": {
+ "General": [
+ "Instructions",
+ "The information provided in this section might be useful, depending on the reporting needs and formats of the regulatory framework of interest. This information aims to facilitate considerations about the adequacy of the (Q)SAR prediction (result) estimate. A (Q)SAR prediction may or may not be considered adequate ('fit-for-purpose'), depending on whether the prediction is sufficiently reliable and relevant in relation to the particular regulatory purpose. The adequacy of the prediction also depends on the availability of other information, and is determined in a weight-of-evidence assessment."
+ ],
+ "4.1": [
+ "Regulatory purpose",
+ "Explain the regulatory purpose for which the prediction described in Section 3 is being used."
+ ],
+ "4.2": [
+ "Approach for regulatory interpretation of the model result",
+ "Describe how the predicted result is going to be interpreted in light of the specific regulatory purpose (e.g. by applying an algorithm or regulatory criteria). This may involve the need to convert the units of the dependent variable (e.g. from log molar units to mg/l). It may also involve the application of another algorithm, an assessment factor, or regulatory criteria, and the use or consideration of additional information in a weight-of-evidence assessment. "
+ ],
+ "4.3": [
+ "Outcome",
+ "Report the interpretation of the model result in relation to the defined regulatory purpose."
+ ],
+ "4.4": [
+ "Conclusion",
+ "Provide an assessment of whether the final result is considered adequate for a regulatory conclusion, or whether additional information is required (and, if so, what this additional information should be)."
+ ]
+ }
+ }
+ },
+ "figures": {
+
+ },
+ "_id": ""
+}
diff --git a/qmrf-report.gemspec b/qsar-report.gemspec
index 2472dba..cda9c74 100644
--- a/qmrf-report.gemspec
+++ b/qsar-report.gemspec
@@ -1,21 +1,23 @@
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
- s.name = "qmrf-report"
+ s.name = "qsar-report"
s.version = File.read("./VERSION")
s.date = "2016-08-19"
s.authors = ["Micha Rautenberg"]
s.email = ["rautenberg@in-silico.ch"]
- s.homepage = "http://github.com/opentox/qmrf-report"
- s.summary = %q{qmrf-report}
- s.description = %q{QMRF reporting for OpenTox ruby module and Lazar Toxicology Predictions}
+ s.homepage = "http://github.com/opentox/qsar-report"
+ s.summary = %q{qsar-report}
+ s.description = %q{QMRF and QPRF reporting for OpenTox ruby module and Lazar Toxicology Predictions}
s.license = 'GPL-3'
- #s.rubyforge_project = "qmrf-report"
+ #s.rubyforge_project = "qsar-report"
s.files = `git ls-files`.split("\n")
s.required_ruby_version = '>= 2.0.0'
s.add_runtime_dependency "nokogiri"
+ s.add_runtime_dependency "haml"
+ s.add_runtime_dependency "json"
end \ No newline at end of file
diff --git a/test/all.rb b/test/all.rb
new file mode 100644
index 0000000..b8ab099
--- /dev/null
+++ b/test/all.rb
@@ -0,0 +1,3 @@
+["qmrf-report.rb","qprf-report.rb"].each do |test|
+ require_relative test
+end \ No newline at end of file
diff --git a/test/data/qprf-t6.json b/test/data/qprf-t6.json
new file mode 100644
index 0000000..46ab12d
--- /dev/null
+++ b/test/data/qprf-t6.json
@@ -0,0 +1,197 @@
+{
+ "meta": {
+ "description": "qprf report",
+ "title": "qprf report",
+ "qprf_version": "1.1",
+ "date": ""
+ },
+ "visible": true,
+ "singleCalculations": {
+ "Date": "2016/08/21",
+ "Disclaimer and Instructions": "Please fill in the fields of the QPRF with information about the prediction and the substance for which the prediction is made. The information that you provide will be used to facilitate considerations on the adequacy of the prediction (model result) in relation to a defined regulatory purpose. The adequacy of a prediction depends on the following conditions: a) the (Q)SAR model is scientifically valid: the scientific validity is established according to the OECD principles for (Q)SAR validation; b) the (Q)SAR model is applicable to the query chemical: a (Q)SAR is applicable if the query chemical falls within the defined applicability domain of the model; c) the (Q)SAR result is reliable: a valid (Q)SAR that is applied to a chemical falling within its applicability domain provides a reliable result; d) the (Q)SAR model is relevant for the regulatory purpose: the predicted endpoint can be used directly or following an extrapolation, possibly in combination with other information, for a particular regulatory purpose. A (Q)SAR prediction (model result) may be considered adequate if it is reliable and relevant, and depending on the totality of information available in a weight-of-evidence assessment (see Section 4 of the QPRF).",
+ "Time": "",
+ "Title": "My QPRF Report",
+ "Version": "2.1"
+ },
+ "arrayCalculations": {
+ "1. Substance": {
+ "colNames": [
+ "Title",
+ "Value"
+ ],
+ "values": {
+ "General": [
+ "Instructions",
+ "This section is aimed at defining the substance for which the (Q)SAR prediction is made."
+ ],
+ "1.1": [
+ "CAS number",
+ "7732-18-5"
+ ],
+ "1.2": [
+ "EC number",
+ "Report the EC number."
+ ],
+ "1.3": [
+ "Chemical name",
+ "Report the chemical names (IUPAC and CAS names)."
+ ],
+ "1.4": [
+ "Structural formula",
+ "Report the structural formula."
+ ],
+ "1.5 General": [
+ "Structure codes",
+ "Report available structural information for the substance, including the structure code used to run the model. If you used a SMILES or InChI code, report the code in the corresponding field below. If you have used any another format (e.g. mol file), please include the corresponding structural representation as supporting information."
+ ],
+ "1.5 a.": [
+ "SMILES",
+ "Report the SMILES of the substance (indicate if this is the one used for the model prediction)."
+ ],
+ "1.5 b.": [
+ "InChI",
+ "Report the InChI code of the substance (indicate if this is the one used for the model prediction)."
+ ],
+ "1.5 c.": [
+ "Other structural representation",
+ "Indicate if another structural representation was used to generate the prediction. Indicate whether this information is included as supporting information. Example: 'mol file used and included in the supporting information'."
+ ],
+ "1.5 d.": [
+ "Stereochemical features",
+ "Indicate whether the substance is a stereo-isomer and consequently may have properties that depend on the orientation of its atoms in space. Identify the stereochemical features that may affect the reliability of predictions for the substance, e.g. cis-trans isomerism, chiral centres. Are these features encoded in the structural representations mentioned above?"
+ ]
+ }
+ },
+ "2. General information": {
+ "colNames": [
+ "Title",
+ "Value"
+ ],
+ "values": {
+ "General": [
+ "Instructions",
+ "General information about the compilation of the current QPRF is provided in this section."
+ ],
+ "2.1": [
+ "Date of QPRF",
+ "Report the date of compilation of the QPRF. Example: “01 January 2007”."
+ ],
+ "2.2": [
+ "QPRF author and contact details",
+ "Report the contact details of the author of the QPRF."
+ ]
+ }
+ },
+ "3. Prediction": {
+ "colNames": [
+ "Title",
+ "Value"
+ ],
+ "values": {
+ "General": [
+ "Instructions",
+ "The information provided in this section will help to facilitate considerations on the scientific validity of the model (as defined in the OECD Principles for the validation of (Q)SAR models) and the reliability of the prediction. Detailed information on the model are stored in the corresponding QMRF which is devised to reflect as much as possible the OECD principles. Remember that the QMRF and the QPRF are complementary, and a QPRF should always be associated with a defined QMRF."
+ ],
+ "3.1 General": [
+ "Endpoint",
+ "(OECD Principle 1)"
+ ],
+ "3.1 a.": [
+ "Endpoint",
+ "Define the endpoint for which the model provides predictions (this information should correspond to the information provided in the QMRF under fields 3.2 and 3.3). Example: 'Nitrate radical degradation rate constant KNO3'."
+ ],
+ "3.1 b.": [
+ "Dependent variable",
+ "Report the dependent variable for which the model provides predictions including any transformations introduced for modelling purposes (note that this information should correspond to the information provided in the QMRF under field 3.5). Example: '-log (KNO3)'."
+ ],
+ "3.2 General": [
+ "Algorithm",
+ "(OECD Principle 2)"
+ ],
+ "3.2 a.": [
+ "Model or submodel name",
+ "Identify the model used to make the prediction and possibly report its name as stored in the corresponding QMRF; in the QMRF the model name is reported in the field QSAR identifier. Examples: “BIOWIN for Biodegradation”; “TOPKAT Developmental Toxicity Potential”. If applicable identify the specific submodel or algorithm applicable to the specific chemical Examples: 'BIOWIN '; 'TOPKAT Skin Irritation Acyclics (Acids, Amines, Esters) MOD v SEV Model'; 'ECOSAR esters model'."
+ ],
+ "3.2 b.": [
+ "Model version",
+ "Identify, where relevant, the version number and/or date of the model and submodel."
+ ],
+ "3.2 c.": [
+ "Reference to QMRF",
+ "Provide relevant information about the QMRF that stores information about the model used to make the prediction. Possible useful pieces of information are: availability, source, reference number (if any) of the QMRF. Examples: 'The corresponding QMRF named -BIOWIN for Biodegradation- has been downloaded from the JRC QSAR Model Database'; 'The corresponding QMRF named -TOPKAT Skin Irritation Acyclics (Acids, Amines, Esters) MOD v SEV Model- has been newly compiled'."
+ ],
+ "3.2 d.": [
+ "Predicted value (model result)",
+ "Report the predicted value (including units) obtained from the application of the model to the query chemical. For an expert system such as Derek for Windows, report the alert triggered together with the reasoning. Example: ' aromatic amine - mutagenicity, plausible'."
+ ],
+ "3.2 e.": [
+ "Predicted value (comments)",
+ "If the result is qualitative (e.g. yes/no) or semi-quantitative (e.g. low/medium/high), explain the cut-off values that were used as the basis for classification. In reporting the predicted value, pay attention to the transformations (e.g. if the prediction is made in log units, apply anti-logarithm function)."
+ ],
+ "3.2 f.": [
+ "Input for prediction",
+ "Specify what kind of input was used to generate the prediction (SMILES, mol file, graphical interface etc). Please provide the structure code used to generate the prediction (unless already provided in section 1.5)."
+ ],
+ "3.2 g.": [
+ "Descriptor values",
+ "Where appropriate, report the values (experimental or calculated data) for numerical descriptors and indicate which values were used for making the prediction."
+ ],
+ "3.3 General": [
+ "Applicability domain",
+ "(OECD principle 3)"
+ ],
+ "3.3 a.": [
+ "Domains",
+ "Discuss whether the query chemical falls in the applicability domain of the model as defined in the corresponding QMRF (section 5 of QMRF, Defining the applicability domain - OECD Principle 3). If additional software/methods were used to assess the applicability domain then they should also be documented in this section. Include a discussion about: i. descriptor domain ii. structural fragment domain (e.g., discuss whether the chemical contains fragments that are not represented in the model training set) iii. mechanism domain (discuss whether the chemical is known or considered to act according to the mechanism of action associated with the used model) iv. metabolic domain, if relevant"
+ ],
+ "3.3 b.": [
+ "Structural analogues",
+ "List the structural analogues that are present in the training or test sets, or accessible from other sources (in this case you should explain how the structural analogue was retrieved1) and why they are considered analogues). For each analogue, report the CAS number, the structural formula, the SMILES code, and the source (e.g., training set, test set or other source). For an expert system (like Derek for Windows or TOPKAT), the example compounds or structurally related analogues with their experimental data should be provided here."
+ ],
+ "3.3 c.": [
+ "Considerations on structural analogues",
+ "Discuss how predicted and experimental data for analogues support the prediction of the chemical under consideration. "
+ ],
+ "3.4": [
+ "The uncertainty of the prediction (OECD principle 4)",
+ "If possible, comment on the uncertainty of the prediction for this chemical, taking into account relevant information (e.g. variability of the experimental results). "
+ ],
+ "3.5": [
+ "The chemical and biological mechanisms according to the model underpinning the predicted result (OECD principle 5)",
+ "Discuss the mechanistic interpretation of the model prediction for this specific chemical. For an expert system based on structural alerts (e.g. Derek for Windows, OncologicTM) the rationale for the structural alert fired should be provided."
+ ]
+ }
+ },
+ "4. Adequacy (Optional)": {
+ "colNames": [
+ "Title",
+ "Value"
+ ],
+ "values": {
+ "General": [
+ "Instructions",
+ "The information provided in this section might be useful, depending on the reporting needs and formats of the regulatory framework of interest. This information aims to facilitate considerations about the adequacy of the (Q)SAR prediction (result) estimate. A (Q)SAR prediction may or may not be considered adequate ('fit-for-purpose'), depending on whether the prediction is sufficiently reliable and relevant in relation to the particular regulatory purpose. The adequacy of the prediction also depends on the availability of other information, and is determined in a weight-of-evidence assessment."
+ ],
+ "4.1": [
+ "Regulatory purpose",
+ "Explain the regulatory purpose for which the prediction described in Section 3 is being used."
+ ],
+ "4.2": [
+ "Approach for regulatory interpretation of the model result",
+ "Describe how the predicted result is going to be interpreted in light of the specific regulatory purpose (e.g. by applying an algorithm or regulatory criteria). This may involve the need to convert the units of the dependent variable (e.g. from log molar units to mg/l). It may also involve the application of another algorithm, an assessment factor, or regulatory criteria, and the use or consideration of additional information in a weight-of-evidence assessment. "
+ ],
+ "4.3": [
+ "Outcome",
+ "Report the interpretation of the model result in relation to the defined regulatory purpose."
+ ],
+ "4.4": [
+ "Conclusion",
+ "Provide an assessment of whether the final result is considered adequate for a regulatory conclusion, or whether additional information is required (and, if so, what this additional information should be)."
+ ]
+ }
+ }
+ },
+ "figures": {
+ },
+ "_id": ""
+} \ No newline at end of file
diff --git a/test/report.rb b/test/qmrf-report.rb
index b9a6c54..0dacd7f 100644
--- a/test/report.rb
+++ b/test/qmrf-report.rb
@@ -3,7 +3,7 @@ require_relative "setup.rb"
class QMRFReportTest < MiniTest::Test
def test_0_self
- puts "MiniTest start OK"
+ puts "MiniTest #{self.class} start OK"
end
def test_1_base
@@ -19,17 +19,17 @@ class QMRFReportTest < MiniTest::Test
def test_3_write_some_values
report = OpenTox::QMRFReport.new
- report.change_qmrf_tag "QSAR_title", "My QSAR Title"
- report.change_qmrf_tag "QSAR_models", "My QSAR Model"
- assert_equal report.get_qmrf_tag("QSAR_title"), "My QSAR Title"
- assert_equal report.get_qmrf_tag("QSAR_models"), "My QSAR Model"
- refute_equal report.get_qmrf_tag("QSAR_title"), "lazar"
+ report.Value "QSAR_title", "My QSAR Title"
+ report.Value "QSAR_models", "My QSAR Model"
+ assert_equal report.Value("QSAR_title"), "My QSAR Title"
+ assert_equal report.Value("QSAR_models"), "My QSAR Model"
+ refute_equal report.Value("QSAR_title"), "lazar"
end
def test_4_write_check
report = OpenTox::QMRFReport.new
- report.change_qmrf_tag "QSAR_title", "My QSAR Title"
- report.change_qmrf_tag "QSAR_models", "My QSAR Model"
+ report.Value "QSAR_title", "My QSAR Title"
+ report.Value "QSAR_models", "My QSAR Model"
assert_equal report.to_xml, File.read(File.join(File.join(DATA_DIR, "qmrf_t4.xml")))
end
@@ -52,8 +52,8 @@ class QMRFReportTest < MiniTest::Test
def test_7_write_alot
report = OpenTox::QMRFReport.new
- report.change_qmrf_tag "QSAR_title", "My QSAR Title"
- report.change_qmrf_tag "QSAR_models", "My QSAR Model"
+ report.Value "QSAR_title", "My QSAR Title"
+ report.Value "QSAR_models", "My QSAR Model"
report.change_catalog :software_catalog, :firstsoftware, {:name => "lazar", :contact => "in-silico toxicology gmbh", :url => "https://lazar.in-silico.ch", :description => "lazar toxicity predictions"}
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.change_catalog :publications_catalog, :publications_catalog_2, {:title => "MyName M (2016) My Second Publication Title, Hornblower, 101ff.", :url => "http://hornblower.dom"}
diff --git a/test/qprf-report.rb b/test/qprf-report.rb
new file mode 100644
index 0000000..438c494
--- /dev/null
+++ b/test/qprf-report.rb
@@ -0,0 +1,52 @@
+require_relative "setup.rb"
+
+class QMRFReportTest < MiniTest::Test
+
+ def test_0_self
+ puts "MiniTest #{self.class} start OK"
+ end
+
+ def test_1_base
+ report = OpenTox::QPRFReport.new
+ assert report
+ assert_kind_of(OpenTox::QPRFReport, report)
+ assert report.to_json
+ assert report.to_html
+ assert report.pretty_json
+ end
+
+ def test_2_md
+ report = OpenTox::QPRFReport.new
+ assert report.to_html
+ end
+
+ def test_3_get_Title
+ report = OpenTox::QPRFReport.new
+ assert_equal report.Title, "QSAR Prediction Reporting Format (QPRF)"
+ end
+
+ def test_4_set_Values
+ report = OpenTox::QPRFReport.new
+ report.Title = "My Test Title"
+ report.Version = "12"
+ assert_equal report.Title, "My Test Title"
+ assert_equal report.Version, "12"
+ #puts report.to_html
+ end
+
+ def test_5_get_11
+ report = OpenTox::QPRFReport.new
+ report.Value "1.1", "7732-18-5"
+ assert_equal report.Value("1.1"), "7732-18-5"
+ end
+
+ def test_6_set_more_Values
+ report = OpenTox::QPRFReport.new
+ report.Title = "My QPRF Report"
+ report.Version = "2.1"
+ report.Date = "2016/08/21"
+ report.Value "1.1", "7732-18-5"
+ assert_equal report.pretty_json, File.read(File.join(DATA_DIR,'qprf-t6.json'))
+ end
+
+end \ No newline at end of file
diff --git a/test/setup.rb b/test/setup.rb
index 5d61c1c..eb28232 100644
--- a/test/setup.rb
+++ b/test/setup.rb
@@ -1,7 +1,6 @@
-ENV["LAZAR_ENV"] = "development"
require 'minitest/autorun'
require_relative '../lib/qmrf-report.rb'
-#require 'lazar'
+require_relative '../lib/qprf-report.rb'
include OpenTox
TEST_DIR ||= File.expand_path(File.dirname(__FILE__))
DATA_DIR ||= File.join(TEST_DIR,"data") \ No newline at end of file