From 004bc2af46e416ce7488d62a91f046394250ccb2 Mon Sep 17 00:00:00 2001 From: Faisal Alkulaib Date: Thu, 11 Jul 2024 14:05:21 -0400 Subject: [PATCH 1/6] issue #1148 , adding an organism hints object --- src/model/hint.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/model/hint.js diff --git a/src/model/hint.js b/src/model/hint.js new file mode 100644 index 00000000..c5183b99 --- /dev/null +++ b/src/model/hint.js @@ -0,0 +1,15 @@ +import _ from 'lodash'; + +//import { ENTITY_TYPE } from './entity-type.js'; + +const HINT_TYPE = Object.freeze({ + ORGANISM: 'organism' +}); +const HINT_TYPES = _.flatMap(HINT_TYPE); + + +const HINT_PASSAGE = Object.freeze({ + TITLE: 'title', + ABSTRACT: 'abstract' +}); +const HINT_PASSAGES = _.flatMap(HINT_PASSAGE); From ec71909995d4a998bdd5b098d6e11cdfd5243f45 Mon Sep 17 00:00:00 2001 From: fileoy Date: Thu, 11 Jul 2024 16:21:02 -0400 Subject: [PATCH 2/6] added more to the hint model --- src/model/hint.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/model/hint.js b/src/model/hint.js index c5183b99..926bbbc7 100644 --- a/src/model/hint.js +++ b/src/model/hint.js @@ -13,3 +13,54 @@ const HINT_PASSAGE = Object.freeze({ ABSTRACT: 'abstract' }); const HINT_PASSAGES = _.flatMap(HINT_PASSAGE); + +class Hint{ + + get text(){ + return this._text; + } + + set text(value){ + this._text = value; + } + + get type(){ + return this._type; + } + + set type(value){ + if( value != HINT_TYPES.ORGANISM){ + throw new Error('Invalid type' + value); + } + this._type = value; + } + + get xref(){ + return this._xref; + } + + set xref(value){ + if (!value.dbPrefix || !value.id){ + throw new Error('Invalid xref' + JSON.stringify(value)); + } + this._xref = value; + } + + get section(){ + return this._section; + } + + set section(value){ + if( value != HINT_PASSAGES.TITLE && value != HINT_PASSAGES.ABSTRACT){ + throw new Error('Invalid section' + value); + } + this._section = value; + } + + +} +export { + Hint, + HINT_TYPES, + HINT_PASSAGES +}; From ec7da6cb0970936bf66a13d4d80357e2492dd1c9 Mon Sep 17 00:00:00 2001 From: fileoy Date: Wed, 17 Jul 2024 15:42:32 -0400 Subject: [PATCH 3/6] new file: src/server/routes/api/document/hint/pubtator.js --- .../routes/api/document/hint/pubtator.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/server/routes/api/document/hint/pubtator.js diff --git a/src/server/routes/api/document/hint/pubtator.js b/src/server/routes/api/document/hint/pubtator.js new file mode 100644 index 00000000..fea9e39f --- /dev/null +++ b/src/server/routes/api/document/hint/pubtator.js @@ -0,0 +1,32 @@ +import _ from 'lodash'; + +import { + Hint, + HINT_TYPES +} from '../../../model/hint.js'; + +function map (bioCDocument) { + let hints = []; + + const byText = annotation => { + const sanitzed = text => text.toLowerCase(); + const { text } = annotation; + return sanitzed(text); + }; + + const byAnnotation = annotation => { + + const isValidType = annotation => { + const {infons: { type } } = annotation; + return type === HINT_TYPES.ORGANISM; + }; + + const hasXref = annotation => { + const { infons } = annotation; + return _.has(infons, 'identifier'); + }; + + return isValidType(annotation) && hasXref(annotation); + }; + +} \ No newline at end of file From ecc9aa5f75126ee2679997ae750377b8b6431db5 Mon Sep 17 00:00:00 2001 From: fileoy Date: Thu, 18 Jul 2024 11:51:18 -0400 Subject: [PATCH 4/6] added comments to hint.js and a constructor. --- src/model/hint.js | 26 ++++++++++++--- .../routes/api/document/hint/pubtator.js | 32 ------------------- 2 files changed, 21 insertions(+), 37 deletions(-) delete mode 100644 src/server/routes/api/document/hint/pubtator.js diff --git a/src/model/hint.js b/src/model/hint.js index 926bbbc7..782417cc 100644 --- a/src/model/hint.js +++ b/src/model/hint.js @@ -1,21 +1,39 @@ import _ from 'lodash'; -//import { ENTITY_TYPE } from './entity-type.js'; - const HINT_TYPE = Object.freeze({ ORGANISM: 'organism' }); const HINT_TYPES = _.flatMap(HINT_TYPE); - const HINT_PASSAGE = Object.freeze({ TITLE: 'title', ABSTRACT: 'abstract' }); const HINT_PASSAGES = _.flatMap(HINT_PASSAGE); +/** + * Class representing a Hint. + */ class Hint{ + /** + * Create a Hint. + * @param {string} text - The hint text. + * @param {string} type - The hint type. + * @param {Object} xref - The hint xref. + * @param {string} section - The hint section. + */ + constructor(text, type, xref, section){ + this._text = text; + this._type = type; + this._xref = xref; + this._section = section; + } + + /** + * Get the hint text. + * @returns {string} The hint text. + */ get text(){ return this._text; } @@ -56,8 +74,6 @@ class Hint{ } this._section = value; } - - } export { Hint, diff --git a/src/server/routes/api/document/hint/pubtator.js b/src/server/routes/api/document/hint/pubtator.js deleted file mode 100644 index fea9e39f..00000000 --- a/src/server/routes/api/document/hint/pubtator.js +++ /dev/null @@ -1,32 +0,0 @@ -import _ from 'lodash'; - -import { - Hint, - HINT_TYPES -} from '../../../model/hint.js'; - -function map (bioCDocument) { - let hints = []; - - const byText = annotation => { - const sanitzed = text => text.toLowerCase(); - const { text } = annotation; - return sanitzed(text); - }; - - const byAnnotation = annotation => { - - const isValidType = annotation => { - const {infons: { type } } = annotation; - return type === HINT_TYPES.ORGANISM; - }; - - const hasXref = annotation => { - const { infons } = annotation; - return _.has(infons, 'identifier'); - }; - - return isValidType(annotation) && hasXref(annotation); - }; - -} \ No newline at end of file From 6df61ab9a18e828cade080239a73c17c13be9aea Mon Sep 17 00:00:00 2001 From: fileoy Date: Thu, 18 Jul 2024 12:26:48 -0400 Subject: [PATCH 5/6] added discriptive comments. --- src/model/hint.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/model/hint.js b/src/model/hint.js index 782417cc..42477d1c 100644 --- a/src/model/hint.js +++ b/src/model/hint.js @@ -11,9 +11,11 @@ const HINT_PASSAGE = Object.freeze({ }); const HINT_PASSAGES = _.flatMap(HINT_PASSAGE); -/** - * Class representing a Hint. - */ +/* +* Class representing a Hint. +* A hint is a piece of information that is extracted from sections of articles, such as the title or abstract. +* It can be about the organism being studied in the article or a gene name under investigation. +*/ class Hint{ /** @@ -32,6 +34,7 @@ class Hint{ /** * Get the hint text. + * The text is a single sentence extracted from the article section. * @returns {string} The hint text. */ get text(){ From 1605d1a9362596fb37e0182bac8a4a634250c025 Mon Sep 17 00:00:00 2001 From: fileoy Date: Thu, 18 Jul 2024 12:31:36 -0400 Subject: [PATCH 6/6] replaced sentence with mention. --- src/model/hint.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/model/hint.js b/src/model/hint.js index 42477d1c..404bc948 100644 --- a/src/model/hint.js +++ b/src/model/hint.js @@ -34,7 +34,7 @@ class Hint{ /** * Get the hint text. - * The text is a single sentence extracted from the article section. + * The text is a single mention extracted from the article section. * @returns {string} The hint text. */ get text(){