diff --git a/Makefile b/Makefile index 4bccc226d..22dc47e30 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,9 @@ uirun: make -B -C src/main/cliapp make -B -C src/main/cliapp run +pretty: + make -B -C src/main/cliapp pretty + uirunalpha: export API_URL=https://alpha-curation.alliancegenome.org; make -B -C src/main/cliapp run; unset API_URL diff --git a/docker/run_opensearch b/docker/run_opensearch index b757da902..80cf62178 100755 --- a/docker/run_opensearch +++ b/docker/run_opensearch @@ -1 +1 @@ -docker run -d --net curation -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" -e "DISABLE_SECURITY_PLUGIN=true" --name opensearch opensearchproject/opensearch:1.2.4 +docker run -d --net curation -p 9200:9200 -p 9600:9600 -e "discovery.type=single-node" -e "DISABLE_SECURITY_PLUGIN=true" --name opensearch opensearchproject/opensearch:2.16.0 diff --git a/pom.xml b/pom.xml index eb73d83ac..ba3d5cc72 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ 3.0.1 2.0.0 0.5.1 - 3.5.0 + 3.13.3 3.0.0-M7 3.3.1 10.17.0 @@ -247,6 +247,11 @@ commons-collections4 4.4 + + org.apache.commons + commons-compress + 1.27.1 + commons-collections commons-collections diff --git a/src/main/cliapp/Makefile b/src/main/cliapp/Makefile index 1d315d0ea..3d00ba5bc 100644 --- a/src/main/cliapp/Makefile +++ b/src/main/cliapp/Makefile @@ -6,6 +6,9 @@ all: run: npm start +pretty: + npx prettier --write . + runalpha: export API_URL=https://alpha-curation.alliancegenome.org; make run; unset API_URL diff --git a/src/main/cliapp/package-lock.json b/src/main/cliapp/package-lock.json index c6d039af3..5efdf1652 100644 --- a/src/main/cliapp/package-lock.json +++ b/src/main/cliapp/package-lock.json @@ -31,6 +31,7 @@ "immer": "^9.0.15", "jose": "^4.10.0", "moment": "^2.29.1", + "moment-timezone": "^0.5.45", "primeflex": "3.1.0", "primeicons": "^5.0.0", "primereact": "^10.0.9", @@ -45,6 +46,7 @@ "react-use-websocket": "^3.0.0", "react18-json-view": "^0.2.8", "sass": "^1.32.8", + "update-browserslist-db": "^1.1.0", "use-immer": "^0.7.0" }, "devDependencies": { @@ -6840,9 +6842,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001509", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001509.tgz", - "integrity": "sha512-2uDDk+TRiTX5hMcUYT/7CSyzMZxjfGu0vAUjS2g0LSD8UoXOv0LtpH4LxGMemsiPq6LCVIUjNwVM0erkOkGCDA==", + "version": "1.0.30001653", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001653.tgz", + "integrity": "sha512-XGWQVB8wFQ2+9NZwZ10GxTYC5hk0Fa+q8cSkr0tgvMhYhMHP/QC+WTgrePMDBWiWc/pV+1ik82Al20XOK25Gcw==", "funding": [ { "type": "opencollective", @@ -8357,9 +8359,9 @@ } }, "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", "engines": { "node": ">=6" } @@ -15354,6 +15356,17 @@ "node": "*" } }, + "node_modules/moment-timezone": { + "version": "0.5.45", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.45.tgz", + "integrity": "sha512-HIWmqA86KcmCAhnMAN0wuDOARV/525R2+lOLotuGFzn4HO+FH+/645z2wx0Dt3iDv6/p61SIvKnDstISainhLQ==", + "dependencies": { + "moment": "^2.29.4" + }, + "engines": { + "node": "*" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -16190,9 +16203,9 @@ "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==" }, "node_modules/picocolors": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz", + "integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==" }, "node_modules/picomatch": { "version": "2.3.1", @@ -20194,9 +20207,9 @@ } }, "node_modules/update-browserslist-db": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.11.tgz", - "integrity": "sha512-dCwEFf0/oT85M1fHBg4F0jtLwJrutGoHSQXCh7u4o2t1drG+c0a9Flnqww6XUKSfQMPpJBRjU8d4RXB09qtvaA==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz", + "integrity": "sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ==", "funding": [ { "type": "opencollective", @@ -20212,8 +20225,8 @@ } ], "dependencies": { - "escalade": "^3.1.1", - "picocolors": "^1.0.0" + "escalade": "^3.1.2", + "picocolors": "^1.0.1" }, "bin": { "update-browserslist-db": "cli.js" diff --git a/src/main/cliapp/package.json b/src/main/cliapp/package.json index d934280f3..d54b0494e 100644 --- a/src/main/cliapp/package.json +++ b/src/main/cliapp/package.json @@ -31,6 +31,7 @@ "immer": "^9.0.15", "jose": "^4.10.0", "moment": "^2.29.1", + "moment-timezone": "^0.5.45", "primeflex": "3.1.0", "primeicons": "^5.0.0", "primereact": "^10.0.9", @@ -45,6 +46,7 @@ "react-use-websocket": "^3.0.0", "react18-json-view": "^0.2.8", "sass": "^1.32.8", + "update-browserslist-db": "^1.1.0", "use-immer": "^0.7.0" }, "scripts": { @@ -56,7 +58,7 @@ "eslintConfig": { "extends": [ "react-app", - "prettier" + "prettier" ] }, "browserslist": [ diff --git a/src/main/cliapp/src/components/EntityCountsComponent.js b/src/main/cliapp/src/components/EntityCountsComponent.js index 998b1cabe..7cd9ad915 100644 --- a/src/main/cliapp/src/components/EntityCountsComponent.js +++ b/src/main/cliapp/src/components/EntityCountsComponent.js @@ -3,6 +3,7 @@ import { DataTable } from 'primereact/datatable'; import { Column } from 'primereact/column'; import { SystemService } from '../service/SystemService'; import { CLASSES } from '../constants/Classes'; +import { NumberTemplate } from './Templates/NumberTemplate'; export const EntityCountsComponent = () => { const [tableData, setTableData] = useState({}); @@ -44,28 +45,80 @@ export const EntityCountsComponent = () => { return {rowData.name}; }; + const ROW_HIGHLIGHT_IGNORE = ['Disease Annotations', 'Literature References', 'Bulk Loads / Failed Loads']; + + const getRowClass = (rowData) => { + if (ROW_HIGHLIGHT_IGNORE.includes(rowData.name)) return; + + if (rowData?.dbCount !== rowData.esCount) { + return 'bg-gray-500 text-white'; + } + }; + return ( <>
- + getRowClass(rowData)} + > - - + } + /> + } + />
- + getRowClass(rowData)} + > - - + } + /> + } + />
- + getRowClass(rowData)} + > - - + } + /> + } + />
diff --git a/src/main/cliapp/src/components/FieldData/GeneticModifierAgmsAdditionalFieldData.js b/src/main/cliapp/src/components/FieldData/GeneticModifierAgmsAdditionalFieldData.js new file mode 100644 index 000000000..dbec8d1b9 --- /dev/null +++ b/src/main/cliapp/src/components/FieldData/GeneticModifierAgmsAdditionalFieldData.js @@ -0,0 +1,14 @@ +import React from 'react'; +import { getIdentifier } from '../../utils/utils'; + +export function GeneticModifierAgmsAdditionalFieldData({ fieldData }) { + let ret = []; + if (fieldData && fieldData.length > 0) { + for (let i = 0; i < fieldData.length; i++) { + if (getIdentifier(fieldData[i]) !== '') { + ret.push(
); + } + } + } + return ret; +} diff --git a/src/main/cliapp/src/components/FieldData/GeneticModifierAllelesAdditionalFieldData.js b/src/main/cliapp/src/components/FieldData/GeneticModifierAllelesAdditionalFieldData.js new file mode 100644 index 000000000..8db528abf --- /dev/null +++ b/src/main/cliapp/src/components/FieldData/GeneticModifierAllelesAdditionalFieldData.js @@ -0,0 +1,20 @@ +import React from 'react'; +import { getIdentifier } from '../../utils/utils'; + +export function GeneticModifierAllelesAdditionalFieldData({ fieldData }) { + let ret = []; + if (fieldData && fieldData.length > 0) { + for (let i = 0; i < fieldData.length; i++) { + if (getIdentifier(fieldData[i]) !== '') { + ret.push( +
+ ); + } + } + } + return ret; +} diff --git a/src/main/cliapp/src/components/FieldData/GeneticModifierGenesAdditionalFieldData.js b/src/main/cliapp/src/components/FieldData/GeneticModifierGenesAdditionalFieldData.js new file mode 100644 index 000000000..174ebf8c1 --- /dev/null +++ b/src/main/cliapp/src/components/FieldData/GeneticModifierGenesAdditionalFieldData.js @@ -0,0 +1,20 @@ +import React from 'react'; +import { getIdentifier } from '../../utils/utils'; + +export function GeneticModifierGenesAdditionalFieldData({ fieldData }) { + let ret = []; + if (fieldData && fieldData.length > 0) { + for (let i = 0; i < fieldData.length; i++) { + if (getIdentifier(fieldData[i]) !== '') { + ret.push( +
+ ); + } + } + } + return ret; +} diff --git a/src/main/cliapp/src/components/FieldData/GeneticModifiersAdditionalFieldData.js b/src/main/cliapp/src/components/FieldData/GeneticModifiersAdditionalFieldData.js deleted file mode 100644 index fd0d27684..000000000 --- a/src/main/cliapp/src/components/FieldData/GeneticModifiersAdditionalFieldData.js +++ /dev/null @@ -1,33 +0,0 @@ -import React from 'react'; -import { getIdentifier } from '../../utils/utils'; - -export function GeneticModifiersAdditionalFieldData({ fieldData }) { - let ret = []; - if (fieldData && fieldData.length > 0) { - for (let i = 0; i < fieldData.length; i++) { - if (getIdentifier(fieldData[i]) !== '') { - if (fieldData[i]['type'] === 'Gene') - ret.push( -
- ); - else if (fieldData[i]['type'] === 'Allele') - ret.push( -
- ); - else if (fieldData[i]['type'] === 'AffectedGenomicModel') - ret.push( -
- ); - } - } - } - return ret; -} diff --git a/src/main/cliapp/src/components/GenericDataTable/DataTableFooter.js b/src/main/cliapp/src/components/GenericDataTable/DataTableFooter.js new file mode 100644 index 000000000..fff69a29c --- /dev/null +++ b/src/main/cliapp/src/components/GenericDataTable/DataTableFooter.js @@ -0,0 +1,40 @@ +import React from 'react'; +import { Paginator } from 'primereact/paginator'; +import { NumberTemplate } from '../Templates/NumberTemplate'; + +export const DataTableFooter = ({ first, rows, totalRecords, onLazyLoad, isInEditMode }) => { + return ( + !isInEditMode && ( + { + const totalRecordsDisplay = ; + const firstDisplay = ; + const lastDisplay = ; + return ( + <> + Showing {firstDisplay} to {lastDisplay} of {totalRecordsDisplay} + + ); + }, + PageLinks: (options) => { + const pageDisplay = ; + return ( + + ); + }, + }} + /> + ) + ); +}; diff --git a/src/main/cliapp/src/components/GenericDataTable/GenericDataTable.js b/src/main/cliapp/src/components/GenericDataTable/GenericDataTable.js index db13153ed..36c3bb13a 100644 --- a/src/main/cliapp/src/components/GenericDataTable/GenericDataTable.js +++ b/src/main/cliapp/src/components/GenericDataTable/GenericDataTable.js @@ -16,7 +16,8 @@ import { EntityDetailsAction } from '../Actions/EntityDetailsAction'; import { filterColumns, orderColumns, getIdentifier } from '../../utils/utils'; import { useGenericDataTable } from './useGenericDataTable'; -import style from './styles.module.scss'; +import './styles.scss'; +import { DataTableFooter } from './DataTableFooter'; export const GenericDataTable = (props) => { const { tableName, @@ -309,30 +310,32 @@ export const GenericDataTable = (props) => { columnResizeMode="expand" showGridlines={true} onColumnResizeEnd={handleColumnResizeEnd} - paginator={!isInEditMode} totalRecords={totalRecords} - onPage={onLazyLoad} lazy={true} - first={tableState.first} - paginatorTemplate="CurrentPageReport FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown" - currentPageReportTemplate="Showing {first} to {last} of {totalRecords}" - rows={tableState.rows} - rowsPerPageOptions={[10, 20, 50, 100, 250, 1000]} rowClassName={(props) => getRowClass(props)} loading={fetching} loadingIcon="pi pi-spin pi-spinner" + footer={ + + } > {isEditable && ( )} {deletionEnabled && ( @@ -342,10 +345,10 @@ export const GenericDataTable = (props) => { body={(props) => deleteAction(props, isInEditMode)} filterElement={rowEditorFilterNameHeader} showFilterMenu={false} - className={`text-center p-0 max-w-3rem ${isEditable ? 'visible' : 'hidden'}`} + className={`text-center p-0 action-column ${isEditable ? 'visible' : 'hidden'}`} bodyStyle={{ textAlign: 'center' }} frozen - headerClassName="surface-0 max-w-3rem sticky" + headerClassName="surface-0 action-column sticky" /> )} {duplicationEnabled && ( @@ -358,10 +361,10 @@ export const GenericDataTable = (props) => { )} showFilterMenu={false} - className={`text-center p-0 max-w-3rem ${isEditable ? 'visible' : 'hidden'}`} + className={`text-center p-0 action-column ${isEditable ? 'visible' : 'hidden'}`} bodyStyle={{ textAlign: 'center' }} frozen - headerClassName="surface-0 max-w-3rem sticky" + headerClassName="surface-0 action-column sticky" /> )} {hasDetails && ( @@ -370,10 +373,10 @@ export const GenericDataTable = (props) => { editor={(props) => } body={(props) => } showFilterMenu={false} - className={`text-center p-0 max-w-3rem ${isEditable ? 'visible' : 'hidden'}`} + className={`text-center p-0 action-column ${isEditable ? 'visible' : 'hidden'}`} bodyStyle={{ textAlign: 'center' }} frozen - headerClassName="surface-0 max-w-3rem sticky" + headerClassName="surface-0 action-column sticky" /> )} {columnList} diff --git a/src/main/cliapp/src/components/GenericDataTable/styles.module.scss b/src/main/cliapp/src/components/GenericDataTable/styles.module.scss deleted file mode 100644 index 7b574f220..000000000 --- a/src/main/cliapp/src/components/GenericDataTable/styles.module.scss +++ /dev/null @@ -1,3 +0,0 @@ -.rowEditorColumn{ - min-width : 6rem !important; -} \ No newline at end of file diff --git a/src/main/cliapp/src/components/GenericDataTable/styles.scss b/src/main/cliapp/src/components/GenericDataTable/styles.scss new file mode 100644 index 000000000..856773f60 --- /dev/null +++ b/src/main/cliapp/src/components/GenericDataTable/styles.scss @@ -0,0 +1,9 @@ +.row-editor-column{ + min-width : 6rem !important; + width : 6rem !important; +} + +.action-column{ + min-width : 3rem !important; + width : 3rem !important; +} \ No newline at end of file diff --git a/src/main/cliapp/src/components/Templates/CrossReferencesTemplate.js b/src/main/cliapp/src/components/Templates/CrossReferencesTemplate.js deleted file mode 100644 index 92ae9b616..000000000 --- a/src/main/cliapp/src/components/Templates/CrossReferencesTemplate.js +++ /dev/null @@ -1,28 +0,0 @@ -import { EllipsisTableCell } from '../EllipsisTableCell'; -import { ListTableCell } from '../ListTableCell'; -import { Tooltip } from 'primereact/tooltip'; - -export const CrossReferencesTemplate = ({ xrefs }) => { - if (!xrefs || xrefs.length === 0) return null; - - const targetClass = `a${global.crypto.randomUUID()}`; - - const sortedXrefs = xrefs.sort((a, b) => - a.displayName > b.displayName ? 1 : a.resourceDescriptorPage.name === b.resourceDescriptorPage.name ? 1 : -1 - ); - - const listTemplate = (item) => { - return {item.displayName + ' (' + item.resourceDescriptorPage.name + ')'}; - }; - - return ( - <> -
- -
- - - - - ); -}; diff --git a/src/main/cliapp/src/components/Templates/DiseaseQualifiersTemplate.js b/src/main/cliapp/src/components/Templates/DiseaseQualifiersTemplate.js deleted file mode 100644 index 2d78a8a4c..000000000 --- a/src/main/cliapp/src/components/Templates/DiseaseQualifiersTemplate.js +++ /dev/null @@ -1,15 +0,0 @@ -import { ListTableCell } from '../ListTableCell'; - -export const DiseaseQualifiersTemplate = ({ diseaseQualifiers }) => { - if (!diseaseQualifiers || diseaseQualifiers.length === 0) return null; - - const sortedDiseaseQualifiers = diseaseQualifiers.sort((a, b) => (a.name > b.name ? 1 : -1)); - - const listTemplate = (item) => item.name; - - return ( -
- -
- ); -}; diff --git a/src/main/cliapp/src/components/Templates/EvidenceCodesTemplate.js b/src/main/cliapp/src/components/Templates/EvidenceCodesTemplate.js deleted file mode 100644 index b765f7786..000000000 --- a/src/main/cliapp/src/components/Templates/EvidenceCodesTemplate.js +++ /dev/null @@ -1,28 +0,0 @@ -import { EllipsisTableCell } from '../EllipsisTableCell'; -import { ListTableCell } from '../ListTableCell'; -import { Tooltip } from 'primereact/tooltip'; - -export const EvidenceCodesTemplate = ({ evidenceCodes }) => { - if (!evidenceCodes || evidenceCodes.length === 0) return null; - - const targetClass = `a${global.crypto.randomUUID()}`; - - const sortedEvidenceCodes = evidenceCodes.sort((a, b) => - a.abbreviation > b.abbreviation ? 1 : a.curie === b.curie ? 1 : -1 - ); - - const listTemplate = (item) => { - return {item.abbreviation + ' - ' + item.name + ' (' + item.curie + ')'}; - }; - - return ( - <> -
- -
- - - - - ); -}; diff --git a/src/main/cliapp/src/components/Templates/IdTemplate.js b/src/main/cliapp/src/components/Templates/IdTemplate.js index 7827776fe..1a847faad 100644 --- a/src/main/cliapp/src/components/Templates/IdTemplate.js +++ b/src/main/cliapp/src/components/Templates/IdTemplate.js @@ -1,5 +1,6 @@ import { EllipsisTableCell } from '../EllipsisTableCell'; import { Tooltip } from 'primereact/tooltip'; +import './styles.scss'; export const IdTemplate = ({ id }) => { if (!id) return null; @@ -10,7 +11,7 @@ export const IdTemplate = ({ id }) => { return ( <> {id} - + ); }; diff --git a/src/main/cliapp/src/components/Templates/NameTemplate.js b/src/main/cliapp/src/components/Templates/NameTemplate.js deleted file mode 100644 index 5511a6b65..000000000 --- a/src/main/cliapp/src/components/Templates/NameTemplate.js +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -import { Tooltip } from 'primereact/tooltip'; - -export const NameTemplate = ({ name }) => { - const targetClass = `a${global.crypto.randomUUID()}`; - if (!name) return null; - return ( - <> -
- -
- - - ); -}; diff --git a/src/main/cliapp/src/components/Templates/NumberTemplate.js b/src/main/cliapp/src/components/Templates/NumberTemplate.js new file mode 100644 index 000000000..50752c9d3 --- /dev/null +++ b/src/main/cliapp/src/components/Templates/NumberTemplate.js @@ -0,0 +1,5 @@ +export const NumberTemplate = ({ number }) => { + //still want to pass through falsy 0 values + if (number === null || number === undefined) return; + return new Intl.NumberFormat().format(number); +}; diff --git a/src/main/cliapp/src/components/Templates/ObjectListTemplate.js b/src/main/cliapp/src/components/Templates/ObjectListTemplate.js new file mode 100644 index 000000000..91546c6e8 --- /dev/null +++ b/src/main/cliapp/src/components/Templates/ObjectListTemplate.js @@ -0,0 +1,27 @@ +import { EllipsisTableCell } from '../EllipsisTableCell'; +import { ListTableCell } from '../ListTableCell'; +import { Tooltip } from 'primereact/tooltip'; + +export const ObjectListTemplate = ({ list, sortMethod, stringTemplate, showBullets = false }) => { + if (!list || list.length === 0) return null; + + const targetClass = `a${global.crypto.randomUUID()}`; + + const sortedList = sortMethod ? sortMethod(list) : list; + + const listTemplate = (item) => { + const template = stringTemplate(item); + return template ? {template} : null; + }; + + return ( + <> +
+ +
+ + + + + ); +}; diff --git a/src/main/cliapp/src/components/Templates/OntologyTermTemplate.js b/src/main/cliapp/src/components/Templates/OntologyTermTemplate.js index 51368c50b..7f371e6e2 100644 --- a/src/main/cliapp/src/components/Templates/OntologyTermTemplate.js +++ b/src/main/cliapp/src/components/Templates/OntologyTermTemplate.js @@ -1,23 +1,23 @@ import { Tooltip } from 'primereact/tooltip'; import { EllipsisTableCell } from '../EllipsisTableCell'; -export const OntologyTermTemplate = ({ object }) => { - if (!object) return null; +export const OntologyTermTemplate = ({ term }) => { + if (!term) return null; const targetClass = `a${global.crypto.randomUUID()}`; - const textString = getTextString(object); + const textString = getTextString(term); return ( <> {textString} - + ); }; -const getTextString = (object) => { - if (!object.name) return object.curie; - if (!object.curie) return object.name; - if (!object.curie && !object.name) return ''; - return `${object.name} (${object.curie})`; +const getTextString = (term) => { + if (!term.name) return term.curie; + if (!term.curie) return term.name; + if (!term.curie && !term.name) return ''; + return `${term.name} (${term.curie})`; }; diff --git a/src/main/cliapp/src/components/Templates/StringListTemplate.js b/src/main/cliapp/src/components/Templates/StringListTemplate.js index 2b9ae3ecc..b025bf0b9 100644 --- a/src/main/cliapp/src/components/Templates/StringListTemplate.js +++ b/src/main/cliapp/src/components/Templates/StringListTemplate.js @@ -1,15 +1,19 @@ import { EllipsisTableCell } from '../EllipsisTableCell'; import { ListTableCell } from '../ListTableCell'; import { Tooltip } from 'primereact/tooltip'; +import './styles.scss'; export const StringListTemplate = ({ list }) => { if (!list || list.length === 0) return null; const targetClass = `a${global.crypto.randomUUID()}`; - const sortedList = list.sort(); + //filter out falsy values + const filteredList = list.filter((item) => item); + const sortedList = filteredList.sort(); const listTemplate = (item) => { + if (!item) return; return {item}; }; @@ -18,7 +22,7 @@ export const StringListTemplate = ({ list }) => {
- + diff --git a/src/main/cliapp/src/components/Templates/StringTemplate.js b/src/main/cliapp/src/components/Templates/StringTemplate.js new file mode 100644 index 000000000..91e3df857 --- /dev/null +++ b/src/main/cliapp/src/components/Templates/StringTemplate.js @@ -0,0 +1,19 @@ +import React from 'react'; +import { Tooltip } from 'primereact/tooltip'; +import './styles.scss'; + +export const StringTemplate = ({ string }) => { + const targetClass = `a${global.crypto.randomUUID()}`; + if (!string) return null; + return ( + <> +
+ +
+ + + ); +}; diff --git a/src/main/cliapp/src/components/Templates/TaxonTemplate.js b/src/main/cliapp/src/components/Templates/TaxonTemplate.js deleted file mode 100644 index 1f0eb7645..000000000 --- a/src/main/cliapp/src/components/Templates/TaxonTemplate.js +++ /dev/null @@ -1,23 +0,0 @@ -import React from 'react'; -import { Tooltip } from 'primereact/tooltip'; -import { EllipsisTableCell } from '../EllipsisTableCell'; - -export const TaxonTemplate = ({ taxon }) => { - if (!taxon) return null; - const targetClass = `a${global.crypto.randomUUID()}`; - const textString = getTextString(taxon); - - return ( - <> - {textString} - - - ); -}; - -const getTextString = (taxon) => { - if (!taxon.name) return taxon.curie; - if (!taxon.curie) return taxon.name; - if (!taxon.curie && !taxon.name) return ''; - return `${taxon.name} (${taxon.curie})`; -}; diff --git a/src/main/cliapp/src/components/Templates/__tests__/CrossReferencesTemplate.test.js b/src/main/cliapp/src/components/Templates/__tests__/CrossReferencesTemplate.test.js deleted file mode 100644 index a376a9b1c..000000000 --- a/src/main/cliapp/src/components/Templates/__tests__/CrossReferencesTemplate.test.js +++ /dev/null @@ -1,52 +0,0 @@ -import { render, fireEvent } from '@testing-library/react'; -import { CrossReferencesTemplate } from '../CrossReferencesTemplate'; -import '../../../tools/jest/setupTests'; - -describe('CrossReferencesTemplate', () => { - it('should render a sorted list of cross-references with their page name in parenthesis', () => { - const xrefs = [ - { displayName: 'xref B', resourceDescriptorPage: { name: 'page B' } }, - { displayName: 'xref C', resourceDescriptorPage: { name: 'page C' } }, - { displayName: 'xref A', resourceDescriptorPage: { name: 'page A' } }, - ]; - - const { container } = render(); - const listItems = container.querySelectorAll('li'); - - expect(listItems[0]).toHaveTextContent('xref A (page A)'); - expect(listItems[1]).toHaveTextContent('xref B (page B)'); - expect(listItems[2]).toHaveTextContent('xref C (page C)'); - }); - - it('should return null when xrefs is undefined', () => { - const { container } = render(); - expect(container.firstChild).toBeNull(); - }); - - it('should return null when xrefs is an empty array', () => { - const xrefs = []; - - const { container } = render(); - expect(container.firstChild).toBeNull(); - }); - - it('should display tooltip when hovering over the cross references list', async () => { - const xrefs = [ - { displayName: 'xref ABC', resourceDescriptorPage: { name: 'page ABC' } }, - { displayName: 'xref DEF', resourceDescriptorPage: { name: 'page DEF' } }, - { displayName: 'xref GHI', resourceDescriptorPage: { name: 'page GHI' } }, - ]; - - const result = render(); - - let listContentArray = result.getAllByText('xref ABC (page ABC)'); - expect(listContentArray).toHaveLength(1); - - fireEvent.mouseEnter(result.container.firstChild); - - //using find... here because it's async and the tooltip is dynamically added - listContentArray = await result.findAllByText('xref ABC (page ABC)'); - - expect(listContentArray).toHaveLength(2); - }); -}); diff --git a/src/main/cliapp/src/components/Templates/__tests__/DataTableFooter.test.js b/src/main/cliapp/src/components/Templates/__tests__/DataTableFooter.test.js new file mode 100644 index 000000000..98120e0e5 --- /dev/null +++ b/src/main/cliapp/src/components/Templates/__tests__/DataTableFooter.test.js @@ -0,0 +1,89 @@ +import { render, fireEvent } from '@testing-library/react'; +import '../../../tools/jest/setupTests'; +import { DataTableFooter } from '../../GenericDataTable/DataTableFooter'; + +describe('DataTableFooter', () => { + it('should render Paginator component when isInEditMode is false', () => { + const result = render( + {}} isInEditMode={false} /> + ); + const paginator = result.queryByTestId('datatable-footer'); + + expect(paginator).toBeInTheDocument(); + }); + + it('should handle totalRecords, first, and last being zero', () => { + const { getByText } = render( + {}} isInEditMode={false} /> + ); + expect(getByText('Showing 0 to 0 of 0')).toBeInTheDocument(); + }); + + it('should display formatted totalRecords, first, and last numbers', () => { + const first = 1000; + const rows = 10; + const totalRecords = 2000; + const onLazyLoad = jest.fn(); + const isInEditMode = false; + + const { getByText } = render( + + ); + + const firstDisplay = getByText('Showing 1,001 to 1,010 of 2,000'); + expect(firstDisplay).toBeInTheDocument(); + }); + + it('should show correct rows per page options in dropdown', () => { + const first = 0; + const rows = 10; + const totalRecords = 100; + const onLazyLoad = jest.fn(); + const isInEditMode = false; + + const result = render( + + ); + + const dropdownButton = result.getAllByText('10')[1]; + fireEvent.click(dropdownButton); + + expect(result.getByText('20')).toBeInTheDocument(); + expect(result.getByText('50')).toBeInTheDocument(); + expect(result.getByText('100')).toBeInTheDocument(); + expect(result.getByText('250')).toBeInTheDocument(); + expect(result.getByText('1000')).toBeInTheDocument(); + }); + + it('should handle null or undefined totalRecords, first, and last', () => { + const onLazyLoad = jest.fn(); + + const result = render( + + ); + + expect(result.getByText(/Showing 0 to 0 of/i)).toBeInTheDocument(); + }); + + it('should not render Paginator when isInEditMode is true', () => { + const onLazyLoad = jest.fn(); + const result = render( + + ); + + const paginator = result.queryByTestId('datatable-footer'); + expect(paginator).toBeNull(); + }); +}); diff --git a/src/main/cliapp/src/components/Templates/__tests__/DiseaseQualifiersTemplate.test.js b/src/main/cliapp/src/components/Templates/__tests__/DiseaseQualifiersTemplate.test.js deleted file mode 100644 index f65298a1f..000000000 --- a/src/main/cliapp/src/components/Templates/__tests__/DiseaseQualifiersTemplate.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import { render, within } from '@testing-library/react'; -import { DiseaseQualifiersTemplate } from '../DiseaseQualifiersTemplate'; -import '../../../tools/jest/setupTests'; - -describe('DiseaseQualifiersTemplate', () => { - it('should return null when diseaseQualifiers is falsy', () => { - const { container } = render(); - expect(container.firstChild).toBeNull(); - }); - - it('should sort diseaseQualifiers by name', () => { - const diseaseQualifiers = [{ name: 'Qualifier C' }, { name: 'Qualifier A' }, { name: 'Qualifier B' }]; - - const result = render(); - - const qualifiersList = result.getByRole('list'); - const listItems = within(qualifiersList).getAllByRole('listitem'); - - expect(listItems[0]).toHaveTextContent('Qualifier A'); - expect(listItems[1]).toHaveTextContent('Qualifier B'); - expect(listItems[2]).toHaveTextContent('Qualifier C'); - }); - - it('should return null when diseaseQualifiers is an empty array', () => { - const { container } = render(); - expect(container.firstChild).toBeNull(); - }); - - it('should render diseaseQualifiers without a name property', () => { - const diseaseQualifiers = [{ id: 1 }, { id: 2 }, { id: 3 }]; - - const result = render(); - - const qualifiersList = result.getByRole('list'); - const listItems = within(qualifiersList).getAllByRole('listitem'); - - expect(listItems[0]).toHaveTextContent(''); - expect(listItems[1]).toHaveTextContent(''); - expect(listItems[2]).toHaveTextContent(''); - }); -}); diff --git a/src/main/cliapp/src/components/Templates/__tests__/EvidenceCodesTemplate.test.js b/src/main/cliapp/src/components/Templates/__tests__/EvidenceCodesTemplate.test.js deleted file mode 100644 index 6d1b97094..000000000 --- a/src/main/cliapp/src/components/Templates/__tests__/EvidenceCodesTemplate.test.js +++ /dev/null @@ -1,52 +0,0 @@ -import { render, fireEvent } from '@testing-library/react'; -import { EvidenceCodesTemplate } from '../EvidenceCodesTemplate'; -import '../../../tools/jest/setupTests'; - -describe('EvidenceCodesTemplate', () => { - it('should render a sorted list of evidence codes', () => { - const evidenceCodes = [ - { abbreviation: 'Code B', name: 'Code B Name', curie: 'Code B Curie' }, - { abbreviation: 'Code A', name: 'Code A Name', curie: 'Code A Curie' }, - { abbreviation: 'Code C', name: 'Code C Name', curie: 'Code C Curie' }, - ]; - - const { container } = render(); - const listItems = container.querySelectorAll('li'); - - expect(listItems[0]).toHaveTextContent('Code A - Code A Name (Code A Curie)'); - expect(listItems[1]).toHaveTextContent('Code B - Code B Name (Code B Curie)'); - expect(listItems[2]).toHaveTextContent('Code C - Code C Name (Code C Curie)'); - }); - - it('should return null when evidenceCodes is undefined', () => { - const { container } = render(); - expect(container.firstChild).toBeNull(); - }); - - it('should return null when evidenceCodes is an empty array', () => { - const evidenceCodes = []; - - const { container } = render(); - expect(container.firstChild).toBeNull(); - }); - - it('should display tooltip when hovering over the evidence codes list', async () => { - const evidenceCodes = [ - { abbreviation: 'ABC', name: 'Code ABC', curie: 'ABC123' }, - { abbreviation: 'DEF', name: 'Code DEF', curie: 'DEF456' }, - { abbreviation: 'GHI', name: 'Code GHI', curie: 'GHI789' }, - ]; - - const result = render(); - - let listContentArray = result.getAllByText('ABC - Code ABC (ABC123)'); - expect(listContentArray).toHaveLength(1); - - fireEvent.mouseEnter(result.container.firstChild); - - //using find... here because it's async and the tooltip is dynamically added - listContentArray = await result.findAllByText('ABC - Code ABC (ABC123)'); - - expect(listContentArray).toHaveLength(2); - }); -}); diff --git a/src/main/cliapp/src/components/Templates/__tests__/GenomicEntityListTemplate.test.js b/src/main/cliapp/src/components/Templates/__tests__/GenomicEntityListTemplate.test.js index 3e1e92436..e12fdeb75 100644 --- a/src/main/cliapp/src/components/Templates/__tests__/GenomicEntityListTemplate.test.js +++ b/src/main/cliapp/src/components/Templates/__tests__/GenomicEntityListTemplate.test.js @@ -171,21 +171,4 @@ describe('GenomicEntityListTemplate', () => { expect(genomicEntity2).toBeInTheDocument(); expect(genomicEntity3).toBeInTheDocument(); }); - it('should render genomicEntities and curie in a tooltip when genomicEntity has alleleSymbol', async () => { - const genomicEntities = [ - { alleleSymbol: { displayText: 'Allele Symbol C' }, curie: 'ID1' }, - { alleleSymbol: { displayText: 'Allele Symbol A' }, modEntityId: 'ID2' }, - { alleleSymbol: { displayText: 'Allele Symbol B' }, modInternalId: 'ID3' }, - ]; - - const result = render(); - - let listContentArray = result.getAllByText('Allele Symbol A (ID2)'); - expect(listContentArray).toHaveLength(1); - - fireEvent.mouseEnter(result.container.firstChild); - - //using find... here because it's async and the tooltip is dynamically added - expect(await result.findAllByText('Allele Symbol A (ID2)')).toHaveLength(2); - }); }); diff --git a/src/main/cliapp/src/components/Templates/__tests__/GenomicEntityTemplate.test.js b/src/main/cliapp/src/components/Templates/__tests__/GenomicEntityTemplate.test.js index 6f4c7045c..e4f9f5795 100644 --- a/src/main/cliapp/src/components/Templates/__tests__/GenomicEntityTemplate.test.js +++ b/src/main/cliapp/src/components/Templates/__tests__/GenomicEntityTemplate.test.js @@ -89,24 +89,6 @@ describe('GenomicEntityTemplate', () => { expect(container.firstChild).toBeNull(); }); - it('should render genomicEntity text and id in a tooltip when genomicEntity has geneSymbol', async () => { - const genomicEntity = { - geneSymbol: { - displayText: 'Gene Symbol', - }, - modInternalId: 'ID', - }; - - const result = render(); - - let divContentArray = result.getAllByText('Gene Symbol (ID)'); - expect(divContentArray).toHaveLength(1); - - fireEvent.mouseEnter(divContentArray[0]); - //using find... here because it's async and the tooltip is dynamically added - expect(await result.findAllByText('Gene Symbol (ID)')).toHaveLength(2); - }); - it('should render tags in the HTML', async () => { const genomicEntity = { geneSymbol: { diff --git a/src/main/cliapp/src/components/Templates/__tests__/IdTemplate.test.js b/src/main/cliapp/src/components/Templates/__tests__/IdTemplate.test.js index c375f74df..5d8c21f06 100644 --- a/src/main/cliapp/src/components/Templates/__tests__/IdTemplate.test.js +++ b/src/main/cliapp/src/components/Templates/__tests__/IdTemplate.test.js @@ -8,14 +8,6 @@ describe('IdTemplate', () => { expect(container.firstChild).toBeNull(); }); - it('should render Tooltip component with EllipsisTableCell as target and id as content', async () => { - const result = render(); - const divArray = result.getAllByText('123'); - expect(divArray).toHaveLength(1); - fireEvent.mouseEnter(divArray[0]); - expect(await result.findAllByText('123')).toHaveLength(2); - }); - it('should handle id as number', () => { const { getByText } = render(); expect(getByText('123')).toBeInTheDocument(); diff --git a/src/main/cliapp/src/components/Templates/__tests__/NumberTemplate.test.js b/src/main/cliapp/src/components/Templates/__tests__/NumberTemplate.test.js new file mode 100644 index 000000000..ec76ab640 --- /dev/null +++ b/src/main/cliapp/src/components/Templates/__tests__/NumberTemplate.test.js @@ -0,0 +1,62 @@ +import { render } from '@testing-library/react'; +import '../../../tools/jest/setupTests'; +import { NumberTemplate } from '../NumberTemplate'; + +describe('NumberTemplate', () => { + it('should format positive integers correctly', () => { + const number = 12345; + const result = NumberTemplate({ number }); + expect(result).toBe('12,345'); + }); + + it('should format negative integers correctly', () => { + const number = -1000; + const formattedNumber = NumberTemplate({ number }); + + expect(formattedNumber).toBe('-1,000'); + }); + + it('should format positive floating-point numbers correctly', () => { + const number = 1234.56; + const formattedNumber = NumberTemplate({ number }); + + expect(formattedNumber).toBe('1,234.56'); + }); + + it('should format negative floating-point numbers correctly', () => { + const number = -1234.5678; + const formattedNumber = NumberTemplate({ number }); + + expect(formattedNumber).toBe('-1,234.568'); + }); + + it('should return formatted number when input is zero', () => { + const number = 0; + + const result = NumberTemplate({ number }); + + expect(result).toBe('0'); + }); + + it('should handle very large numbers correctly', () => { + const number = 1000000000000000000000000000000; + + const result = NumberTemplate({ number }); + + expect(result).toBe('1,000,000,000,000,000,000,000,000,000,000'); + }); + + it('should handle string representations of numbers correctly', () => { + const number = '1000'; + + const result = NumberTemplate({ number }); + + expect(result).toBe('1,000'); + }); + + it('should return undefined when number is null', () => { + const number = null; + const result = NumberTemplate({ number }); + expect(result).toBeUndefined(); + }); +}); diff --git a/src/main/cliapp/src/components/Templates/__tests__/ObjectListTemplate.test.js b/src/main/cliapp/src/components/Templates/__tests__/ObjectListTemplate.test.js new file mode 100644 index 000000000..e00d145d4 --- /dev/null +++ b/src/main/cliapp/src/components/Templates/__tests__/ObjectListTemplate.test.js @@ -0,0 +1,82 @@ +import { render, screen } from '@testing-library/react'; +import { ObjectListTemplate } from '../ObjectListTemplate'; +import '../../../tools/jest/setupTests'; +import { BrowserRouter } from 'react-router-dom/cjs/react-router-dom.min'; + +describe('ObjectListTemplate', () => { + it('should render a list of items using the provided stringTemplate with object list', () => { + const list = [ + { id: 1, name: 'item1' }, + { id: 2, name: 'item2' }, + ]; + const stringTemplate = (item) => `Template: ${item.name}`; + const sortMethod = (list) => list.sort((a, b) => a.name - b.name); + + render(); + + const renderedListItems = screen.getAllByRole('listitem'); + const firstItemText = renderedListItems[0].textContent; + const secondItemText = renderedListItems[1].textContent; + + expect(renderedListItems.length).toBe(2); + expect(firstItemText).toBe('Template: item1'); + expect(secondItemText).toBe('Template: item2'); + }); + + it('should return null when list is empty or null', () => { + const { container: container1 } = render(); + expect(container1.firstChild).toBeNull(); + + const { container: container2 } = render(); + expect(container2.firstChild).toBeNull(); + }); + + it('should apply custom sort method to the list when provided', () => { + const list = [ + { id: 2, name: 'Alice' }, + { id: 1, name: 'Bob' }, + ]; + const sortMethod = (list) => list.sort((a, b) => a.id - b.id); + const stringTemplate = (item) => item.name; + + render( + + ); + + // Assert the order of items in the rendered list after custom sorting + const renderedListItems = screen.getAllByRole('listitem'); + expect(renderedListItems[0]).toHaveTextContent('Bob'); + expect(renderedListItems[1]).toHaveTextContent('Alice'); + }); + + it('should render in original order when no sort method is provided', () => { + const list = [ + { id: 2, name: 'B' }, + { id: 1, name: 'A' }, + ]; + const stringTemplate = (item) => item.name; + + const result = render(); + + const renderedListItems = screen.getAllByRole('listitem'); + const firstItemText = renderedListItems[0].textContent; + const secondItemText = renderedListItems[1].textContent; + + expect(firstItemText).toBe('B'); + expect(secondItemText).toBe('A'); + }); + + it('should handle null fields that are accessed by string template', () => { + const list = [{ id: 2 }, { id: 1, name: 'A' }]; + const stringTemplate = (item) => item.name; + + render(); + + const renderedListItems = screen.getAllByRole('listitem'); + const firstItemText = renderedListItems[0].textContent; + const secondItemText = renderedListItems[1].textContent; + + expect(firstItemText).toBe(''); + expect(secondItemText).toBe('A'); + }); +}); diff --git a/src/main/cliapp/src/components/Templates/__tests__/DiseaseTemplate.test.js b/src/main/cliapp/src/components/Templates/__tests__/OntologyTermTemplate.test.js similarity index 61% rename from src/main/cliapp/src/components/Templates/__tests__/DiseaseTemplate.test.js rename to src/main/cliapp/src/components/Templates/__tests__/OntologyTermTemplate.test.js index 811b1454e..4f03eeb93 100644 --- a/src/main/cliapp/src/components/Templates/__tests__/DiseaseTemplate.test.js +++ b/src/main/cliapp/src/components/Templates/__tests__/OntologyTermTemplate.test.js @@ -9,29 +9,14 @@ describe('OntologyTermTemplate', () => { curie: 'Disease Curie', }; - const result = render(); + const result = render(); const content = result.getByText('Disease Name (Disease Curie)'); expect(content).toBeInTheDocument(); }); - it('should display a tooltip with the name and curie of the disease object when hovering over the EllipsisTableCell component', async () => { - const object = { - name: 'Disease Name', - curie: 'Disease Curie', - }; - - const result = render(); - - const divContentArray = result.getAllByText('Disease Name (Disease Curie)'); - expect(divContentArray).toHaveLength(1); - fireEvent.mouseEnter(divContentArray[0]); - - expect(await result.findAllByText('Disease Name (Disease Curie)')).toHaveLength(2); - }); - it('should return null if the object is falsy', () => { - const result = render(); + const result = render(); expect(result.container.firstChild).toBeNull(); }); @@ -39,7 +24,7 @@ describe('OntologyTermTemplate', () => { it('should render an empty EllipsisTableCell component if the object has no name or curie', () => { const object = {}; - const result = render(); + const result = render(); const ellipsisTableCell = result.container.firstChild; expect(ellipsisTableCell).toHaveTextContent(''); @@ -50,7 +35,7 @@ describe('OntologyTermTemplate', () => { name: 'Disease Name', }; - const result = render(); + const result = render(); const ellipsisTableCell = result.getByText('Disease Name'); expect(ellipsisTableCell).toBeInTheDocument(); @@ -61,7 +46,7 @@ describe('OntologyTermTemplate', () => { curie: 'Disease Curie', }; - const result = render(); + const result = render(); const ellipsisTableCell = result.getByText('Disease Curie'); expect(ellipsisTableCell).toBeInTheDocument(); diff --git a/src/main/cliapp/src/components/Templates/__tests__/StringListTemplate.test.js b/src/main/cliapp/src/components/Templates/__tests__/StringListTemplate.test.js new file mode 100644 index 000000000..d95610807 --- /dev/null +++ b/src/main/cliapp/src/components/Templates/__tests__/StringListTemplate.test.js @@ -0,0 +1,44 @@ +import { render, screen } from '@testing-library/react'; +import { StringListTemplate } from '../StringListTemplate'; +import '../../../tools/jest/setupTests'; +import { BrowserRouter } from 'react-router-dom/cjs/react-router-dom.min'; + +describe('StringListTemplate', () => { + it('should render correctly when provided with a non-empty list', () => { + const list = ['item1', 'item2', 'item3']; + const { container } = render(); + + expect(container.firstChild).not.toBeNull(); + + const renderedListItems = screen.getAllByRole('listitem'); + + expect(renderedListItems.length).toBe(list.length); + }); + + it('should return null when provided with an empty list', () => { + const list = []; + const { container } = render(); + + expect(container.firstChild).toBeNull(); + }); + + it('should return null when list is null', () => { + const list = null; + + const result = StringListTemplate({ list }); + + expect(result).toBeNull(); + }); + + it('should handle lists with falsy elements', () => { + const list = [null, undefined, 0, '', false, 'Apple', null, 'Banana']; + + render(); + + const renderedListItems = screen.getAllByRole('listitem'); + + expect(renderedListItems).toHaveLength(2); + expect(renderedListItems[0].textContent).toBe('Apple'); + expect(renderedListItems[1].textContent).toBe('Banana'); + }); +}); diff --git a/src/main/cliapp/src/components/Templates/__tests__/NameTemplate.test.js b/src/main/cliapp/src/components/Templates/__tests__/StringTemplate.test.js similarity index 59% rename from src/main/cliapp/src/components/Templates/__tests__/NameTemplate.test.js rename to src/main/cliapp/src/components/Templates/__tests__/StringTemplate.test.js index ff88d911a..52f1c32d7 100644 --- a/src/main/cliapp/src/components/Templates/__tests__/NameTemplate.test.js +++ b/src/main/cliapp/src/components/Templates/__tests__/StringTemplate.test.js @@ -1,15 +1,15 @@ import { render } from '@testing-library/react'; -import { NameTemplate } from '../NameTemplate'; +import { StringTemplate } from '../StringTemplate'; import '../../../tools/jest/setupTests'; -describe('NameTemplate', () => { +describe('StringTemplate', () => { it('should return null when value is null', () => { - const { container } = render(); + const { container } = render(); expect(container.firstChild).toBeNull(); }); it('should render the name inside the div', () => { - const result = render(); + const result = render(); expect(result.getByText('test')).toBeInTheDocument(); }); }); diff --git a/src/main/cliapp/src/components/Templates/__tests__/TaxonTemplate.test.js b/src/main/cliapp/src/components/Templates/__tests__/TaxonTemplate.test.js deleted file mode 100644 index b7eb35d47..000000000 --- a/src/main/cliapp/src/components/Templates/__tests__/TaxonTemplate.test.js +++ /dev/null @@ -1,68 +0,0 @@ -import { render, fireEvent } from '@testing-library/react'; -import { TaxonTemplate } from '../TaxonTemplate'; -import '../../../tools/jest/setupTests'; - -describe('TaxonTemplate', () => { - it('should return null when object is null/falsy', () => { - const result = render(); - expect(result.container.firstChild).toBeNull(); - }); - - it('should render an empty EllipsisTableCell component if the object has no name or curie', () => { - const object = {}; - - const result = render(); - - const ellipsisTableCell = result.container.firstChild; - expect(ellipsisTableCell).toHaveTextContent(''); - }); - - it('should render an EllipsisTableCell component with only the name if the object has no curie', () => { - const object = { - name: 'Taxon Name', - }; - - const result = render(); - - const ellipsisTableCell = result.getByText('Taxon Name'); - expect(ellipsisTableCell).toBeInTheDocument(); - }); - - it('should render an EllipsisTableCell component with only the curie if the object has no name', () => { - const object = { - curie: 'Taxon Curie', - }; - - const result = render(); - - const ellipsisTableCell = result.getByText('Taxon Curie'); - expect(ellipsisTableCell).toBeInTheDocument(); - }); - - it('should render the name and curie of the Taxon object in an EllipsisTableCell component', () => { - const object = { - name: 'Taxon Name', - curie: 'Taxon Curie', - }; - - const result = render(); - - const content = result.getByText('Taxon Name (Taxon Curie)'); - expect(content).toBeInTheDocument(); - }); - - it('should display a tooltip with the name and curie of the Taxon object when hovering over the EllipsisTableCell component', async () => { - const object = { - name: 'Taxon Name', - curie: 'Taxon Curie', - }; - - const result = render(); - - const divContentArray = result.getAllByText('Taxon Name (Taxon Curie)'); - expect(divContentArray).toHaveLength(1); - fireEvent.mouseEnter(divContentArray[0]); - - expect(await result.findAllByText('Taxon Name (Taxon Curie)')).toHaveLength(2); - }); -}); diff --git a/src/main/cliapp/src/components/Templates/genomicEntity/GenomicEntityListTemplate.js b/src/main/cliapp/src/components/Templates/genomicEntity/GenomicEntityListTemplate.js index d63982e03..803fa04a5 100644 --- a/src/main/cliapp/src/components/Templates/genomicEntity/GenomicEntityListTemplate.js +++ b/src/main/cliapp/src/components/Templates/genomicEntity/GenomicEntityListTemplate.js @@ -32,7 +32,7 @@ export const GenomicEntityListTemplate = ({ genomicEntities }) => {
- + diff --git a/src/main/cliapp/src/components/Templates/genomicEntity/GenomicEntityTemplate.js b/src/main/cliapp/src/components/Templates/genomicEntity/GenomicEntityTemplate.js index 3d84a7faa..e3286371d 100644 --- a/src/main/cliapp/src/components/Templates/genomicEntity/GenomicEntityTemplate.js +++ b/src/main/cliapp/src/components/Templates/genomicEntity/GenomicEntityTemplate.js @@ -18,7 +18,7 @@ export const GenomicEntityTemplate = ({ genomicEntity }) => { __html: `${subjectText} (${indentifier})`, }} /> - +
{ __html: refString, }} /> - +
{ + return conditions.sort((a, b) => (a.conditionSummary > b.conditionSummary ? 1 : -1)); +}; + +export const crossReferencesSort = (crossReferences) => { + return crossReferences.sort((a, b) => + a.displayName > b.displayName ? 1 : a.resourceDescriptorPage.name === b.resourceDescriptorPage.name ? 1 : -1 + ); +}; + +export const diseaseQualifiersSort = (qualifiers) => qualifiers.sort((a, b) => (a.name > b.name ? 1 : -1)); + +export const evidenceCodesSort = (evidenceCodes) => { + return evidenceCodes.sort((a, b) => (a.abbreviation > b.abbreviation ? 1 : a.curie === b.curie ? 1 : -1)); +}; diff --git a/src/main/cliapp/src/constants/FilterFields.js b/src/main/cliapp/src/constants/FilterFields.js index b75e08beb..acc2a8c70 100644 --- a/src/main/cliapp/src/constants/FilterFields.js +++ b/src/main/cliapp/src/constants/FilterFields.js @@ -326,14 +326,33 @@ export const FIELD_SETS = Object.freeze({ filterName: 'geneSystematicNameFilter', fields: ['geneSystematicName.displayText', 'geneSystematicName.formatText'], }, - geneticModifiersFieldSet: { - filterName: 'geneticModifiersFilter', + geneticModifierAgmsFieldSet: { + filterName: 'geneticModifierAgmsFilter', fields: [ - 'diseaseGeneticModifiers.symbol', - 'diseaseGeneticModifiers.name', - 'diseaseGeneticModifiers.curie', - 'diseaseGeneticModifiers.modEntityId', - 'diseaseGeneticModifiers.modInternalId', + 'diseaseGeneticModifierAgms.name', + 'diseaseGeneticModifierAgms.curie', + 'diseaseGeneticModifierAgms.modEntityId', + 'diseaseGeneticModifierAgms.modInternalId', + ], + }, + geneticModifierAllelesFieldSet: { + filterName: 'geneticModifierAllelesFilter', + fields: [ + 'diseaseGeneticModifierAlleles.alleleSymbol.displayText', + 'diseaseGeneticModifierAlleles.alleleSymbol.formatText', + 'diseaseGeneticModifierAlleles.curie', + 'diseaseGeneticModifierAlleles.modEntityId', + 'diseaseGeneticModifierAlleles.modInternalId', + ], + }, + geneticModifierGenesFieldSet: { + filterName: 'geneticModifierGenesFilter', + fields: [ + 'diseaseGeneticModifierGenes.geneSymbol.displayText', + 'diseaseGeneticModifierGenes.geneSymbol.formatText', + 'diseaseGeneticModifierGenes.curie', + 'diseaseGeneticModifierGenes.modEntityId', + 'diseaseGeneticModifierGenes.modInternalId', ], }, geneticModifierRelationFieldSet: { @@ -793,7 +812,18 @@ export const FILTER_CONFIGS = Object.freeze({ geneSynonymsFilterConfig: { filterComponentType: 'input', fieldSets: [FIELD_SETS.geneSynonymsFieldSet] }, geneSystematicNameFilterConfig: { filterComponentType: 'input', fieldSets: [FIELD_SETS.geneSystematicNameFieldSet] }, geneTypeFilterConfig: { filterComponentType: 'input', fieldSets: [FIELD_SETS.geneTypeFieldSet] }, - geneticModifiersFilterConfig: { filterComponentType: 'input', fieldSets: [FIELD_SETS.geneticModifiersFieldSet] }, + geneticModifierAgmsFilterConfig: { + filterComponentType: 'input', + fieldSets: [FIELD_SETS.geneticModifierAgmsFieldSet], + }, + geneticModifierAllelesFilterConfig: { + filterComponentType: 'input', + fieldSets: [FIELD_SETS.geneticModifierAllelesFieldSet], + }, + geneticModifierGenesFilterConfig: { + filterComponentType: 'input', + fieldSets: [FIELD_SETS.geneticModifierGenesFieldSet], + }, idExampleFilterConfig: { filterComponentType: 'input', fieldSets: [FIELD_SETS.idExampleFieldSet] }, idPatternFilterConfig: { filterComponentType: 'input', fieldSets: [FIELD_SETS.idPatternFieldSet] }, inchiFilterConfig: { filterComponentType: 'input', fieldSets: [FIELD_SETS.inchiFieldSet] }, diff --git a/src/main/cliapp/src/constants/SortFields.js b/src/main/cliapp/src/constants/SortFields.js index 4e7f7ed92..a9fe4ed27 100644 --- a/src/main/cliapp/src/constants/SortFields.js +++ b/src/main/cliapp/src/constants/SortFields.js @@ -19,7 +19,9 @@ export const SORT_FIELDS = Object.freeze([ 'sgdStrainBackground.name', 'annotationType.name', 'diseaseGeneticModifierRelation.name', - 'diseaseGeneticModifiers.symbol', + 'diseaseGeneticModifierAgms.name', + 'diseaseGeneticModifierAlleles.alleleSymbol.displayText', + 'diseaseGeneticModifierGenes.geneSymbol.displayText', 'inferredGene.geneSymbol.displayText', 'assertedGenes.geneSymbol.displayText', 'inferredAllele.alleleSymbol.displayText', diff --git a/src/main/cliapp/src/containers/affectedGenomicModelPage/AffectedGenomicModelTable.js b/src/main/cliapp/src/containers/affectedGenomicModelPage/AffectedGenomicModelTable.js index 0052e4816..94f94c218 100644 --- a/src/main/cliapp/src/containers/affectedGenomicModelPage/AffectedGenomicModelTable.js +++ b/src/main/cliapp/src/containers/affectedGenomicModelPage/AffectedGenomicModelTable.js @@ -3,15 +3,16 @@ import { GenericDataTable } from '../../components/GenericDataTable/GenericDataT import { Toast } from 'primereact/toast'; import { getDefaultTableState } from '../../service/TableStateService'; import { FILTER_CONFIGS } from '../../constants/FilterFields'; -import { NameTemplate } from '../../components/Templates/NameTemplate'; -import { TaxonTemplate } from '../../components/Templates/TaxonTemplate'; +import { StringTemplate } from '../../components/Templates/StringTemplate'; import { IdTemplate } from '../../components/Templates/IdTemplate'; import { BooleanTemplate } from '../../components/Templates/BooleanTemplate'; -import { CrossReferencesTemplate } from '../../components/Templates/CrossReferencesTemplate'; +import { ObjectListTemplate } from '../../components/Templates/ObjectListTemplate'; import { useGetTableData } from '../../service/useGetTableData'; import { useGetUserSettings } from '../../service/useGetUserSettings'; import { SearchService } from '../../service/SearchService'; +import { crossReferencesSort } from '../../components/Templates/utils/sortMethods'; +import { OntologyTermTemplate } from '../../components/Templates/OntologyTermTemplate'; export const AffectedGenomicModelTable = () => { const [isInEditMode, setIsInEditMode] = useState(false); @@ -48,13 +49,14 @@ export const AffectedGenomicModelTable = () => { { field: 'name', header: 'Name', - body: (rowData) => , + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.nameFilterConfig, }, { field: 'subtype.name', header: 'Sub Type', + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.subtypeFilterConfig, }, @@ -62,7 +64,7 @@ export const AffectedGenomicModelTable = () => { field: 'taxon.name', header: 'Taxon', sortable: true, - body: (rowData) => , + body: (rowData) => , filterConfig: FILTER_CONFIGS.taxonFilterConfig, }, { @@ -76,12 +78,19 @@ export const AffectedGenomicModelTable = () => { header: 'Cross References', sortable: true, filterConfig: FILTER_CONFIGS.crossReferencesFilterConfig, - body: (rowData) => , + body: (rowData) => ( + `${item.displayName} (${item.resourceDescriptorPage.name})`} + /> + ), }, { field: 'updatedBy.uniqueId', header: 'Updated By', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.updatedByFilterConfig, }, { @@ -89,6 +98,7 @@ export const AffectedGenomicModelTable = () => { header: 'Date Updated', sortable: true, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.dateUpdatedFilterConfig, }, { @@ -96,6 +106,7 @@ export const AffectedGenomicModelTable = () => { header: 'Created By', sortable: true, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.createdByFilterConfig, }, { @@ -103,6 +114,7 @@ export const AffectedGenomicModelTable = () => { header: 'Date Created', sortable: true, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.dataCreatedFilterConfig, }, { diff --git a/src/main/cliapp/src/containers/allelesPage/AllelesTable.js b/src/main/cliapp/src/containers/allelesPage/AllelesTable.js index 471566ee7..a99c8570d 100644 --- a/src/main/cliapp/src/containers/allelesPage/AllelesTable.js +++ b/src/main/cliapp/src/containers/allelesPage/AllelesTable.js @@ -25,12 +25,11 @@ import { BooleanTableEditor } from '../../components/Editors/boolean/BooleanTabl import { TruncatedReferencesTemplate } from '../../components/Templates/reference/TruncatedReferencesTemplate'; import { IdTemplate } from '../../components/Templates/IdTemplate'; import { BooleanTemplate } from '../../components/Templates/BooleanTemplate'; -import { TaxonTemplate } from '../../components/Templates/TaxonTemplate'; import { TextDialogTemplate } from '../../components/Templates/dialog/TextDialogTemplate'; import { ListDialogTemplate } from '../../components/Templates/dialog/ListDialogTemplate'; import { NestedListDialogTemplate } from '../../components/Templates/dialog/NestedListDialogTemplate'; import { CountDialogTemplate } from '../../components/Templates/dialog/CountDialogTemplate'; -import { CrossReferencesTemplate } from '../../components/Templates/CrossReferencesTemplate'; +import { ObjectListTemplate } from '../../components/Templates/ObjectListTemplate'; import { Tooltip } from 'primereact/tooltip'; import { Toast } from 'primereact/toast'; @@ -38,6 +37,9 @@ import { Button } from 'primereact/button'; import { EditMessageTooltip } from '../../components/EditMessageTooltip'; import { getDefaultTableState } from '../../service/TableStateService'; import { FILTER_CONFIGS } from '../../constants/FilterFields'; +import { crossReferencesSort } from '../../components/Templates/utils/sortMethods'; +import { StringTemplate } from '../../components/Templates/StringTemplate'; +import { OntologyTermTemplate } from '../../components/Templates/OntologyTermTemplate'; export const AllelesTable = () => { const [isInEditMode, setIsInEditMode] = useState(false); @@ -1076,7 +1078,6 @@ export const AllelesTable = () => { { field: 'alleleSecondaryIds.secondaryId', header: 'Secondary IDs', - //todo body: (rowData) => ( { { field: 'taxon.name', header: 'Taxon', - body: (rowData) => , sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.taxonFilterConfig, editor: (props) => , }, @@ -1200,6 +1201,7 @@ export const AllelesTable = () => { field: 'inCollection.name', header: 'In Collection', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.inCollectionFilterConfig, editor: (props) => , }, @@ -1234,12 +1236,19 @@ export const AllelesTable = () => { header: 'Cross References', sortable: true, filterConfig: FILTER_CONFIGS.crossReferencesFilterConfig, - body: (rowData) => , + body: (rowData) => ( + `${item.displayName} (${item.resourceDescriptorPage.name})`} + /> + ), }, { field: 'updatedBy.uniqueId', header: 'Updated By', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.updatedByFilterConfig, }, { @@ -1247,6 +1256,7 @@ export const AllelesTable = () => { header: 'Date Updated', sortable: true, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.dateUpdatedFilterConfig, }, { @@ -1254,6 +1264,7 @@ export const AllelesTable = () => { header: 'Created By', sortable: true, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.createdByFilterConfig, }, { @@ -1261,6 +1272,7 @@ export const AllelesTable = () => { header: 'Date Created', sortable: true, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.dataCreatedFilterConfig, }, { diff --git a/src/main/cliapp/src/containers/conditionRelationPage/ConditionRelationTable.js b/src/main/cliapp/src/containers/conditionRelationPage/ConditionRelationTable.js index 26d72cd3c..497b655b2 100644 --- a/src/main/cliapp/src/containers/conditionRelationPage/ConditionRelationTable.js +++ b/src/main/cliapp/src/containers/conditionRelationPage/ConditionRelationTable.js @@ -6,9 +6,6 @@ import { Messages } from 'primereact/messages'; import { ControlledVocabularyDropdown } from '../../components/ControlledVocabularySelector'; import { ErrorMessageComponent } from '../../components/Error/ErrorMessageComponent'; import { useControlledVocabularyService } from '../../service/useControlledVocabularyService'; -import { EllipsisTableCell } from '../../components/EllipsisTableCell'; -import { ListTableCell } from '../../components/ListTableCell'; -import { Tooltip } from 'primereact/tooltip'; import { Button } from 'primereact/button'; import { ConditionRelationService } from '../../service/ConditionRelationService'; import { AutocompleteEditor } from '../../components/Autocomplete/AutocompleteEditor'; @@ -31,6 +28,9 @@ import { getDefaultTableState } from '../../service/TableStateService'; import { FILTER_CONFIGS } from '../../constants/FilterFields'; import { useGetTableData } from '../../service/useGetTableData'; import { useGetUserSettings } from '../../service/useGetUserSettings'; +import { ObjectListTemplate } from '../../components/Templates/ObjectListTemplate'; +import { SingleReferenceTemplate } from '../../components/Templates/reference/SingleReferenceTemplate'; +import { conditionsSort } from '../../components/Templates/utils/sortMethods'; export const ConditionRelationTable = () => { const [isInEditMode, setIsInEditMode] = useState(false); @@ -126,19 +126,6 @@ export const ConditionRelationTable = () => { ); }; - const conditionTemplate = (rowData) => { - if (rowData.conditions) { - const listTemplate = (condition) => { - return {condition.conditionSummary}; - }; - return ( -
- -
- ); - } - }; - const onConditionRelationValueChange = (event, setFieldValue, props) => { multipleAutocompleteOnChange(props, event, 'conditions', setFieldValue); }; @@ -186,29 +173,6 @@ export const ConditionRelationTable = () => { ); }; - const singleReferenceBodyTemplate = (rowData) => { - if (rowData && rowData.singleReference) { - let refString = getRefString(rowData.singleReference); - return ( - <> -
- -
- - - ); - } - }; - const columns = [ { field: 'handle', @@ -224,7 +188,7 @@ export const ConditionRelationTable = () => { sortable: true, filterConfig: FILTER_CONFIGS.singleReferenceFilterConfig, editor: (props) => referenceEditorTemplate(props), - body: singleReferenceBodyTemplate, + body: (rowData) => , }, { field: 'conditionRelationType.name', @@ -237,7 +201,14 @@ export const ConditionRelationTable = () => { field: 'conditions.conditionSummary', header: 'Experimental Conditions', sortable: true, - body: conditionTemplate, + body: (rowData) => ( + item.conditionSummary} + showBullets={true} + /> + ), filterConfig: FILTER_CONFIGS.experimentalConditionFilterConfig, editor: (props) => conditionRelationTemplate(props), }, diff --git a/src/main/cliapp/src/containers/constructsPage/ConstructsTable.js b/src/main/cliapp/src/containers/constructsPage/ConstructsTable.js index 5bfc45f21..e440dbeaa 100644 --- a/src/main/cliapp/src/containers/constructsPage/ConstructsTable.js +++ b/src/main/cliapp/src/containers/constructsPage/ConstructsTable.js @@ -16,6 +16,7 @@ import { ListDialogTemplate } from '../../components/Templates/dialog/ListDialog import { StringListTemplate } from '../../components/Templates/StringListTemplate'; import { BooleanTemplate } from '../../components/Templates/BooleanTemplate'; import { TruncatedReferencesTemplate } from '../../components/Templates/reference/TruncatedReferencesTemplate'; +import { StringTemplate } from '../../components/Templates/StringTemplate'; import { SearchService } from '../../service/SearchService'; @@ -257,6 +258,7 @@ export const ConstructsTable = () => { field: 'updatedBy.uniqueId', header: 'Updated By', sortable: { isInEditMode }, + body: (rowData) => , filterConfig: FILTER_CONFIGS.updatedByFilterConfig, }, { @@ -264,6 +266,7 @@ export const ConstructsTable = () => { header: 'Date Updated', sortable: { isInEditMode }, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.dateUpdatedFilterConfig, }, { @@ -271,6 +274,7 @@ export const ConstructsTable = () => { header: 'Created By', sortable: { isInEditMode }, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.createdByFilterConfig, }, { @@ -278,6 +282,7 @@ export const ConstructsTable = () => { header: 'Date Created', sortable: { isInEditMode }, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.dataCreatedFilterConfig, }, { diff --git a/src/main/cliapp/src/containers/controlledVocabularyPage/ControlledVocabularyTable.js b/src/main/cliapp/src/containers/controlledVocabularyPage/ControlledVocabularyTable.js index aa5955cf2..383b1177b 100644 --- a/src/main/cliapp/src/containers/controlledVocabularyPage/ControlledVocabularyTable.js +++ b/src/main/cliapp/src/containers/controlledVocabularyPage/ControlledVocabularyTable.js @@ -19,6 +19,9 @@ import { useGetUserSettings } from '../../service/useGetUserSettings'; import { SearchService } from '../../service/SearchService'; import { setNewEntity } from '../../utils/utils'; import { StringListTemplate } from '../../components/Templates/StringListTemplate'; +import { StringTemplate } from '../../components/Templates/StringTemplate'; +import { IdTemplate } from '../../components/Templates/IdTemplate'; +import { BooleanTemplate } from '../../components/Templates/BooleanTemplate'; export const ControlledVocabularyTable = () => { const newTermReducer = (state, action) => { @@ -184,41 +187,12 @@ export const ControlledVocabularyTable = () => { ); }; - const nameBodyTemplate = (rowData) => { - if (rowData.name) { - return
{rowData.name}
; - } - }; - - const abbreviationBodyTemplate = (rowData) => { - if (rowData.abbreviation) { - return
{rowData.abbreviation}
; - } - }; - - const vocabularyBodyTemplate = (rowData) => { - if (rowData.vocabulary && rowData.vocabulary.name) { - return
{rowData.vocabulary.name}
; - } - }; - - const definitionBodyTemplate = (rowData) => { - if (rowData.definition) { - return
{rowData.definition}
; - } - }; - - const obsoleteBodyTemplate = (rowData) => { - if (rowData && rowData.obsolete !== null && rowData.obsolete !== undefined) { - return
{JSON.stringify(rowData.obsolete)}
; - } - }; - const columns = [ { field: 'id', header: 'Id', sortable: false, + body: (rowData) => , }, { field: 'name', @@ -226,7 +200,7 @@ export const ControlledVocabularyTable = () => { sortable: true, filterConfig: FILTER_CONFIGS.nameFilterConfig, editor: (props) => nameEditorTemplate(props), - body: nameBodyTemplate, + body: (rowData) => , }, { field: 'abbreviation', @@ -234,7 +208,7 @@ export const ControlledVocabularyTable = () => { sortable: true, filterConfig: FILTER_CONFIGS.abbreviationFilterConfig, editor: (props) => abbreviationEditorTemplate(props), - body: abbreviationBodyTemplate, + body: (rowData) => , }, { field: 'synonyms', @@ -249,7 +223,7 @@ export const ControlledVocabularyTable = () => { sortable: true, filterConfig: FILTER_CONFIGS.vocabularyNameFilterConfig, editor: (props) => vocabularyEditorTemplate(props), - body: vocabularyBodyTemplate, + body: (rowData) => , }, { field: 'definition', @@ -257,7 +231,7 @@ export const ControlledVocabularyTable = () => { sortable: true, filterConfig: FILTER_CONFIGS.definitionFilterConfig, editor: (props) => definitionEditorTemplate(props), - body: definitionBodyTemplate, + body: (rowData) => , }, { field: 'obsolete', @@ -265,7 +239,7 @@ export const ControlledVocabularyTable = () => { sortable: true, filterConfig: FILTER_CONFIGS.obsoleteFilterConfig, editor: (props) => obsoleteEditorTemplate(props), - body: obsoleteBodyTemplate, + body: (rowData) => , }, ]; diff --git a/src/main/cliapp/src/containers/dataLoadsPage/DataLoadsComponent.js b/src/main/cliapp/src/containers/dataLoadsPage/DataLoadsComponent.js index 360ec99b7..936baa078 100644 --- a/src/main/cliapp/src/containers/dataLoadsPage/DataLoadsComponent.js +++ b/src/main/cliapp/src/containers/dataLoadsPage/DataLoadsComponent.js @@ -1,6 +1,7 @@ import React, { useReducer, useRef, useState, useContext } from 'react'; import { useQuery } from '@tanstack/react-query'; import { DataTable } from 'primereact/datatable'; +import Moment from 'react-moment'; import { Column } from 'primereact/column'; import { FileUpload } from 'primereact/fileupload'; import { Toast } from 'primereact/toast'; @@ -19,6 +20,8 @@ import { HistoryDialog } from './HistoryDialog'; import { useQueryClient } from '@tanstack/react-query'; import { SiteContext } from '../layout/SiteContext'; import { LoadingOverlay } from '../../components/LoadingOverlay'; +import moment from 'moment-timezone'; +import { NumberTemplate } from '../../components/Templates/NumberTemplate'; export const DataLoadsComponent = () => { const { authState } = useOktaAuth(); @@ -45,7 +48,7 @@ export const DataLoadsComponent = () => { const [bulkLoadDialog, setBulkLoadDialog] = useState(false); const [expandedGroupRows, setExpandedGroupRows] = useState(null); const [expandedLoadRows, setExpandedLoadRows] = useState(null); - const [expandedFileRows, setExpandedFileRows] = useState(null); + //const [expandedFileRows, setExpandedFileRows] = useState(null); const [expandedErrorLoadRows, setExpandedErrorLoadRows] = useState(null); const [disableFormFields, setDisableFormFields] = useState(false); const errorMessage = useRef(null); @@ -81,7 +84,10 @@ export const DataLoadsComponent = () => { 'GeneDTO', 'AlleleDTO', 'AffectedGenomicModelDTO', + // 'VariantDTO', 'ConstructDTO', + 'AlleleGeneAssociationDTO', + 'ConstructGenomicEntityAssociationDTO', ], ], ['DISEASE_ANNOTATION', ['GeneDiseaseAnnotationDTO', 'AlleleDiseaseAnnotationDTO', 'AGMDiseaseAnnotationDTO']], @@ -91,7 +97,7 @@ export const DataLoadsComponent = () => { ['GENE', ['GeneDTO']], ['ALLELE', ['AlleleDTO']], ['AGM', ['AffectedGenomicModelDTO']], - ['VARIANT', ['VariantDTO']], + // ['VARIANT', ['VariantDTO']], ['CONSTRUCT', ['ConstructDTO']], ['ALLELE_ASSOCIATION', ['AlleleGeneAssociationDTO']], ['CONSTRUCT_ASSOCIATION', ['ConstructGenomicEntityAssociationDTO']], @@ -105,8 +111,8 @@ export const DataLoadsComponent = () => { if (group.loads) { for (let load of group.loads) { load.group = group.id; - if (load.loadFiles) { - let sortedFiles = sortFilesByDate(load.loadFiles); + if (load.history) { + let sortedFiles = sortFilesByDate(load.history); if (sortedFiles[0].bulkloadStatus === 'FAILED') { _errorLoads.push(load); } @@ -161,7 +167,7 @@ export const DataLoadsComponent = () => { }; const urlTemplate = (rowData) => { - return Download; + return Download; }; const refresh = () => { @@ -170,15 +176,15 @@ export const DataLoadsComponent = () => { const runLoad = (rowData) => { getService() - .restartLoad(rowData.type, rowData.id) + .restartLoad(rowData.id) .then((response) => { queryClient.invalidateQueries(['bulkloadtable']); }); }; - const runLoadFile = (rowData) => { + const runHistoryLoad = (rowData) => { getService() - .restartLoadFile(rowData.id) + .restartHistoryLoad(rowData.id) .then((response) => { queryClient.invalidateQueries(['bulkloadtable']); }); @@ -190,9 +196,9 @@ export const DataLoadsComponent = () => { setDisableFormFields(true); }; - const deleteLoadFile = (rowData) => { + const deleteLoadFileHistory = (rowData) => { getService() - .deleteLoadFile(rowData.id) + .deleteLoadFileHistory(rowData.id) .then((response) => { queryClient.invalidateQueries(['bulkloadtable']); }); @@ -236,12 +242,13 @@ export const DataLoadsComponent = () => { }*/} - {rowData.failedRecords > 0 && ( - - )} + {rowData.counts && + Object.values(rowData.counts).some((field) => field.failed !== undefined && field.failed > 0) && ( + + )} ); }; @@ -276,21 +283,25 @@ export const DataLoadsComponent = () => { setUploadConfirmDialog(false); }; - const loadFileActionBodyTemplate = (rowData) => { + const loadFileActionBodyTemplate = (rowData, bulkload) => { let ret = []; + // console.log(rowData); if ( !rowData.bulkloadStatus || rowData.bulkloadStatus === 'FINISHED' || rowData.bulkloadStatus === 'FAILED' || rowData.bulkloadStatus === 'STOPPED' ) { - if (fileWithinSchemaRange(rowData.linkMLSchemaVersion, rowData.loadType)) { + if ( + fileWithinSchemaRange(rowData.bulkLoadFile.linkMLSchemaVersion, bulkload.backendBulkLoadType) || + exemptTypes(bulkload.backendBulkLoadType) + ) { ret.push(
); }; +*/ const loadTable = (group) => { let sortedLoads = []; @@ -599,7 +675,7 @@ export const DataLoadsComponent = () => { responsiveLayout="scroll" expandedRows={expandedLoadRows} onRowToggle={(e) => setExpandedLoadRows(e.data)} - rowExpansionTemplate={fileTable} + rowExpansionTemplate={historyTable} dataKey="id" > @@ -631,6 +707,10 @@ export const DataLoadsComponent = () => { } }; + const exemptTypes = (loadType) => { + return loadType === 'GFF_EXON' || loadType === 'GFF_TRANSCRIPT' || loadType === 'GFF_CDS'; + }; + const fileWithinSchemaRange = (fileVersion, loadType) => { if (!fileVersion) return false; const classVersions = apiVersion?.agrCurationSchemaVersions; @@ -795,7 +875,7 @@ export const DataLoadsComponent = () => { responsiveLayout="scroll" expandedRows={expandedErrorLoadRows} onRowToggle={(e) => setExpandedErrorLoadRows(e.data)} - rowExpansionTemplate={fileTable} + rowExpansionTemplate={historyTable} dataKey="id" > diff --git a/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js b/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js index a561bdecf..e7217070e 100644 --- a/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js +++ b/src/main/cliapp/src/containers/diseaseAnnotationsPage/DiseaseAnnotationsTable.js @@ -14,9 +14,8 @@ import { DiseaseAnnotationService } from '../../service/DiseaseAnnotationService import { RelatedNotesDialog } from '../../components/RelatedNotesDialog'; import { ConditionRelationsDialog } from '../../components/ConditionRelationsDialog'; -import { EvidenceCodesTemplate } from '../../components/Templates/EvidenceCodesTemplate'; import { SingleReferenceTemplate } from '../../components/Templates/reference/SingleReferenceTemplate'; -import { DiseaseQualifiersTemplate } from '../../components/Templates/DiseaseQualifiersTemplate'; +import { ObjectListTemplate } from '../../components/Templates/ObjectListTemplate'; import { IdTemplate } from '../../components/Templates/IdTemplate'; import { OntologyTermTemplate } from '../../components/Templates/OntologyTermTemplate'; import { GenomicEntityTemplate } from '../../components/Templates/genomicEntity/GenomicEntityTemplate'; @@ -25,6 +24,7 @@ import { BooleanTemplate } from '../../components/Templates/BooleanTemplate'; import { NotTemplate } from '../../components/Templates/NotTemplate'; import { CountDialogTemplate } from '../../components/Templates/dialog/CountDialogTemplate'; import { TextDialogTemplate } from '../../components/Templates/dialog/TextDialogTemplate'; +import { StringTemplate } from '../../components/Templates/StringTemplate'; import { NotEditor } from '../../components/Editors/NotEditor'; @@ -44,6 +44,7 @@ import { getIdentifier, setNewEntity, } from '../../utils/utils'; +import { diseaseQualifiersSort, evidenceCodesSort } from '../../components/Templates/utils/sortMethods'; import { useNewAnnotationReducer } from './useNewAnnotationReducer'; import { NewAnnotationForm } from './NewAnnotationForm'; import { AutocompleteMultiEditor } from '../../components/Autocomplete/AutocompleteMultiEditor'; @@ -626,11 +627,110 @@ export const DiseaseAnnotationsTable = () => { ); }; - const onGeneticModifiersValueChange = (event, setFieldValue, props) => { - multipleAutocompleteOnChange(props, event, 'diseaseGeneticModifiers', setFieldValue); + const onGeneticModifierAgmsValueChange = (event, setFieldValue, props) => { + multipleAutocompleteOnChange(props, event, 'diseaseGeneticModifierAgms', setFieldValue); }; - const geneticModifiersSearch = (event, setFiltered, setInputValue) => { + const geneticModifierAgmsSearch = (event, setFiltered, setInputValue) => { + const autocompleteFields = ['name', 'curie', 'modEntityId', 'modInternalId', 'crossReferences.referencedCurie']; + const endpoint = 'agm'; + const filterName = 'geneticModifierAgmsFilter'; + const filter = buildAutocompleteFilter(event, autocompleteFields); + setInputValue(event.query); + autocompleteSearch(searchService, endpoint, filterName, filter, setFiltered); + }; + + const geneticModifierAgmsEditorTemplate = (props) => { + return ( + <> + ( + + )} + onValueChangeHandler={onGeneticModifierAgmsValueChange} + /> + + + + ); + }; + + const onGeneticModifierAllelesValueChange = (event, setFieldValue, props) => { + multipleAutocompleteOnChange(props, event, 'diseaseGeneticModifierAlleles', setFieldValue); + }; + + const geneticModifierAllelesSearch = (event, setFiltered, setInputValue) => { + const autocompleteFields = [ + 'alleleSymbol.formatText', + 'alleleFullName.formatText', + 'alleleFullName.displayText', + 'alleleSynonyms.formatText', + 'alleleSynonyms.displayText', + 'curie', + 'modEntityId', + 'modInternalId', + 'crossReferences.referencedCurie', + 'alleleSecondaryIds.secondaryId', + ]; + const endpoint = 'allele'; + const filterName = 'geneticModifierAllelesFilter'; + const filter = buildAutocompleteFilter(event, autocompleteFields); + setInputValue(event.query); + autocompleteSearch(searchService, endpoint, filterName, filter, setFiltered); + }; + + const geneticModifierAllelesEditorTemplate = (props) => { + return ( + <> + ( + + )} + onValueChangeHandler={onGeneticModifierAllelesValueChange} + /> + + + + ); + }; + + const onGeneticModifierGenesValueChange = (event, setFieldValue, props) => { + multipleAutocompleteOnChange(props, event, 'diseaseGeneticModifierGenes', setFieldValue); + }; + + const geneticModifierGenesSearch = (event, setFiltered, setInputValue) => { const autocompleteFields = [ 'geneSymbol.formatText', 'geneSymbol.displayText', @@ -641,33 +741,26 @@ export const DiseaseAnnotationsTable = () => { 'geneSystematicName.formatText', 'geneSystematicName.displayText', 'geneSecondaryIds.secondaryId', - 'alleleSymbol.formatText', - 'alleleFullName.formatText', - 'alleleFullName.displayText', - 'alleleSynonyms.formatText', - 'alleleSynonyms.displayText', - 'name', 'curie', 'modEntityId', 'modInternalId', 'crossReferences.referencedCurie', - 'alleleSecondaryIds.secondaryId', ]; - const endpoint = 'biologicalentity'; - const filterName = 'geneticModifiersFilter'; + const endpoint = 'gene'; + const filterName = 'geneticModifierGenesFilter'; const filter = buildAutocompleteFilter(event, autocompleteFields); setInputValue(event.query); autocompleteSearch(searchService, endpoint, filterName, filter, setFiltered); }; - const geneticModifiersEditorTemplate = (props) => { + const geneticModifierGenesEditorTemplate = (props) => { return ( <> ( { query={query} /> )} - onValueChangeHandler={onGeneticModifiersValueChange} + onValueChangeHandler={onGeneticModifierGenesValueChange} /> ); @@ -1065,7 +1158,7 @@ export const DiseaseAnnotationsTable = () => { { field: 'diseaseAnnotationObject.name', header: 'Disease', - body: (rowData) => , + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.diseaseAnnotationObjectFilterConfig, editor: (props) => diseaseEditorTemplate(props), @@ -1081,7 +1174,13 @@ export const DiseaseAnnotationsTable = () => { { field: 'evidenceCodes.abbreviation', header: 'Evidence Code', - body: (rowData) => , + body: (rowData) => ( + `${item.abbreviation} - ${item.name} (${item.curie})`} + /> + ), sortable: true, filterConfig: FILTER_CONFIGS.evidenceCodesFilterConfig, editor: (props) => evidenceEditorTemplate(props), @@ -1149,7 +1248,13 @@ export const DiseaseAnnotationsTable = () => { { field: 'diseaseQualifiers.name', header: 'Disease Qualifiers', - body: (rowData) => , + body: (rowData) => ( + item.name} + /> + ), sortable: true, filterConfig: FILTER_CONFIGS.diseaseQualifiersFilterConfig, editor: (props) => diseaseQualifiersEditor(props), @@ -1177,12 +1282,28 @@ export const DiseaseAnnotationsTable = () => { editor: (props) => geneticModifierRelationEditor(props), }, { - field: 'diseaseGeneticModifiers.symbol', - header: 'Genetic Modifiers', - body: (rowData) => , + field: 'diseaseGeneticModifierAgms.name', + header: 'Genetic Modifier AGMs', + body: (rowData) => , + sortable: true, + filterConfig: FILTER_CONFIGS.geneticModifierAgmsFilterConfig, + editor: (props) => geneticModifierAgmsEditorTemplate(props), + }, + { + field: 'diseaseGeneticModifierAlleles.alleleSymbol.displayText', + header: 'Genetic Modifier Alleles', + body: (rowData) => , + sortable: true, + filterConfig: FILTER_CONFIGS.geneticModifierAllelesFilterConfig, + editor: (props) => geneticModifierAllelesEditorTemplate(props), + }, + { + field: 'diseaseGeneticModifierGenes.geneSymbol.displayText', + header: 'Genetic Modifier Genes', + body: (rowData) => , sortable: true, - filterConfig: FILTER_CONFIGS.geneticModifiersFilterConfig, - editor: (props) => geneticModifiersEditorTemplate(props), + filterConfig: FILTER_CONFIGS.geneticModifierGenesFilterConfig, + editor: (props) => geneticModifierGenesEditorTemplate(props), }, { field: 'inferredGene.geneSymbol.displayText', @@ -1230,24 +1351,28 @@ export const DiseaseAnnotationsTable = () => { field: 'updatedBy.uniqueId', header: 'Updated By', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.updatedByFilterConfig, }, { field: 'dateUpdated', header: 'Date Updated', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.dateUpdatedFilterConfig, }, { field: 'createdBy.uniqueId', header: 'Created By', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.createdByFilterConfig, }, { field: 'dateCreated', header: 'Date Created', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.dataCreatedFilterConfig, }, { diff --git a/src/main/cliapp/src/containers/diseaseAnnotationsPage/NewAnnotationForm.js b/src/main/cliapp/src/containers/diseaseAnnotationsPage/NewAnnotationForm.js index 8f54d5921..0ebad9548 100644 --- a/src/main/cliapp/src/containers/diseaseAnnotationsPage/NewAnnotationForm.js +++ b/src/main/cliapp/src/containers/diseaseAnnotationsPage/NewAnnotationForm.js @@ -36,7 +36,9 @@ import { SGDStrainBackgroundAdditionalFieldData } from '../../components/FieldDa import { AssertedGenesAdditionalFieldData } from '../../components/FieldData/AssertedGenesAdditionalFieldData'; import { EvidenceCodesAdditionalFieldData } from '../../components/FieldData/EvidenceCodesAdditionalFieldData'; import { WithAdditionalFieldData } from '../../components/FieldData/WithAdditionalFieldData'; -import { GeneticModifiersAdditionalFieldData } from '../../components/FieldData/GeneticModifiersAdditionalFieldData'; +import { GeneticModifierAgmsAdditionalFieldData } from '../../components/FieldData/GeneticModifierAgmsAdditionalFieldData'; +import { GeneticModifierAllelesAdditionalFieldData } from '../../components/FieldData/GeneticModifierAllelesAdditionalFieldData'; +import { GeneticModifierGenesAdditionalFieldData } from '../../components/FieldData/GeneticModifierGenesAdditionalFieldData'; import ErrorBoundary from '../../components/Error/ErrorBoundary'; import { ConfirmButton } from '../../components/ConfirmButton'; import { getDefaultFormState, getModFormFields } from '../../service/TableStateService'; @@ -94,7 +96,9 @@ export const NewAnnotationForm = ({ 'SGD Strain Background', 'Annotation Type', 'Genetic Modifier Relation', - 'Genetic Modifiers', + 'Genetic Modifier AGMs', + 'Genetic Modifier Alleles', + 'Genetic Modifier Genes', 'Internal', ]; const oktaToken = JSON.parse(localStorage.getItem('okta-token-storage')); @@ -232,23 +236,45 @@ export const NewAnnotationForm = ({ autocompleteSearch(searchService, endpoint, filterName, filter, setFiltered, otherFilters); }; - const geneticModifiersSearch = (event, setFiltered, setQuery) => { + const geneticModifierAgmsSearch = (event, setFiltered, setQuery) => { + const autocompleteFields = ['modEntityId', 'modInternalId', 'name', 'curie', 'crossReferences.referencedCurie']; + const endpoint = 'agm'; + const filterName = 'geneticModifierAgmsFilter'; + const filter = buildAutocompleteFilter(event, autocompleteFields); + setQuery(event.query); + autocompleteSearch(searchService, endpoint, filterName, filter, setFiltered); + }; + + const geneticModifierAllelesSearch = (event, setFiltered, setQuery) => { const autocompleteFields = [ - 'geneSymbol.displayText', - 'geneFullName.displayText', 'alleleSymbol.displayText', 'alleleFullName.displayText', 'modEntityId', 'modInternalId', - 'name', 'curie', 'crossReferences.referencedCurie', 'alleleSecondaryIds.secondaryId', - 'geneSynonyms.displayText', 'alleleSynonyms.displayText', ]; - const endpoint = 'biologicalentity'; - const filterName = 'geneticModifiersFilter'; + const endpoint = 'allele'; + const filterName = 'geneticModifierAllelesFilter'; + const filter = buildAutocompleteFilter(event, autocompleteFields); + setQuery(event.query); + autocompleteSearch(searchService, endpoint, filterName, filter, setFiltered); + }; + + const geneticModifierGenesSearch = (event, setFiltered, setQuery) => { + const autocompleteFields = [ + 'geneSymbol.displayText', + 'geneFullName.displayText', + 'modEntityId', + 'modInternalId', + 'curie', + 'crossReferences.referencedCurie', + 'geneSynonyms.displayText', + ]; + const endpoint = 'gene'; + const filterName = 'geneticModifierGenesFilter'; const filter = buildAutocompleteFilter(event, autocompleteFields); setQuery(event.query); autocompleteSearch(searchService, endpoint, filterName, filter, setFiltered); @@ -1027,18 +1053,18 @@ export const NewAnnotationForm = ({ )} - {selectedFormFields?.includes('Genetic Modifiers') && ( + {selectedFormFields?.includes('Genetic Modifier AGMs') && ( <>
- +
( )} onValueChangeHandler={onArrayFieldChange} - classNames={classNames({ 'p-invalid': submitted && errorMessages.diseaseGeneticModifiers })} + classNames={classNames({ 'p-invalid': submitted && errorMessages.diseaseGeneticModifierAgms })} />
- - + + +
+
+ + )} + + {selectedFormFields?.includes('Genetic Modifier Alleles') && ( + <> +
+
+ +
+
+ ( + + )} + onValueChangeHandler={onArrayFieldChange} + classNames={classNames({ 'p-invalid': submitted && errorMessages.diseaseGeneticModifierAlleles })} + /> +
+
+ + +
+
+ + )} + + {selectedFormFields?.includes('Genetic Modifier Genes') && ( + <> +
+
+ +
+
+ ( + + )} + onValueChangeHandler={onArrayFieldChange} + classNames={classNames({ 'p-invalid': submitted && errorMessages.diseaseGeneticModifierGenes })} + /> +
+
+ +
diff --git a/src/main/cliapp/src/containers/diseaseAnnotationsPage/__tests__/DiseaseAnnotationsTable.test.js b/src/main/cliapp/src/containers/diseaseAnnotationsPage/__tests__/DiseaseAnnotationsTable.test.js index 7d332cfd8..2fd3cb844 100644 --- a/src/main/cliapp/src/containers/diseaseAnnotationsPage/__tests__/DiseaseAnnotationsTable.test.js +++ b/src/main/cliapp/src/containers/diseaseAnnotationsPage/__tests__/DiseaseAnnotationsTable.test.js @@ -59,6 +59,9 @@ describe('', () => { const geneticSexTd = await result.findByText('genetic sex test'); const sgdStrainBackgroundTd = await result.findByText('SGD Strain Background test (sgd test curie)'); const diseaseGeneticModifierRelationTd = await result.findByText('disease genetic modifier relation test'); + const diseaseGeneticModifierAgmsTd = await result.findByText('DGM AGM test (WB:DGM1)'); + const diseaseGeneticModifierAllelesTd = await result.findByText('DGM Allele test (WB:DGM2)'); + const diseaseGeneticModifierGenesTd = await result.findByText('DGM Gene test (WB:DGM3)'); const secondaryDataProviderTd = await result.findByText('test provider'); const updatedByCreatedByArray = await result.findAllByText('MGI:curation_staff'); @@ -85,6 +88,9 @@ describe('', () => { expect(sgdStrainBackgroundTd).toBeInTheDocument(); expect(diseaseQualifiersTd).toBeInTheDocument(); expect(diseaseGeneticModifierRelationTd).toBeInTheDocument(); + expect(diseaseGeneticModifierAgmsTd).toBeInTheDocument(); + expect(diseaseGeneticModifierAllelesTd).toBeInTheDocument(); + expect(diseaseGeneticModifierGenesTd).toBeInTheDocument(); expect(secondaryDataProviderTd).toBeInTheDocument(); expect(updatedByCreatedByArray.length).toEqual(2); expect(dateUpdatedDateCreatedArray.length).toEqual(2); diff --git a/src/main/cliapp/src/containers/diseaseAnnotationsPage/mockData/mockData.js b/src/main/cliapp/src/containers/diseaseAnnotationsPage/mockData/mockData.js index 7cc7b0344..aa2992b83 100644 --- a/src/main/cliapp/src/containers/diseaseAnnotationsPage/mockData/mockData.js +++ b/src/main/cliapp/src/containers/diseaseAnnotationsPage/mockData/mockData.js @@ -58,7 +58,9 @@ export const data = { curie: 'sgd test curie', name: 'SGD Strain Background test', }, - diseaseGeneticModifiers: [{ symbol: 'disease genetic modifier test' }], + diseaseGeneticModifierAgms: [{ name: 'DGM AGM test', modEntityId: 'WB:DGM1' }], + diseaseGeneticModifierAlleles: [{ modEntityId: 'WB:DGM2', alleleSymbol: { displayText: 'DGM Allele test' } }], + diseaseGeneticModifierGenes: [{ modEntityId: 'WB:DGM3', geneSymbol: { displayText: 'DGM Gene test' } }], diseaseQualifiers: [{ name: 'disease qualifiers test' }], dateCreated: '2017-06-08T14:15:35Z', dateUpdated: '2017-06-08T14:15:35Z', diff --git a/src/main/cliapp/src/containers/diseaseAnnotationsPage/useNewAnnotationReducer.js b/src/main/cliapp/src/containers/diseaseAnnotationsPage/useNewAnnotationReducer.js index 78bc721e9..6c2a2b0b3 100644 --- a/src/main/cliapp/src/containers/diseaseAnnotationsPage/useNewAnnotationReducer.js +++ b/src/main/cliapp/src/containers/diseaseAnnotationsPage/useNewAnnotationReducer.js @@ -26,7 +26,9 @@ const DEFAULT_ANNOTATION = { sgdStrainBackground: null, annotationType: null, diseaseGeneticModifierRelation: null, - diseaseGeneticModifiers: [], + diseaseGeneticModifierAgm: [], + diseaseGeneticModifierAlleles: [], + diseaseGeneticModifierGenes: [], internal: false, }; const initialNewAnnotationState = { @@ -68,8 +70,12 @@ const buildAnnotation = (rowData) => { diseaseGeneticModifierRelation: global.structuredClone(rowData.diseaseGeneticModifierRelation) || DEFAULT_ANNOTATION.diseaseGeneticModifierRelation, - diseaseGeneticModifiers: - global.structuredClone(rowData.diseaseGeneticModifiers) || DEFAULT_ANNOTATION.diseaseGeneticModifiers, + diseaseGeneticModifierAgms: + global.structuredClone(rowData.diseaseGeneticModifierAgms) || DEFAULT_ANNOTATION.diseaseGeneticModifierAgms, + diseaseGeneticModifierAlleles: + global.structuredClone(rowData.diseaseGeneticModifierAlleles) || DEFAULT_ANNOTATION.diseaseGeneticModifierAlleles, + diseaseGeneticModifierGenes: + global.structuredClone(rowData.diseaseGeneticModifierGenes) || DEFAULT_ANNOTATION.diseaseGeneticModifierGenes, internal: rowData.internal || DEFAULT_ANNOTATION.internal, }; }; diff --git a/src/main/cliapp/src/containers/experimentalConditionsPage/ExperimentalConditionsTable.js b/src/main/cliapp/src/containers/experimentalConditionsPage/ExperimentalConditionsTable.js index 30f6be110..414dd7ee0 100644 --- a/src/main/cliapp/src/containers/experimentalConditionsPage/ExperimentalConditionsTable.js +++ b/src/main/cliapp/src/containers/experimentalConditionsPage/ExperimentalConditionsTable.js @@ -6,9 +6,7 @@ import { useMutation } from '@tanstack/react-query'; import { Toast } from 'primereact/toast'; import { SearchService } from '../../service/SearchService'; import { ErrorMessageComponent } from '../../components/Error/ErrorMessageComponent'; -import { EllipsisTableCell } from '../../components/EllipsisTableCell'; import { ExperimentalConditionService } from '../../service/ExperimentalConditionService'; -import { Tooltip } from 'primereact/tooltip'; import { Button } from 'primereact/button'; import { TrueFalseDropdown } from '../../components/TrueFalseDropDownSelector'; import { NewConditionForm } from './NewConditionForm'; @@ -24,6 +22,11 @@ import { getDefaultTableState } from '../../service/TableStateService'; import { FILTER_CONFIGS } from '../../constants/FilterFields'; import { useGetTableData } from '../../service/useGetTableData'; import { useGetUserSettings } from '../../service/useGetUserSettings'; +import { IdTemplate } from '../../components/Templates/IdTemplate'; +import { StringTemplate } from '../../components/Templates/StringTemplate'; +import { BooleanTemplate } from '../../components/Templates/BooleanTemplate'; +import { NumberTemplate } from '../../components/Templates/NumberTemplate'; +import { OntologyTermTemplate } from '../../components/Templates/OntologyTermTemplate'; export const ExperimentalConditionsTable = () => { const [errorMessages, setErrorMessages] = useState({}); @@ -73,115 +76,6 @@ export const ExperimentalConditionsTable = () => { ); }; - const uniqueIdBodyTemplate = (rowData) => { - if (rowData) { - return ( - <> - {rowData.uniqueId} - - - ); - } - }; - - const summaryBodyTemplate = (rowData) => { - if (rowData) { - return ( - <> - {rowData.conditionSummary} - - - ); - } - }; - - const conditionClassBodyTemplate = (rowData) => { - if (rowData?.conditionClass) { - return ( - <> - - {rowData.conditionClass.name} ({rowData.conditionClass.curie}) - - - - ); - } - }; - - const conditionIdBodyTemplate = (rowData) => { - if (rowData?.conditionId) { - return ( - <> - - {rowData.conditionId.name} ({rowData.conditionId.curie}) - - - - ); - } - }; - - const conditionGeneOntologyBodyTemplate = (rowData) => { - if (rowData?.conditionGeneOntology) { - return ( - - {rowData.conditionGeneOntology.name} ({rowData.conditionGeneOntology.curie}) - - ); - } - }; - - const conditionChemicalBodyTemplate = (rowData) => { - if (rowData?.conditionChemical) { - return ( - - {rowData.conditionChemical.name} ({rowData.conditionChemical.curie}) - - ); - } - }; - - const conditionAnatomyBodyTemplate = (rowData) => { - if (rowData?.conditionAnatomy) { - return ( - - {rowData.conditionAnatomy.name} ({rowData.conditionAnatomy.curie}) - - ); - } - }; - - const conditionTaxonBodyTemplate = (rowData) => { - if (rowData?.conditionTaxon) { - return ( - <> - - {rowData.conditionTaxon.name} ({rowData.conditionTaxon.curie}) - - - - ); - } - }; - - const internalBodyTemplate = (rowData) => { - if (rowData && rowData.internal !== null && rowData.internal !== undefined) { - return {JSON.stringify(rowData.internal)}; - } - }; - const onInternalEditorValueChange = (props, event) => { let updatedAnnotations = [...props.props.value]; if (event.value || event.value === '') { @@ -273,21 +167,21 @@ export const ExperimentalConditionsTable = () => { field: 'uniqueId', header: 'Unique ID', sortable: true, - body: uniqueIdBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.uniqueidFilterConfig, }, { field: 'conditionSummary', header: 'Summary', sortable: true, - body: summaryBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.conditionRelationSummaryFilterConfig, }, { field: 'conditionClass.name', header: 'Class', sortable: true, - body: conditionClassBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.conditionClassFilterConfig, editor: (props) => conditionClassEditorTemplate(props, curieAutocompleteFields), }, @@ -295,7 +189,7 @@ export const ExperimentalConditionsTable = () => { field: 'conditionId.name', header: 'Condition Term', sortable: true, - body: conditionIdBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.conditionIdFilterConfig, editor: (props) => singleOntologyEditorTemplate( @@ -309,16 +203,16 @@ export const ExperimentalConditionsTable = () => { field: 'conditionGeneOntology.name', header: 'Gene Ontology', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.conditionGeneOntologyFilterConfig, editor: (props) => singleOntologyEditorTemplate(props, 'conditionGeneOntology', 'goterm', curieAutocompleteFields), - body: conditionGeneOntologyBodyTemplate, }, { field: 'conditionChemical.name', header: 'Chemical', sortable: true, - body: conditionChemicalBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.conditionChemicalFilterConfig, editor: (props) => singleOntologyEditorTemplate(props, 'conditionChemical', 'chemicalterm', curieAutocompleteFields), @@ -327,7 +221,7 @@ export const ExperimentalConditionsTable = () => { field: 'conditionAnatomy.name', header: 'Anatomy', sortable: true, - body: conditionAnatomyBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.conditionAnatomyFilterConfig, editor: (props) => singleOntologyEditorTemplate(props, 'conditionAnatomy', 'anatomicalterm', curieAutocompleteFields), @@ -336,7 +230,7 @@ export const ExperimentalConditionsTable = () => { field: 'conditionTaxon.name', header: 'Condition Taxon', sortable: true, - body: conditionTaxonBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.conditionTaxonFilterConfig, editor: (props) => singleOntologyEditorTemplate(props, 'conditionTaxon', 'ncbitaxonterm', curieAutocompleteFields), @@ -345,6 +239,7 @@ export const ExperimentalConditionsTable = () => { field: 'conditionQuantity', header: 'Quantity', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.conditionQuantityFilterConfig, editor: (props) => freeTextEditor(props, 'conditionQuantity'), }, @@ -352,13 +247,14 @@ export const ExperimentalConditionsTable = () => { field: 'conditionFreeText', header: 'Free Text', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.conditionFreeTextFilterConfig, editor: (props) => freeTextEditor(props, 'conditionFreeText'), }, { field: 'internal', header: 'Internal', - body: internalBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.internalFilterConfig, sortable: true, editor: (props) => internalEditor(props), diff --git a/src/main/cliapp/src/containers/geneGeneticInteractionsPage/GeneGeneticInteractionsTable.js b/src/main/cliapp/src/containers/geneGeneticInteractionsPage/GeneGeneticInteractionsTable.js index ab75cd4d4..31be4e215 100644 --- a/src/main/cliapp/src/containers/geneGeneticInteractionsPage/GeneGeneticInteractionsTable.js +++ b/src/main/cliapp/src/containers/geneGeneticInteractionsPage/GeneGeneticInteractionsTable.js @@ -12,6 +12,7 @@ import { useGetTableData } from '../../service/useGetTableData'; import { useGetUserSettings } from '../../service/useGetUserSettings'; import { SearchService } from '../../service/SearchService'; import { TruncatedReferencesTemplate } from '../../components/Templates/reference/TruncatedReferencesTemplate'; +import { StringTemplate } from '../../components/Templates/StringTemplate'; export const GeneGeneticInteractionsTable = () => { const [isInEditMode, setIsInEditMode] = useState(false); //needs better name @@ -82,6 +83,7 @@ export const GeneGeneticInteractionsTable = () => { field: 'relation.name', header: 'Interaction Relation', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.gmiRelationFilterConfig, }, { @@ -94,42 +96,42 @@ export const GeneGeneticInteractionsTable = () => { { field: 'interactionType.name', header: 'Interaction Type', - body: (rowData) => , + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.interactionTypeFilterConfig, }, { field: 'interactorARole.name', header: 'Interactor A Role', - body: (rowData) => , + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.interactorARoleFilterConfig, }, { field: 'interactorBRole.name', header: 'Interactor B Role', - body: (rowData) => , + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.interactorBRoleFilterConfig, }, { field: 'interactorAType.name', header: 'Interactor A Type', - body: (rowData) => , + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.interactorATypeFilterConfig, }, { field: 'interactorBType.name', header: 'Interactor B Type', - body: (rowData) => , + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.interactorBTypeFilterConfig, }, { field: 'interactionSource.name', header: 'Interaction Source', - body: (rowData) => , + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.interactionSourceFilterConfig, }, diff --git a/src/main/cliapp/src/containers/geneMolecularInteractionsPage/GeneMolecularInteractionsTable.js b/src/main/cliapp/src/containers/geneMolecularInteractionsPage/GeneMolecularInteractionsTable.js index 969adaf97..58a0ea749 100644 --- a/src/main/cliapp/src/containers/geneMolecularInteractionsPage/GeneMolecularInteractionsTable.js +++ b/src/main/cliapp/src/containers/geneMolecularInteractionsPage/GeneMolecularInteractionsTable.js @@ -10,6 +10,7 @@ import { OntologyTermTemplate } from '../../components/Templates/OntologyTermTem import { useGetTableData } from '../../service/useGetTableData'; import { useGetUserSettings } from '../../service/useGetUserSettings'; import { TruncatedReferencesTemplate } from '../../components/Templates/reference/TruncatedReferencesTemplate'; +import { StringTemplate } from '../../components/Templates/StringTemplate'; import { SearchService } from '../../service/SearchService'; @@ -76,6 +77,7 @@ export const GeneMolecularInteractionsTable = () => { field: 'relation.name', header: 'Interaction Relation', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.gmiRelationFilterConfig, }, { @@ -88,56 +90,56 @@ export const GeneMolecularInteractionsTable = () => { { field: 'interactionType.name', header: 'Interaction Type', - body: (rowData) => , + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.interactionTypeFilterConfig, }, { field: 'interactorARole.name', header: 'Interactor A Role', - body: (rowData) => , + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.interactorARoleFilterConfig, }, { field: 'interactorBRole.name', header: 'Interactor B Role', - body: (rowData) => , + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.interactorBRoleFilterConfig, }, { field: 'interactorAType.name', header: 'Interactor A Type', - body: (rowData) => , + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.interactorATypeFilterConfig, }, { field: 'interactorBType.name', header: 'Interactor B Type', - body: (rowData) => , + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.interactorBTypeFilterConfig, }, { field: 'interactionSource.name', header: 'Interaction Source', - body: (rowData) => , + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.interactionSourceFilterConfig, }, { field: 'aggregationDatabase.name', header: 'Aggregation DB', - body: (rowData) => , + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.aggregationDatabaseFilterConfig, }, { field: 'detectionMethod.name', header: 'Detection Method', - body: (rowData) => , + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.detectionMethodFilterConfig, }, diff --git a/src/main/cliapp/src/containers/genesPage/GenesTable.js b/src/main/cliapp/src/containers/genesPage/GenesTable.js index e6054770e..73caadb6d 100644 --- a/src/main/cliapp/src/containers/genesPage/GenesTable.js +++ b/src/main/cliapp/src/containers/genesPage/GenesTable.js @@ -8,15 +8,17 @@ import { SynonymsDialog } from '../nameSlotAnnotations/dialogs/SynonymsDialog'; import { SymbolDialog } from '../nameSlotAnnotations/dialogs/SymbolDialog'; import { FullNameDialog } from '../nameSlotAnnotations/dialogs/FullNameDialog'; import { SystematicNameDialog } from './SystematicNameDialog'; -import { CrossReferencesTemplate } from '../../components/Templates/CrossReferencesTemplate'; +import { ObjectListTemplate } from '../../components/Templates/ObjectListTemplate'; import { useGetTableData } from '../../service/useGetTableData'; import { useGetUserSettings } from '../../service/useGetUserSettings'; import { IdTemplate } from '../../components/Templates/IdTemplate'; import { TextDialogTemplate } from '../../components/Templates/dialog/TextDialogTemplate'; import { ListDialogTemplate } from '../../components/Templates/dialog/ListDialogTemplate'; -import { TaxonTemplate } from '../../components/Templates/TaxonTemplate'; import { BooleanTemplate } from '../../components/Templates/BooleanTemplate'; import { OntologyTermTemplate } from '../../components/Templates/OntologyTermTemplate'; +import { StringTemplate } from '../../components/Templates/StringTemplate'; + +import { crossReferencesSort } from '../../components/Templates/utils/sortMethods'; import { SearchService } from '../../service/SearchService'; @@ -195,7 +197,7 @@ export const GenesTable = () => { { field: 'geneType.name', header: 'Gene Type', - body: (rowData) => , + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.geneTypeFilterConfig, }, @@ -203,7 +205,7 @@ export const GenesTable = () => { field: 'taxon.name', header: 'Taxon', sortable: true, - body: (rowData) => , + body: (rowData) => , filter: true, filterConfig: FILTER_CONFIGS.taxonFilterConfig, }, @@ -218,12 +220,19 @@ export const GenesTable = () => { header: 'Cross References', sortable: true, filterConfig: FILTER_CONFIGS.crossReferencesFilterConfig, - body: (rowData) => , + body: (rowData) => ( + `${item.displayName} (${item.resourceDescriptorPage.name})`} + /> + ), }, { field: 'updatedBy.uniqueId', header: 'Updated By', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.updatedByFilterConfig, }, { @@ -231,6 +240,7 @@ export const GenesTable = () => { header: 'Date Updated', sortable: true, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.dateUpdatedFilterConfig, }, { @@ -238,6 +248,7 @@ export const GenesTable = () => { header: 'Created By', sortable: true, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.createdByFilterConfig, }, { @@ -245,6 +256,7 @@ export const GenesTable = () => { header: 'Date Created', sortable: true, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.dataCreatedFilterConfig, }, { @@ -265,7 +277,7 @@ export const GenesTable = () => { }, ]; - const DEFAULT_COLUMN_WIDTH = 20; + const DEFAULT_COLUMN_WIDTH = 10; const SEARCH_ENDPOINT = 'gene'; const initialTableState = getDefaultTableState('Genes', columns, DEFAULT_COLUMN_WIDTH); diff --git a/src/main/cliapp/src/containers/moleculesPage/MoleculesTable.js b/src/main/cliapp/src/containers/moleculesPage/MoleculesTable.js index 971b47063..88ff2f443 100644 --- a/src/main/cliapp/src/containers/moleculesPage/MoleculesTable.js +++ b/src/main/cliapp/src/containers/moleculesPage/MoleculesTable.js @@ -1,13 +1,14 @@ import React, { useRef, useState } from 'react'; import { GenericDataTable } from '../../components/GenericDataTable/GenericDataTable'; -import { EllipsisTableCell } from '../../components/EllipsisTableCell'; -import { Tooltip } from 'primereact/tooltip'; import { Toast } from 'primereact/toast'; import { getDefaultTableState } from '../../service/TableStateService'; import { FILTER_CONFIGS } from '../../constants/FilterFields'; import { useGetTableData } from '../../service/useGetTableData'; import { useGetUserSettings } from '../../service/useGetUserSettings'; +import { IdTemplate } from '../../components/Templates/IdTemplate'; +import { StringTemplate } from '../../components/Templates/StringTemplate'; + import { SearchService } from '../../service/SearchService'; export const MoleculesTable = () => { @@ -21,43 +22,13 @@ export const MoleculesTable = () => { const toast_topleft = useRef(null); const toast_topright = useRef(null); - const inChiBodyTemplate = (rowData) => { - return ( - <> - {rowData.inchi} - - - ); - }; - - const iupacBodyTemplate = (rowData) => { - return ( - <> - {rowData.iupac} - - - ); - }; - - const smilesBodyTemplate = (rowData) => { - return ( - <> - {rowData.smiles} - - - ); - }; - const columns = [ { field: 'curie', header: 'Curie', sortable: true, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.curieFilterConfig, }, { @@ -65,6 +36,7 @@ export const MoleculesTable = () => { header: 'Name', sortable: true, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.nameFilterConfig, }, { @@ -72,7 +44,7 @@ export const MoleculesTable = () => { header: 'InChi', sortable: true, filter: true, - body: inChiBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.inchiFilterConfig, }, { @@ -80,6 +52,7 @@ export const MoleculesTable = () => { header: 'InChiKey', sortable: true, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.inchiKeyFilterConfig, }, { @@ -87,7 +60,7 @@ export const MoleculesTable = () => { header: 'IUPAC', sortable: true, filter: true, - body: iupacBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.iupacFilterConfig, }, { @@ -95,6 +68,7 @@ export const MoleculesTable = () => { header: 'Formula', sortable: true, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.formulaFilterConfig, }, { @@ -102,7 +76,7 @@ export const MoleculesTable = () => { header: 'SMILES', sortable: true, filter: true, - body: smilesBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.smilesFilterConfig, }, ]; @@ -141,6 +115,7 @@ export const MoleculesTable = () => { tableState={tableState} setTableState={setTableState} columns={columns} + defaultColumnWidth={DEFAULT_COLUMN_WIDTH} dataKey="curie" isEditable={false} isInEditMode={isInEditMode} diff --git a/src/main/cliapp/src/containers/ontologies/DefinitionTemplate.js b/src/main/cliapp/src/containers/ontologies/DefinitionTemplate.js deleted file mode 100644 index 0e9cbacaf..000000000 --- a/src/main/cliapp/src/containers/ontologies/DefinitionTemplate.js +++ /dev/null @@ -1,16 +0,0 @@ -import React from 'react'; -import { EllipsisTableCell } from '../../components/EllipsisTableCell'; -import { Tooltip } from 'primereact/tooltip'; - -export const DefinitionTemplate = ({ rowData }) => { - return ( - <> - {rowData.definition} - - - ); -}; diff --git a/src/main/cliapp/src/containers/ontologies/GeneralOntologyComponent.js b/src/main/cliapp/src/containers/ontologies/GeneralOntologyComponent.js index 81074b487..04fa2b632 100644 --- a/src/main/cliapp/src/containers/ontologies/GeneralOntologyComponent.js +++ b/src/main/cliapp/src/containers/ontologies/GeneralOntologyComponent.js @@ -1,20 +1,19 @@ import React, { useRef, useState } from 'react'; import { Toast } from 'primereact/toast'; -import { NameTemplate } from './NameTemplate'; import { TabView, TabPanel } from 'primereact/tabview'; -import { DefinitionTemplate } from './DefinitionTemplate'; import { BooleanTemplate } from '../../components/Templates/BooleanTemplate'; import { GenericDataTable } from '../../components/GenericDataTable/GenericDataTable'; import { GenericDataTree } from '../../components/GenericDataTree'; import { getDefaultTableState } from '../../service/TableStateService'; import { FILTER_CONFIGS } from '../../constants/FilterFields'; -import { EllipsisTableCell } from '../../components/EllipsisTableCell'; -import { ListTableCell } from '../../components/ListTableCell'; -import { Tooltip } from 'primereact/tooltip'; import { useGetTableData } from '../../service/useGetTableData'; import { useGetUserSettings } from '../../service/useGetUserSettings'; +import { IdTemplate } from '../../components/Templates/IdTemplate'; +import { StringTemplate } from '../../components/Templates/StringTemplate'; + import { SearchService } from '../../service/SearchService'; +import { StringListTemplate } from '../../components/Templates/StringListTemplate'; export const GeneralOntologyComponent = ({ name, endpoint, showNamespace, showAbbreviation, hideDefinition }) => { const [isInEditMode, setIsInEditMode] = useState(false); @@ -31,70 +30,18 @@ export const GeneralOntologyComponent = ({ name, endpoint, showNamespace, showAb const columns = []; - const synonymsTemplate = (rowData) => { - if (rowData?.synonyms && rowData.synonyms.length > 0) { - const listTemplate = (synonym) => { - return ( - -
- - ); - }; - return ( - <> -
- a.name).sort()} /> -
- - a.name).sort()} /> - - - ); - } - }; - - const secondaryIdsTemplate = (rowData) => { - if (rowData?.secondaryIdentifiers && rowData.secondaryIdentifiers.length > 0) { - const sortedIds = rowData.secondaryIdentifiers.sort(); - const listTemplate = (secondaryId) => { - return ( - -
- - ); - }; - return ( - <> -
- -
- - - - - ); - } - }; - columns.push({ field: 'curie', header: 'Curie', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.curieFilterConfig, }); columns.push({ field: 'name', header: 'Name', sortable: true, - body: (rowData) => , + body: (rowData) => , filterConfig: FILTER_CONFIGS.nameFilterConfig, }); if (!hideDefinition) { @@ -102,7 +49,7 @@ export const GeneralOntologyComponent = ({ name, endpoint, showNamespace, showAb field: 'definition', header: 'Definition', sortable: true, - body: (rowData) => , + body: (rowData) => , filterConfig: FILTER_CONFIGS.definitionFilterConfig, }); } @@ -111,6 +58,7 @@ export const GeneralOntologyComponent = ({ name, endpoint, showNamespace, showAb field: 'abbreviation', header: 'Abbreviation', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.abbreviationFilterConfig, }); } @@ -119,13 +67,14 @@ export const GeneralOntologyComponent = ({ name, endpoint, showNamespace, showAb field: 'namespace', header: 'Name Space', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.namespaceFilterConfig, }); } columns.push({ field: 'synonyms.name', header: 'Synonyms', - body: synonymsTemplate, + body: (rowData) => synonym?.name)} />, sortable: true, filterConfig: FILTER_CONFIGS.ontologySynonymsFilterConfig, }); @@ -133,7 +82,7 @@ export const GeneralOntologyComponent = ({ name, endpoint, showNamespace, showAb field: 'secondaryIdentifiers', header: 'Secondary IDs', sortable: true, - body: secondaryIdsTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.secondaryIdsFilterConfig, }); columns.push({ diff --git a/src/main/cliapp/src/containers/ontologies/NameTemplate.js b/src/main/cliapp/src/containers/ontologies/NameTemplate.js deleted file mode 100644 index c9cb9a460..000000000 --- a/src/main/cliapp/src/containers/ontologies/NameTemplate.js +++ /dev/null @@ -1,16 +0,0 @@ -import React from 'react'; -import { EllipsisTableCell } from '../../components/EllipsisTableCell'; -import { Tooltip } from 'primereact/tooltip'; - -export const NameTemplate = ({ rowData }) => { - return ( - <> - {rowData.name} - - - ); -}; diff --git a/src/main/cliapp/src/containers/referencePage/LiteratureReferenceTable.js b/src/main/cliapp/src/containers/referencePage/LiteratureReferenceTable.js index 6af711f86..8847ae91f 100644 --- a/src/main/cliapp/src/containers/referencePage/LiteratureReferenceTable.js +++ b/src/main/cliapp/src/containers/referencePage/LiteratureReferenceTable.js @@ -7,7 +7,7 @@ import { FILTER_CONFIGS } from '../../constants/FilterFields'; import { useGetTableData } from '../../service/useGetTableData'; import { useGetUserSettings } from '../../service/useGetUserSettings'; import { StringListTemplate } from '../../components/Templates/StringListTemplate'; -import { NameTemplate } from '../../components/Templates/NameTemplate'; +import { StringTemplate } from '../../components/Templates/StringTemplate'; import { SearchService } from '../../service/SearchService'; export const LiteratureReferenceTable = () => { @@ -42,7 +42,7 @@ export const LiteratureReferenceTable = () => { header: 'Title', sortable: true, filter: true, - body: (rowData) => , + body: (rowData) => , filterConfig: FILTER_CONFIGS.titleFilterConfig, }, { @@ -50,7 +50,7 @@ export const LiteratureReferenceTable = () => { header: 'Abstract', sortable: true, filter: true, - body: (rowData) => , + body: (rowData) => , filterConfig: FILTER_CONFIGS.abstractFilterConfig, }, { @@ -58,7 +58,7 @@ export const LiteratureReferenceTable = () => { header: 'Citation', sortable: true, filter: true, - body: (rowData) => , + body: (rowData) => , filterConfig: FILTER_CONFIGS.citationFilterConfig, }, { diff --git a/src/main/cliapp/src/containers/resourceDescriptorPage/ResourceDescriptorsTable.js b/src/main/cliapp/src/containers/resourceDescriptorPage/ResourceDescriptorsTable.js index c8abf9c6a..dfaa2f640 100644 --- a/src/main/cliapp/src/containers/resourceDescriptorPage/ResourceDescriptorsTable.js +++ b/src/main/cliapp/src/containers/resourceDescriptorPage/ResourceDescriptorsTable.js @@ -1,8 +1,5 @@ import React, { useRef, useState } from 'react'; import { GenericDataTable } from '../../components/GenericDataTable/GenericDataTable'; -import { EllipsisTableCell } from '../../components/EllipsisTableCell'; -import { ListTableCell } from '../../components/ListTableCell'; -import { Tooltip } from 'primereact/tooltip'; import { Toast } from 'primereact/toast'; import { getDefaultTableState } from '../../service/TableStateService'; import { FILTER_CONFIGS } from '../../constants/FilterFields'; @@ -10,6 +7,9 @@ import { useGetTableData } from '../../service/useGetTableData'; import { useGetUserSettings } from '../../service/useGetUserSettings'; import { SearchService } from '../../service/SearchService'; +import { StringTemplate } from '../../components/Templates/StringTemplate'; +import { StringListTemplate } from '../../components/Templates/StringListTemplate'; + export const ResourceDescriptorsTable = () => { const [isInEditMode, setIsInEditMode] = useState(false); const [errorMessages, setErrorMessages] = useState({}); @@ -22,118 +22,46 @@ export const ResourceDescriptorsTable = () => { const toast_topleft = useRef(null); const toast_topright = useRef(null); - const nameBodyTemplate = (rowData) => { - return ( - <> - {rowData.name} - - - ); - }; - - const prefixBodyTemplate = (rowData) => { - return ( - <> - {rowData.prefix} - - - ); - }; - - const idPatternBodyTemplate = (rowData) => { - return ( - <> - {rowData.idPattern} - - - ); - }; - - const idExampleBodyTemplate = (rowData) => { - return ( - <> - {rowData.idExample} - - - ); - }; - - const defaultUrlTemplateBodyTemplate = (rowData) => { - return ( - <> - {rowData.defaultUrlTemplate} - - - ); - }; - - const synonymsBodyTemplate = (rowData) => { - if (rowData?.synonyms && rowData.synonyms.length > 0) { - const sortedSynonyms = rowData.synonyms.sort(); - const listTemplate = (item) => { - return {item}; - }; - return ( - <> -
- -
- - - - - ); - } - }; - const columns = [ { field: 'prefix', header: 'Prefix', sortable: true, - body: prefixBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.prefixFilterConfig, }, { field: 'name', header: 'Name', sortable: true, - body: nameBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.nameFilterConfig, }, { field: 'synonyms', header: 'Synonyms', - body: synonymsBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.synonymsFilterConfig, }, { field: 'idPattern', header: 'ID Pattern', sortable: true, - body: idPatternBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.idPatternFilterConfig, }, { field: 'idExample', header: 'ID Example', sortable: true, - body: idExampleBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.idExampleFilterConfig, }, { field: 'defaultUrlTemplate', header: 'Default URL Template', sortable: true, - body: defaultUrlTemplateBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.defaultUrlTemplateFilterConfig, }, ]; diff --git a/src/main/cliapp/src/containers/resourceDescriptorPagePage/ResourceDescriptorPagesTable.js b/src/main/cliapp/src/containers/resourceDescriptorPagePage/ResourceDescriptorPagesTable.js index bc4eed180..8d182fcfd 100644 --- a/src/main/cliapp/src/containers/resourceDescriptorPagePage/ResourceDescriptorPagesTable.js +++ b/src/main/cliapp/src/containers/resourceDescriptorPagePage/ResourceDescriptorPagesTable.js @@ -1,7 +1,5 @@ import React, { useRef, useState } from 'react'; import { GenericDataTable } from '../../components/GenericDataTable/GenericDataTable'; -import { EllipsisTableCell } from '../../components/EllipsisTableCell'; -import { Tooltip } from 'primereact/tooltip'; import { Toast } from 'primereact/toast'; import { getDefaultTableState } from '../../service/TableStateService'; import { FILTER_CONFIGS } from '../../constants/FilterFields'; @@ -9,6 +7,8 @@ import { useGetTableData } from '../../service/useGetTableData'; import { useGetUserSettings } from '../../service/useGetUserSettings'; import { SearchService } from '../../service/SearchService'; +import { StringTemplate } from '../../components/Templates/StringTemplate'; + export const ResourceDescriptorPagesTable = () => { const [isInEditMode, setIsInEditMode] = useState(false); const [errorMessages, setErrorMessages] = useState({}); @@ -21,83 +21,35 @@ export const ResourceDescriptorPagesTable = () => { const toast_topleft = useRef(null); const toast_topright = useRef(null); - const resourceDescriptorBodyTemplate = (rowData) => { - return ( - <> - - {rowData.resourceDescriptor.prefix} ({rowData.resourceDescriptor.name}) - - - - ); - }; - - const nameBodyTemplate = (rowData) => { - return ( - <> - {rowData.name} - - - ); - }; - - const urlTemplateBodyTemplate = (rowData) => { - return ( - <> - {rowData.urlTemplate} - - - ); - }; - - const pageDescriptionBodyTemplate = (rowData) => { - return ( - <> - {rowData.pageDescription} - - - ); - }; - const columns = [ { field: 'resourceDescriptor.prefix', header: 'Resource Descriptor', sortable: true, - body: resourceDescriptorBodyTemplate, + body: (rowData) => ( + + ), filterConfig: FILTER_CONFIGS.resourceDescriptorFilterConfig, }, { field: 'name', header: 'Name', sortable: true, - body: nameBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.nameFilterConfig, }, { field: 'urlTemplate', header: 'URL Template', sortable: true, - body: urlTemplateBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.urlTemplateFilterConfig, }, { field: 'pageDescription', header: 'Page Description', sortable: true, - body: pageDescriptionBodyTemplate, + body: (rowData) => , filterConfig: FILTER_CONFIGS.pageDescriptionFilterConfig, }, ]; diff --git a/src/main/cliapp/src/containers/resourceDescriptorPagePage/__tests__/ResourceDescriptorPagesTable.test.js b/src/main/cliapp/src/containers/resourceDescriptorPagePage/__tests__/ResourceDescriptorPagesTable.test.js index 4a9c84601..3aa63e60a 100644 --- a/src/main/cliapp/src/containers/resourceDescriptorPagePage/__tests__/ResourceDescriptorPagesTable.test.js +++ b/src/main/cliapp/src/containers/resourceDescriptorPagePage/__tests__/ResourceDescriptorPagesTable.test.js @@ -38,12 +38,12 @@ describe('', () => { it('The table contains correct data', async () => { let result = await renderWithClient(); - const prefixTd = await result.findByText(/ZFIN_prefix/i); - const nameTd = await result.findByText(/ZFIN_name/i); + const resourceDescriptorTd = await result.findByText('ZFIN_prefix (ZFIN_name)'); + const nameTd = await result.findByText('gene/wild_type_expression'); const urlTemplateTd = await result.findByText('https://zfin.org/[%s]/wt-expression'); - const pageDescriptionTd = await result.findByText(/Wild type expression data/i); + const pageDescriptionTd = await result.findByText('Wild type expression data'); await waitFor(() => { - expect(prefixTd).toBeInTheDocument(); + expect(resourceDescriptorTd).toBeInTheDocument(); expect(nameTd).toBeInTheDocument(); expect(urlTemplateTd).toBeInTheDocument(); expect(pageDescriptionTd).toBeInTheDocument(); diff --git a/src/main/cliapp/src/containers/variantsPage/VariantsTable.js b/src/main/cliapp/src/containers/variantsPage/VariantsTable.js index 143b1e4a3..36712327f 100644 --- a/src/main/cliapp/src/containers/variantsPage/VariantsTable.js +++ b/src/main/cliapp/src/containers/variantsPage/VariantsTable.js @@ -1,8 +1,6 @@ import React, { useRef, useState } from 'react'; import { useMutation } from '@tanstack/react-query'; import { GenericDataTable } from '../../components/GenericDataTable/GenericDataTable'; -import { EllipsisTableCell } from '../../components/EllipsisTableCell'; -import { internalTemplate, obsoleteTemplate } from '../../components/AuditedObjectComponent'; import { ErrorMessageComponent } from '../../components/Error/ErrorMessageComponent'; import { VariantService } from '../../service/VariantService'; import { RelatedNotesDialog } from '../../components/RelatedNotesDialog'; @@ -11,7 +9,6 @@ import { VariantTypeTableEditor } from '../../components/Editors/variantType/Var import { SourceGeneralConsequenceTableEditor } from '../../components/Editors/sourceGeneralConsequence/SourceGeneralConsequenceTableEditor'; import { BooleanTableEditor } from '../../components/Editors/boolean/BooleanTableEditor'; -import { Tooltip } from 'primereact/tooltip'; import { Toast } from 'primereact/toast'; import { Button } from 'primereact/button'; import { EditMessageTooltip } from '../../components/EditMessageTooltip'; @@ -19,9 +16,17 @@ import { getDefaultTableState } from '../../service/TableStateService'; import { FILTER_CONFIGS } from '../../constants/FilterFields'; import { useControlledVocabularyService } from '../../service/useControlledVocabularyService'; import { ControlledVocabularyDropdown } from '../../components/ControlledVocabularySelector'; -import { CrossReferencesTemplate } from '../../components/Templates/CrossReferencesTemplate'; + +import { ObjectListTemplate } from '../../components/Templates/ObjectListTemplate'; +import { StringTemplate } from '../../components/Templates/StringTemplate'; +import { OntologyTermTemplate } from '../../components/Templates/OntologyTermTemplate'; +import { CountDialogTemplate } from '../../components/Templates/dialog/CountDialogTemplate'; +import { BooleanTemplate } from '../../components/Templates/BooleanTemplate'; +import { IdTemplate } from '../../components/Templates/IdTemplate'; + import { useGetTableData } from '../../service/useGetTableData'; import { useGetUserSettings } from '../../service/useGetUserSettings'; +import { crossReferencesSort } from '../../components/Templates/utils/sortMethods'; import { SearchService } from '../../service/SearchService'; @@ -58,59 +63,6 @@ export const VariantsTable = () => { const variantStatusTerms = useControlledVocabularyService('variant_status'); - const taxonTemplate = (rowData) => { - if (rowData?.taxon) { - return ( - <> - - {rowData.taxon.name} ({rowData.taxon.curie}) - - - - ); - } - }; - - const sourceGeneralConsequenceTemplate = (rowData) => { - if (rowData?.sourceGeneralConsequence) { - return ( - <> - - {rowData.sourceGeneralConsequence?.name} ({rowData.sourceGeneralConsequence?.curie}) - - - - ); - } - }; - - const variantTypeTemplate = (rowData) => { - if (rowData?.variantType) { - return ( - <> - - {rowData.variantType?.name} ({rowData.variantType?.curie}) - - - - ); - } - }; - const onVariantStatusEditorValueChange = (props, event) => { let updatedVariants = [...props.props.value]; updatedVariants[props.rowIndex].variantStatus = event.value; @@ -131,11 +83,11 @@ export const VariantsTable = () => { ); }; - const handleRelatedNotesOpen = (event, rowData, isInEdit) => { + const handleRelatedNotesOpen = (relatedNotes) => { let _relatedNotesData = {}; - _relatedNotesData['originalRelatedNotes'] = rowData.relatedNotes; + _relatedNotesData['originalRelatedNotes'] = relatedNotes; _relatedNotesData['dialog'] = true; - _relatedNotesData['isInEdit'] = isInEdit; + _relatedNotesData['isInEdit'] = false; setRelatedNotesData(() => ({ ..._relatedNotesData, })); @@ -156,21 +108,6 @@ export const VariantsTable = () => { })); }; - const relatedNotesTemplate = (rowData) => { - if (rowData?.relatedNotes) { - return ( - - ); - } - }; - const relatedNotesEditor = (props) => { if (props?.rowData?.relatedNotes) { return ( @@ -230,33 +167,36 @@ export const VariantsTable = () => { field: 'curie', header: 'Curie', sortable: { isInEditMode }, + body: (rowData) => , filterConfig: FILTER_CONFIGS.curieFilterConfig, }, { field: 'modEntityId', header: 'MOD Entity ID', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.modentityidFilterConfig, }, { field: 'modInternalId', header: 'MOD Internal ID', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.modinternalidFilterConfig, }, { field: 'taxon.name', header: 'Taxon', - body: taxonTemplate, sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.taxonFilterConfig, editor: (props) => , }, { field: 'variantType.name', header: 'Variant Type', - body: variantTypeTemplate, sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.variantTypeFilterConfig, editor: (props) => , }, @@ -264,22 +204,25 @@ export const VariantsTable = () => { field: 'variantStatus.name', header: 'Variant Status', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.variantStatusFilterConfig, editor: (props) => variantStatusEditor(props), }, { field: 'relatedNotes.freeText', header: 'Related Notes', - body: relatedNotesTemplate, sortable: true, + body: (rowData) => ( + + ), filterConfig: FILTER_CONFIGS.relatedNotesFilterConfig, editor: relatedNotesEditor, }, { field: 'sourceGeneralConsequence.name', header: 'Source General Consequence', - body: sourceGeneralConsequenceTemplate, sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.sourceGeneralConsequenceFilterConfig, editor: (props) => , }, @@ -287,6 +230,7 @@ export const VariantsTable = () => { field: 'dataProvider.sourceOrganization.abbreviation', header: 'Data Provider', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.variantDataProviderFilterConfig, }, { @@ -294,12 +238,19 @@ export const VariantsTable = () => { header: 'Cross References', sortable: true, filterConfig: FILTER_CONFIGS.crossReferencesFilterConfig, - body: (rowData) => , + body: (rowData) => ( + `${item.displayName} (${item.resourceDescriptorPage.name})`} + /> + ), }, { field: 'updatedBy.uniqueId', header: 'Updated By', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.updatedByFilterConfig, }, { @@ -307,6 +258,7 @@ export const VariantsTable = () => { header: 'Date Updated', sortable: true, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.dateUpdatedFilterConfig, }, { @@ -314,6 +266,7 @@ export const VariantsTable = () => { header: 'Created By', sortable: true, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.createdByFilterConfig, }, { @@ -321,13 +274,14 @@ export const VariantsTable = () => { header: 'Date Created', sortable: true, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.dataCreatedFilterConfig, }, { field: 'internal', header: 'Internal', - body: internalTemplate, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.internalFilterConfig, sortable: true, editor: (props) => ( @@ -337,8 +291,8 @@ export const VariantsTable = () => { { field: 'obsolete', header: 'Obsolete', - body: obsoleteTemplate, filter: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.obsoleteFilterConfig, sortable: true, editor: (props) => ( diff --git a/src/main/cliapp/src/containers/vocabularyPage/VocabulariesTable.js b/src/main/cliapp/src/containers/vocabularyPage/VocabulariesTable.js index 4d53b5142..ca05294e8 100644 --- a/src/main/cliapp/src/containers/vocabularyPage/VocabulariesTable.js +++ b/src/main/cliapp/src/containers/vocabularyPage/VocabulariesTable.js @@ -2,14 +2,11 @@ import React, { useRef, useState } from 'react'; import { useMutation } from '@tanstack/react-query'; import { Toast } from 'primereact/toast'; import { Button } from 'primereact/button'; -import { BooleanTemplate } from '../../components/Templates/BooleanTemplate'; import { VocabularyService } from '../../service/VocabularyService'; import { useControlledVocabularyService } from '../../service/useControlledVocabularyService'; import { GenericDataTable } from '../../components/GenericDataTable/GenericDataTable'; import { NewVocabularyForm } from '../../containers/controlledVocabularyPage/NewVocabularyForm'; -import { EllipsisTableCell } from '../../components/EllipsisTableCell'; import { ErrorMessageComponent } from '../../components/Error/ErrorMessageComponent'; -import { Tooltip } from 'primereact/tooltip'; import { getDefaultTableState } from '../../service/TableStateService'; import { FILTER_CONFIGS } from '../../constants/FilterFields'; import { InputTextEditor } from '../../components/InputTextEditor'; @@ -19,6 +16,9 @@ import { useGetUserSettings } from '../../service/useGetUserSettings'; import { SearchService } from '../../service/SearchService'; import { setNewEntity } from '../../utils/utils'; +import { StringTemplate } from '../../components/Templates/StringTemplate'; +import { BooleanTemplate } from '../../components/Templates/BooleanTemplate'; + export const VocabulariesTable = () => { const [isInEditMode, setIsInEditMode] = useState(false); const [totalRecords, setTotalRecords] = useState(0); @@ -45,19 +45,6 @@ export const VocabulariesTable = () => { return vocabularyService.saveVocabulary(updatedVocabulary); }); - const stringBodyTemplate = (rowData, field) => { - return ( - <> - {rowData[field]} - - - ); - }; - const stringEditor = (props, field) => { return ( <> @@ -93,7 +80,7 @@ export const VocabulariesTable = () => { field: 'name', header: 'Name', sortable: true, - body: (rowData) => stringBodyTemplate(rowData, 'name'), + body: (rowData) => , filterConfig: FILTER_CONFIGS.nameFilterConfig, editor: (props) => stringEditor(props, 'name'), }, @@ -101,7 +88,7 @@ export const VocabulariesTable = () => { field: 'vocabularyDescription', header: 'Description', sortable: true, - body: (rowData) => stringBodyTemplate(rowData, 'vocabularyDescription'), + body: (rowData) => , filterConfig: FILTER_CONFIGS.vocabularyDescriptionFilterConfig, editor: (props) => stringEditor(props, 'vocabularyDescription'), }, @@ -117,8 +104,8 @@ export const VocabulariesTable = () => { field: 'vocabularyLabel', header: 'Label', sortable: true, + body: (rowData) => , filterConfig: FILTER_CONFIGS.vocabularyLabelFilterConfig, - body: (rowData) => stringBodyTemplate(rowData, 'vocabularyLabel'), }, ]; diff --git a/src/main/cliapp/src/containers/vocabularyTermSetPage/VocabularyTermSetTable.js b/src/main/cliapp/src/containers/vocabularyTermSetPage/VocabularyTermSetTable.js index 739b7cc3e..04b9df0b5 100644 --- a/src/main/cliapp/src/containers/vocabularyTermSetPage/VocabularyTermSetTable.js +++ b/src/main/cliapp/src/containers/vocabularyTermSetPage/VocabularyTermSetTable.js @@ -4,8 +4,6 @@ import { Toast } from 'primereact/toast'; import { SearchService } from '../../service/SearchService'; import { Messages } from 'primereact/messages'; import { ErrorMessageComponent } from '../../components/Error/ErrorMessageComponent'; -import { EllipsisTableCell } from '../../components/EllipsisTableCell'; -import { ListTableCell } from '../../components/ListTableCell'; import { Button } from 'primereact/button'; import { VocabularyTermSetService } from '../../service/VocabularyTermSetService'; import { VocabTermAutocompleteTemplate } from '../../components/Autocomplete/VocabTermAutocompleteTemplate'; @@ -24,10 +22,12 @@ import { import { AutocompleteMultiEditor } from '../../components/Autocomplete/AutocompleteMultiEditor'; import { getDefaultTableState } from '../../service/TableStateService'; import { FILTER_CONFIGS } from '../../constants/FilterFields'; -import { Tooltip } from 'primereact/tooltip'; import { useGetTableData } from '../../service/useGetTableData'; import { useGetUserSettings } from '../../service/useGetUserSettings'; +import { StringTemplate } from '../../components/Templates/StringTemplate'; +import { StringListTemplate } from '../../components/Templates/StringListTemplate'; + export const VocabularyTermSetTable = () => { const [isInEditMode, setIsInEditMode] = useState(false); const [totalRecords, setTotalRecords] = useState(0); @@ -56,12 +56,6 @@ export const VocabularyTermSetTable = () => { newVocabularyTermSetDispatch({ type: 'OPEN_DIALOG' }); }; - const vocabularyTemplate = (rowData) => { - if (rowData.vocabularyTermSetVocabulary) { - return {rowData.vocabularyTermSetVocabulary.name}; - } - }; - const onVocabularyChange = (event, setFieldValue, props) => { defaultAutocompleteOnChange(props, event, 'vocabularyTermSetVocabulary', setFieldValue, 'name'); }; @@ -102,19 +96,6 @@ export const VocabularyTermSetTable = () => { ); }; - const memberTermsTemplate = (rowData) => { - if (rowData.memberTerms) { - const listTemplate = (memberTerm) => { - return {memberTerm.name}; - }; - return ( - <> - - - ); - } - }; - const onMemberTermsChange = (event, setFieldValue, props) => { multipleAutocompleteOnChange(props, event, 'memberTerms', setFieldValue); }; @@ -182,24 +163,11 @@ export const VocabularyTermSetTable = () => { ); }; - const stringBodyTemplate = (rowData, field) => { - return ( - <> - {rowData[field]} - - - ); - }; - const columns = [ { field: 'name', header: 'Name', - body: (rowData) => stringBodyTemplate(rowData, 'name'), + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.nameFilterConfig, editor: (props) => nameEditor(props), @@ -208,7 +176,7 @@ export const VocabularyTermSetTable = () => { field: 'vocabularyTermSetVocabulary.name', header: 'Vocabulary', sortable: true, - body: (rowData) => vocabularyTemplate(rowData), + body: (rowData) => , filterConfig: FILTER_CONFIGS.vocabularyFieldSetFilterConfig, editor: (props) => vocabularyEditorTemplate(props), }, @@ -216,14 +184,14 @@ export const VocabularyTermSetTable = () => { field: 'memberTerms.name', header: 'Member Terms', sortable: true, - body: memberTermsTemplate, + body: (rowData) => memberTerm?.name)} />, filterConfig: FILTER_CONFIGS.vocabularyMemberTermsFilterConfig, editor: (props) => memberTermsEditorTemplate(props), }, { field: 'vocabularyTermSetDescription', header: 'Description', - body: (rowData) => stringBodyTemplate(rowData, 'vocabularyTermSetDescription'), + body: (rowData) => , sortable: true, filterConfig: FILTER_CONFIGS.vocabularyTermSetDescriptionFilterConfig, editor: (props) => descriptionEditor(props), @@ -231,8 +199,8 @@ export const VocabularyTermSetTable = () => { { field: 'vocabularyLabel', header: 'Label', + body: (rowData) => , filterConfig: FILTER_CONFIGS.vocabularyLabelFilterConfig, - body: (rowData) => stringBodyTemplate(rowData, 'vocabularyLabel'), }, ]; diff --git a/src/main/cliapp/src/service/DataLoadService.js b/src/main/cliapp/src/service/DataLoadService.js index 28b2eaa66..dc60d520d 100644 --- a/src/main/cliapp/src/service/DataLoadService.js +++ b/src/main/cliapp/src/service/DataLoadService.js @@ -19,8 +19,6 @@ export class DataLoadService extends BaseAuthService { delete newLoad[objectKey]; } } - console.log('Creating: '); - console.log(newLoad); return this.api.post(`/${endpoint}`, newLoad); } @@ -44,13 +42,12 @@ export class DataLoadService extends BaseAuthService { return this.api.delete(`/${endpoint}/${id}`); } - restartLoad(loadType, id) { - let endpoint = loadType.toLowerCase(); - return this.api.get(`/${endpoint}/restart/${id}`); + restartLoad(id) { + return this.api.get(`/bulkloadfilehistory/restartload/${id}`); } - restartLoadFile(id) { - return this.api.get(`/bulkloadfile/restart/${id}`); + restartHistoryLoad(id) { + return this.api.get(`/bulkloadfilehistory/restartloadhistory/${id}`); } getFileHistoryFile(id) { @@ -77,11 +74,20 @@ export class DataLoadService extends BaseAuthService { return this.api.delete(`/bulkloadfile/${id}`); } + deleteLoadFileHistory(id) { + return this.api.delete(`/bulkloadfilehistory/${id}`); + } + getBackendBulkLoadTypes(loadType) { const bulkLoadTypes = { BulkFMSLoad: [ - 'GFF', + 'GFF', // This needs to be removed at some point + + 'GFF_EXON', + 'GFF_CDS', + 'GFF_TRANSCRIPT', 'HTPDATASET', + 'HTPDATASAMPLE', 'INTERACTION-GEN', 'INTERACTION-MOL', 'MOLECULE', @@ -89,8 +95,18 @@ export class DataLoadService extends BaseAuthService { 'PHENOTYPE', 'PARALOGY', 'SEQUENCE_TARGETING_REAGENT', + // 'VARIATION', + 'BIOGRID-ORCS', + ], + BulkURLLoad: [ + 'ONTOLOGY', + 'GENE', + 'ALLELE', + 'AGM', + 'DISEASE_ANNOTATION', + 'RESOURCE_DESCRIPTOR', + 'EXPRESSION_ATLAS', ], - BulkURLLoad: ['ONTOLOGY', 'GENE', 'ALLELE', 'AGM', 'DISEASE_ANNOTATION', 'RESOURCE_DESCRIPTOR'], BulkManualLoad: [ 'FULL_INGEST', 'DISEASE_ANNOTATION', @@ -100,7 +116,7 @@ export class DataLoadService extends BaseAuthService { 'GENE', 'ALLELE', 'AGM', - 'VARIANT', + // 'VARIANT', 'CONSTRUCT', 'ALLELE_ASSOCIATION', 'CONSTRUCT_ASSOCIATION', diff --git a/src/main/cliapp/src/service/TableStateService.js b/src/main/cliapp/src/service/TableStateService.js index 29a5c812e..9d7529b70 100644 --- a/src/main/cliapp/src/service/TableStateService.js +++ b/src/main/cliapp/src/service/TableStateService.js @@ -123,7 +123,9 @@ const modTableSettings = { 'Experimental Conditions', 'Genetic Sex', 'Genetic Modifier Relation', - 'Genetic Modifiers', + 'Genetic Modifier AGMs', + 'Genetic Modifier Alleles', + 'Genetic Modifier Genes', 'Data Provider', 'Updated By', 'Date Updated', @@ -143,7 +145,9 @@ const modTableSettings = { 'Experimental Conditions', 'Genetic Sex', 'Genetic Modifier Relation', - 'Genetic Modifiers', + 'Genetic Modifier AGMs', + 'Genetic Modifier Alleles', + 'Genetic Modifier Genes', 'Asserted Genes', ], filters: { @@ -176,7 +180,9 @@ const modTableSettings = { 'Evidence Code', 'Inferred Gene', 'Genetic Modifier Relation', - 'Genetic Modifiers', + 'Genetic Modifier AGMs', + 'Genetic Modifier Alleles', + 'Genetic Modifier Genes', 'Related Notes', 'Data Provider', 'Updated By', @@ -193,7 +199,9 @@ const modTableSettings = { 'Evidence Code', 'Related Notes', 'Genetic Modifier Relation', - 'Genetic Modifiers', + 'Genetic Modifier AGMs', + 'Genetic Modifier Alleles', + 'Genetic Modifier Genes', ], filters: { dataProviderFilter: { @@ -360,7 +368,9 @@ const modTableSettings = { 'SGD Strain Background', 'Annotation Type', 'Genetic Modifier Relation', - 'Genetic Modifiers', + 'Genetic Modifier AGMs', + 'Genetic Modifier Alleles', + 'Genetic Modifier Genes', 'Inferred Gene', 'Asserted Genes', 'Inferred Allele', @@ -387,7 +397,9 @@ const modTableSettings = { 'SGD Strain Background', 'Annotation Type', 'Genetic Modifier Relation', - 'Genetic Modifiers', + 'Genetic Modifier AGMs', + 'Genetic Modifier Alleles', + 'Genetic Modifier Genes', 'Internal', ], filters: { diff --git a/src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java b/src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java index 1f22b716f..7eb0a89cd 100644 --- a/src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java +++ b/src/main/java/org/alliancegenome/curation_api/constants/EntityFieldConstants.java @@ -19,6 +19,7 @@ private EntityFieldConstants() { public static final String CODING_SEQUENCE_ASSOCIATION_SUBJECT = "codingSequenceAssociationSubject"; public static final String CONSTRUCT_ASSOCIATION_SUBJECT = "constructAssociationSubject"; public static final String EXON_ASSOCIATION_SUBJECT = "exonAssociationSubject"; + public static final String VARIANT_ASSOCIATION_SUBJECT = "variantAssociationSubject"; public static final String SQTR_ASSOCIATION_SUBJECT = "sequenceTargetingReagentAssociationSubject"; public static final String TRANSCRIPT_ASSOCIATION_SUBJECT = "transcriptAssociationSubject"; @@ -30,13 +31,20 @@ private EntityFieldConstants() { public static final String CODING_SEQUENCE_ASSOCIATION_SUBJECT_DATA_PROVIDER = CODING_SEQUENCE_ASSOCIATION_SUBJECT + "." + DATA_PROVIDER; public static final String CONSTRUCT_ASSOCIATION_SUBJECT_DATA_PROVIDER = CONSTRUCT_ASSOCIATION_SUBJECT + "." + DATA_PROVIDER; public static final String EXON_ASSOCIATION_SUBJECT_DATA_PROVIDER = EXON_ASSOCIATION_SUBJECT + "." + DATA_PROVIDER; + public static final String VARIANT_ASSOCIATION_SUBJECT_DATA_PROVIDER = VARIANT_ASSOCIATION_SUBJECT + "." + DATA_PROVIDER; public static final String SQTR_ASSOCIATION_SUBJECT_DATA_PROVIDER = SQTR_ASSOCIATION_SUBJECT + "." + DATA_PROVIDER; public static final String TRANSCRIPT_ASSOCIATION_SUBJECT_DATA_PROVIDER = TRANSCRIPT_ASSOCIATION_SUBJECT + "." + DATA_PROVIDER; + public static final String CODING_SEQUENCE_ASSOCIATION_SUBJECT_TAXON = CODING_SEQUENCE_ASSOCIATION_SUBJECT + "." + TAXON; + public static final String EXON_ASSOCIATION_SUBJECT_TAXON = EXON_ASSOCIATION_SUBJECT + "." + TAXON; + public static final String TRANSCRIPT_ASSOCIATION_SUBJECT_TAXON = TRANSCRIPT_ASSOCIATION_SUBJECT + "." + TAXON; + public static final String VARIANT_ASSOCIATION_SUBJECT_TAXON = VARIANT_ASSOCIATION_SUBJECT + "." + TAXON; + public static final String GENOMIC_LOCATION_ASSOCIATION_OBJECT = "GenomicLocationAssociationObject"; - public static final String CODING_SEQUENCE_GENOMIC_LOCATION_ASSOCIATION_OBJECT = "codingSequence" + GENOMIC_LOCATION_ASSOCIATION_OBJECT + ".name"; - public static final String EXON_GENOMIC_LOCATION_ASSOCIATION_OBJECT = "exon" + GENOMIC_LOCATION_ASSOCIATION_OBJECT + ".name"; - public static final String TRANSCRIPT_GENOMIC_LOCATION_ASSOCIATION_OBJECT = "transcript" + GENOMIC_LOCATION_ASSOCIATION_OBJECT + ".name"; + public static final String CODING_SEQUENCE_GENOMIC_LOCATION_ASSOCIATION_OBJECT = "codingSequence" + GENOMIC_LOCATION_ASSOCIATION_OBJECT; + public static final String EXON_GENOMIC_LOCATION_ASSOCIATION_OBJECT = "exon" + GENOMIC_LOCATION_ASSOCIATION_OBJECT; + public static final String TRANSCRIPT_GENOMIC_LOCATION_ASSOCIATION_OBJECT = "transcript" + GENOMIC_LOCATION_ASSOCIATION_OBJECT; + public static final String VARIANT_GENOMIC_LOCATION_ASSOCIATION_OBJECT = "variant" + GENOMIC_LOCATION_ASSOCIATION_OBJECT; public static final String CODING_SEQUENCE_GENOMIC_LOCATION_ASSOCIATION_OBJECT_ASSEMBLY = "codingSequence" + GENOMIC_LOCATION_ASSOCIATION_OBJECT + "." + ASSEMBLY; public static final String EXON_GENOMIC_LOCATION_ASSOCIATION_OBJECT_ASSEMBLY = "exon" + GENOMIC_LOCATION_ASSOCIATION_OBJECT + "." + ASSEMBLY; public static final String TRANSCRIPT_GENOMIC_LOCATION_ASSOCIATION_OBJECT_ASSEMBLY = "transcript" + GENOMIC_LOCATION_ASSOCIATION_OBJECT + "." + ASSEMBLY; diff --git a/src/main/java/org/alliancegenome/curation_api/constants/Gff3Constants.java b/src/main/java/org/alliancegenome/curation_api/constants/Gff3Constants.java index 1c7a78891..9ecf6976c 100644 --- a/src/main/java/org/alliancegenome/curation_api/constants/Gff3Constants.java +++ b/src/main/java/org/alliancegenome/curation_api/constants/Gff3Constants.java @@ -11,7 +11,8 @@ private Gff3Constants() { public static final List TRANSCRIPT_TYPES = List.of( "mRNA", "ncRNA", "piRNA", "lincRNA", "miRNA", "pre_miRNA", "snoRNA", "lncRNA", "tRNA", "snRNA", "rRNA", "antisense_RNA", "C_gene_segment", "V_gene_segment", - "pseudogene_attribute", "snoRNA_gene", "pseudogenic_transcript", "lnc_RNA" + "pseudogene_attribute", "pseudogenic_transcript", "lnc_RNA", "nc_primary_transcript", + "circular_ncRNA" ); public static final List STRANDS = List.of("+", "-"); diff --git a/src/main/java/org/alliancegenome/curation_api/constants/LinkMLSchemaConstants.java b/src/main/java/org/alliancegenome/curation_api/constants/LinkMLSchemaConstants.java index 65fdf41c8..4c54350c0 100644 --- a/src/main/java/org/alliancegenome/curation_api/constants/LinkMLSchemaConstants.java +++ b/src/main/java/org/alliancegenome/curation_api/constants/LinkMLSchemaConstants.java @@ -5,8 +5,8 @@ public class LinkMLSchemaConstants { private LinkMLSchemaConstants() { // Hidden from view, as it is a utility class } - public static final String LATEST_RELEASE = "2.4.0"; + public static final String LATEST_RELEASE = "2.8.0"; public static final String MIN_ONTOLOGY_RELEASE = "1.2.4"; public static final String MAX_ONTOLOGY_RELEASE = LATEST_RELEASE; -} \ No newline at end of file +} diff --git a/src/main/java/org/alliancegenome/curation_api/constants/ValidationConstants.java b/src/main/java/org/alliancegenome/curation_api/constants/ValidationConstants.java index 39a44ba41..0e879c431 100644 --- a/src/main/java/org/alliancegenome/curation_api/constants/ValidationConstants.java +++ b/src/main/java/org/alliancegenome/curation_api/constants/ValidationConstants.java @@ -14,5 +14,6 @@ private ValidationConstants() { public static final String UNSUPPORTED_MESSAGE = "Unsupported value specified"; public static final String DUPLICATE_MESSAGE = "Duplicate entries found"; public static final String DUPLICATE_RELATION_PREFIX = "Entries found with same relation field - "; - + public static final String UNRECOGNIZED_MESSAGE = "Unrecognized entry"; // To be used instead of INVALID_MESSAGE when entry to be skipped instead of failed + } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java b/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java index 11b293783..db0a0d007 100644 --- a/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java +++ b/src/main/java/org/alliancegenome/curation_api/constants/VocabularyConstants.java @@ -27,6 +27,9 @@ private VocabularyConstants() { public static final String ALLELE_RELATION_VOCABULARY = "allele_relation"; public static final String ALLELE_GENE_RELATION_VOCABULARY_TERM_SET = "allele_gene_relation"; + public static final String ALLELE_VARIANT_RELATION_VOCABULARY_TERM_SET = "allele_variant_relation"; + + public static final String LOCATION_ASSOCIATION_RELATION_VOCABULARY = "location_association_relation"; public static final String FULL_NAME_TYPE_TERM_SET = "full_name_type"; public static final String SYSTEMATIC_NAME_TYPE_TERM_SET = "systematic_name_type"; @@ -70,4 +73,18 @@ private VocabularyConstants() { public static final String GENE_EXPRESSION_VOCABULARY = "gene_expression"; public static final String GENE_EXPRESSION_RELATION_TERM = "is_expressed_in"; + public static final String TRANSCRIPT_RELATION_VOCABULARY = "transcript_relation"; + public static final String TRANSCRIPT_CHILD_TERM = "is_child_of"; + public static final String TRANSCRIPT_PARENT_TERM = "is_parent_of"; + + public static final String STAGE_UBERON_SLIM_TERMS = "stage_uberon_slim_terms"; + public static final String ANATOMICAL_STRUCTURE_UBERON_SLIM_TERMS = "anatomical_structure_uberon_slim_terms"; + public static final String SPATIAL_EXPRESSION_QUALIFIERS = "spatial_expression_qualifiers"; + public static final String ANATOMICAL_STRUCTURE_QUALIFIER = "anatomical_structure_qualifier"; + public static final String ANATOMICAL_SUBSTRUCTURE_QUALIFIER = "anatomical_subtructure_qualifier"; + public static final String CELLULAR_COMPONENT_QUALIFIER = "cellular_component_qualifier"; + + public static final String HTP_DATASET_CATEGORY_TAGS = "data_set_category_tags"; + public static final String HTP_DATASET_NOTE_TYPE_VOCABULARY_TERM_SET = "htp_expression_dataset_note_type"; + public static final String HTP_DATASET_SAMPLE_NOTE_TYPE_VOCABULARY_TERM_SET = "htp_expression_dataset_sample_note_type"; } diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/base/BaseAnnotationDTOCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/base/BaseAnnotationDTOCrudController.java index 17136ef31..1e3765869 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/base/BaseAnnotationDTOCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/base/BaseAnnotationDTOCrudController.java @@ -2,7 +2,7 @@ import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.interfaces.base.BaseUpsertControllerInterface; import org.alliancegenome.curation_api.model.entities.Annotation; import org.alliancegenome.curation_api.model.ingest.dto.AnnotationDTO; @@ -22,11 +22,11 @@ protected void setService(S service) { } @Override - public E upsert(T dto) throws ObjectUpdateException { + public E upsert(T dto) throws ValidationException { return service.upsert(dto); } - public E upsert(T dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public E upsert(T dto, BackendBulkDataProvider dataProvider) throws ValidationException { return service.upsert(dto, dataProvider); } diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/base/SubmittedObjectCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/base/SubmittedObjectCrudController.java index fa5fdc9a5..6831cdb0e 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/base/SubmittedObjectCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/base/SubmittedObjectCrudController.java @@ -2,7 +2,7 @@ import org.alliancegenome.curation_api.dao.base.BaseEntityDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.interfaces.base.BaseSubmittedObjectCrudInterface; import org.alliancegenome.curation_api.interfaces.base.BaseUpsertControllerInterface; import org.alliancegenome.curation_api.model.entities.base.SubmittedObject; @@ -21,11 +21,11 @@ protected void setService(S service) { } @Override - public E upsert(T dto) throws ObjectUpdateException { + public E upsert(T dto) throws ValidationException { return service.upsert(dto); } - public E upsert(T dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public E upsert(T dto, BackendBulkDataProvider dataProvider) throws ValidationException { return service.upsert(dto, dataProvider); } diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/AssemblyComponentCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/AssemblyComponentCrudController.java new file mode 100644 index 000000000..ae8512aff --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/AssemblyComponentCrudController.java @@ -0,0 +1,35 @@ +package org.alliancegenome.curation_api.controllers.crud; + +import org.alliancegenome.curation_api.controllers.base.BaseEntityCrudController; +import org.alliancegenome.curation_api.dao.AssemblyComponentDAO; +import org.alliancegenome.curation_api.interfaces.crud.AssemblyComponentCrudInterface; +import org.alliancegenome.curation_api.model.entities.AssemblyComponent; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.services.AssemblyComponentService; + +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; + +@RequestScoped +public class AssemblyComponentCrudController extends BaseEntityCrudController implements AssemblyComponentCrudInterface { + + @Inject AssemblyComponentService assemblyComponentService; + + @Override + @PostConstruct + protected void init() { + setService(assemblyComponentService); + } + + @Override + public ObjectResponse getByIdentifier(String identifierString) { + return assemblyComponentService.getByIdentifier(identifierString); + } + + @Override + public ObjectResponse deleteByIdentifier(String identifierString) { + return assemblyComponentService.deleteByIdentifier(identifierString); + } + +} diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/CodingSequenceCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/CodingSequenceCrudController.java index 5585ab971..a2394cb01 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/crud/CodingSequenceCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/CodingSequenceCrudController.java @@ -5,10 +5,11 @@ import org.alliancegenome.curation_api.controllers.base.BaseEntityCrudController; import org.alliancegenome.curation_api.dao.CodingSequenceDAO; import org.alliancegenome.curation_api.interfaces.crud.CodingSequenceCrudInterface; -import org.alliancegenome.curation_api.jobs.executors.Gff3Executor; +import org.alliancegenome.curation_api.jobs.executors.gff.Gff3CDSExecutor; import org.alliancegenome.curation_api.model.entities.CodingSequence; import org.alliancegenome.curation_api.model.ingest.dto.fms.Gff3DTO; import org.alliancegenome.curation_api.response.APIResponse; +import org.alliancegenome.curation_api.response.LoadHistoryResponce; import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.services.CodingSequenceService; @@ -19,10 +20,8 @@ @RequestScoped public class CodingSequenceCrudController extends BaseEntityCrudController implements CodingSequenceCrudInterface { - @Inject - CodingSequenceService codingSequenceService; - @Inject - Gff3Executor gff3Executor; + @Inject CodingSequenceService codingSequenceService; + @Inject Gff3CDSExecutor gff3CDSExecutor; @Override @PostConstruct @@ -30,8 +29,10 @@ protected void init() { setService(codingSequenceService); } + @Override public APIResponse updateCodingSequences(String dataProvider, String assembly, List gffData) { - return gff3Executor.runLoadApi(dataProvider, assembly, gffData); + LoadHistoryResponce resp = (LoadHistoryResponce) gff3CDSExecutor.runLoadApi(dataProvider, assembly, gffData); + return new LoadHistoryResponce(resp.getHistory()); } @Override diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/DataProviderCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/DataProviderCrudController.java index 0165bd9e2..00b25012f 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/crud/DataProviderCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/DataProviderCrudController.java @@ -1,5 +1,8 @@ package org.alliancegenome.curation_api.controllers.crud; +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; import org.alliancegenome.curation_api.controllers.base.BaseEntityCrudController; import org.alliancegenome.curation_api.dao.DataProviderDAO; import org.alliancegenome.curation_api.interfaces.crud.DataProviderCrudInterface; @@ -7,10 +10,6 @@ import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.services.DataProviderService; -import jakarta.annotation.PostConstruct; -import jakarta.enterprise.context.RequestScoped; -import jakarta.inject.Inject; - @RequestScoped public class DataProviderCrudController extends BaseEntityCrudController implements DataProviderCrudInterface { diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/ExonCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/ExonCrudController.java index bf4c105dd..4554999a5 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/crud/ExonCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/ExonCrudController.java @@ -5,10 +5,11 @@ import org.alliancegenome.curation_api.controllers.base.BaseEntityCrudController; import org.alliancegenome.curation_api.dao.ExonDAO; import org.alliancegenome.curation_api.interfaces.crud.ExonCrudInterface; -import org.alliancegenome.curation_api.jobs.executors.Gff3Executor; +import org.alliancegenome.curation_api.jobs.executors.gff.Gff3ExonExecutor; import org.alliancegenome.curation_api.model.entities.Exon; import org.alliancegenome.curation_api.model.ingest.dto.fms.Gff3DTO; import org.alliancegenome.curation_api.response.APIResponse; +import org.alliancegenome.curation_api.response.LoadHistoryResponce; import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.services.ExonService; @@ -19,10 +20,8 @@ @RequestScoped public class ExonCrudController extends BaseEntityCrudController implements ExonCrudInterface { - @Inject - ExonService exonService; - @Inject - Gff3Executor gff3Executor; + @Inject ExonService exonService; + @Inject Gff3ExonExecutor gff3ExonExecutor; @Override @PostConstruct @@ -32,7 +31,8 @@ protected void init() { @Override public APIResponse updateExons(String dataProvider, String assembly, List gffData) { - return gff3Executor.runLoadApi(dataProvider, assembly, gffData); + LoadHistoryResponce resp = (LoadHistoryResponce) gff3ExonExecutor.runLoadApi(dataProvider, assembly, gffData); + return new LoadHistoryResponce(resp.getHistory()); } @Override diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/GenomeAssemblyCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/GenomeAssemblyCrudController.java new file mode 100644 index 000000000..176f72c29 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/GenomeAssemblyCrudController.java @@ -0,0 +1,35 @@ +package org.alliancegenome.curation_api.controllers.crud; + +import org.alliancegenome.curation_api.controllers.base.BaseEntityCrudController; +import org.alliancegenome.curation_api.dao.GenomeAssemblyDAO; +import org.alliancegenome.curation_api.interfaces.crud.GenomeAssemblyCrudInterface; +import org.alliancegenome.curation_api.model.entities.GenomeAssembly; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.services.GenomeAssemblyService; + +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; + +@RequestScoped +public class GenomeAssemblyCrudController extends BaseEntityCrudController implements GenomeAssemblyCrudInterface { + + @Inject GenomeAssemblyService genomeAssemblyService; + + @Override + @PostConstruct + protected void init() { + setService(genomeAssemblyService); + } + + @Override + public ObjectResponse getByIdentifier(String identifierString) { + return genomeAssemblyService.getByIdentifier(identifierString); + } + + @Override + public ObjectResponse deleteByIdentifier(String identifierString) { + return genomeAssemblyService.deleteByIdentifier(identifierString); + } + +} diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/HTPExpressionDatasetAnnotationCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/HTPExpressionDatasetAnnotationCrudController.java new file mode 100644 index 000000000..28c27ceae --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/HTPExpressionDatasetAnnotationCrudController.java @@ -0,0 +1,35 @@ +package org.alliancegenome.curation_api.controllers.crud; + +import org.alliancegenome.curation_api.controllers.base.BaseEntityCrudController; +import org.alliancegenome.curation_api.dao.HTPExpressionDatasetAnnotationDAO; +import org.alliancegenome.curation_api.interfaces.crud.HTPExpressionDatasetAnnotationCrudInterface; +import org.alliancegenome.curation_api.jobs.executors.HTPExpressionDatasetAnnotationExecutor; +import org.alliancegenome.curation_api.model.entities.HTPExpressionDatasetAnnotation; +import org.alliancegenome.curation_api.model.ingest.dto.fms.HTPExpressionDatasetAnnotationIngestFmsDTO; +import org.alliancegenome.curation_api.response.APIResponse; +import org.alliancegenome.curation_api.services.HTPExpressionDatasetAnnotationService; + +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; + +@RequestScoped +public class HTPExpressionDatasetAnnotationCrudController extends BaseEntityCrudController implements HTPExpressionDatasetAnnotationCrudInterface { + + @Inject + HTPExpressionDatasetAnnotationService htpExpressionDatasetAnnotationService; + @Inject + HTPExpressionDatasetAnnotationExecutor htpExpressionDatasetAnnotationExecutor; + + @Override + @PostConstruct + public void init() { + setService(htpExpressionDatasetAnnotationService); + } + + @Override + public APIResponse updateHTPExpressionDatasetAnnotation(String dataProvider, HTPExpressionDatasetAnnotationIngestFmsDTO htpDatasetData) { + return htpExpressionDatasetAnnotationExecutor.runLoadApi(dataProvider, htpDatasetData.getData()); + } + +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/PhenotypeAnnotationCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/PhenotypeAnnotationCrudController.java index 7625529b0..5d490d22e 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/crud/PhenotypeAnnotationCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/PhenotypeAnnotationCrudController.java @@ -30,11 +30,13 @@ protected void init() { setService(phenotypeAnnotationService); } + @Override public ObjectResponse getByIdentifier(String identifierString) { return phenotypeAnnotationService.getByIdentifier(identifierString); } + @Override public APIResponse updatePhenotypeAnnotations(String dataProvider, List annotations) { - return phenotypeAnnotationExecutor.runLoad(dataProvider, annotations); + return phenotypeAnnotationExecutor.runLoadApi(dataProvider, annotations); } } diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/SequenceTargetingReagentCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/SequenceTargetingReagentCrudController.java index 61afd749a..c4c10e03a 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/crud/SequenceTargetingReagentCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/SequenceTargetingReagentCrudController.java @@ -1,12 +1,14 @@ package org.alliancegenome.curation_api.controllers.crud; -import org.alliancegenome.curation_api.controllers.base.BaseEntityCrudController; +import org.alliancegenome.curation_api.controllers.base.SubmittedObjectCrudController; import org.alliancegenome.curation_api.dao.SequenceTargetingReagentDAO; import org.alliancegenome.curation_api.interfaces.crud.SequenceTargetingReagentCrudInterface; import org.alliancegenome.curation_api.jobs.executors.SequenceTargetingReagentExecutor; import org.alliancegenome.curation_api.model.entities.SequenceTargetingReagent; +import org.alliancegenome.curation_api.model.ingest.dto.fms.SequenceTargetingReagentFmsDTO; import org.alliancegenome.curation_api.model.ingest.dto.fms.SequenceTargetingReagentIngestFmsDTO; import org.alliancegenome.curation_api.response.APIResponse; +import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.services.SequenceTargetingReagentService; import jakarta.annotation.PostConstruct; @@ -14,7 +16,7 @@ import jakarta.inject.Inject; @RequestScoped -public class SequenceTargetingReagentCrudController extends BaseEntityCrudController implements SequenceTargetingReagentCrudInterface { +public class SequenceTargetingReagentCrudController extends SubmittedObjectCrudController implements SequenceTargetingReagentCrudInterface { @Inject SequenceTargetingReagentService sqtrService; @@ -32,5 +34,10 @@ protected void init() { public APIResponse updateSequenceTargetingReagent(String dataProvider, SequenceTargetingReagentIngestFmsDTO sqtrFmsDTO) { return sqtrExecutor.runLoadApi(dataProvider, sqtrFmsDTO.getData()); } + + @Override + public ObjectResponse getByIdentifier(String identifierString) { + return sqtrService.getByIdentifier(identifierString); + } } diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/TranscriptCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/TranscriptCrudController.java index a2b5e6c2a..25c06d38b 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/crud/TranscriptCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/TranscriptCrudController.java @@ -5,10 +5,11 @@ import org.alliancegenome.curation_api.controllers.base.BaseEntityCrudController; import org.alliancegenome.curation_api.dao.TranscriptDAO; import org.alliancegenome.curation_api.interfaces.crud.TranscriptCrudInterface; -import org.alliancegenome.curation_api.jobs.executors.Gff3Executor; +import org.alliancegenome.curation_api.jobs.executors.gff.Gff3TranscriptExecutor; import org.alliancegenome.curation_api.model.entities.Transcript; import org.alliancegenome.curation_api.model.ingest.dto.fms.Gff3DTO; import org.alliancegenome.curation_api.response.APIResponse; +import org.alliancegenome.curation_api.response.LoadHistoryResponce; import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.services.TranscriptService; @@ -19,10 +20,9 @@ @RequestScoped public class TranscriptCrudController extends BaseEntityCrudController implements TranscriptCrudInterface { - @Inject - TranscriptService transcriptService; - @Inject - Gff3Executor gff3Executor; + @Inject TranscriptService transcriptService; + + @Inject Gff3TranscriptExecutor gff3TranscriptExecutor; @Override @PostConstruct @@ -30,8 +30,10 @@ protected void init() { setService(transcriptService); } + @Override public APIResponse updateTranscripts(String dataProvider, String assembly, List gffData) { - return gff3Executor.runLoadApi(dataProvider, assembly, gffData); + LoadHistoryResponce resp = (LoadHistoryResponce) gff3TranscriptExecutor.runLoadApi(dataProvider, assembly, gffData); + return new LoadHistoryResponce(resp.getHistory()); } @Override diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/VariantCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/VariantCrudController.java index 36c0ce36f..ca68a6a88 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/crud/VariantCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/VariantCrudController.java @@ -6,8 +6,10 @@ import org.alliancegenome.curation_api.dao.VariantDAO; import org.alliancegenome.curation_api.interfaces.crud.VariantCrudInterface; import org.alliancegenome.curation_api.jobs.executors.VariantExecutor; +import org.alliancegenome.curation_api.jobs.executors.VariantFmsExecutor; import org.alliancegenome.curation_api.model.entities.Variant; import org.alliancegenome.curation_api.model.ingest.dto.VariantDTO; +import org.alliancegenome.curation_api.model.ingest.dto.fms.VariantFmsDTO; import org.alliancegenome.curation_api.response.APIResponse; import org.alliancegenome.curation_api.services.VariantService; @@ -23,6 +25,9 @@ public class VariantCrudController extends SubmittedObjectCrudController variantD return variantExecutor.runLoadApi(variantService, dataProvider, variantData); } + @Override + public APIResponse updateFmsVariants(String dataProvider, List variantData) { + return variantFmsExecutor.runLoadApi(dataProvider, variantData); + } + } diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkFMSLoadCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkFMSLoadCrudController.java index e31dc34ea..5b7ba77fc 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkFMSLoadCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkFMSLoadCrudController.java @@ -4,7 +4,6 @@ import org.alliancegenome.curation_api.dao.loads.BulkFMSLoadDAO; import org.alliancegenome.curation_api.interfaces.crud.bulkloads.BulkFMSLoadCrudInterface; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkFMSLoad; -import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.services.loads.BulkFMSLoadService; import jakarta.annotation.PostConstruct; @@ -23,9 +22,4 @@ protected void init() { setService(bulkFMSLoadService); } - @Override - public ObjectResponse restartLoad(Long id) { - return bulkFMSLoadService.restartLoad(id); - } - } diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkLoadFileCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkLoadFileCrudController.java index e59b72ec1..768cfed2b 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkLoadFileCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkLoadFileCrudController.java @@ -4,7 +4,6 @@ import org.alliancegenome.curation_api.dao.loads.BulkLoadFileDAO; import org.alliancegenome.curation_api.interfaces.crud.bulkloads.BulkLoadFileCrudInterface; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; -import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.services.loads.BulkLoadFileService; import jakarta.annotation.PostConstruct; @@ -23,9 +22,4 @@ protected void init() { setService(bulkLoadFileService); } - @Override - public ObjectResponse restartLoadFile(Long id) { - return bulkLoadFileService.restartLoad(id); - } - } diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkLoadFileHistoryCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkLoadFileHistoryCrudController.java index 51a71f20e..f2374faa6 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkLoadFileHistoryCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkLoadFileHistoryCrudController.java @@ -3,7 +3,10 @@ import org.alliancegenome.curation_api.controllers.base.BaseEntityCrudController; import org.alliancegenome.curation_api.dao.loads.BulkLoadFileHistoryDAO; import org.alliancegenome.curation_api.interfaces.crud.bulkloads.BulkLoadFileHistoryCrudInterface; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoad; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; +import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.services.loads.BulkLoadFileHistoryService; import jakarta.annotation.PostConstruct; @@ -27,5 +30,14 @@ protected void init() { public Response download(Long id) { return bulkLoadFileHistoryService.download(id); } - + + @Override + public ObjectResponse restartBulkLoad(Long id) { + return bulkLoadFileHistoryService.restartBulkLoad(id); + } + + @Override + public ObjectResponse restartBulkLoadHistory(Long id) { + return bulkLoadFileHistoryService.restartBulkLoadHistory(id); + } } diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkManualLoadCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkManualLoadCrudController.java index 4e6e17b03..4f52f4a52 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkManualLoadCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkManualLoadCrudController.java @@ -4,7 +4,6 @@ import org.alliancegenome.curation_api.dao.loads.BulkManualLoadDAO; import org.alliancegenome.curation_api.interfaces.crud.bulkloads.BulkManualLoadCrudInterface; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkManualLoad; -import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.services.loads.BulkManualLoadService; import jakarta.annotation.PostConstruct; @@ -23,8 +22,4 @@ protected void init() { setService(bulkManualLoadService); } - @Override - public ObjectResponse restartLoad(Long id) { - return bulkManualLoadService.restartLoad(id); - } } diff --git a/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkURLLoadCrudController.java b/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkURLLoadCrudController.java index f9eba2212..fd2fa7676 100644 --- a/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkURLLoadCrudController.java +++ b/src/main/java/org/alliancegenome/curation_api/controllers/crud/loads/BulkURLLoadCrudController.java @@ -4,7 +4,6 @@ import org.alliancegenome.curation_api.dao.loads.BulkURLLoadDAO; import org.alliancegenome.curation_api.interfaces.crud.bulkloads.BulkURLLoadCrudInterface; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkURLLoad; -import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.services.loads.BulkURLLoadService; import jakarta.annotation.PostConstruct; @@ -23,8 +22,4 @@ protected void init() { setService(bulkURLLoadService); } - @Override - public ObjectResponse restartLoad(Long id) { - return bulkURLLoadService.restartLoad(id); - } } diff --git a/src/main/java/org/alliancegenome/curation_api/dao/ConstructDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/ConstructDAO.java index 05ab89cbc..1d588c9ee 100644 --- a/src/main/java/org/alliancegenome/curation_api/dao/ConstructDAO.java +++ b/src/main/java/org/alliancegenome/curation_api/dao/ConstructDAO.java @@ -1,15 +1,34 @@ package org.alliancegenome.curation_api.dao; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.persistence.Query; import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; import org.alliancegenome.curation_api.model.entities.Construct; -import jakarta.enterprise.context.ApplicationScoped; +import java.util.HashMap; +import java.util.List; +import java.util.Map; @ApplicationScoped public class ConstructDAO extends BaseSQLDAO { - + protected ConstructDAO() { super(Construct.class); } + public Map getConstructIdMap() { + Map constructIdMap = new HashMap<>(); + Query q = entityManager.createNativeQuery("SELECT a.id, a.modEntityId, a.modInternalId FROM Reagent as a where exists (select * from construct as g where g.id = a.id)"); + List ids = q.getResultList(); + ids.forEach(record -> { + if (record[1] != null) { + constructIdMap.put((String) record[1], (long) record[0]); + } + if (record[2] != null) { + constructIdMap.put((String) record[2], (long) record[0]); + } + }); + return constructIdMap; + } + } diff --git a/src/main/java/org/alliancegenome/curation_api/dao/CrossReferenceDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/CrossReferenceDAO.java index 4bd4398bc..162d95391 100644 --- a/src/main/java/org/alliancegenome/curation_api/dao/CrossReferenceDAO.java +++ b/src/main/java/org/alliancegenome/curation_api/dao/CrossReferenceDAO.java @@ -1,9 +1,14 @@ package org.alliancegenome.curation_api.dao; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.persistence.Query; import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; import org.alliancegenome.curation_api.model.entities.CrossReference; +import org.alliancegenome.curation_api.model.entities.ResourceDescriptorPage; -import jakarta.enterprise.context.ApplicationScoped; +import java.util.HashMap; +import java.util.List; +import java.util.Map; @ApplicationScoped public class CrossReferenceDAO extends BaseSQLDAO { @@ -11,4 +16,31 @@ public class CrossReferenceDAO extends BaseSQLDAO { protected CrossReferenceDAO() { super(CrossReference.class); } + + public Map getGenesWithCrossRefs(ResourceDescriptorPage page) { + String sql = """ + select gc.genomicentity_id, cr.referencedcurie from genomicentity_crossreference as gc, crossreference as cr + where gc.crossreferences_id = cr.id AND cr.resourcedescriptorpage_id = :pageID + """; + Query query = entityManager.createNativeQuery(sql); + query.setParameter("pageID", page.getId()); + List objects = query.getResultList(); + Map ensemblGeneMap = new HashMap<>(); + objects.forEach(object -> { + ensemblGeneMap.put((String) object[1], (Long) object[0]); + }); + return ensemblGeneMap; + } + + public Integer persistAccessionGeneAssociated(Long crossReferenceID, Long geneID) { + String sql = """ + insert into genomicentity_crossreference (crossreferences_id,genomicentity_id) + VALUES (:crossRef, :geneID) + """; + Query query = entityManager.createNativeQuery(sql); + query.setParameter("crossRef", crossReferenceID); + query.setParameter("geneID", geneID); + int update = query.executeUpdate(); + return update; + } } diff --git a/src/main/java/org/alliancegenome/curation_api/dao/DataProviderDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/DataProviderDAO.java index 420710b65..bbef29e34 100644 --- a/src/main/java/org/alliancegenome/curation_api/dao/DataProviderDAO.java +++ b/src/main/java/org/alliancegenome/curation_api/dao/DataProviderDAO.java @@ -1,14 +1,74 @@ package org.alliancegenome.curation_api.dao; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; +import org.alliancegenome.curation_api.model.entities.CrossReference; import org.alliancegenome.curation_api.model.entities.DataProvider; +import org.alliancegenome.curation_api.model.entities.Organization; +import org.alliancegenome.curation_api.model.entities.ResourceDescriptorPage; +import org.alliancegenome.curation_api.model.input.Pagination; +import org.alliancegenome.curation_api.response.SearchResponse; -import jakarta.enterprise.context.ApplicationScoped; +import java.util.HashMap; +import java.util.List; @ApplicationScoped public class DataProviderDAO extends BaseSQLDAO { + @Inject + CrossReferenceDAO crossReferenceDAO; + + private HashMap dataProviderCache = new HashMap<>(); + protected DataProviderDAO() { super(DataProvider.class); } + + @Transactional + public DataProvider getOrCreateDataProvider(Organization sourceOrganization) { + + if (dataProviderCache.containsKey(sourceOrganization.getAbbreviation())) { + return dataProviderCache.get(sourceOrganization.getAbbreviation()); + } + + HashMap params = new HashMap<>(); + params.put("sourceOrganization.abbreviation", sourceOrganization.getAbbreviation()); + params.put("crossReference.referencedCurie", sourceOrganization.getAbbreviation()); + + SearchResponse orgResponse = findByParams(params); + if (orgResponse != null && orgResponse.getSingleResult() != null) { + DataProvider member = orgResponse.getSingleResult(); + if (member.getSourceOrganization() != null && member.getCrossReference() != null) { + dataProviderCache.put(sourceOrganization.getAbbreviation(), member); + return member; + } + } else { + DataProvider dataProvider = new DataProvider(); + + dataProvider.setSourceOrganization(sourceOrganization); + + CrossReference xref = new CrossReference(); + xref.setDisplayName(sourceOrganization.getAbbreviation()); + xref.setReferencedCurie(sourceOrganization.getAbbreviation()); + xref.setResourceDescriptorPage(sourceOrganization.getHomepageResourceDescriptorPage()); + dataProvider.setCrossReference(crossReferenceDAO.persist(xref)); + + DataProvider dp = persist(dataProvider); + return dp; + } + + return null; + } + + public List getAllDataProvider(Organization sourceOrganization, ResourceDescriptorPage page) { + HashMap params = new HashMap<>(); + params.put("sourceOrganization.abbreviation", sourceOrganization.getAbbreviation()); + params.put("crossReference.resourceDescriptorPage.name", page.getName()); + Pagination pagination = new Pagination(); + pagination.setLimit(10_000_000); + SearchResponse orgResponse = findByParams(pagination, params); + return orgResponse.getResults(); + } } diff --git a/src/main/java/org/alliancegenome/curation_api/dao/ExternalDataBaseEntityDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/ExternalDataBaseEntityDAO.java new file mode 100644 index 000000000..95342da51 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/dao/ExternalDataBaseEntityDAO.java @@ -0,0 +1,14 @@ +package org.alliancegenome.curation_api.dao; + +import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; +import org.alliancegenome.curation_api.model.entities.ExternalDataBaseEntity; + +import jakarta.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class ExternalDataBaseEntityDAO extends BaseSQLDAO { + + protected ExternalDataBaseEntityDAO() { + super(ExternalDataBaseEntity.class); + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/dao/GeneDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/GeneDAO.java index 179d52cf8..723785ac5 100644 --- a/src/main/java/org/alliancegenome/curation_api/dao/GeneDAO.java +++ b/src/main/java/org/alliancegenome/curation_api/dao/GeneDAO.java @@ -4,9 +4,11 @@ import java.util.List; import java.util.Map; +import jakarta.persistence.Query; import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; import org.alliancegenome.curation_api.dao.orthology.GeneToGeneOrthologyDAO; import org.alliancegenome.curation_api.model.entities.Gene; +import org.alliancegenome.curation_api.model.entities.Species; import org.apache.commons.collections.CollectionUtils; import jakarta.enterprise.context.ApplicationScoped; @@ -109,4 +111,24 @@ public List findReferencingGeneExpressionAnnotations(Long geneId) { params.put("expressionAnnotationSubject.id", geneId); return geneExpressionAnnotationDAO.findIdsByParams(params); } + + public Map getAllGeneIdsPerSpecies(Species species) { + String sql = """ + select g.id, be.modentityid, s.displaytext + from biologicalentity as be, gene as g, slotannotation as s + where be.taxon_id = :ID + AND be.id = g.id + AND s.singlegene_id = g.id + AND s.slotannotationtype = 'GeneSymbolSlotAnnotation' + """; + Query query = entityManager.createNativeQuery(sql); + query.setParameter("ID", species.getTaxon().getId()); + List objects = query.getResultList(); + Map ensemblGeneMap = new HashMap<>(); + objects.forEach(object -> { + ensemblGeneMap.put((String) object[1], (Long) object[0]); + ensemblGeneMap.put((String) object[2], (Long) object[0]); + }); + return ensemblGeneMap; + } } diff --git a/src/main/java/org/alliancegenome/curation_api/dao/GenomicEntityDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/GenomicEntityDAO.java index 575b00d34..bc6d184da 100644 --- a/src/main/java/org/alliancegenome/curation_api/dao/GenomicEntityDAO.java +++ b/src/main/java/org/alliancegenome/curation_api/dao/GenomicEntityDAO.java @@ -1,9 +1,13 @@ package org.alliancegenome.curation_api.dao; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.persistence.Query; import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; import org.alliancegenome.curation_api.model.entities.GenomicEntity; -import jakarta.enterprise.context.ApplicationScoped; +import java.util.HashMap; +import java.util.List; +import java.util.Map; @ApplicationScoped public class GenomicEntityDAO extends BaseSQLDAO { @@ -12,4 +16,19 @@ protected GenomicEntityDAO() { super(GenomicEntity.class); } + public Map getGenomicEntityIdMap() { + Map genomicEntityIdMap = new HashMap<>(); + Query q = entityManager.createNativeQuery("SELECT a.id, a.modEntityId, a.modInternalId FROM BiologicalEntity as a where exists (select * from genomicentity as g where g.id = a.id)"); + List ids = q.getResultList(); + ids.forEach(record -> { + if (record[1] != null) { + genomicEntityIdMap.put((String) record[1], (long) record[0]); + } + if (record[2] != null) { + genomicEntityIdMap.put((String) record[2], (long) record[0]); + } + }); + return genomicEntityIdMap; + } + } diff --git a/src/main/java/org/alliancegenome/curation_api/dao/HTPExpressionDatasetAnnotationDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/HTPExpressionDatasetAnnotationDAO.java new file mode 100644 index 000000000..35d7d823a --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/dao/HTPExpressionDatasetAnnotationDAO.java @@ -0,0 +1,14 @@ +package org.alliancegenome.curation_api.dao; + +import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; +import org.alliancegenome.curation_api.model.entities.HTPExpressionDatasetAnnotation; + +import jakarta.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class HTPExpressionDatasetAnnotationDAO extends BaseSQLDAO { + + protected HTPExpressionDatasetAnnotationDAO() { + super(HTPExpressionDatasetAnnotation.class); + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/dao/OrganizationDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/OrganizationDAO.java index 18fbb5f0a..c28fafc7f 100644 --- a/src/main/java/org/alliancegenome/curation_api/dao/OrganizationDAO.java +++ b/src/main/java/org/alliancegenome/curation_api/dao/OrganizationDAO.java @@ -1,15 +1,38 @@ package org.alliancegenome.curation_api.dao; +import java.util.HashMap; + import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; import org.alliancegenome.curation_api.model.entities.Organization; +import org.alliancegenome.curation_api.response.SearchResponse; import jakarta.enterprise.context.ApplicationScoped; @ApplicationScoped public class OrganizationDAO extends BaseSQLDAO { + private HashMap organizationCache = new HashMap<>(); + protected OrganizationDAO() { super(Organization.class); } + public Organization getOrCreateOrganization(String abbreviation) { + if (organizationCache.containsKey(abbreviation)) { + return organizationCache.get(abbreviation); + } else { + HashMap params = new HashMap<>(); + params.put("abbreviation", abbreviation); + SearchResponse resp = findByParams(params); + if (resp != null) { + organizationCache.put(abbreviation, resp.getSingleResult()); + return resp.getSingleResult(); + } else { + Organization o = new Organization(); + o.setAbbreviation(abbreviation); + organizationCache.put(abbreviation, o); + return persist(o); + } + } + } } diff --git a/src/main/java/org/alliancegenome/curation_api/dao/associations/alleleAssociations/AlleleVariantAssociationDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/associations/alleleAssociations/AlleleVariantAssociationDAO.java new file mode 100644 index 000000000..fc672aefb --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/dao/associations/alleleAssociations/AlleleVariantAssociationDAO.java @@ -0,0 +1,15 @@ +package org.alliancegenome.curation_api.dao.associations.alleleAssociations; + +import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; +import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleVariantAssociation; + +import jakarta.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class AlleleVariantAssociationDAO extends BaseSQLDAO { + + protected AlleleVariantAssociationDAO() { + super(AlleleVariantAssociation.class); + } + +} diff --git a/src/main/java/org/alliancegenome/curation_api/dao/associations/transcriptAssociations/TranscriptCodingSequenceAssociationDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/associations/transcriptAssociations/TranscriptCodingSequenceAssociationDAO.java new file mode 100644 index 000000000..6a1024ed6 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/dao/associations/transcriptAssociations/TranscriptCodingSequenceAssociationDAO.java @@ -0,0 +1,15 @@ +package org.alliancegenome.curation_api.dao.associations.transcriptAssociations; + +import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; +import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptCodingSequenceAssociation; + +import jakarta.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class TranscriptCodingSequenceAssociationDAO extends BaseSQLDAO { + + protected TranscriptCodingSequenceAssociationDAO() { + super(TranscriptCodingSequenceAssociation.class); + } + +} diff --git a/src/main/java/org/alliancegenome/curation_api/dao/associations/transcriptAssociations/TranscriptExonAssociationDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/associations/transcriptAssociations/TranscriptExonAssociationDAO.java new file mode 100644 index 000000000..a1bdefae4 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/dao/associations/transcriptAssociations/TranscriptExonAssociationDAO.java @@ -0,0 +1,15 @@ +package org.alliancegenome.curation_api.dao.associations.transcriptAssociations; + +import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; +import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptExonAssociation; + +import jakarta.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class TranscriptExonAssociationDAO extends BaseSQLDAO { + + protected TranscriptExonAssociationDAO() { + super(TranscriptExonAssociation.class); + } + +} diff --git a/src/main/java/org/alliancegenome/curation_api/dao/associations/transcriptAssociations/TranscriptGeneAssociationDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/associations/transcriptAssociations/TranscriptGeneAssociationDAO.java new file mode 100644 index 000000000..32950fe4a --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/dao/associations/transcriptAssociations/TranscriptGeneAssociationDAO.java @@ -0,0 +1,15 @@ +package org.alliancegenome.curation_api.dao.associations.transcriptAssociations; + +import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; +import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptGeneAssociation; + +import jakarta.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class TranscriptGeneAssociationDAO extends BaseSQLDAO { + + protected TranscriptGeneAssociationDAO() { + super(TranscriptGeneAssociation.class); + } + +} diff --git a/src/main/java/org/alliancegenome/curation_api/dao/associations/variantAssociations/CuratedVariantGenomicLocationAssociationDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/associations/variantAssociations/CuratedVariantGenomicLocationAssociationDAO.java new file mode 100644 index 000000000..cc93da69f --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/dao/associations/variantAssociations/CuratedVariantGenomicLocationAssociationDAO.java @@ -0,0 +1,15 @@ +package org.alliancegenome.curation_api.dao.associations.variantAssociations; + +import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; +import org.alliancegenome.curation_api.model.entities.associations.variantAssociations.CuratedVariantGenomicLocationAssociation; + +import jakarta.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class CuratedVariantGenomicLocationAssociationDAO extends BaseSQLDAO { + + protected CuratedVariantGenomicLocationAssociationDAO() { + super(CuratedVariantGenomicLocationAssociation.class); + } + +} diff --git a/src/main/java/org/alliancegenome/curation_api/dao/base/BaseSQLDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/base/BaseSQLDAO.java index e0153efa3..3432ef373 100644 --- a/src/main/java/org/alliancegenome/curation_api/dao/base/BaseSQLDAO.java +++ b/src/main/java/org/alliancegenome/curation_api/dao/base/BaseSQLDAO.java @@ -1,15 +1,14 @@ package org.alliancegenome.curation_api.dao.base; -import static org.reflections.scanners.Scanners.TypesAnnotated; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; - +import io.quarkus.logging.Log; +import jakarta.inject.Inject; +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceException; +import jakarta.persistence.TypedQuery; +import jakarta.persistence.criteria.*; +import jakarta.persistence.metamodel.IdentifiableType; +import jakarta.persistence.metamodel.Metamodel; +import jakarta.transaction.Transactional; import org.alliancegenome.curation_api.exceptions.ApiErrorException; import org.alliancegenome.curation_api.model.entities.base.AuditedObject; import org.alliancegenome.curation_api.model.input.Pagination; @@ -17,7 +16,6 @@ import org.alliancegenome.curation_api.response.SearchResponse; import org.alliancegenome.curation_api.services.processing.IndexProcessDisplayService; import org.alliancegenome.curation_api.util.ProcessDisplayHelper; -import org.eclipse.microprofile.config.inject.ConfigProperty; import org.elasticsearch.index.query.Operator; import org.hibernate.exception.ConstraintViolationException; import org.hibernate.query.sqm.internal.QuerySqmImpl; @@ -40,31 +38,20 @@ import org.jboss.logging.Logger.Level; import org.reflections.Reflections; -import io.quarkus.logging.Log; -import jakarta.inject.Inject; -import jakarta.persistence.EntityManager; -import jakarta.persistence.PersistenceException; -import jakarta.persistence.TypedQuery; -import jakarta.persistence.criteria.CriteriaBuilder; -import jakarta.persistence.criteria.CriteriaQuery; -import jakarta.persistence.criteria.Join; -import jakarta.persistence.criteria.JoinType; -import jakarta.persistence.criteria.Path; -import jakarta.persistence.criteria.Predicate; -import jakarta.persistence.criteria.Root; -import jakarta.persistence.metamodel.IdentifiableType; -import jakarta.persistence.metamodel.Metamodel; -import jakarta.transaction.Transactional; - -public class BaseSQLDAO extends BaseEntityDAO { +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; - @ConfigProperty(name = "quarkus.hibernate-search-orm.elasticsearch.hosts") String esHosts; +import static org.reflections.scanners.Scanners.TypesAnnotated; - @ConfigProperty(name = "quarkus.hibernate-search-orm.elasticsearch.protocol") String esProtocol; +public class BaseSQLDAO extends BaseEntityDAO { - @Inject protected EntityManager entityManager; - @Inject protected SearchSession searchSession; - @Inject protected IndexProcessDisplayService indexProcessDisplayService; + @Inject + protected EntityManager entityManager; + @Inject + protected SearchSession searchSession; + @Inject + protected IndexProcessDisplayService indexProcessDisplayService; protected BaseSQLDAO(Class myClass) { super(myClass); @@ -361,7 +348,7 @@ public void reindexEverything(Integer batchSizeToLoadObjects, Integer idFetchSiz Reflections reflections = new Reflections("org.alliancegenome.curation_api"); Set> annotatedClasses = reflections.get(TypesAnnotated.with(Indexed.class).asClass(reflections.getConfiguration().getClassLoaders())); - ProcessDisplayHelper ph = new ProcessDisplayHelper(2000); + ProcessDisplayHelper ph = new ProcessDisplayHelper(5000); ph.addDisplayHandler(indexProcessDisplayService); ph.startProcess("Mass Index Everything"); MassIndexer indexer = searchSession.massIndexer(annotatedClasses).batchSizeToLoadObjects(batchSizeToLoadObjects).idFetchSize(idFetchSize).dropAndCreateSchemaOnStart(true).mergeSegmentsOnFinish(false).typesToIndexInParallel(typesToIndexInParallel).threadsToLoadObjects(threadsToLoadObjects) @@ -402,7 +389,7 @@ public void reindex(Class objectClass, Integer batchSizeToLoadObjects, Intege MassIndexer indexer = searchSession.massIndexer(objectClass).batchSizeToLoadObjects(batchSizeToLoadObjects).idFetchSize(idFetchSize).dropAndCreateSchemaOnStart(true).mergeSegmentsOnFinish(false).typesToIndexInParallel(typesToIndexInParallel).threadsToLoadObjects(threadsToLoadObjects) .monitor(new MassIndexingMonitor() { - ProcessDisplayHelper ph = new ProcessDisplayHelper(2000); + ProcessDisplayHelper ph = new ProcessDisplayHelper(5000); @Override public void documentsAdded(long increment) { @@ -485,8 +472,9 @@ public SearchResponse searchByParams(Pagination pagination, Map clause = p.bool(); if (useKeywordFields != null && useKeywordFields) { clause.should(p.match().field(field + "_keyword").matching(searchFilters.get(filterName).get(field).get("queryString").toString()).boost(boost + 500)); + } else { + clause.should(p.match().field(field).matching(searchFilters.get(filterName).get(field).get("queryString").toString()).boost(boost)); } - clause.should(p.match().field(field).matching(searchFilters.get(filterName).get(field).get("queryString").toString()).boost(boost)); q.should(clause); } else { // assume simple query BooleanPredicateClausesStep clause = p.bool(); @@ -667,10 +655,10 @@ public SearchResponse findByParams(Pagination pagination, Map if (orderByField != null) { query.orderBy(builder.asc(root.get(orderByField))); } else { - // Metamodel metaModel = entityManager.getMetamodel(); - // IdentifiableType of = (IdentifiableType) - // metaModel.managedType(myClass); - // query.orderBy(builder.asc(root.get(of.getId(of.getIdType().getJavaType()).getName()))); + // Else always order by the ID field to prevent random lists when using different page,limit combinations + Metamodel metaModel = entityManager.getMetamodel(); + IdentifiableType of = (IdentifiableType) metaModel.managedType(myClass); + query.orderBy(builder.asc(root.get(of.getId(of.getIdType().getJavaType()).getName()))); } if (queryOperator == Operator.AND) { @@ -723,4 +711,8 @@ public E getNewInstance() { return null; } + public E getShallowEntity(Class entityClass, long id) { + return entityManager.getReference(entityClass, id); + } + } diff --git a/src/main/java/org/alliancegenome/curation_api/dao/loads/BulkLoadFileExceptionDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/loads/BulkLoadFileExceptionDAO.java index 774194e14..d4008becd 100644 --- a/src/main/java/org/alliancegenome/curation_api/dao/loads/BulkLoadFileExceptionDAO.java +++ b/src/main/java/org/alliancegenome/curation_api/dao/loads/BulkLoadFileExceptionDAO.java @@ -3,11 +3,21 @@ import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileException; +import io.quarkus.logging.Log; import jakarta.enterprise.context.ApplicationScoped; +import jakarta.persistence.Query; +import jakarta.transaction.Transactional; @ApplicationScoped public class BulkLoadFileExceptionDAO extends BaseSQLDAO { protected BulkLoadFileExceptionDAO() { super(BulkLoadFileException.class); } + + @Transactional + public void cleanUpTwoWeekOldExceptions() { + Log.info("Deleting Old Bulk Exceptions: \"DELETE FROM BulkLoadFileException WHERE dbdatecreated < NOW() - INTERVAL '14 days'\""); + Query jpqlQuery = entityManager.createNativeQuery("DELETE FROM BulkLoadFileException WHERE dbdatecreated < NOW() - INTERVAL '14 days'"); + jpqlQuery.executeUpdate(); + } } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/dao/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationDAO.java index e8d85cd2a..425f3ddf5 100644 --- a/src/main/java/org/alliancegenome/curation_api/dao/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationDAO.java +++ b/src/main/java/org/alliancegenome/curation_api/dao/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotationDAO.java @@ -19,7 +19,7 @@ protected ConstructComponentSlotAnnotationDAO() { } public void deleteAttachedNote(Long id) { - Query jpqlQuery = entityManager.createNativeQuery("DELETE FROM constructcomponentslotannotation_note WHERE relatednotes_id = '" + id + "'"); + Query jpqlQuery = entityManager.createNativeQuery("DELETE FROM slotannotation_note WHERE relatednotes_id = '" + id + "'"); jpqlQuery.executeUpdate(); noteDAO.remove(id); diff --git a/src/main/java/org/alliancegenome/curation_api/enums/BackendBulkLoadType.java b/src/main/java/org/alliancegenome/curation_api/enums/BackendBulkLoadType.java index 2c3ae805d..11b17cb8a 100644 --- a/src/main/java/org/alliancegenome/curation_api/enums/BackendBulkLoadType.java +++ b/src/main/java/org/alliancegenome/curation_api/enums/BackendBulkLoadType.java @@ -18,13 +18,25 @@ public enum BackendBulkLoadType { ALLELE_ASSOCIATION("json"), CONSTRUCT_ASSOCIATION("json"), VARIANT("json"), - GFF("gff"), + VARIATION("json"), // FMS variants as opposed to direct submission for VARIANT + + // GFF all from the same file but split out + GFF("gff"), // For Database entries + + GFF_EXON("gff"), + GFF_CDS("gff"), + GFF_TRANSCRIPT("gff"), + INTERACTION_MOL("tsv"), + EXPRESSION_ATLAS("tsv"), INTERACTION_GEN("tsv"), + BIOGRID_ORCS("tsv"), PARALOGY("json"), SEQUENCE_TARGETING_REAGENT("json"), EXPRESSION("json"), - HTPDATASET("json"); + HTPDATASET("json"), + HTPDATASAMPLE("json"), + ; public String fileExtension; diff --git a/src/main/java/org/alliancegenome/curation_api/enums/ChromosomeAccessionEnum.java b/src/main/java/org/alliancegenome/curation_api/enums/ChromosomeAccessionEnum.java new file mode 100644 index 000000000..05e9dceb5 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/enums/ChromosomeAccessionEnum.java @@ -0,0 +1,161 @@ +package org.alliancegenome.curation_api.enums; + +public enum ChromosomeAccessionEnum { + + FB_2L("2L", "RefSeq:NT_033779.5", "R6"), + FB_2R("2R", "RefSeq:NT_033778.4", "R6"), + FB_3L("3L", "RefSeq:NT_037436.4", "R6"), + FB_3R("3R", "RefSeq:NT_033777.3", "R6"), + FB_4("4", "RefSeq:NC_004353.4", "R6"), + FB_X("X", "RefSeq:NC_004354.4", "R6"), + FB_Y("Y", "RefSeq:NC_024512.1", "R6"), + FB_MT("mitochondrion_genome", "RefSeq:NC_024511.2", "R6"), + FB_US("Unmapped_Scaffold_8_D1580_D1567", "RefSeq:NW_007931083.1", "R6"), + FB_211000022278279("211000022278279", "RefSeq:NW_007931104.1", "R6"), + FB_211000022278436("211000022278436", "RefSeq:NW_001845431.1", "R6"), + FB_211000022278449("211000022278449", "RefSeq:NW_001845819.1", "R6"), + FB_211000022278760("211000022278760", "RefSeq:NW_001846712.1", "R6"), + FB_211000022279165("211000022279165", "RefSeq:NW_001846812.1", "R6"), + FB_211000022279188("211000022279188", "RefSeq:NW_001845284.1", "R6"), + FB_211000022279264("211000022279264", "RefSeq:NW_001847227.1", "R6"), + FB_211000022279392("211000022279392", "RefSeq:NW_001846198.1", "R6"), + FB_211000022279681("211000022279681", "RefSeq:NW_001845031.1", "R6"), + FB_211000022280328("211000022280328", "RefSeq:NW_001844935.1", "R6"), + FB_211000022280341("211000022280341", "RefSeq:NW_001846187.1", "R6"), + FB_211000022280347("211000022280347", "RefSeq:NW_001845870.1", "R6"), + FB_211000022280481("211000022280481", "RefSeq:NW_001845220.1", "R6"), + FB_211000022280494("211000022280494", "RefSeq:NW_001845164.1", "R6"), + FB_211000022280703("211000022280703", "RefSeq:NW_001845199.1", "R6"), + FB_RDNA("rDNA", "RefSeq:NW_007931121.1", "R6"), + MGI_1("1", "RefSeq:NC_000067.7", "GRCm39"), + MGI_2("2", "RefSeq:NC_000068.8", "GRCm39"), + MGI_3("3", "RefSeq:NC_000069.7", "GRCm39"), + MGI_4("4", "RefSeq:NC_000070.7", "GRCm39"), + MGI_5("5", "RefSeq:NC_000071.7", "GRCm39"), + MGI_6("6", "RefSeq:NC_000072.7", "GRCm39"), + MGI_7("7", "RefSeq:NC_000073.7", "GRCm39"), + MGI_8("8", "RefSeq:NC_000074.7", "GRCm39"), + MGI_9("9", "RefSeq:NC_000075.7", "GRCm39"), + MGI_10("10", "RefSeq:NC_000076.7", "GRCm39"), + MGI_11("11", "RefSeq:NC_000077.7", "GRCm39"), + MGI_12("12", "RefSeq:NC_000078.7", "GRCm39"), + MGI_13("13", "RefSeq:NC_000079.7", "GRCm39"), + MGI_14("14", "RefSeq:NC_000080.7", "GRCm39"), + MGI_15("15", "RefSeq:NC_000081.7", "GRCm39"), + MGI_16("16", "RefSeq:NC_000082.7", "GRCm39"), + MGI_17("17", "RefSeq:NC_000083.7", "GRCm39"), + MGI_18("18", "RefSeq:NC_000084.7", "GRCm39"), + MGI_19("19", "RefSeq:NC_000085.7", "GRCm39"), + MGI_X("X", "RefSeq:NC_000086.8", "GRCm39"), + MGI_Y("Y", "RefSeq:NC_000087.8", "GRCm39"), + MGI_MT("MT", "RefSeq:NC_005089.1", "GRCm39"), + RGD_1("1", "RefSeq:NC_051336.1", "mRatBN7.2"), + RGD_2("2", "RefSeq:NC_051337.1", "mRatBN7.2"), + RGD_3("3", "RefSeq:NC_051338.1", "mRatBN7.2"), + RGD_4("4", "RefSeq:NC_051339.1", "mRatBN7.2"), + RGD_5("5", "RefSeq:NC_051340.1", "mRatBN7.2"), + RGD_6("6", "RefSeq:NC_051341.1", "mRatBN7.2"), + RGD_7("7", "RefSeq:NC_051342.1", "mRatBN7.2"), + RGD_8("8", "RefSeq:NC_051343.1", "mRatBN7.2"), + RGD_9("9", "RefSeq:NC_051344.1", "mRatBN7.2"), + RGD_10("10", "RefSeq:NC_051345.1", "mRatBN7.2"), + RGD_11("11", "RefSeq:NC_051346.1", "mRatBN7.2"), + RGD_12("12", "RefSeq:NC_051347.1", "mRatBN7.2"), + RGD_13("13", "RefSeq:NC_051348.1", "mRatBN7.2"), + RGD_14("14", "RefSeq:NC_051349.1", "mRatBN7.2"), + RGD_15("15", "RefSeq:NC_051350.1", "mRatBN7.2"), + RGD_16("16", "RefSeq:NC_051351.1", "mRatBN7.2"), + RGD_17("17", "RefSeq:NC_051352.1", "mRatBN7.2"), + RGD_18("18", "RefSeq:NC_051353.1", "mRatBN7.2"), + RGD_19("19", "RefSeq:NC_051354.1", "mRatBN7.2"), + RGD_20("20", "RefSeq:NC_051355.1", "mRatBN7.2"), + RGD_X("X", "RefSeq:NC_051356.1", "mRatBN7.2"), + RGD_Y("Y", "RefSeq:NC_051357.1", "mRatBN7.2"), + RGD_MT("MT", "RefSeq:NC_001665.2", "mRatBN7.2"), + SGD_I("chrI", "RefSeq:NC_001133.9", "R64-4-1"), + SGD_II("chrII", "RefSeq:NC_001134.8", "R64-4-1"), + SGD_III("chrIII", "RefSeq:NC_001135.5", "R64-4-1"), + SGD_IV("chrIV", "RefSeq:NC_001136.10", "R64-4-1"), + SGD_V("chrV", "RefSeq:NC_001137.3", "R64-4-1"), + SGD_VI("chrVI", "RefSeq:NC_001138.5", "R64-4-1"), + SGD_VII("chrVII", "RefSeq:NC_001139.9", "R64-4-1"), + SGD_VIII("chrVIII", "RefSeq:NC_001140.6", "R64-4-1"), + SGD_IX("chrIX", "RefSeq:NC_001141.2", "R64-4-1"), + SGD_X("chrX", "RefSeq:NC_001142.9", "R64-4-1"), + SGD_XI("chrXI", "RefSeq:NC_001143.9", "R64-4-1"), + SGD_XII("chrXII", "RefSeq:NC_001144.5", "R64-4-1"), + SGD_XIII("chrXIII", "RefSeq:NC_001145.3", "R64-4-1"), + SGD_XIV("chrXIV", "RefSeq:NC_001146.8", "R64-4-1"), + SGD_XV("chrXV", "RefSeq:NC_001147.6", "R64-4-1"), + SGD_XVI("chrXVI", "RefSeq:NC_001148.4", "R64-4-1"), + SGD_MT("chrmt", "RefSeq:NC_001224.1", "R64-4-1"), + WB_I("I", "RefSeq:NC_003279.8", "WBcel235"), + WB_II("II", "RefSeq:NC_003280.10", "WBcel235"), + WB_III("III", "RefSeq:NC_003281.10", "WBcel235"), + WB_IV("IV", "RefSeq:NC_003282.8", "WBcel235"), + WB_V("V", "RefSeq:NC_003283.11", "WBcel235"), + WB_X("X", "RefSeq:NC_003284.9", "WBcel235"), + WB_MT("MtDNA", "RefSeq:NC_001328.1", "WBcel235"), + ZFIN_1("1", "RefSeq:NC_007112.7", "GRCz11"), + ZFIN_2("2", "RefSeq:NC_007113.7", "GRCz11"), + ZFIN_3("3", "RefSeq:NC_007114.7", "GRCz11"), + ZFIN_4("4", "RefSeq:NC_007115.7", "GRCz11"), + ZFIN_5("5", "RefSeq:NC_007116.7", "GRCz11"), + ZFIN_6("6", "RefSeq:NC_007117.7", "GRCz11"), + ZFIN_7("7", "RefSeq:NC_007118.7", "GRCz11"), + ZFIN_8("8", "RefSeq:NC_007119.7", "GRCz11"), + ZFIN_9("9", "RefSeq:NC_007120.7", "GRCz11"), + ZFIN_10("10", "RefSeq:NC_007121.7", "GRCz11"), + ZFIN_11("11", "RefSeq:NC_007122.7", "GRCz11"), + ZFIN_12("12", "RefSeq:NC_007123.7", "GRCz11"), + ZFIN_13("13", "RefSeq:NC_007124.7", "GRCz11"), + ZFIN_14("14", "RefSeq:NC_007125.7", "GRCz11"), + ZFIN_15("15", "RefSeq:NC_007126.7", "GRCz11"), + ZFIN_16("16", "RefSeq:NC_007127.7", "GRCz11"), + ZFIN_17("17", "RefSeq:NC_007128.7", "GRCz11"), + ZFIN_18("18", "RefSeq:NC_007129.7", "GRCz11"), + ZFIN_19("19", "RefSeq:NC_007130.7", "GRCz11"), + ZFIN_20("20", "RefSeq:NC_007131.7", "GRCz11"), + ZFIN_21("21", "RefSeq:NC_007132.7", "GRCz11"), + ZFIN_22("22", "RefSeq:NC_007133.7", "GRCz11"), + ZFIN_23("23", "RefSeq:NC_007134.7", "GRCz11"), + ZFIN_24("24", "RefSeq:NC_007135.7", "GRCz11"), + ZFIN_25("25", "RefSeq:NC_007136.7", "GRCz11"), + ZFIN_MT("MT", "RefSeq:NC_002333.2", "GRCz11"); + + + public String chromosomeName; + public String accession; + public String assemblyIdentifier; + + private ChromosomeAccessionEnum(String chromosomeName, String accession, String assemblyName) { + this.chromosomeName = chromosomeName; + this.accession = accession; + this.assemblyIdentifier = assemblyName; + } + + public static ChromosomeAccessionEnum getChromosomeAccessionEnum(String chromosomeAccession) { + if (chromosomeAccession == null) { + return null; + } + for (ChromosomeAccessionEnum chromosome : values()) { + if (chromosomeAccession.equals(chromosome.accession)) { + return chromosome; + } + } + return null; + } + + public static String getChromosomeAccession(String chromosomeName, String assemblyIdentifier) { + if (chromosomeName == null || assemblyIdentifier == null) { + return null; + } + for (ChromosomeAccessionEnum chromosome : values()) { + if (chromosomeName.equals(chromosome.chromosomeName) + && assemblyIdentifier.equals(chromosome.assemblyIdentifier)) { + return chromosome.accession; + } + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/exceptions/KnownIssueValidationException.java b/src/main/java/org/alliancegenome/curation_api/exceptions/KnownIssueValidationException.java new file mode 100644 index 000000000..5ce5b4cfc --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/exceptions/KnownIssueValidationException.java @@ -0,0 +1,8 @@ +package org.alliancegenome.curation_api.exceptions; + +public class KnownIssueValidationException extends ValidationException { + + public KnownIssueValidationException(String message) { + super(message); + } +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/exceptions/ObjectUpdateException.java b/src/main/java/org/alliancegenome/curation_api/exceptions/ObjectUpdateException.java index 15516e435..1999bc7c6 100644 --- a/src/main/java/org/alliancegenome/curation_api/exceptions/ObjectUpdateException.java +++ b/src/main/java/org/alliancegenome/curation_api/exceptions/ObjectUpdateException.java @@ -13,7 +13,7 @@ import lombok.NoArgsConstructor; @Data -public class ObjectUpdateException extends Exception { +public class ObjectUpdateException extends ValidationException { private ObjectUpdateExceptionData data; diff --git a/src/main/java/org/alliancegenome/curation_api/exceptions/ValidationException.java b/src/main/java/org/alliancegenome/curation_api/exceptions/ValidationException.java new file mode 100644 index 000000000..e56f8e5cf --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/exceptions/ValidationException.java @@ -0,0 +1,10 @@ +package org.alliancegenome.curation_api.exceptions; + +import lombok.NoArgsConstructor; + +@NoArgsConstructor +public class ValidationException extends Exception { + public ValidationException(String message) { + super(message); + } +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseUpsertControllerInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseUpsertControllerInterface.java index 07efff0e9..010bd50ad 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseUpsertControllerInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/base/BaseUpsertControllerInterface.java @@ -1,6 +1,6 @@ package org.alliancegenome.curation_api.interfaces.base; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.base.AuditedObject; import org.alliancegenome.curation_api.model.ingest.dto.base.BaseDTO; import org.alliancegenome.curation_api.view.View; @@ -15,5 +15,5 @@ public interface BaseUpsertControllerInterface { + +} diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/BaseUpsertServiceInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/BaseUpsertServiceInterface.java index 1bf4ebeda..a45799d43 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/BaseUpsertServiceInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/BaseUpsertServiceInterface.java @@ -1,16 +1,16 @@ package org.alliancegenome.curation_api.interfaces.crud; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.base.AuditedObject; import org.alliancegenome.curation_api.model.ingest.dto.base.BaseDTO; public interface BaseUpsertServiceInterface { - default E upsert(T dto) throws ObjectUpdateException { + default E upsert(T dto) throws ValidationException { return upsert(dto, null); } - E upsert(T dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException; + E upsert(T dto, BackendBulkDataProvider dataProvider) throws ValidationException; } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ExpressionAtlasCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ExpressionAtlasCrudInterface.java new file mode 100644 index 000000000..0541efab8 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/ExpressionAtlasCrudInterface.java @@ -0,0 +1,26 @@ +package org.alliancegenome.curation_api.interfaces.crud; + +import com.fasterxml.jackson.annotation.JsonView; +import jakarta.ws.rs.*; +import jakarta.ws.rs.core.MediaType; +import org.alliancegenome.curation_api.interfaces.base.crud.BaseCreateControllerInterface; +import org.alliancegenome.curation_api.model.entities.CrossReference; +import org.alliancegenome.curation_api.model.ingest.dto.CrossReferenceDTO; +import org.alliancegenome.curation_api.response.APIResponse; +import org.alliancegenome.curation_api.view.View; +import org.eclipse.microprofile.openapi.annotations.tags.Tag; + +import java.util.List; + +@Path("/expression-atlas") +@Tag(name = "CRUD - Expression Atlas") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public interface ExpressionAtlasCrudInterface extends BaseCreateControllerInterface { + + @POST + @Path("/bulk/{dataProvider}_{assemblyName}/transcripts") + @JsonView(View.FieldsAndLists.class) + APIResponse updateExpressionAtlas(@PathParam("dataProvider") String dataProvider, @PathParam("assemblyName") String assemblyName, List crossRefData); + +} diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GenomeAssemblyCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GenomeAssemblyCrudInterface.java new file mode 100644 index 000000000..ece1b03ca --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/GenomeAssemblyCrudInterface.java @@ -0,0 +1,18 @@ +package org.alliancegenome.curation_api.interfaces.crud; + +import org.alliancegenome.curation_api.interfaces.base.BaseSubmittedObjectCrudInterface; +import org.alliancegenome.curation_api.model.entities.GenomeAssembly; +import org.eclipse.microprofile.openapi.annotations.tags.Tag; + +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; + +@Path("/genomeassembly") +@Tag(name = "CRUD - GenomeAssembly") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public interface GenomeAssemblyCrudInterface extends BaseSubmittedObjectCrudInterface { + +} diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/HTPExpressionDatasetAnnotationCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/HTPExpressionDatasetAnnotationCrudInterface.java new file mode 100644 index 000000000..51fc32c3e --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/HTPExpressionDatasetAnnotationCrudInterface.java @@ -0,0 +1,29 @@ +package org.alliancegenome.curation_api.interfaces.crud; + +import org.alliancegenome.curation_api.interfaces.base.BaseIdCrudInterface; +import org.alliancegenome.curation_api.model.entities.HTPExpressionDatasetAnnotation; +import org.alliancegenome.curation_api.model.ingest.dto.fms.HTPExpressionDatasetAnnotationIngestFmsDTO; +import org.alliancegenome.curation_api.response.APIResponse; +import org.alliancegenome.curation_api.view.View; +import org.eclipse.microprofile.openapi.annotations.tags.Tag; + +import com.fasterxml.jackson.annotation.JsonView; + +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; + +@Path("/htpexpressiondatasetannotation") +@Tag(name = "CRUD - HTP Expression Dataset Annotation") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public interface HTPExpressionDatasetAnnotationCrudInterface extends BaseIdCrudInterface { + + @POST + @Path("/bulk/{dataProvider}/htpexpressiondatasetannotationfile") + @JsonView(View.FieldsAndLists.class) + APIResponse updateHTPExpressionDatasetAnnotation(@PathParam("dataProvider") String dataProvider, HTPExpressionDatasetAnnotationIngestFmsDTO htpDatasetData); +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/SequenceTargetingReagentCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/SequenceTargetingReagentCrudInterface.java index da513eca4..bea40b284 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/SequenceTargetingReagentCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/SequenceTargetingReagentCrudInterface.java @@ -2,7 +2,7 @@ import java.util.HashMap; -import org.alliancegenome.curation_api.interfaces.base.BaseIdCrudInterface; +import org.alliancegenome.curation_api.interfaces.base.BaseSubmittedObjectCrudInterface; import org.alliancegenome.curation_api.model.entities.SequenceTargetingReagent; import org.alliancegenome.curation_api.model.ingest.dto.fms.SequenceTargetingReagentIngestFmsDTO; import org.alliancegenome.curation_api.response.APIResponse; @@ -28,7 +28,7 @@ @Tag(name = "CRUD - SQTR") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) -public interface SequenceTargetingReagentCrudInterface extends BaseIdCrudInterface { +public interface SequenceTargetingReagentCrudInterface extends BaseSubmittedObjectCrudInterface { @POST @Path("/bulk/{dataProvider}/sqtrfile") @@ -49,10 +49,9 @@ public interface SequenceTargetingReagentCrudInterface extends BaseIdCrudInterfa @JsonView({ View.SequenceTargetingReagentView.class }) SearchResponse search(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); - @Override @GET - @Path("/{id}") + @Path("/{identifierString}") @JsonView(View.SequenceTargetingReagentDetailView.class) - ObjectResponse getById(@PathParam("id") Long id); + ObjectResponse getByIdentifier(@PathParam("identifierString") String identifierString); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VariantCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VariantCrudInterface.java index b8e76f289..786743f55 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VariantCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/VariantCrudInterface.java @@ -7,6 +7,7 @@ import org.alliancegenome.curation_api.interfaces.base.BaseUpsertControllerInterface; import org.alliancegenome.curation_api.model.entities.Variant; import org.alliancegenome.curation_api.model.ingest.dto.VariantDTO; +import org.alliancegenome.curation_api.model.ingest.dto.fms.VariantFmsDTO; import org.alliancegenome.curation_api.response.APIResponse; import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.response.SearchResponse; @@ -38,9 +39,14 @@ public interface VariantCrudInterface extends BaseSubmittedObjectCrudInterface alleleData); + @POST + @Path("/bulk/{dataProvider}/fmsvariants") + @JsonView(View.FieldsAndLists.class) + APIResponse updateFmsVariants(@PathParam("dataProvider") String dataProvider, List alleleData); + @Override @GET - @JsonView(View.VariantView.class) + @JsonView(View.VariantDetailView.class) @Path("/{identifierString}") ObjectResponse getByIdentifier(@PathParam("identifierString") String identifierString); @@ -60,7 +66,7 @@ public interface VariantCrudInterface extends BaseSubmittedObjectCrudInterface find(@DefaultValue("0") @QueryParam("page") Integer page, @DefaultValue("10") @QueryParam("limit") Integer limit, @RequestBody HashMap params); @Override diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkFMSLoadCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkFMSLoadCrudInterface.java index b1f856ab7..0985bedac 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkFMSLoadCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkFMSLoadCrudInterface.java @@ -2,16 +2,10 @@ import org.alliancegenome.curation_api.interfaces.base.BaseIdCrudInterface; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkFMSLoad; -import org.alliancegenome.curation_api.response.ObjectResponse; -import org.alliancegenome.curation_api.view.View; import org.eclipse.microprofile.openapi.annotations.tags.Tag; -import com.fasterxml.jackson.annotation.JsonView; - import jakarta.ws.rs.Consumes; -import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; @@ -20,10 +14,5 @@ @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public interface BulkFMSLoadCrudInterface extends BaseIdCrudInterface { - - @GET - @Path("/restart/{id}") - @JsonView(View.FieldsOnly.class) - ObjectResponse restartLoad(@PathParam("id") Long id); - + } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkLoadFileCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkLoadFileCrudInterface.java index 3a8bd1c47..44e3f5037 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkLoadFileCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkLoadFileCrudInterface.java @@ -2,16 +2,10 @@ import org.alliancegenome.curation_api.interfaces.base.BaseIdCrudInterface; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; -import org.alliancegenome.curation_api.response.ObjectResponse; -import org.alliancegenome.curation_api.view.View; import org.eclipse.microprofile.openapi.annotations.tags.Tag; -import com.fasterxml.jackson.annotation.JsonView; - import jakarta.ws.rs.Consumes; -import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; @@ -21,8 +15,4 @@ @Consumes(MediaType.APPLICATION_JSON) public interface BulkLoadFileCrudInterface extends BaseIdCrudInterface { - @GET - @Path("/restart/{id}") - @JsonView(View.FieldsOnly.class) - ObjectResponse restartLoadFile(@PathParam("id") Long id); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkLoadFileHistoryCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkLoadFileHistoryCrudInterface.java index a9a202735..5cd921812 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkLoadFileHistoryCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkLoadFileHistoryCrudInterface.java @@ -1,7 +1,10 @@ package org.alliancegenome.curation_api.interfaces.crud.bulkloads; import org.alliancegenome.curation_api.interfaces.base.BaseIdCrudInterface; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoad; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; +import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.view.View; import org.eclipse.microprofile.openapi.annotations.tags.Tag; @@ -25,4 +28,14 @@ public interface BulkLoadFileHistoryCrudInterface extends BaseIdCrudInterface restartBulkLoad(@PathParam("id") Long id); + + @GET + @Path("/restartloadhistory/{id}") + @JsonView(View.FieldsOnly.class) + ObjectResponse restartBulkLoadHistory(@PathParam("id") Long id); } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkManualLoadCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkManualLoadCrudInterface.java index b6f33cf41..56b5e31b9 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkManualLoadCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkManualLoadCrudInterface.java @@ -2,16 +2,10 @@ import org.alliancegenome.curation_api.interfaces.base.BaseIdCrudInterface; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkManualLoad; -import org.alliancegenome.curation_api.response.ObjectResponse; -import org.alliancegenome.curation_api.view.View; import org.eclipse.microprofile.openapi.annotations.tags.Tag; -import com.fasterxml.jackson.annotation.JsonView; - import jakarta.ws.rs.Consumes; -import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; @@ -21,9 +15,4 @@ @Consumes(MediaType.APPLICATION_JSON) public interface BulkManualLoadCrudInterface extends BaseIdCrudInterface { - @GET - @Path("/restart/{id}") - @JsonView(View.FieldsOnly.class) - ObjectResponse restartLoad(@PathParam("id") Long id); - } diff --git a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkURLLoadCrudInterface.java b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkURLLoadCrudInterface.java index d5827eca7..d7e31e355 100644 --- a/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkURLLoadCrudInterface.java +++ b/src/main/java/org/alliancegenome/curation_api/interfaces/crud/bulkloads/BulkURLLoadCrudInterface.java @@ -2,16 +2,10 @@ import org.alliancegenome.curation_api.interfaces.base.BaseIdCrudInterface; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkURLLoad; -import org.alliancegenome.curation_api.response.ObjectResponse; -import org.alliancegenome.curation_api.view.View; import org.eclipse.microprofile.openapi.annotations.tags.Tag; -import com.fasterxml.jackson.annotation.JsonView; - import jakarta.ws.rs.Consumes; -import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; @@ -21,8 +15,4 @@ @Consumes(MediaType.APPLICATION_JSON) public interface BulkURLLoadCrudInterface extends BaseIdCrudInterface { - @GET - @Path("/restart/{id}") - @JsonView(View.FieldsOnly.class) - ObjectResponse restartLoad(@PathParam("id") Long id); } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/JobScheduler.java b/src/main/java/org/alliancegenome/curation_api/jobs/JobScheduler.java index 6042e6459..f121192d3 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/JobScheduler.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/JobScheduler.java @@ -2,28 +2,25 @@ import java.io.File; import java.time.ZonedDateTime; -import java.util.Collections; -import java.util.Comparator; import java.util.concurrent.Semaphore; import org.alliancegenome.curation_api.dao.loads.BulkLoadDAO; import org.alliancegenome.curation_api.dao.loads.BulkLoadFileDAO; import org.alliancegenome.curation_api.dao.loads.BulkLoadFileExceptionDAO; +import org.alliancegenome.curation_api.dao.loads.BulkLoadFileHistoryDAO; import org.alliancegenome.curation_api.dao.loads.BulkLoadGroupDAO; import org.alliancegenome.curation_api.enums.JobStatus; -import org.alliancegenome.curation_api.jobs.events.PendingBulkLoadFileJobEvent; import org.alliancegenome.curation_api.jobs.events.PendingBulkLoadJobEvent; -import org.alliancegenome.curation_api.jobs.events.StartedBulkLoadFileJobEvent; +import org.alliancegenome.curation_api.jobs.events.PendingLoadJobEvent; import org.alliancegenome.curation_api.jobs.events.StartedBulkLoadJobEvent; +import org.alliancegenome.curation_api.jobs.events.StartedLoadJobEvent; import org.alliancegenome.curation_api.jobs.util.SlackNotifier; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoad; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileException; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadGroup; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkScheduledLoad; import org.alliancegenome.curation_api.response.SearchResponse; -import org.alliancegenome.curation_api.util.ProcessDisplayHelper; import org.eclipse.microprofile.config.inject.ConfigProperty; import com.cronutils.model.Cron; @@ -38,7 +35,7 @@ import jakarta.annotation.PostConstruct; import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.event.Event; -import jakarta.enterprise.event.Observes; +import jakarta.enterprise.event.ObservesAsync; import jakarta.inject.Inject; @ApplicationScoped @@ -51,9 +48,11 @@ public class JobScheduler { @Inject Event startedJobEvents; - @Inject Event startedFileJobEvents; + @Inject Event startedFileJobEvents; + @Inject BulkLoadFileDAO bulkLoadFileDAO; + @Inject BulkLoadFileHistoryDAO bulkLoadFileHistoryDAO; @Inject BulkLoadGroupDAO groupDAO; @Inject BulkLoadDAO bulkLoadDAO; @Inject BulkLoadFileExceptionDAO bulkLoadFileExceptionDAO; @@ -75,21 +74,23 @@ public void init() { if (g.getLoads().size() > 0) { for (BulkLoad b : g.getLoads()) { boolean isFirst = true; - for (BulkLoadFile bf : b.getLoadFiles()) { - if (bf.getBulkloadStatus() == null || bf.getBulkloadStatus().isRunning() || bf.getBulkloadStatus().isStarted() || bf.getLocalFilePath() != null) { - if (bf.getLocalFilePath() != null) { - File file = new File(bf.getLocalFilePath()); + for (BulkLoadFileHistory bfh : b.getHistory()) { + BulkLoadFile bulkLoadFile = bfh.getBulkLoadFile(); + if (bfh.getBulkloadStatus() == null || bfh.getBulkloadStatus().isPending() || bfh.getBulkloadStatus().isRunning() || bfh.getBulkloadStatus().isStarted() || bulkLoadFile.getLocalFilePath() != null) { + if (bulkLoadFile.getLocalFilePath() != null) { + File file = new File(bulkLoadFile.getLocalFilePath()); if (file.exists()) { file.delete(); } } - bf.setLocalFilePath(null); - bf.setErrorMessage("Failed due to server start up: Process never finished before the server restarted"); - bf.setBulkloadStatus(JobStatus.FAILED); + bulkLoadFile.setLocalFilePath(null); + bfh.setErrorMessage("Failed due to server start up: Process never finished before the server restarted"); + bfh.setBulkloadStatus(JobStatus.FAILED); if (isFirst) { - slackNotifier.slackalert(bf); // Only notify on the first failed file not all the failed files under a load + slackNotifier.slackalert(bfh); // Only notify on the first failed file not all the failed files under a load } - bulkLoadFileDAO.merge(bf); + bulkLoadFileDAO.merge(bulkLoadFile); + bulkLoadFileHistoryDAO.merge(bfh); } isFirst = false; } @@ -136,7 +137,7 @@ public void scheduleCronGroupJobs() { bsl.setSchedulingErrorMessage(null); bsl.setBulkloadStatus(JobStatus.SCHEDULED_PENDING); bulkLoadDAO.merge(bsl); - pendingJobEvents.fire(new PendingBulkLoadJobEvent(bsl.getId())); + pendingJobEvents.fireAsync(new PendingBulkLoadJobEvent(bsl.getId())); } } } catch (Exception e) { @@ -160,78 +161,33 @@ public void scheduleCronGroupJobs() { } } - public void pendingJobs(@Observes PendingBulkLoadJobEvent event) { - // Log.info("pendingJobs: " + event.getId()); + public void pendingJobs(@ObservesAsync PendingBulkLoadJobEvent event) { BulkLoad load = bulkLoadDAO.find(event.getId()); if (load != null) { if (load.getBulkloadStatus().isPending()) { load.setBulkloadStatus(load.getBulkloadStatus().getNextStatus()); bulkLoadDAO.merge(load); - // Log.info("Firing Start Job Event: " + load.getId()); - startedJobEvents.fire(new StartedBulkLoadJobEvent(load.getId())); + Log.debug("Firing Start Job Event: " + load.getId()); + startedJobEvents.fireAsync(new StartedBulkLoadJobEvent(load.getId())); } } } - public void pendingFileJobs(@Observes PendingBulkLoadFileJobEvent event) { - // Log.info("pendingFileJobs: " + event.getId()); - BulkLoadFile fileLoad = bulkLoadFileDAO.find(event.getId()); - if (fileLoad != null) { - if (fileLoad.getBulkloadStatus().isPending()) { - fileLoad.setBulkloadStatus(fileLoad.getBulkloadStatus().getNextStatus()); - bulkLoadFileDAO.merge(fileLoad); - // Log.info("Firing Start File Job Event: " + fileLoad.getId()); - startedFileJobEvents.fire(new StartedBulkLoadFileJobEvent(fileLoad.getId())); + public void pendingFileJobs(@ObservesAsync PendingLoadJobEvent event) { + BulkLoadFileHistory fileLoadHistory = bulkLoadFileHistoryDAO.find(event.getId()); + if (fileLoadHistory != null) { + if (fileLoadHistory.getBulkloadStatus().isPending()) { + fileLoadHistory.setBulkloadStatus(fileLoadHistory.getBulkloadStatus().getNextStatus()); + bulkLoadFileHistoryDAO.merge(fileLoadHistory); + Log.debug("Firing Start File History Job Event: " + fileLoadHistory.getId()); + startedFileJobEvents.fireAsync(new StartedLoadJobEvent(fileLoadHistory.getId())); } } } - @Scheduled(cron = "0 0 0 ? * SAT") + @Scheduled(cron = "0 0 0 ? * *") public void cleanUpFileExceptions() { - SearchResponse groups = groupDAO.findAll(); - - Comparator c = new Comparator() { - @Override - public int compare(BulkLoadFile blf1, BulkLoadFile blf2) { - if (blf1.getDateLastLoaded() == null && blf2.getDateLastLoaded() == null) { - return 0; - } - if (blf1.getDateLastLoaded() == null) { - return 1; - } - if (blf2.getDateLastLoaded() == null) { - return -1; - } - return blf2.getDateLastLoaded().compareTo(blf1.getDateLastLoaded()); - } - }; - - int historyExceptionsToKeep = 3; - - ProcessDisplayHelper ph = new ProcessDisplayHelper(); - ph.startProcess("Bulk Load File History Exception Cleanup"); - - for (BulkLoadGroup g : groups.getResults()) { - Log.debug("Group Clean Up: " + g.getName()); - if (g.getLoads().size() > 0) { - for (BulkLoad b : g.getLoads()) { - Log.debug("Load Clean Up: " + b.getName()); - Collections.sort(b.getLoadFiles(), c); - if (b.getLoadFiles().size() > historyExceptionsToKeep) { - for (int i = historyExceptionsToKeep; i < b.getLoadFiles().size(); i++) { - Log.debug("File Clean Up: " + b.getLoadFiles().get(i).getDateLastLoaded()); - for (BulkLoadFileHistory h : b.getLoadFiles().get(i).getHistory()) { - for (BulkLoadFileException e : h.getExceptions()) { - bulkLoadFileExceptionDAO.remove(e.getId()); - ph.progressProcess(); - } - } - } - } - } - } - } - ph.finishProcess(); + bulkLoadFileExceptionDAO.cleanUpTwoWeekOldExceptions(); } @Scheduled(cron = "0 0 0 ? * SUN") diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/events/PendingBulkLoadFileJobEvent.java b/src/main/java/org/alliancegenome/curation_api/jobs/events/PendingLoadJobEvent.java similarity index 78% rename from src/main/java/org/alliancegenome/curation_api/jobs/events/PendingBulkLoadFileJobEvent.java rename to src/main/java/org/alliancegenome/curation_api/jobs/events/PendingLoadJobEvent.java index e4765286f..9e789d4f8 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/events/PendingBulkLoadFileJobEvent.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/events/PendingLoadJobEvent.java @@ -4,6 +4,6 @@ import lombok.Data; @Data @AllArgsConstructor -public class PendingBulkLoadFileJobEvent { +public class PendingLoadJobEvent { private Long id; } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/events/StartedBulkLoadFileJobEvent.java b/src/main/java/org/alliancegenome/curation_api/jobs/events/StartedLoadJobEvent.java similarity index 78% rename from src/main/java/org/alliancegenome/curation_api/jobs/events/StartedBulkLoadFileJobEvent.java rename to src/main/java/org/alliancegenome/curation_api/jobs/events/StartedLoadJobEvent.java index 97ecbde78..ecd5f5abf 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/events/StartedBulkLoadFileJobEvent.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/events/StartedLoadJobEvent.java @@ -4,6 +4,6 @@ import lombok.Data; @Data @AllArgsConstructor -public class StartedBulkLoadFileJobEvent { +public class StartedLoadJobEvent { private Long id; } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmDiseaseAnnotationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmDiseaseAnnotationExecutor.java index 26a9dfaff..3e3cf0656 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmDiseaseAnnotationExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmDiseaseAnnotationExecutor.java @@ -6,7 +6,6 @@ import org.alliancegenome.curation_api.dao.AGMDiseaseAnnotationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkManualLoad; import org.alliancegenome.curation_api.model.ingest.dto.AGMDiseaseAnnotationDTO; @@ -26,13 +25,13 @@ public class AgmDiseaseAnnotationExecutor extends LoadFileExecutor { @Inject DiseaseAnnotationService diseaseAnnotationService; @Inject AGMDiseaseAnnotationService agmDiseaseAnnotationService; - public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory, Boolean cleanUp) { - BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + BulkManualLoad manual = (BulkManualLoad) bulkLoadFileHistory.getBulkLoad(); BackendBulkDataProvider dataProvider = manual.getDataProvider(); log.info("Running with dataProvider: " + dataProvider.name()); - IngestDTO ingestDto = readIngestFile(bulkLoadFile, AGMDiseaseAnnotationDTO.class); + IngestDTO ingestDto = readIngestFile(bulkLoadFileHistory, AGMDiseaseAnnotationDTO.class); if (ingestDto == null) { return; } @@ -49,17 +48,19 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { annotationIdsBefore.removeIf(Objects::isNull); } - bulkLoadFile.setRecordCount(annotations.size() + bulkLoadFile.getRecordCount()); - bulkLoadFileDAO.merge(bulkLoadFile); + bulkLoadFileHistory.getBulkLoadFile().setRecordCount(annotations.size() + bulkLoadFileHistory.getBulkLoadFile().getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); - BulkLoadFileHistory history = new BulkLoadFileHistory(annotations.size()); - createHistory(history, bulkLoadFile); - boolean success = runLoad(agmDiseaseAnnotationService, history, dataProvider, annotations, annotationIdsLoaded); + bulkLoadFileHistory.setCount(annotations.size()); + updateHistory(bulkLoadFileHistory); + + boolean success = runLoad(agmDiseaseAnnotationService, bulkLoadFileHistory, dataProvider, annotations, annotationIdsLoaded); if (success && cleanUp) { - runCleanup(diseaseAnnotationService, history, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, "AGM disease annotation", bulkLoadFile.getMd5Sum()); + runCleanup(diseaseAnnotationService, bulkLoadFileHistory, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, "AGM disease annotation"); } - history.finishLoad(); - finalSaveHistory(history); + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); } } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmExecutor.java index a46ef21e6..85abf0bf1 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AgmExecutor.java @@ -5,7 +5,6 @@ import org.alliancegenome.curation_api.dao.AffectedGenomicModelDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkManualLoad; import org.alliancegenome.curation_api.model.ingest.dto.AffectedGenomicModelDTO; @@ -26,12 +25,12 @@ public class AgmExecutor extends LoadFileExecutor { @Inject NcbiTaxonTermService ncbiTaxonTermService; - public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory, Boolean cleanUp) { - BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + BulkManualLoad manual = (BulkManualLoad) bulkLoadFileHistory.getBulkLoad(); Log.info("Running with: " + manual.getDataProvider().name()); - IngestDTO ingestDto = readIngestFile(bulkLoadFile, AffectedGenomicModelDTO.class); + IngestDTO ingestDto = readIngestFile(bulkLoadFileHistory, AffectedGenomicModelDTO.class); if (ingestDto == null) { return; } @@ -50,17 +49,19 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { Log.debug("runLoad: Before: total " + agmIdsBefore.size()); } - bulkLoadFile.setRecordCount(agms.size() + bulkLoadFile.getRecordCount()); - bulkLoadFileDAO.merge(bulkLoadFile); + bulkLoadFileHistory.getBulkLoadFile().setRecordCount(agms.size() + bulkLoadFileHistory.getBulkLoadFile().getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); - BulkLoadFileHistory history = new BulkLoadFileHistory(agms.size()); - createHistory(history, bulkLoadFile); - boolean success = runLoad(affectedGenomicModelService, history, dataProvider, agms, agmIdsLoaded); + bulkLoadFileHistory.setCount(agms.size()); + updateHistory(bulkLoadFileHistory); + + boolean success = runLoad(affectedGenomicModelService, bulkLoadFileHistory, dataProvider, agms, agmIdsLoaded); if (success && cleanUp) { - runCleanup(affectedGenomicModelService, history, dataProvider.name(), agmIdsBefore, agmIdsLoaded, "AGM", bulkLoadFile.getMd5Sum()); + runCleanup(affectedGenomicModelService, bulkLoadFileHistory, dataProvider.name(), agmIdsBefore, agmIdsLoaded, "AGM"); } - history.finishLoad(); - finalSaveHistory(history); + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleDiseaseAnnotationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleDiseaseAnnotationExecutor.java index 22b3134d4..324f1e17e 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleDiseaseAnnotationExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleDiseaseAnnotationExecutor.java @@ -6,7 +6,6 @@ import org.alliancegenome.curation_api.dao.AlleleDiseaseAnnotationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkManualLoad; import org.alliancegenome.curation_api.model.ingest.dto.AlleleDiseaseAnnotationDTO; @@ -26,13 +25,13 @@ public class AlleleDiseaseAnnotationExecutor extends LoadFileExecutor { @Inject AlleleDiseaseAnnotationService alleleDiseaseAnnotationService; @Inject DiseaseAnnotationService diseaseAnnotationService; - public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory, Boolean cleanUp) { - BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + BulkManualLoad manual = (BulkManualLoad) bulkLoadFileHistory.getBulkLoad(); BackendBulkDataProvider dataProvider = manual.getDataProvider(); log.info("Running with dataProvider: " + dataProvider.name()); - IngestDTO ingestDto = readIngestFile(bulkLoadFile, AlleleDiseaseAnnotationDTO.class); + IngestDTO ingestDto = readIngestFile(bulkLoadFileHistory, AlleleDiseaseAnnotationDTO.class); if (ingestDto == null) { return; } @@ -49,17 +48,20 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { annotationIdsBefore.removeIf(Objects::isNull); } - bulkLoadFile.setRecordCount(annotations.size() + bulkLoadFile.getRecordCount()); - bulkLoadFileDAO.merge(bulkLoadFile); + bulkLoadFileHistory.getBulkLoadFile().setRecordCount(annotations.size() + bulkLoadFileHistory.getBulkLoadFile().getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); - BulkLoadFileHistory history = new BulkLoadFileHistory(annotations.size()); - createHistory(history, bulkLoadFile); - boolean success = runLoad(alleleDiseaseAnnotationService, history, dataProvider, annotations, annotationIdsLoaded); + bulkLoadFileHistory.setCount(annotations.size()); + + updateHistory(bulkLoadFileHistory); + + boolean success = runLoad(alleleDiseaseAnnotationService, bulkLoadFileHistory, dataProvider, annotations, annotationIdsLoaded); if (success && cleanUp) { - runCleanup(diseaseAnnotationService, history, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, "allele disease annotation", bulkLoadFile.getMd5Sum()); + runCleanup(diseaseAnnotationService, bulkLoadFileHistory, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, "allele disease annotation"); } - history.finishLoad(); - finalSaveHistory(history); + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); } } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleExecutor.java index 7b1293226..7de8a612d 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/AlleleExecutor.java @@ -5,7 +5,6 @@ import org.alliancegenome.curation_api.dao.AlleleDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkManualLoad; import org.alliancegenome.curation_api.model.ingest.dto.AlleleDTO; @@ -22,12 +21,12 @@ public class AlleleExecutor extends LoadFileExecutor { @Inject AlleleDAO alleleDAO; @Inject AlleleService alleleService; - public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory, Boolean cleanUp) { - BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + BulkManualLoad manual = (BulkManualLoad) bulkLoadFileHistory.getBulkLoad(); Log.info("Running with: " + manual.getDataProvider().name()); - IngestDTO ingestDto = readIngestFile(bulkLoadFile, AlleleDTO.class); + IngestDTO ingestDto = readIngestFile(bulkLoadFileHistory, AlleleDTO.class); if (ingestDto == null) { return; } @@ -46,17 +45,19 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { Log.debug("runLoad: Before: total " + alleleIdsBefore.size()); } - bulkLoadFile.setRecordCount(alleles.size() + bulkLoadFile.getRecordCount()); - bulkLoadFileDAO.merge(bulkLoadFile); + bulkLoadFileHistory.getBulkLoadFile().setRecordCount(alleles.size() + bulkLoadFileHistory.getBulkLoadFile().getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); - BulkLoadFileHistory history = new BulkLoadFileHistory(alleles.size()); - createHistory(history, bulkLoadFile); - boolean success = runLoad(alleleService, history, dataProvider, alleles, alleleIdsLoaded); + bulkLoadFileHistory.setCount(alleles.size()); + updateHistory(bulkLoadFileHistory); + + boolean success = runLoad(alleleService, bulkLoadFileHistory, dataProvider, alleles, alleleIdsLoaded); if (success && cleanUp) { - runCleanup(alleleService, history, dataProvider.name(), alleleIdsBefore, alleleIdsLoaded, "allele", bulkLoadFile.getMd5Sum()); + runCleanup(alleleService, bulkLoadFileHistory, dataProvider.name(), alleleIdsBefore, alleleIdsLoaded, "allele"); } - history.finishLoad(); - finalSaveHistory(history); + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); } } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/BiogridOrcExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/BiogridOrcExecutor.java new file mode 100644 index 000000000..b90f3f015 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/BiogridOrcExecutor.java @@ -0,0 +1,99 @@ +package org.alliancegenome.curation_api.jobs.executors; + +import java.io.FileInputStream; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.zip.GZIPInputStream; + +import org.alliancegenome.curation_api.exceptions.ObjectUpdateException.ObjectUpdateExceptionData; +import org.alliancegenome.curation_api.jobs.util.CsvSchemaBuilder; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; +import org.alliancegenome.curation_api.model.ingest.dto.fms.BiogridOrcFmsDTO; +import org.alliancegenome.curation_api.util.ProcessDisplayHelper; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.compress.archivers.tar.TarArchiveEntry; +import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; + +import com.fasterxml.jackson.databind.MappingIterator; +import com.fasterxml.jackson.dataformat.csv.CsvMapper; +import com.fasterxml.jackson.dataformat.csv.CsvParser; +import com.fasterxml.jackson.dataformat.csv.CsvSchema; + +import jakarta.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class BiogridOrcExecutor extends LoadFileExecutor { + + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory) { + try (TarArchiveInputStream tarInputStream = new TarArchiveInputStream( + new GZIPInputStream(new FileInputStream(bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath())))) { + TarArchiveEntry tarEntry; + + Set biogridIds = new HashSet<>(); + + while ((tarEntry = tarInputStream.getNextEntry()) != null) { + + CsvMapper csvMapper = new CsvMapper(); + CsvSchema biogridOrcFmsSchema = CsvSchemaBuilder.biogridOrcFmsSchema(); + String regexPattern = "BIOGRID-ORCS-SCREEN_(\\d+)-1.1.16.screen.tab.txt"; + Pattern pattern = Pattern.compile(regexPattern); + + Matcher matcher = pattern.matcher(tarEntry.getName()); + + if (tarEntry.isDirectory() || !matcher.matches()) { + continue; + } + + MappingIterator it = csvMapper + .enable(CsvParser.Feature.INSERT_NULLS_FOR_MISSING_COLUMNS) + .readerFor(BiogridOrcFmsDTO.class) + .with(biogridOrcFmsSchema) + .readValues(tarInputStream.readAllBytes()); + + List biogridData = it.readAll(); + runLoad(bulkLoadFileHistory, biogridData, biogridIds); + + } + } catch (Exception e) { + failLoad(bulkLoadFileHistory, e); + e.printStackTrace(); + } + } + + private boolean runLoad(BulkLoadFileHistory history, List biogridList, Set biogridIds) { + ProcessDisplayHelper ph = new ProcessDisplayHelper(); + ph.addDisplayHandler(loadProcessDisplayService); + if (CollectionUtils.isNotEmpty(biogridList)) { + String loadMessage = biogridList.get(0).getClass().getSimpleName() + " update"; + ph.startProcess(loadMessage, biogridList.size()); + + updateHistory(history); + for (BiogridOrcFmsDTO biogridOrcFmsDTO : biogridList) { + try { + if (biogridOrcFmsDTO.getIdentifierType().equals("ENTREZ_GENE")) { + String identifier = "NCBI_Gene:" + biogridOrcFmsDTO.getIdentifierId(); + biogridIds.add(identifier); + history.incrementCompleted(); + } else { + history.incrementSkipped(); + + } + } catch (Exception e) { + e.printStackTrace(); + history.incrementFailed(); + addException(history, + new ObjectUpdateExceptionData(biogridOrcFmsDTO, e.getMessage(), e.getStackTrace())); + } + ph.progressProcess(); + } + updateHistory(history); + updateExceptions(history); + ph.finishProcess(); + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/BulkLoadJobExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/BulkLoadJobExecutor.java index 2c1728e20..9fe7ab0b3 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/BulkLoadJobExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/BulkLoadJobExecutor.java @@ -19,7 +19,10 @@ import org.alliancegenome.curation_api.enums.BackendBulkLoadType; import org.alliancegenome.curation_api.jobs.executors.associations.alleleAssociations.AlleleGeneAssociationExecutor; import org.alliancegenome.curation_api.jobs.executors.associations.constructAssociations.ConstructGenomicEntityAssociationExecutor; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; +import org.alliancegenome.curation_api.jobs.executors.gff.Gff3CDSExecutor; +import org.alliancegenome.curation_api.jobs.executors.gff.Gff3ExonExecutor; +import org.alliancegenome.curation_api.jobs.executors.gff.Gff3TranscriptExecutor; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; @@ -51,76 +54,94 @@ public class BulkLoadJobExecutor { @Inject ParalogyExecutor paralogyExecutor; @Inject GeneExpressionExecutor geneExpressionExecutor; @Inject SequenceTargetingReagentExecutor sqtrExecutor; - @Inject Gff3Executor gff3Executor; + @Inject VariantFmsExecutor variantFmsExecutor; + @Inject Gff3ExonExecutor gff3ExonExecutor; + @Inject Gff3CDSExecutor gff3CDSExecutor; + @Inject Gff3TranscriptExecutor gff3TranscriptExecutor; + + @Inject HTPExpressionDatasetAnnotationExecutor htpExpressionDatasetAnnotationExecutor; + @Inject ExpressionAtlasExecutor expressionAtlasExecutor; - public void process(BulkLoadFile bulkLoadFile, Boolean cleanUp) throws Exception { + @Inject BiogridOrcExecutor biogridOrcExecutor; - BackendBulkLoadType loadType = bulkLoadFile.getBulkLoad().getBackendBulkLoadType(); + public void process(BulkLoadFileHistory bulkLoadFileHistory, Boolean cleanUp) throws Exception { + + BackendBulkLoadType loadType = bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType(); List ingestTypes = List.of(AGM_DISEASE_ANNOTATION, ALLELE_DISEASE_ANNOTATION, GENE_DISEASE_ANNOTATION, DISEASE_ANNOTATION, AGM, ALLELE, GENE, VARIANT, CONSTRUCT, FULL_INGEST, ALLELE_ASSOCIATION, CONSTRUCT_ASSOCIATION); if (ingestTypes.contains(loadType)) { - bulkLoadFile.setRecordCount(0); - bulkLoadFileDAO.merge(bulkLoadFile); - if (loadType == AGM || loadType == FULL_INGEST) { - agmExecutor.execLoad(bulkLoadFile, cleanUp); + agmExecutor.execLoad(bulkLoadFileHistory, cleanUp); } if (loadType == ALLELE || loadType == FULL_INGEST) { - alleleExecutor.execLoad(bulkLoadFile, cleanUp); + alleleExecutor.execLoad(bulkLoadFileHistory, cleanUp); } if (loadType == GENE || loadType == FULL_INGEST) { - geneExecutor.execLoad(bulkLoadFile, cleanUp); + geneExecutor.execLoad(bulkLoadFileHistory, cleanUp); } if (loadType == CONSTRUCT || loadType == FULL_INGEST) { - constructExecutor.execLoad(bulkLoadFile, cleanUp); + constructExecutor.execLoad(bulkLoadFileHistory, cleanUp); } if (loadType == VARIANT || loadType == FULL_INGEST) { - variantExecutor.execLoad(bulkLoadFile, cleanUp); + // TODO: re-enable once accepting direct submissions of variants by DQMs again and FMS load turned off + // variantExecutor.execLoad(bulkLoadFileHistory, cleanUp); } if (loadType == ALLELE_DISEASE_ANNOTATION || loadType == DISEASE_ANNOTATION || loadType == FULL_INGEST) { - alleleDiseaseAnnotationExecutor.execLoad(bulkLoadFile, cleanUp); + alleleDiseaseAnnotationExecutor.execLoad(bulkLoadFileHistory, cleanUp); } if (loadType == AGM_DISEASE_ANNOTATION || loadType == DISEASE_ANNOTATION || loadType == FULL_INGEST) { - agmDiseaseAnnotationExecutor.execLoad(bulkLoadFile, cleanUp); + agmDiseaseAnnotationExecutor.execLoad(bulkLoadFileHistory, cleanUp); } if (loadType == GENE_DISEASE_ANNOTATION || loadType == DISEASE_ANNOTATION || loadType == FULL_INGEST) { - geneDiseaseAnnotationExecutor.execLoad(bulkLoadFile, cleanUp); + geneDiseaseAnnotationExecutor.execLoad(bulkLoadFileHistory, cleanUp); } if (loadType == ALLELE_ASSOCIATION || loadType == FULL_INGEST) { - alleleGeneAssociationExecutor.execLoad(bulkLoadFile, cleanUp); + alleleGeneAssociationExecutor.execLoad(bulkLoadFileHistory, cleanUp); } if (loadType == CONSTRUCT_ASSOCIATION || loadType == FULL_INGEST) { - constructGenomicEntityAssociationExecutor.execLoad(bulkLoadFile, cleanUp); + constructGenomicEntityAssociationExecutor.execLoad(bulkLoadFileHistory, cleanUp); } - } else if (bulkLoadFile.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.MOLECULE) { - moleculeExecutor.execLoad(bulkLoadFile); - } else if (bulkLoadFile.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.SEQUENCE_TARGETING_REAGENT) { - sqtrExecutor.execLoad(bulkLoadFile); - } else if (bulkLoadFile.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.INTERACTION_MOL) { - geneMolecularInteractionExecutor.execLoad(bulkLoadFile); - } else if (bulkLoadFile.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.INTERACTION_GEN) { - geneGeneticInteractionExecutor.execLoad(bulkLoadFile); - } else if (bulkLoadFile.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.PHENOTYPE) { - phenotypeAnnotationExecutor.execLoad(bulkLoadFile); - } else if (bulkLoadFile.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.ORTHOLOGY) { - orthologyExecutor.execLoad(bulkLoadFile); - } else if (bulkLoadFile.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.PARALOGY) { - paralogyExecutor.execLoad(bulkLoadFile); - } else if (bulkLoadFile.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.ONTOLOGY) { - ontologyExecutor.execLoad(bulkLoadFile); - } else if (bulkLoadFile.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.RESOURCE_DESCRIPTOR) { - resourceDescriptorExecutor.execLoad(bulkLoadFile); - } else if (bulkLoadFile.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.EXPRESSION) { - geneExpressionExecutor.execLoad(bulkLoadFile); - } else if (bulkLoadFile.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.GFF) { - gff3Executor.execLoad(bulkLoadFile); + } else if (bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.MOLECULE) { + moleculeExecutor.execLoad(bulkLoadFileHistory); + } else if (bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.SEQUENCE_TARGETING_REAGENT) { + sqtrExecutor.execLoad(bulkLoadFileHistory); + } else if (bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.INTERACTION_MOL) { + geneMolecularInteractionExecutor.execLoad(bulkLoadFileHistory); + } else if (bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.INTERACTION_GEN) { + geneGeneticInteractionExecutor.execLoad(bulkLoadFileHistory); + } else if (bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.PHENOTYPE) { + phenotypeAnnotationExecutor.execLoad(bulkLoadFileHistory); + } else if (bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.ORTHOLOGY) { + orthologyExecutor.execLoad(bulkLoadFileHistory); + } else if (bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.PARALOGY) { + paralogyExecutor.execLoad(bulkLoadFileHistory); + } else if (bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.ONTOLOGY) { + ontologyExecutor.execLoad(bulkLoadFileHistory); + } else if (bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.RESOURCE_DESCRIPTOR) { + resourceDescriptorExecutor.execLoad(bulkLoadFileHistory); + } else if (bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.EXPRESSION) { + geneExpressionExecutor.execLoad(bulkLoadFileHistory); + } else if (bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.VARIATION) { + variantFmsExecutor.execLoad(bulkLoadFileHistory); + } else if (bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.GFF_EXON) { + gff3ExonExecutor.execLoad(bulkLoadFileHistory); + } else if (bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.GFF_CDS) { + gff3CDSExecutor.execLoad(bulkLoadFileHistory); + } else if (bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.GFF_TRANSCRIPT) { + gff3TranscriptExecutor.execLoad(bulkLoadFileHistory); + } else if (bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.HTPDATASET) { + htpExpressionDatasetAnnotationExecutor.execLoad(bulkLoadFileHistory); + } else if (bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.EXPRESSION_ATLAS) { + expressionAtlasExecutor.execLoad(bulkLoadFileHistory); + } else if (bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.BIOGRID_ORCS) { + biogridOrcExecutor.execLoad(bulkLoadFileHistory); } else { - log.info("Load: " + bulkLoadFile.getBulkLoad().getName() + " not implemented"); - throw new Exception("Load: " + bulkLoadFile.getBulkLoad().getName() + " not implemented"); + log.info("Load: " + bulkLoadFileHistory.getBulkLoad().getName() + " for type " + bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() + " not implemented"); + throw new Exception("Load: " + bulkLoadFileHistory.getBulkLoad().getName() + " for type " + bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() + " not implemented"); } - log.info("Process Finished for: " + bulkLoadFile.getBulkLoad().getName()); + log.info("Process Finished for: " + bulkLoadFileHistory.getBulkLoad().getName()); } } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/ConstructExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/ConstructExecutor.java index 22096d26d..6241e6477 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/ConstructExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/ConstructExecutor.java @@ -5,7 +5,6 @@ import org.alliancegenome.curation_api.dao.ConstructDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkManualLoad; import org.alliancegenome.curation_api.model.ingest.dto.ConstructDTO; @@ -26,12 +25,12 @@ public class ConstructExecutor extends LoadFileExecutor { @Inject NcbiTaxonTermService ncbiTaxonTermService; - public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory, Boolean cleanUp) { - BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + BulkManualLoad manual = (BulkManualLoad) bulkLoadFileHistory.getBulkLoad(); Log.info("Running with: " + manual.getDataProvider().name()); - IngestDTO ingestDto = readIngestFile(bulkLoadFile, ConstructDTO.class); + IngestDTO ingestDto = readIngestFile(bulkLoadFileHistory, ConstructDTO.class); if (ingestDto == null) { return; } @@ -50,17 +49,20 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { Log.debug("runLoad: Before: total " + constructIdsBefore.size()); } - bulkLoadFile.setRecordCount(constructs.size() + bulkLoadFile.getRecordCount()); - bulkLoadFileDAO.merge(bulkLoadFile); + bulkLoadFileHistory.getBulkLoadFile().setRecordCount(constructs.size() + bulkLoadFileHistory.getBulkLoadFile().getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); - BulkLoadFileHistory history = new BulkLoadFileHistory(constructs.size()); - createHistory(history, bulkLoadFile); - boolean success = runLoad(constructService, history, dataProvider, constructs, constructIdsLoaded); + bulkLoadFileHistory.setCount("Deleted", constructs.size()); + + updateHistory(bulkLoadFileHistory); + + boolean success = runLoad(constructService, bulkLoadFileHistory, dataProvider, constructs, constructIdsLoaded); if (success && cleanUp) { - runCleanup(constructService, history, dataProvider.name(), constructIdsBefore, constructIdsLoaded, "construct", bulkLoadFile.getMd5Sum()); + runCleanup(constructService, bulkLoadFileHistory, dataProvider.name(), constructIdsBefore, constructIdsLoaded, "construct"); } - history.finishLoad(); - finalSaveHistory(history); + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); } } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/ExpressionAtlasExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/ExpressionAtlasExecutor.java new file mode 100644 index 000000000..b8bbb4e25 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/ExpressionAtlasExecutor.java @@ -0,0 +1,116 @@ +package org.alliancegenome.curation_api.jobs.executors; + +import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import lombok.extern.jbosslog.JBossLog; +import org.alliancegenome.curation_api.model.entities.CrossReference; +import org.alliancegenome.curation_api.model.entities.DataProvider; +import org.alliancegenome.curation_api.model.entities.Organization; +import org.alliancegenome.curation_api.model.entities.ResourceDescriptorPage; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkURLLoad; +import org.alliancegenome.curation_api.services.DataProviderService; +import org.alliancegenome.curation_api.services.OrganizationService; +import org.alliancegenome.curation_api.services.ResourceDescriptorPageService; +import org.alliancegenome.curation_api.util.ProcessDisplayHelper; +import org.jetbrains.annotations.NotNull; + +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import static org.alliancegenome.curation_api.services.DataProviderService.RESOURCE_DESCRIPTOR_PREFIX; + +@JBossLog +@ApplicationScoped +public class ExpressionAtlasExecutor extends LoadFileExecutor { + + @Inject + DataProviderService service; + @Inject + ResourceDescriptorPageService resourceDescriptorPageService; + @Inject + OrganizationService organizationService; + + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory) throws IOException { + + String url = ((BulkURLLoad) bulkLoadFileHistory.getBulkLoad()).getBulkloadUrl(); + + XmlMapper mapper = new XmlMapper(); + URL src = new URL(url); + Urlset urlset = mapper.readValue(src, Urlset.class); + List accessionUrlList = urlset.url.stream().map(UrlElement::getLoc).toList(); + List accessions = accessionUrlList.stream() + .map(sUrl -> sUrl.substring(sUrl.lastIndexOf("/") + 1)) + .toList(); + + String name = bulkLoadFileHistory.getBulkLoad().getName(); + String dataProviderName = name.substring(0, name.indexOf(" ")); + + Organization organization = organizationService.getByAbbr(dataProviderName).getEntity(); + ResourceDescriptorPage ensemblGenePage = resourceDescriptorPageService.getPageForResourceDescriptor("ENSEMBL", "expression_atlas"); + + List dataProviderIdsBefore = + new ArrayList<>(service.getDataProviderMap(organization, ensemblGenePage).values().stream().map(DataProvider::getId).toList()); + dataProviderIdsBefore.removeIf(Objects::isNull); + + List dataProviderIdsLoaded = new ArrayList<>(); + ProcessDisplayHelper ph = new ProcessDisplayHelper(); + ph.addDisplayHandler(loadProcessDisplayService); + ph.startProcess(name, accessions.size()); + accessions.forEach(accession -> { + CrossReference reference = getCrossReference(ensemblGenePage, accession, organization); + DataProvider provider = new DataProvider(); + provider.setSourceOrganization(organization); + provider.setCrossReference(reference); + DataProvider entity = service.insertExpressionAtlasDataProvider(provider).getEntity(); + if (entity != null) { + dataProviderIdsLoaded.add(entity.getId()); + bulkLoadFileHistory.incrementCompleted(); + } else { + bulkLoadFileHistory.incrementSkipped(); + } + ph.progressProcess(); + }); + bulkLoadFileHistory.setTotalCount(accessions.size()); + runCleanup(service, bulkLoadFileHistory, dataProviderName, dataProviderIdsBefore, dataProviderIdsLoaded, "Atlas Load Type"); + ph.finishProcess(); + updateHistory(bulkLoadFileHistory); + + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); + } + + @NotNull + private static CrossReference getCrossReference(ResourceDescriptorPage ensemblGenePage, String accession, Organization organization) { + CrossReference reference = new CrossReference(); + if (List.of("FB", "SGD").contains(organization.getAbbreviation())) { + reference.setReferencedCurie(accession); + } else { + reference.setReferencedCurie(RESOURCE_DESCRIPTOR_PREFIX + ":" + accession); + } + reference.setDisplayName(accession); + reference.setResourceDescriptorPage(ensemblGenePage); + return reference; + } + +} + +class Urlset { + @JacksonXmlElementWrapper(useWrapping = false) + public List url = new ArrayList<>(); +} + +class UrlElement { + public String loc; + public String changefreq; + + public String getLoc() { + return loc; + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneDiseaseAnnotationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneDiseaseAnnotationExecutor.java index aeb8367d0..07a68d88e 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneDiseaseAnnotationExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneDiseaseAnnotationExecutor.java @@ -6,7 +6,6 @@ import org.alliancegenome.curation_api.dao.GeneDiseaseAnnotationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkManualLoad; import org.alliancegenome.curation_api.model.ingest.dto.GeneDiseaseAnnotationDTO; @@ -26,13 +25,13 @@ public class GeneDiseaseAnnotationExecutor extends LoadFileExecutor { @Inject GeneDiseaseAnnotationService geneDiseaseAnnotationService; @Inject DiseaseAnnotationService diseaseAnnotationService; - public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory, Boolean cleanUp) { - BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + BulkManualLoad manual = (BulkManualLoad) bulkLoadFileHistory.getBulkLoad(); BackendBulkDataProvider dataProvider = manual.getDataProvider(); log.info("Running with dataProvider: " + dataProvider.name()); - IngestDTO ingestDto = readIngestFile(bulkLoadFile, GeneDiseaseAnnotationDTO.class); + IngestDTO ingestDto = readIngestFile(bulkLoadFileHistory, GeneDiseaseAnnotationDTO.class); if (ingestDto == null) { return; } @@ -49,17 +48,19 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { annotationIdsBefore.removeIf(Objects::isNull); } - bulkLoadFile.setRecordCount(annotations.size() + bulkLoadFile.getRecordCount()); - bulkLoadFileDAO.merge(bulkLoadFile); + bulkLoadFileHistory.getBulkLoadFile().setRecordCount(annotations.size() + bulkLoadFileHistory.getBulkLoadFile().getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); - BulkLoadFileHistory history = new BulkLoadFileHistory(annotations.size()); - createHistory(history, bulkLoadFile); - boolean success = runLoad(geneDiseaseAnnotationService, history, dataProvider, annotations, annotationIdsLoaded); + bulkLoadFileHistory.setCount(annotations.size()); + updateHistory(bulkLoadFileHistory); + + boolean success = runLoad(geneDiseaseAnnotationService, bulkLoadFileHistory, dataProvider, annotations, annotationIdsLoaded); if (success && cleanUp) { - runCleanup(diseaseAnnotationService, history, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, "gene disease annotation", bulkLoadFile.getMd5Sum()); + runCleanup(diseaseAnnotationService, bulkLoadFileHistory, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, "gene disease annotation"); } - history.finishLoad(); - finalSaveHistory(history); + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneExecutor.java index a7b0cec73..b8b59e9e7 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneExecutor.java @@ -5,7 +5,6 @@ import org.alliancegenome.curation_api.dao.GeneDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkManualLoad; import org.alliancegenome.curation_api.model.ingest.dto.GeneDTO; @@ -27,13 +26,13 @@ public class GeneExecutor extends LoadFileExecutor { @Inject NcbiTaxonTermService ncbiTaxonTermService; - public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory, Boolean cleanUp) { - BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + BulkManualLoad manual = (BulkManualLoad) bulkLoadFileHistory.getBulkLoad(); BackendBulkDataProvider dataProvider = manual.getDataProvider(); log.info("Running with dataProvider : " + dataProvider.name()); - IngestDTO ingestDto = readIngestFile(bulkLoadFile, GeneDTO.class); + IngestDTO ingestDto = readIngestFile(bulkLoadFileHistory, GeneDTO.class); if (ingestDto == null) { return; } @@ -50,17 +49,19 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { log.debug("runLoad: Before: total " + geneIdsBefore.size()); } - bulkLoadFile.setRecordCount(genes.size() + bulkLoadFile.getRecordCount()); - bulkLoadFileDAO.merge(bulkLoadFile); + bulkLoadFileHistory.getBulkLoadFile().setRecordCount(genes.size() + bulkLoadFileHistory.getBulkLoadFile().getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); - BulkLoadFileHistory history = new BulkLoadFileHistory(genes.size()); - createHistory(history, bulkLoadFile); - boolean success = runLoad(geneService, history, dataProvider, genes, geneIdsLoaded); + bulkLoadFileHistory.setCount(genes.size()); + updateHistory(bulkLoadFileHistory); + + boolean success = runLoad(geneService, bulkLoadFileHistory, dataProvider, genes, geneIdsLoaded); if (success && cleanUp) { - runCleanup(geneService, history, dataProvider.name(), geneIdsBefore, geneIdsLoaded, "gene", bulkLoadFile.getMd5Sum()); + runCleanup(geneService, bulkLoadFileHistory, dataProvider.name(), geneIdsBefore, geneIdsLoaded, "gene"); } - history.finishLoad(); - finalSaveHistory(history); + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneExpressionExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneExpressionExecutor.java index 8f9d81f88..a3898eca6 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneExpressionExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneExpressionExecutor.java @@ -1,55 +1,58 @@ package org.alliancegenome.curation_api.jobs.executors; -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.inject.Inject; +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.zip.GZIPInputStream; + import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.model.entities.GeneExpressionAnnotation; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkFMSLoad; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.ingest.dto.fms.GeneExpressionIngestFmsDTO; import org.alliancegenome.curation_api.services.GeneExpressionAnnotationService; import org.apache.commons.lang3.StringUtils; -import java.io.FileInputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.zip.GZIPInputStream; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; @ApplicationScoped public class GeneExpressionExecutor extends LoadFileExecutor { @Inject GeneExpressionAnnotationService geneExpressionAnnotationService; - public void execLoad(BulkLoadFile bulkLoadFile) { + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory) { try { - BulkFMSLoad fms = (BulkFMSLoad) bulkLoadFile.getBulkLoad(); + BulkFMSLoad fms = (BulkFMSLoad) bulkLoadFileHistory.getBulkLoad(); BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(fms.getFmsDataSubType()); - GeneExpressionIngestFmsDTO geneExpressionIngestFmsDTO = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), GeneExpressionIngestFmsDTO.class); - bulkLoadFile.setRecordCount(geneExpressionIngestFmsDTO.getData().size()); + GeneExpressionIngestFmsDTO geneExpressionIngestFmsDTO = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath())), GeneExpressionIngestFmsDTO.class); + bulkLoadFileHistory.getBulkLoadFile().setRecordCount(geneExpressionIngestFmsDTO.getData().size()); AGRCurationSchemaVersion version = GeneExpressionAnnotation.class.getAnnotation(AGRCurationSchemaVersion.class); - bulkLoadFile.setLinkMLSchemaVersion(version.max()); + bulkLoadFileHistory.getBulkLoadFile().setLinkMLSchemaVersion(version.max()); if (geneExpressionIngestFmsDTO.getMetaData() != null && StringUtils.isNotBlank(geneExpressionIngestFmsDTO.getMetaData().getRelease())) { - bulkLoadFile.setAllianceMemberReleaseVersion(geneExpressionIngestFmsDTO.getMetaData().getRelease()); + bulkLoadFileHistory.getBulkLoadFile().setAllianceMemberReleaseVersion(geneExpressionIngestFmsDTO.getMetaData().getRelease()); } + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); - BulkLoadFileHistory history = new BulkLoadFileHistory(geneExpressionIngestFmsDTO.getData().size()); - createHistory(history, bulkLoadFile); + bulkLoadFileHistory.setCount(geneExpressionIngestFmsDTO.getData().size()); + updateHistory(bulkLoadFileHistory); + List annotationIdsLoaded = new ArrayList<>(); List annotationIdsBefore = geneExpressionAnnotationService.getAnnotationIdsByDataProvider(dataProvider); - boolean success = runLoad(geneExpressionAnnotationService, history, dataProvider, geneExpressionIngestFmsDTO.getData(), annotationIdsLoaded); + boolean success = runLoad(geneExpressionAnnotationService, bulkLoadFileHistory, dataProvider, geneExpressionIngestFmsDTO.getData(), annotationIdsLoaded); if (success) { - runCleanup(geneExpressionAnnotationService, history, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, "gene expression annotation", bulkLoadFile.getMd5Sum()); + runCleanup(geneExpressionAnnotationService, bulkLoadFileHistory, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded, "gene expression annotation"); } - history.finishLoad(); - finalSaveHistory(history); + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); } catch (Exception e) { - failLoad(bulkLoadFile, e); + failLoad(bulkLoadFileHistory, e); e.printStackTrace(); } } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneGeneticInteractionExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneGeneticInteractionExecutor.java index cba477bd8..74e9c0259 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneGeneticInteractionExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneGeneticInteractionExecutor.java @@ -7,7 +7,6 @@ import org.alliancegenome.curation_api.dao.GeneGeneticInteractionDAO; import org.alliancegenome.curation_api.jobs.util.CsvSchemaBuilder; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.ingest.dto.fms.PsiMiTabDTO; import org.alliancegenome.curation_api.services.GeneGeneticInteractionService; @@ -28,28 +27,30 @@ public class GeneGeneticInteractionExecutor extends LoadFileExecutor { @Inject GeneGeneticInteractionService geneGeneticInteractionService; @Inject GeneInteractionService geneInteractionService; - public void execLoad(BulkLoadFile bulkLoadFile) { + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory) { try { CsvSchema psiMiTabSchema = CsvSchemaBuilder.psiMiTabSchema(); CsvMapper csvMapper = new CsvMapper(); - MappingIterator it = csvMapper.enable(CsvParser.Feature.INSERT_NULLS_FOR_MISSING_COLUMNS).readerFor(PsiMiTabDTO.class).with(psiMiTabSchema).readValues(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath()))); + MappingIterator it = csvMapper.enable(CsvParser.Feature.INSERT_NULLS_FOR_MISSING_COLUMNS).readerFor(PsiMiTabDTO.class).with(psiMiTabSchema).readValues(new GZIPInputStream(new FileInputStream(bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath()))); List interactionData = it.readAll(); List interactionIdsLoaded = new ArrayList<>(); List interactionIdsBefore = geneGeneticInteractionDAO.findAllIds().getResults(); + bulkLoadFileHistory.setCount(interactionData.size()); + updateHistory(bulkLoadFileHistory); - BulkLoadFileHistory history = new BulkLoadFileHistory(interactionData.size()); - createHistory(history, bulkLoadFile); - boolean success = runLoad(geneGeneticInteractionService, history, null, interactionData, interactionIdsLoaded, false); + boolean success = runLoad(geneGeneticInteractionService, bulkLoadFileHistory, null, interactionData, interactionIdsLoaded, false); if (success) { - runCleanup(geneInteractionService, history, "COMBINED", interactionIdsBefore, interactionIdsLoaded, "gene genetic interaction", bulkLoadFile.getMd5Sum()); + runCleanup(geneInteractionService, bulkLoadFileHistory, "COMBINED", interactionIdsBefore, interactionIdsLoaded, "gene genetic interaction"); } - history.finishLoad(); - finalSaveHistory(history); + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); } catch (Exception e) { + failLoad(bulkLoadFileHistory, e); e.printStackTrace(); } } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneMolecularInteractionExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneMolecularInteractionExecutor.java index acfbe9953..482ee00be 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneMolecularInteractionExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/GeneMolecularInteractionExecutor.java @@ -7,7 +7,6 @@ import org.alliancegenome.curation_api.dao.GeneMolecularInteractionDAO; import org.alliancegenome.curation_api.jobs.util.CsvSchemaBuilder; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.ingest.dto.fms.PsiMiTabDTO; import org.alliancegenome.curation_api.services.GeneInteractionService; @@ -28,27 +27,30 @@ public class GeneMolecularInteractionExecutor extends LoadFileExecutor { @Inject GeneMolecularInteractionService geneMolecularInteractionService; @Inject GeneInteractionService geneInteractionService; - public void execLoad(BulkLoadFile bulkLoadFile) { + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory) { try { CsvSchema psiMiTabSchema = CsvSchemaBuilder.psiMiTabSchema(); CsvMapper csvMapper = new CsvMapper(); - MappingIterator it = csvMapper.enable(CsvParser.Feature.INSERT_NULLS_FOR_MISSING_COLUMNS).readerFor(PsiMiTabDTO.class).with(psiMiTabSchema).readValues(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath()))); + MappingIterator it = csvMapper.enable(CsvParser.Feature.INSERT_NULLS_FOR_MISSING_COLUMNS).readerFor(PsiMiTabDTO.class).with(psiMiTabSchema).readValues(new GZIPInputStream(new FileInputStream(bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath()))); List interactionData = it.readAll(); List interactionIdsLoaded = new ArrayList<>(); List interactionIdsBefore = geneMolecularInteractionDAO.findAllIds().getResults(); - BulkLoadFileHistory history = new BulkLoadFileHistory(interactionData.size()); - createHistory(history, bulkLoadFile); - boolean success = runLoad(geneMolecularInteractionService, history, null, interactionData, interactionIdsLoaded, false); + bulkLoadFileHistory.setCount(interactionData.size()); + updateHistory(bulkLoadFileHistory); + + boolean success = runLoad(geneMolecularInteractionService, bulkLoadFileHistory, null, interactionData, interactionIdsLoaded, false); if (success) { - runCleanup(geneInteractionService, history, "COMBINED", interactionIdsBefore, interactionIdsLoaded, "gene molecular interaction", bulkLoadFile.getMd5Sum()); + runCleanup(geneInteractionService, bulkLoadFileHistory, "COMBINED", interactionIdsBefore, interactionIdsLoaded, "gene molecular interaction"); } - history.finishLoad(); - finalSaveHistory(history); + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); } catch (Exception e) { + failLoad(bulkLoadFileHistory, e); e.printStackTrace(); } } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/Gff3Executor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/Gff3Executor.java deleted file mode 100644 index 794ef80ea..000000000 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/Gff3Executor.java +++ /dev/null @@ -1,205 +0,0 @@ -package org.alliancegenome.curation_api.jobs.executors; - -import java.io.FileInputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.zip.GZIPInputStream; - -import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException.ObjectUpdateExceptionData; -import org.alliancegenome.curation_api.jobs.util.CsvSchemaBuilder; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkFMSLoad; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; -import org.alliancegenome.curation_api.model.ingest.dto.fms.Gff3DTO; -import org.alliancegenome.curation_api.response.APIResponse; -import org.alliancegenome.curation_api.response.LoadHistoryResponce; -import org.alliancegenome.curation_api.services.CodingSequenceService; -import org.alliancegenome.curation_api.services.ExonService; -import org.alliancegenome.curation_api.services.Gff3Service; -import org.alliancegenome.curation_api.services.TranscriptService; -import org.alliancegenome.curation_api.services.associations.codingSequenceAssociations.CodingSequenceGenomicLocationAssociationService; -import org.alliancegenome.curation_api.services.associations.exonAssociations.ExonGenomicLocationAssociationService; -import org.alliancegenome.curation_api.services.associations.transcriptAssociations.TranscriptGenomicLocationAssociationService; -import org.alliancegenome.curation_api.util.ProcessDisplayHelper; - -import com.fasterxml.jackson.databind.MappingIterator; -import com.fasterxml.jackson.dataformat.csv.CsvMapper; -import com.fasterxml.jackson.dataformat.csv.CsvParser; -import com.fasterxml.jackson.dataformat.csv.CsvSchema; - -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.inject.Inject; - -@ApplicationScoped -public class Gff3Executor extends LoadFileExecutor { - - @Inject Gff3Service gff3Service; - @Inject ExonService exonService; - @Inject CodingSequenceService cdsService; - @Inject TranscriptService transcriptService; - @Inject ExonGenomicLocationAssociationService exonLocationService; - @Inject CodingSequenceGenomicLocationAssociationService cdsLocationService; - @Inject TranscriptGenomicLocationAssociationService transcriptLocationService; - - public void execLoad(BulkLoadFile bulkLoadFile) { - try { - - CsvSchema gff3Schema = CsvSchemaBuilder.gff3Schema(); - CsvMapper csvMapper = new CsvMapper(); - MappingIterator it = csvMapper.enable(CsvParser.Feature.INSERT_NULLS_FOR_MISSING_COLUMNS).readerFor(Gff3DTO.class).with(gff3Schema).readValues(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath()))); - List gffData = it.readAll(); - List gffHeaderData = new ArrayList<>(); - for (Gff3DTO gffLine : gffData) { - if (gffLine.getSeqId().startsWith("#")) { - gffHeaderData.add(gffLine.getSeqId()); - } else { - break; - } - } - gffData.subList(0, gffHeaderData.size()).clear(); - - - BulkFMSLoad fmsLoad = (BulkFMSLoad) bulkLoadFile.getBulkLoad(); - BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(fmsLoad.getFmsDataSubType()); - - Map> idsAdded = new HashMap>(); - idsAdded.put("Transcript", new ArrayList()); - idsAdded.put("Exon", new ArrayList()); - idsAdded.put("CodingSequence", new ArrayList()); - idsAdded.put("TranscriptGenomicLocationAssociation", new ArrayList()); - idsAdded.put("ExonGenomicLocationAssociation", new ArrayList()); - idsAdded.put("CodingSequenceGenomicLocationAssociation", new ArrayList()); - - Map> previousIds = getPreviouslyLoadedIds(dataProvider); - - BulkLoadFileHistory history = new BulkLoadFileHistory((gffData.size() * 2) + 1); - createHistory(history, bulkLoadFile); - idsAdded = runLoad(history, gffHeaderData, gffData, idsAdded, dataProvider); - runCleanup(transcriptService, history, dataProvider.name(), previousIds.get("Transcript"), idsAdded.get("Transcript"), "GFF transcript", bulkLoadFile.getMd5Sum()); - runCleanup(exonService, history, dataProvider.name(), previousIds.get("Exon"), idsAdded.get("Exon"), "GFF exon", bulkLoadFile.getMd5Sum()); - runCleanup(cdsService, history, dataProvider.name(), previousIds.get("CodingSequence"), idsAdded.get("CodingSequence"), "GFF coding sequence", bulkLoadFile.getMd5Sum()); - runCleanup(transcriptLocationService, history, dataProvider.name(), previousIds.get("TranscriptGenomicLocationAssociation"), idsAdded.get("TranscriptGenomicLocationAssociation"), "GFF transcript genomic location association", bulkLoadFile.getMd5Sum()); - runCleanup(exonLocationService, history, dataProvider.name(), previousIds.get("ExonGenomicLocationAssociation"), idsAdded.get("ExonGenomicLocationAssociation"), "GFF exon genomic location association", bulkLoadFile.getMd5Sum()); - runCleanup(cdsLocationService, history, dataProvider.name(), previousIds.get("CodingSequenceGenomicLocationAssociation"), idsAdded.get("CodingSequenceGenomicLocationAssociation"), "GFF coding sequence genomic location association", bulkLoadFile.getMd5Sum()); - - history.finishLoad(); - finalSaveHistory(history); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - private Map> getPreviouslyLoadedIds(BackendBulkDataProvider dataProvider) { - Map> previousIds = new HashMap<>(); - - previousIds.put("Transcript", transcriptService.getIdsByDataProvider(dataProvider)); - previousIds.put("Exon", exonService.getIdsByDataProvider(dataProvider)); - previousIds.put("CodingSequence", cdsService.getIdsByDataProvider(dataProvider)); - previousIds.put("TranscriptGenomicLocationAssociation", transcriptLocationService.getIdsByDataProvider(dataProvider)); - previousIds.put("ExonGenomicLocationAssociation", exonLocationService.getIdsByDataProvider(dataProvider)); - previousIds.put("CodingSequenceGenomicLocationAssociation", cdsLocationService.getIdsByDataProvider(dataProvider)); - - - return previousIds; - } - - private Map> runLoad(BulkLoadFileHistory history, List gffHeaderData, List gffData, - Map> idsAdded, BackendBulkDataProvider dataProvider) { - return runLoad(history, gffHeaderData, gffData, idsAdded, dataProvider, null); - } - - private Map> runLoad(BulkLoadFileHistory history, List gffHeaderData, List gffData, - Map> idsAdded, BackendBulkDataProvider dataProvider, String assemblyId) { - - ProcessDisplayHelper ph = new ProcessDisplayHelper(); - ph.addDisplayHandler(loadProcessDisplayService); - ph.startProcess("GFF update for " + dataProvider.name(), (gffData.size() * 2) + 1); - - assemblyId = loadGenomeAssembly(assemblyId, history, gffHeaderData, dataProvider, ph); - idsAdded = loadEntities(history, gffData, idsAdded, dataProvider, ph); - idsAdded = loadAssociations(history, gffData, idsAdded, dataProvider, assemblyId, ph); - - return idsAdded; - } - - public APIResponse runLoadApi(String dataProviderName, String assemblyName, List gffData) { - Map> idsAdded = new HashMap>(); - idsAdded.put("Transcript", new ArrayList()); - idsAdded.put("Exon", new ArrayList()); - idsAdded.put("CodingSequence", new ArrayList()); - idsAdded.put("TranscriptGenomicLocationAssociation", new ArrayList()); - idsAdded.put("ExonGenomicLocationAssociation", new ArrayList()); - idsAdded.put("CodingSequenceGenomicLocationAssociation", new ArrayList()); - BulkLoadFileHistory history = new BulkLoadFileHistory((gffData.size() * 2) + 1); - BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(dataProviderName); - runLoad(history, null, gffData, idsAdded, dataProvider, assemblyName); - history.finishLoad(); - - return new LoadHistoryResponce(history); - } - - private String loadGenomeAssembly(String assemblyName, BulkLoadFileHistory history, List gffHeaderData, BackendBulkDataProvider dataProvider, ProcessDisplayHelper ph) { - try { - assemblyName = gff3Service.loadGenomeAssembly(assemblyName, gffHeaderData, dataProvider); - history.incrementCompleted(); - } catch (ObjectUpdateException e) { - history.incrementFailed(); - addException(history, e.getData()); - } catch (Exception e) { - e.printStackTrace(); - history.incrementFailed(); - addException(history, new ObjectUpdateExceptionData(gffHeaderData, e.getMessage(), e.getStackTrace())); - } - updateHistory(history); - ph.progressProcess(); - - return assemblyName; - } - - private Map> loadEntities(BulkLoadFileHistory history, List gffData, Map> idsAdded, - BackendBulkDataProvider dataProvider, ProcessDisplayHelper ph) { - for (Gff3DTO gff3Entry : gffData) { - try { - idsAdded = gff3Service.loadEntity(history, gff3Entry, idsAdded, dataProvider); - history.incrementCompleted(); - } catch (ObjectUpdateException e) { - history.incrementFailed(); - addException(history, e.getData()); - } catch (Exception e) { - e.printStackTrace(); - history.incrementFailed(); - addException(history, new ObjectUpdateExceptionData(gff3Entry, e.getMessage(), e.getStackTrace())); - } - updateHistory(history); - ph.progressProcess(); - } - - return idsAdded; - } - - private Map> loadAssociations(BulkLoadFileHistory history, List gffData, Map> idsAdded, - BackendBulkDataProvider dataProvider, String assemblyId, ProcessDisplayHelper ph) { - for (Gff3DTO gff3Entry : gffData) { - try { - idsAdded = gff3Service.loadAssociations(history, gff3Entry, idsAdded, dataProvider, assemblyId); - history.incrementCompleted(); - } catch (ObjectUpdateException e) { - history.incrementFailed(); - addException(history, e.getData()); - } catch (Exception e) { - e.printStackTrace(); - history.incrementFailed(); - addException(history, new ObjectUpdateExceptionData(gff3Entry, e.getMessage(), e.getStackTrace())); - } - updateHistory(history); - ph.progressProcess(); - } - - return idsAdded; - } -} diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/HTPExpressionDatasetAnnotationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/HTPExpressionDatasetAnnotationExecutor.java new file mode 100644 index 000000000..209ac9c95 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/HTPExpressionDatasetAnnotationExecutor.java @@ -0,0 +1,123 @@ +package org.alliancegenome.curation_api.jobs.executors; + +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.zip.GZIPInputStream; + +import org.alliancegenome.curation_api.dao.ExternalDataBaseEntityDAO; +import org.alliancegenome.curation_api.dao.HTPExpressionDatasetAnnotationDAO; +import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ObjectUpdateException.ObjectUpdateExceptionData; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.entities.HTPExpressionDatasetAnnotation; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkFMSLoad; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; +import org.alliancegenome.curation_api.model.ingest.dto.fms.HTPExpressionDatasetAnnotationFmsDTO; +import org.alliancegenome.curation_api.model.ingest.dto.fms.HTPExpressionDatasetAnnotationIngestFmsDTO; +import org.alliancegenome.curation_api.response.APIResponse; +import org.alliancegenome.curation_api.response.LoadHistoryResponce; +import org.alliancegenome.curation_api.services.ExternalDataBaseEntityService; +import org.alliancegenome.curation_api.services.HTPExpressionDatasetAnnotationService; +import org.alliancegenome.curation_api.util.ProcessDisplayHelper; +import org.apache.commons.lang3.StringUtils; + +import io.quarkus.logging.Log; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; + +@ApplicationScoped +public class HTPExpressionDatasetAnnotationExecutor extends LoadFileExecutor { + + @Inject ExternalDataBaseEntityService externalDataBaseEntityService; + @Inject ExternalDataBaseEntityDAO externalDataBaseEntityDAO; + @Inject HTPExpressionDatasetAnnotationService htpExpressionDatasetAnnotationService; + @Inject HTPExpressionDatasetAnnotationDAO htpExpressionDatasetAnnotationDAO; + + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory) { + try { + BulkFMSLoad fms = (BulkFMSLoad) bulkLoadFileHistory.getBulkLoad(); + + HTPExpressionDatasetAnnotationIngestFmsDTO htpExpressionDatasetData = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath())), HTPExpressionDatasetAnnotationIngestFmsDTO.class); + bulkLoadFileHistory.getBulkLoadFile().setRecordCount(htpExpressionDatasetData.getData().size()); + + AGRCurationSchemaVersion version = HTPExpressionDatasetAnnotation.class.getAnnotation(AGRCurationSchemaVersion.class); + bulkLoadFileHistory.getBulkLoadFile().setLinkMLSchemaVersion(version.max()); + if (htpExpressionDatasetData.getMetaData() != null && StringUtils.isNotBlank(htpExpressionDatasetData.getMetaData().getRelease())) { + bulkLoadFileHistory.getBulkLoadFile().setAllianceMemberReleaseVersion(htpExpressionDatasetData.getMetaData().getRelease()); + } + + BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(fms.getFmsDataSubType()); + List htpAnnotationsIdsLoaded = new ArrayList<>(); + List previousIds = htpExpressionDatasetAnnotationService.getAnnotationIdsByDataProvider(dataProvider.name()); + + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); + + bulkLoadFileHistory.setCount((long) htpExpressionDatasetData.getData().size()); + updateHistory(bulkLoadFileHistory); + + boolean success = runLoad(bulkLoadFileHistory, dataProvider, htpExpressionDatasetData.getData(), htpAnnotationsIdsLoaded); + + if (success) { + runCleanup(htpExpressionDatasetAnnotationService, bulkLoadFileHistory, dataProvider.name(), previousIds, htpAnnotationsIdsLoaded, fms.getFmsDataType()); + } + bulkLoadFileHistory.finishLoad(); + + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); + + } catch (Exception e) { + failLoad(bulkLoadFileHistory, e); + e.printStackTrace(); + } + } + + private boolean runLoad(BulkLoadFileHistory history, BackendBulkDataProvider dataProvider, List htpDatasetAnnotations, List htpAnnotationsIdsLoaded) { + ProcessDisplayHelper ph = new ProcessDisplayHelper(); + ph.addDisplayHandler(loadProcessDisplayService); + ph.startProcess("HTP Expression Dataset Annotation DTO Update for " + dataProvider.name(), htpDatasetAnnotations.size() * 2); + + updateHistory(history); + for (HTPExpressionDatasetAnnotationFmsDTO dto : htpDatasetAnnotations) { + try { + HTPExpressionDatasetAnnotation dbObject = htpExpressionDatasetAnnotationService.upsert(dto, dataProvider); + history.incrementCompleted(); + if (dbObject != null) { + htpAnnotationsIdsLoaded.add(dbObject.getId()); + } + } catch (ObjectUpdateException e) { + history.incrementFailed(); + addException(history, e.getData()); + } catch (Exception e) { + e.printStackTrace(); + history.incrementFailed(); + addException(history, new ObjectUpdateExceptionData(dto, e.getMessage(), e.getStackTrace())); + } + if (history.getErrorRate() > 0.25) { + Log.error("Failure Rate > 25% aborting load"); + updateHistory(history); + updateExceptions(history); + failLoadAboveErrorRateCutoff(history); + return false; + } + ph.progressProcess(); + } + updateHistory(history); + updateExceptions(history); + ph.finishProcess(); + return true; + } + + public APIResponse runLoadApi(String dataProviderName, List htpDataset) { + List htpAnnotationsIdsLoaded = new ArrayList<>(); + + BulkLoadFileHistory history = new BulkLoadFileHistory(htpDataset.size()); + BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(dataProviderName); + history = bulkLoadFileHistoryDAO.persist(history); + runLoad(history, dataProvider, htpDataset, htpAnnotationsIdsLoaded); + history.finishLoad(); + + return new LoadHistoryResponce(history); + } +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java index 827693c81..d7b6b8b52 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/LoadFileExecutor.java @@ -14,13 +14,13 @@ import org.alliancegenome.curation_api.dao.loads.BulkLoadFileHistoryDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.enums.JobStatus; +import org.alliancegenome.curation_api.exceptions.KnownIssueValidationException; import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; import org.alliancegenome.curation_api.exceptions.ObjectUpdateException.ObjectUpdateExceptionData; import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.interfaces.crud.BaseUpsertServiceInterface; import org.alliancegenome.curation_api.jobs.util.SlackNotifier; import org.alliancegenome.curation_api.model.entities.base.AuditedObject; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileException; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.ingest.dto.IngestDTO; @@ -45,28 +45,17 @@ public class LoadFileExecutor { @Inject protected ObjectMapper mapper; @Inject protected LoadProcessDisplayService loadProcessDisplayService; @Inject protected BulkLoadFileDAO bulkLoadFileDAO; - @Inject BulkLoadFileHistoryDAO bulkLoadFileHistoryDAO; + @Inject protected BulkLoadFileHistoryDAO bulkLoadFileHistoryDAO; @Inject BulkLoadFileExceptionDAO bulkLoadFileExceptionDAO; @Inject APIVersionInfoService apiVersionInfoService; @Inject SlackNotifier slackNotifier; - protected void createHistory(BulkLoadFileHistory history, BulkLoadFile bulkLoadFile) { - if (bulkLoadFile != null) { - history.setBulkLoadFile(bulkLoadFile); - } - bulkLoadFileHistoryDAO.persist(history); - if (bulkLoadFile != null) { - bulkLoadFile.getHistory().add(history); - bulkLoadFileDAO.merge(bulkLoadFile); - } - } - protected void updateHistory(BulkLoadFileHistory history) { bulkLoadFileHistoryDAO.merge(history); } - protected void finalSaveHistory(BulkLoadFileHistory history) { - bulkLoadFileHistoryDAO.merge(history); + protected void updateExceptions(BulkLoadFileHistory history) { + //bulkLoadFileHistoryDAO.merge(history); for (BulkLoadFileException e : history.getExceptions()) { bulkLoadFileExceptionDAO.merge(e); } @@ -76,7 +65,9 @@ protected void addException(BulkLoadFileHistory history, ObjectUpdateExceptionDa BulkLoadFileException exception = new BulkLoadFileException(); exception.setException(objectUpdateExceptionData); exception.setBulkLoadFileHistory(history); - history.getExceptions().add(exception); + //history.getExceptions().add(exception); + bulkLoadFileExceptionDAO.persist(exception); + //bulkLoadFileHistoryDAO.merge(history); } protected String getVersionNumber(String versionString) { @@ -108,39 +99,41 @@ private List getVersionParts(String version) { return intParts; } - protected boolean checkSchemaVersion(BulkLoadFile bulkLoadFile, Class dtoClass) { - if (bulkLoadFile.getLinkMLSchemaVersion() == null) { - bulkLoadFile.setErrorMessage("Missing Schema Version"); - bulkLoadFile.setBulkloadStatus(JobStatus.FAILED); - slackNotifier.slackalert(bulkLoadFile); - bulkLoadFileDAO.merge(bulkLoadFile); + protected boolean checkSchemaVersion(BulkLoadFileHistory bulkLoadFileHistory, Class dtoClass) { + if (bulkLoadFileHistory.getBulkLoadFile().getLinkMLSchemaVersion() == null) { + bulkLoadFileHistory.setErrorMessage("Missing Schema Version"); + bulkLoadFileHistory.setBulkloadStatus(JobStatus.FAILED); + slackNotifier.slackalert(bulkLoadFileHistory); + bulkLoadFileHistoryDAO.merge(bulkLoadFileHistory); return false; } - if (!validSchemaVersion(bulkLoadFile.getLinkMLSchemaVersion(), dtoClass)) { - bulkLoadFile.setErrorMessage("Invalid Schema Version: " + bulkLoadFile.getLinkMLSchemaVersion()); - bulkLoadFile.setBulkloadStatus(JobStatus.FAILED); - slackNotifier.slackalert(bulkLoadFile); - bulkLoadFileDAO.merge(bulkLoadFile); + if (!validSchemaVersion(bulkLoadFileHistory.getBulkLoadFile().getLinkMLSchemaVersion(), dtoClass)) { + bulkLoadFileHistory.setErrorMessage("Invalid Schema Version: " + bulkLoadFileHistory.getBulkLoadFile().getLinkMLSchemaVersion()); + bulkLoadFileHistory.setBulkloadStatus(JobStatus.FAILED); + slackNotifier.slackalert(bulkLoadFileHistory); + bulkLoadFileHistoryDAO.merge(bulkLoadFileHistory); return false; } return true; } - protected IngestDTO readIngestFile(BulkLoadFile bulkLoadFile, Class dtoClass) { + protected IngestDTO readIngestFile(BulkLoadFileHistory bulkLoadFileHistory, Class dtoClass) { try { - IngestDTO ingestDto = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), IngestDTO.class); - bulkLoadFile.setLinkMLSchemaVersion(getVersionNumber(ingestDto.getLinkMLVersion())); + IngestDTO ingestDto = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath())), IngestDTO.class); + bulkLoadFileHistory.getBulkLoadFile().setLinkMLSchemaVersion(getVersionNumber(ingestDto.getLinkMLVersion())); if (StringUtils.isNotBlank(ingestDto.getAllianceMemberReleaseVersion())) { - bulkLoadFile.setAllianceMemberReleaseVersion(ingestDto.getAllianceMemberReleaseVersion()); + bulkLoadFileHistory.getBulkLoadFile().setAllianceMemberReleaseVersion(ingestDto.getAllianceMemberReleaseVersion()); } - - if (!checkSchemaVersion(bulkLoadFile, dtoClass)) { + + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); + + if (!checkSchemaVersion(bulkLoadFileHistory, dtoClass)) { return null; } return ingestDto; } catch (Exception e) { - failLoad(bulkLoadFile, e); + failLoad(bulkLoadFileHistory, e); e.printStackTrace(); } return null; @@ -192,6 +185,7 @@ protected boolean validSchemaVersion(String submittedSchemaVersion, Class dto public APIResponse runLoadApi(BaseUpsertServiceInterface service, String dataProviderName, List objectList) { List idsLoaded = new ArrayList<>(); BulkLoadFileHistory history = new BulkLoadFileHistory(objectList.size()); + history = bulkLoadFileHistoryDAO.persist(history); BackendBulkDataProvider dataProvider = null; if (dataProviderName != null) { dataProvider = BackendBulkDataProvider.valueOf(dataProviderName); @@ -214,7 +208,8 @@ protected boolean runLoad(BaseUpser loadMessage = loadMessage + " for " + dataProvider.name(); } ph.startProcess(loadMessage, objectList.size()); - + + updateHistory(history); for (T dtoObject : objectList) { try { E dbObject = service.upsert(dtoObject, dataProvider); @@ -226,6 +221,9 @@ protected boolean runLoad(BaseUpser // e.printStackTrace(); history.incrementFailed(); addException(history, e.getData()); + } catch (KnownIssueValidationException e) { + Log.debug(e.getMessage()); + history.incrementSkipped(); } catch (Exception e) { // e.printStackTrace(); history.incrementFailed(); @@ -233,24 +231,26 @@ protected boolean runLoad(BaseUpser } if (terminateFailing && history.getErrorRate() > 0.25) { Log.error("Failure Rate > 25% aborting load"); - finalSaveHistory(history); - failLoadAboveErrorRateCutoff(history.getBulkLoadFile()); + updateHistory(history); + updateExceptions(history); + failLoadAboveErrorRateCutoff(history); return false; } - updateHistory(history); ph.progressProcess(); } + updateHistory(history); + updateExceptions(history); ph.finishProcess(); } return true; } - protected > void runCleanup(S service, BulkLoadFileHistory history, String dataProviderName, List annotationIdsBefore, List annotationIdsAfter, String loadTypeString, String md5sum) { - runCleanup(service, history, dataProviderName, annotationIdsBefore, annotationIdsAfter, loadTypeString, md5sum, true); + protected > void runCleanup(S service, BulkLoadFileHistory history, String dataProviderName, List annotationIdsBefore, List annotationIdsAfter, String loadTypeString) { + runCleanup(service, history, dataProviderName, annotationIdsBefore, annotationIdsAfter, loadTypeString, true); } // The following methods are for bulk validation - protected > void runCleanup(S service, BulkLoadFileHistory history, String dataProviderName, List annotationIdsBefore, List annotationIdsAfter, String loadTypeString, String md5sum, Boolean deprecate) { + protected > void runCleanup(S service, BulkLoadFileHistory history, String dataProviderName, List annotationIdsBefore, List annotationIdsAfter, String loadTypeString, Boolean deprecate) { Log.debug("runLoad: After: " + dataProviderName + " " + annotationIdsAfter.size()); List distinctAfter = annotationIdsAfter.stream().distinct().collect(Collectors.toList()); @@ -259,27 +259,37 @@ protected boolean runLoad(BaseUpser List idsToRemove = ListUtils.subtract(annotationIdsBefore, distinctAfter); Log.debug("runLoad: Remove: " + dataProviderName + " " + idsToRemove.size()); - long existingDeletes = history.getTotalDeleteRecords() == null ? 0 : history.getTotalDeleteRecords(); - history.setTotalDeleteRecords((long) idsToRemove.size() + existingDeletes); + String countType = loadTypeString + " Deleted"; + + long existingDeletes = history.getCount(countType).getTotal() == null ? 0 : history.getCount(countType).getTotal(); + history.setCount(countType, idsToRemove.size() + existingDeletes); + String loadDescription = dataProviderName + " " + loadTypeString + " bulk load (" + history.getBulkLoadFile().getMd5Sum() + ")"; + ProcessDisplayHelper ph = new ProcessDisplayHelper(10000); - ph.startProcess("Deletion/deprecation of entities linked to unloaded " + dataProviderName, idsToRemove.size()); + ph.startProcess("Deletion/deprecation of: " + dataProviderName + " " + loadTypeString, idsToRemove.size()); + //updateHistory(history); for (Long id : idsToRemove) { try { - String loadDescription = dataProviderName + " " + loadTypeString + " bulk load (" + md5sum + ")"; service.deprecateOrDelete(id, false, loadDescription, deprecate); - history.incrementDeleted(); + history.incrementCompleted(countType); } catch (Exception e) { - history.incrementDeleteFailed(); + history.incrementFailed(countType); addException(history, new ObjectUpdateExceptionData("{ \"id\": " + id + "}", e.getMessage(), e.getStackTrace())); } - updateHistory(history); + if (history.getErrorRate(countType) > 0.25) { + Log.error(countType + " failure rate > 25% aborting load"); + failLoadAboveErrorRateCutoff(history); + break; + } ph.progressProcess(); } + updateHistory(history); + updateExceptions(history); ph.finishProcess(); } - protected void failLoad(BulkLoadFile bulkLoadFile, Exception e) { + protected void failLoad(BulkLoadFileHistory bulkLoadFileHistory, Exception e) { Set errorMessages = new LinkedHashSet(); errorMessages.add(e.getMessage()); errorMessages.add(e.getLocalizedMessage()); @@ -288,16 +298,16 @@ protected void failLoad(BulkLoadFile bulkLoadFile, Exception e) { errorMessages.add(cause.getMessage()); cause = cause.getCause(); } - bulkLoadFile.setErrorMessage(String.join("|", errorMessages)); - bulkLoadFile.setBulkloadStatus(JobStatus.FAILED); - slackNotifier.slackalert(bulkLoadFile); - bulkLoadFileDAO.merge(bulkLoadFile); + bulkLoadFileHistory.setErrorMessage(String.join("|", errorMessages)); + bulkLoadFileHistory.setBulkloadStatus(JobStatus.FAILED); + slackNotifier.slackalert(bulkLoadFileHistory); + updateHistory(bulkLoadFileHistory); } - protected void failLoadAboveErrorRateCutoff(BulkLoadFile bulkLoadFile) { - bulkLoadFile.setBulkloadStatus(JobStatus.FAILED); - bulkLoadFile.setErrorMessage("Failure rate exceeded cutoff"); - slackNotifier.slackalert(bulkLoadFile); - bulkLoadFileDAO.merge(bulkLoadFile); + protected void failLoadAboveErrorRateCutoff(BulkLoadFileHistory bulkLoadFileHistory) { + bulkLoadFileHistory.setBulkloadStatus(JobStatus.FAILED); + bulkLoadFileHistory.setErrorMessage("Failure rate exceeded cutoff"); + slackNotifier.slackalert(bulkLoadFileHistory); + updateHistory(bulkLoadFileHistory); } } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/MoleculeExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/MoleculeExecutor.java index 8a8b58a52..927fd0043 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/MoleculeExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/MoleculeExecutor.java @@ -5,7 +5,6 @@ import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.model.entities.Molecule; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.ingest.dto.fms.MoleculeIngestFmsDTO; import org.alliancegenome.curation_api.services.MoleculeService; @@ -19,24 +18,26 @@ public class MoleculeExecutor extends LoadFileExecutor { @Inject MoleculeService moleculeService; - public void execLoad(BulkLoadFile bulkLoadFile) { + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory) { try { - MoleculeIngestFmsDTO moleculeData = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), MoleculeIngestFmsDTO.class); - bulkLoadFile.setRecordCount(moleculeData.getData().size()); - if (bulkLoadFile.getLinkMLSchemaVersion() == null) { + MoleculeIngestFmsDTO moleculeData = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath())), MoleculeIngestFmsDTO.class); + bulkLoadFileHistory.getBulkLoadFile().setRecordCount(moleculeData.getData().size()); + if (bulkLoadFileHistory.getBulkLoadFile().getLinkMLSchemaVersion() == null) { AGRCurationSchemaVersion version = Molecule.class.getAnnotation(AGRCurationSchemaVersion.class); - bulkLoadFile.setLinkMLSchemaVersion(version.max()); + bulkLoadFileHistory.getBulkLoadFile().setLinkMLSchemaVersion(version.max()); } if (moleculeData.getMetaData() != null && StringUtils.isNotBlank(moleculeData.getMetaData().getRelease())) { - bulkLoadFile.setAllianceMemberReleaseVersion(moleculeData.getMetaData().getRelease()); + bulkLoadFileHistory.getBulkLoadFile().setAllianceMemberReleaseVersion(moleculeData.getMetaData().getRelease()); } - bulkLoadFileDAO.merge(bulkLoadFile); + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); - BulkLoadFileHistory history = new BulkLoadFileHistory(moleculeData.getData().size()); - createHistory(history, bulkLoadFile); - runLoad(moleculeService, history, null, moleculeData.getData(), null); - history.finishLoad(); - finalSaveHistory(history); + bulkLoadFileHistory.setCount(moleculeData.getData().size()); + updateHistory(bulkLoadFileHistory); + + runLoad(moleculeService, bulkLoadFileHistory, null, moleculeData.getData(), null); + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); } catch (Exception e) { e.printStackTrace(); } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/OntologyExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/OntologyExecutor.java index cbd396d53..0956b296c 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/OntologyExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/OntologyExecutor.java @@ -1,14 +1,13 @@ package org.alliancegenome.curation_api.jobs.executors; import java.io.FileInputStream; -import java.time.OffsetDateTime; import java.util.Map; import java.util.Map.Entry; import java.util.zip.GZIPInputStream; import org.alliancegenome.curation_api.dao.loads.BulkLoadFileDAO; import org.alliancegenome.curation_api.enums.OntologyBulkLoadType; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.entities.ontology.OntologyTerm; import org.alliancegenome.curation_api.services.base.BaseOntologyTermService; import org.alliancegenome.curation_api.services.helpers.GenericOntologyLoadConfig; @@ -21,9 +20,9 @@ import org.alliancegenome.curation_api.services.ontology.CmoTermService; import org.alliancegenome.curation_api.services.ontology.DaoTermService; import org.alliancegenome.curation_api.services.ontology.DoTermService; -import org.alliancegenome.curation_api.services.ontology.FbcvTermService; import org.alliancegenome.curation_api.services.ontology.EcoTermService; import org.alliancegenome.curation_api.services.ontology.EmapaTermService; +import org.alliancegenome.curation_api.services.ontology.FbcvTermService; import org.alliancegenome.curation_api.services.ontology.FbdvTermService; import org.alliancegenome.curation_api.services.ontology.GenoTermService; import org.alliancegenome.curation_api.services.ontology.GoTermService; @@ -112,20 +111,19 @@ public class OntologyExecutor { @Inject BulkLoadFileDAO bulkLoadFileDAO; @Inject LoadProcessDisplayService loadProcessDisplayService; - public void execLoad(BulkLoadFile bulkLoadFile) throws Exception { - bulkLoadFile.setRecordCount(0); + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory) throws Exception { GenericOntologyLoadConfig config = new GenericOntologyLoadConfig(); - OntologyBulkLoadType ontologyType = bulkLoadFile.getBulkLoad().getOntologyType(); + OntologyBulkLoadType ontologyType = bulkLoadFileHistory.getBulkLoad().getOntologyType(); switch (ontologyType) { case ZECO -> { config.setLoadOnlyIRIPrefix("ZECO"); - processTerms(bulkLoadFile, zecoTermService, config); + processTerms(bulkLoadFileHistory, zecoTermService, config); } case EMAPA -> { config.getAltNameSpaces().add("anatomical_structure"); - processTerms(bulkLoadFile, emapaTermService, config); + processTerms(bulkLoadFileHistory, emapaTermService, config); } case GO -> { config.setLoadOnlyIRIPrefix("GO"); // GO has to have both prefix and namespaces as obsolete terms do not show up in @@ -133,137 +131,137 @@ public void execLoad(BulkLoadFile bulkLoadFile) throws Exception { config.getAltNameSpaces().add("biological_process"); config.getAltNameSpaces().add("molecular_function"); config.getAltNameSpaces().add("cellular_component"); - processTerms(bulkLoadFile, goTermService, config); + processTerms(bulkLoadFileHistory, goTermService, config); } - case SO -> processTerms(bulkLoadFile, soTermService, config); - case XCO -> processTerms(bulkLoadFile, xcoTermService, config); + case SO -> processTerms(bulkLoadFileHistory, soTermService, config); + case XCO -> processTerms(bulkLoadFileHistory, xcoTermService, config); case ECO -> { - processTerms(bulkLoadFile, ecoTermService, config); + processTerms(bulkLoadFileHistory, ecoTermService, config); ecoTermService.updateAbbreviations(); } case CHEBI -> { config.setLoadOnlyIRIPrefix("CHEBI"); - processTerms(bulkLoadFile, chebiTermService, config); + processTerms(bulkLoadFileHistory, chebiTermService, config); } case ZFA -> { config.getAltNameSpaces().add("zebrafish_anatomy"); - processTerms(bulkLoadFile, zfaTermService, config); + processTerms(bulkLoadFileHistory, zfaTermService, config); } - case DO -> processTerms(bulkLoadFile, doTermService, config); + case DO -> processTerms(bulkLoadFileHistory, doTermService, config); case MP -> { config.setLoadOnlyIRIPrefix("MP"); - processTerms(bulkLoadFile, mpTermService, config); + processTerms(bulkLoadFileHistory, mpTermService, config); } case RO -> { config.setLoadObjectProperties(true); config.setLoadOnlyIRIPrefix("RO"); - processTerms(bulkLoadFile, roTermService, config); + processTerms(bulkLoadFileHistory, roTermService, config); } - case MA -> processTerms(bulkLoadFile, maTermService, config); - case WBBT -> processTerms(bulkLoadFile, wbbtTermService, config); + case MA -> processTerms(bulkLoadFileHistory, maTermService, config); + case WBBT -> processTerms(bulkLoadFileHistory, wbbtTermService, config); case DAO -> { config.setLoadOnlyIRIPrefix("FBbt"); - processTerms(bulkLoadFile, daoTermService, config); + processTerms(bulkLoadFileHistory, daoTermService, config); } - case WBLS -> processTerms(bulkLoadFile, wblsTermService, config); - case FBDV -> processTerms(bulkLoadFile, fbdvTermService, config); + case WBLS -> processTerms(bulkLoadFileHistory, wblsTermService, config); + case FBDV -> processTerms(bulkLoadFileHistory, fbdvTermService, config); case MMUSDV -> { config.getAltNameSpaces().add("mouse_developmental_stage"); config.getAltNameSpaces().add("mouse_stages_ontology"); - processTerms(bulkLoadFile, mmusdvTermService, config); + processTerms(bulkLoadFileHistory, mmusdvTermService, config); } - case ZFS -> processTerms(bulkLoadFile, zfsTermService, config); + case ZFS -> processTerms(bulkLoadFileHistory, zfsTermService, config); case XBA_XBS -> { config.getAltNameSpaces().add("xenopus_anatomy"); config.getAltNameSpaces().add("xenopus_anatomy_in_vitro"); - processTerms(bulkLoadFile, OntologyBulkLoadType.XBA, xbaTermService, config); + processTerms(bulkLoadFileHistory, OntologyBulkLoadType.XBA, xbaTermService, config); GenericOntologyLoadConfig config2 = new GenericOntologyLoadConfig(); config2.getAltNameSpaces().add("xenopus_developmental_stage"); - processTerms(bulkLoadFile, OntologyBulkLoadType.XBS, xbsTermService, config2); + processTerms(bulkLoadFileHistory, OntologyBulkLoadType.XBS, xbsTermService, config2); } case XPO -> { config.setLoadOnlyIRIPrefix("XPO"); - processTerms(bulkLoadFile, xpoTermService, config); + processTerms(bulkLoadFileHistory, xpoTermService, config); } case ATP -> { config.setLoadOnlyIRIPrefix("ATP"); - processTerms(bulkLoadFile, atpTermService, config); + processTerms(bulkLoadFileHistory, atpTermService, config); } - case XBED -> processTerms(bulkLoadFile, xbedTermService, config); - case VT -> processTerms(bulkLoadFile, vtTermService, config); - case XSMO -> processTerms(bulkLoadFile, xsmoTermService, config); + case XBED -> processTerms(bulkLoadFileHistory, xbedTermService, config); + case VT -> processTerms(bulkLoadFileHistory, vtTermService, config); + case XSMO -> processTerms(bulkLoadFileHistory, xsmoTermService, config); case OBI -> { config.setLoadOnlyIRIPrefix("OBI"); - processTerms(bulkLoadFile, obiTermService, config); + processTerms(bulkLoadFileHistory, obiTermService, config); } - case WBPheno -> processTerms(bulkLoadFile, wbPhenotypeTermService, config); - case PATO -> processTerms(bulkLoadFile, patoTermService, config); + case WBPheno -> processTerms(bulkLoadFileHistory, wbPhenotypeTermService, config); + case PATO -> processTerms(bulkLoadFileHistory, patoTermService, config); case HP -> { config.setLoadOnlyIRIPrefix("HP"); - processTerms(bulkLoadFile, hpTermService, config); + processTerms(bulkLoadFileHistory, hpTermService, config); } case FBCV -> { config.setLoadOnlyIRIPrefix("FBcv"); - processTerms(bulkLoadFile, fbcvTermService, config); + processTerms(bulkLoadFileHistory, fbcvTermService, config); } - case MMO -> processTerms(bulkLoadFile, mmoTermService, config); + case MMO -> processTerms(bulkLoadFileHistory, mmoTermService, config); case APO -> { config.getAltNameSpaces().add("experiment_type"); config.getAltNameSpaces().add("mutant_type"); config.getAltNameSpaces().add("observable"); config.getAltNameSpaces().add("qualifier"); - processTerms(bulkLoadFile, apoTermService, config); + processTerms(bulkLoadFileHistory, apoTermService, config); } - case MI -> processTerms(bulkLoadFile, miTermService, config); - case MPATH -> processTerms(bulkLoadFile, mpathTermService, config); - case MOD -> processTerms(bulkLoadFile, modTermService, config); + case MI -> processTerms(bulkLoadFileHistory, miTermService, config); + case MPATH -> processTerms(bulkLoadFileHistory, mpathTermService, config); + case MOD -> processTerms(bulkLoadFileHistory, modTermService, config); case UBERON -> { config.setLoadOnlyIRIPrefix("UBERON"); - processTerms(bulkLoadFile, uberonTermService, config); + processTerms(bulkLoadFileHistory, uberonTermService, config); } - case RS -> processTerms(bulkLoadFile, rsTermService, config); - case PW -> processTerms(bulkLoadFile, pwTermService, config); + case RS -> processTerms(bulkLoadFileHistory, rsTermService, config); + case PW -> processTerms(bulkLoadFileHistory, pwTermService, config); case CL -> { config.setLoadOnlyIRIPrefix("CL"); - processTerms(bulkLoadFile, clTermService, config); + processTerms(bulkLoadFileHistory, clTermService, config); } case CMO -> { config.setLoadOnlyIRIPrefix("CMO"); - processTerms(bulkLoadFile, cmoTermService, config); + processTerms(bulkLoadFileHistory, cmoTermService, config); } case BSPO -> { config.setLoadOnlyIRIPrefix("BSPO"); - processTerms(bulkLoadFile, bspoTermService, config); + processTerms(bulkLoadFileHistory, bspoTermService, config); } case GENO -> { config.setLoadOnlyIRIPrefix("GENO"); - processTerms(bulkLoadFile, genoTermService, config); + processTerms(bulkLoadFileHistory, genoTermService, config); } default -> { - log.info("Ontology Load: " + bulkLoadFile.getBulkLoad().getName() + " for OT: " + ontologyType + " not implemented"); - throw new Exception("Ontology Load: " + bulkLoadFile.getBulkLoad().getName() + " for OT: " + ontologyType + " not implemented"); + log.info("Ontology Load: " + bulkLoadFileHistory.getBulkLoad().getName() + " for OT: " + ontologyType + " not implemented"); + throw new Exception("Ontology Load: " + bulkLoadFileHistory.getBulkLoad().getName() + " for OT: " + ontologyType + " not implemented"); } } } - private void processTerms(BulkLoadFile bulkLoadFile, BaseOntologyTermService service, GenericOntologyLoadConfig config) throws Exception { - processTerms(bulkLoadFile, bulkLoadFile.getBulkLoad().getOntologyType(), service, config); + private void processTerms(BulkLoadFileHistory bulkLoadFileHistory, BaseOntologyTermService service, GenericOntologyLoadConfig config) throws Exception { + processTerms(bulkLoadFileHistory, bulkLoadFileHistory.getBulkLoad().getOntologyType(), service, config); } - private void processTerms(BulkLoadFile bulkLoadFile, OntologyBulkLoadType ontologyType, BaseOntologyTermService service, GenericOntologyLoadConfig config) throws Exception { + private void processTerms(BulkLoadFileHistory bulkLoadFileHistory, OntologyBulkLoadType ontologyType, BaseOntologyTermService service, GenericOntologyLoadConfig config) throws Exception { GenericOntologyLoadHelper loader = new GenericOntologyLoadHelper<>(ontologyType.getClazz(), config); - Map termMap = loader.load(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath()))); + Map termMap = loader.load(new GZIPInputStream(new FileInputStream(bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath()))); - bulkLoadFile.setRecordCount(bulkLoadFile.getRecordCount() + termMap.size()); + bulkLoadFileHistory.getBulkLoadFile().setRecordCount(bulkLoadFileHistory.getBulkLoadFile().getRecordCount() + termMap.size()); - bulkLoadFile.setDateLastLoaded(OffsetDateTime.now()); - bulkLoadFileDAO.merge(bulkLoadFile); + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); + ProcessDisplayHelper ph = new ProcessDisplayHelper(); ph.addDisplayHandler(loadProcessDisplayService); - ph.startProcess(bulkLoadFile.getBulkLoad().getName() + ": " + ontologyType.getClazz().getSimpleName() + " Terms", termMap.size()); + ph.startProcess(bulkLoadFileHistory.getBulkLoad().getName() + ": " + ontologyType.getClazz().getSimpleName() + " Terms", termMap.size()); for (Entry entry : termMap.entrySet()) { service.processUpdate(entry.getValue()); ph.progressProcess(); @@ -272,7 +270,7 @@ private void processTerms(BulkLoadFile bulkLoadFile, OntologyBulkLoadType ontolo ProcessDisplayHelper ph1 = new ProcessDisplayHelper(); ph.addDisplayHandler(loadProcessDisplayService); - ph1.startProcess(bulkLoadFile.getBulkLoad().getName() + ": " + ontologyType.getClazz().getSimpleName() + " Closure", termMap.size()); + ph1.startProcess(bulkLoadFileHistory.getBulkLoad().getName() + ": " + ontologyType.getClazz().getSimpleName() + " Closure", termMap.size()); for (Entry entry : termMap.entrySet()) { service.processUpdateRelationships(entry.getValue()); // Thread.sleep(5000); @@ -282,7 +280,7 @@ private void processTerms(BulkLoadFile bulkLoadFile, OntologyBulkLoadType ontolo ProcessDisplayHelper ph2 = new ProcessDisplayHelper(); ph.addDisplayHandler(loadProcessDisplayService); - ph2.startProcess(bulkLoadFile.getBulkLoad().getName() + ": " + ontologyType.getClazz().getSimpleName() + " Counts", termMap.size()); + ph2.startProcess(bulkLoadFileHistory.getBulkLoad().getName() + ": " + ontologyType.getClazz().getSimpleName() + " Counts", termMap.size()); for (Entry entry : termMap.entrySet()) { service.processCounts(entry.getValue()); // Thread.sleep(5000); diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/OrthologyExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/OrthologyExecutor.java index bf36f066a..1f9caf336 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/OrthologyExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/OrthologyExecutor.java @@ -9,7 +9,6 @@ import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkFMSLoad; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.entities.orthology.GeneToGeneOrthologyGenerated; import org.alliancegenome.curation_api.model.ingest.dto.fms.OrthologyIngestFmsDTO; @@ -27,17 +26,17 @@ public class OrthologyExecutor extends LoadFileExecutor { @Inject GeneToGeneOrthologyGeneratedService generatedOrthologyService; @Inject GeneToGeneOrthologyGeneratedDAO generatedOrthologyDAO; - public void execLoad(BulkLoadFile bulkLoadFile) { + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory) { try { - BulkFMSLoad fms = (BulkFMSLoad) bulkLoadFile.getBulkLoad(); + BulkFMSLoad fms = (BulkFMSLoad) bulkLoadFileHistory.getBulkLoad(); - OrthologyIngestFmsDTO orthologyData = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), OrthologyIngestFmsDTO.class); - bulkLoadFile.setRecordCount(orthologyData.getData().size()); + OrthologyIngestFmsDTO orthologyData = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath())), OrthologyIngestFmsDTO.class); + bulkLoadFileHistory.getBulkLoadFile().setRecordCount(orthologyData.getData().size()); AGRCurationSchemaVersion version = GeneToGeneOrthologyGenerated.class.getAnnotation(AGRCurationSchemaVersion.class); - bulkLoadFile.setLinkMLSchemaVersion(version.max()); + bulkLoadFileHistory.getBulkLoadFile().setLinkMLSchemaVersion(version.max()); if (orthologyData.getMetaData() != null && StringUtils.isNotBlank(orthologyData.getMetaData().getRelease())) { - bulkLoadFile.setAllianceMemberReleaseVersion(orthologyData.getMetaData().getRelease()); + bulkLoadFileHistory.getBulkLoadFile().setAllianceMemberReleaseVersion(orthologyData.getMetaData().getRelease()); } List orthoPairIdsLoaded = new ArrayList<>(); @@ -45,18 +44,20 @@ public void execLoad(BulkLoadFile bulkLoadFile) { List orthoPairIdsBefore = generatedOrthologyService.getAllOrthologyPairIdsBySubjectGeneDataProvider(dataProvider); log.debug("runLoad: Before: total " + orthoPairIdsBefore.size()); - bulkLoadFileDAO.merge(bulkLoadFile); + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); - BulkLoadFileHistory history = new BulkLoadFileHistory(orthologyData.getData().size()); - createHistory(history, bulkLoadFile); - boolean success = runLoad(generatedOrthologyService, history, dataProvider, orthologyData.getData(), orthoPairIdsLoaded); + bulkLoadFileHistory.setCount(orthologyData.getData().size()); + updateHistory(bulkLoadFileHistory); + + boolean success = runLoad(generatedOrthologyService, bulkLoadFileHistory, dataProvider, orthologyData.getData(), orthoPairIdsLoaded); if (success) { - runCleanup(generatedOrthologyService, history, fms.getFmsDataSubType(), orthoPairIdsBefore, orthoPairIdsLoaded, fms.getFmsDataType(), bulkLoadFile.getMd5Sum(), false); + runCleanup(generatedOrthologyService, bulkLoadFileHistory, fms.getFmsDataSubType(), orthoPairIdsBefore, orthoPairIdsLoaded, fms.getFmsDataType(), false); } - history.finishLoad(); - finalSaveHistory(history); + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); } catch (Exception e) { - failLoad(bulkLoadFile, e); + failLoad(bulkLoadFileHistory, e); e.printStackTrace(); } } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/ParalogyExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/ParalogyExecutor.java index f2cbf69c6..a4f5ff276 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/ParalogyExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/ParalogyExecutor.java @@ -10,7 +10,6 @@ import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.model.entities.GeneToGeneParalogy; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkFMSLoad; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.ingest.dto.fms.ParalogyIngestFmsDTO; import org.alliancegenome.curation_api.services.GeneToGeneParalogyService; @@ -26,17 +25,17 @@ public class ParalogyExecutor extends LoadFileExecutor { @Inject GeneToGeneParalogyService geneToGeneParalogyService; @Inject GeneToGeneParalogyDAO geneToGeneParalogyDAO; - public void execLoad(BulkLoadFile bulkLoadFile) { + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory) { try { - BulkFMSLoad fms = (BulkFMSLoad) bulkLoadFile.getBulkLoad(); + BulkFMSLoad fms = (BulkFMSLoad) bulkLoadFileHistory.getBulkLoad(); - ParalogyIngestFmsDTO paralogyData = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), ParalogyIngestFmsDTO.class); - bulkLoadFile.setRecordCount(paralogyData.getData().size()); + ParalogyIngestFmsDTO paralogyData = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath())), ParalogyIngestFmsDTO.class); + bulkLoadFileHistory.getBulkLoadFile().setRecordCount(paralogyData.getData().size()); AGRCurationSchemaVersion version = GeneToGeneParalogy.class.getAnnotation(AGRCurationSchemaVersion.class); - bulkLoadFile.setLinkMLSchemaVersion(version.max()); + bulkLoadFileHistory.getBulkLoadFile().setLinkMLSchemaVersion(version.max()); if (paralogyData.getMetaData() != null && StringUtils.isNotBlank(paralogyData.getMetaData().getRelease())) { - bulkLoadFile.setAllianceMemberReleaseVersion(paralogyData.getMetaData().getRelease()); + bulkLoadFileHistory.getBulkLoadFile().setAllianceMemberReleaseVersion(paralogyData.getMetaData().getRelease()); } List paralogyIdsLoaded = new ArrayList<>(); @@ -44,21 +43,23 @@ public void execLoad(BulkLoadFile bulkLoadFile) { List paralogyPairsBefore = geneToGeneParalogyService.getAllParalogyPairIdsBySubjectGeneDataProvider(dataProvider); Log.debug("runLoad: Before: total " + paralogyPairsBefore.size()); - bulkLoadFileDAO.merge(bulkLoadFile); + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); - BulkLoadFileHistory history = new BulkLoadFileHistory(paralogyData.getData().size()); - createHistory(history, bulkLoadFile); - boolean success = runLoad(geneToGeneParalogyService, history, dataProvider, paralogyData.getData(), paralogyIdsLoaded, false); + bulkLoadFileHistory.setCount(paralogyData.getData().size()); + updateHistory(bulkLoadFileHistory); + + boolean success = runLoad(geneToGeneParalogyService, bulkLoadFileHistory, dataProvider, paralogyData.getData(), paralogyIdsLoaded, false); if (success) { - runCleanup(geneToGeneParalogyService, history, fms.getFmsDataSubType(), paralogyPairsBefore, paralogyIdsLoaded, fms.getFmsDataType(), bulkLoadFile.getMd5Sum(), false); + runCleanup(geneToGeneParalogyService, bulkLoadFileHistory, fms.getFmsDataSubType(), paralogyPairsBefore, paralogyIdsLoaded, fms.getFmsDataType(), false); } - history.finishLoad(); + bulkLoadFileHistory.finishLoad(); - finalSaveHistory(history); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); } catch (Exception e) { - failLoad(bulkLoadFile, e); + failLoad(bulkLoadFileHistory, e); e.printStackTrace(); } } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/PhenotypeAnnotationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/PhenotypeAnnotationExecutor.java index 772f78a46..26e43dc6c 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/PhenotypeAnnotationExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/PhenotypeAnnotationExecutor.java @@ -13,7 +13,6 @@ import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.model.entities.Molecule; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkFMSLoad; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.ingest.dto.fms.PhenotypeFmsDTO; import org.alliancegenome.curation_api.model.ingest.dto.fms.PhenotypeIngestFmsDTO; @@ -32,44 +31,47 @@ public class PhenotypeAnnotationExecutor extends LoadFileExecutor { @Inject PhenotypeAnnotationService phenotypeAnnotationService; - public void execLoad(BulkLoadFile bulkLoadFile) { + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory) { try { - BulkFMSLoad fmsLoad = (BulkFMSLoad) bulkLoadFile.getBulkLoad(); + BulkFMSLoad fmsLoad = (BulkFMSLoad) bulkLoadFileHistory.getBulkLoad(); BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(fmsLoad.getFmsDataSubType()); - PhenotypeIngestFmsDTO phenotypeData = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), PhenotypeIngestFmsDTO.class); - bulkLoadFile.setRecordCount(phenotypeData.getData().size()); - if (bulkLoadFile.getLinkMLSchemaVersion() == null) { + PhenotypeIngestFmsDTO phenotypeData = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath())), PhenotypeIngestFmsDTO.class); + bulkLoadFileHistory.getBulkLoadFile().setRecordCount(phenotypeData.getData().size()); + if (bulkLoadFileHistory.getBulkLoadFile().getLinkMLSchemaVersion() == null) { AGRCurationSchemaVersion version = Molecule.class.getAnnotation(AGRCurationSchemaVersion.class); - bulkLoadFile.setLinkMLSchemaVersion(version.max()); + bulkLoadFileHistory.getBulkLoadFile().setLinkMLSchemaVersion(version.max()); } if (phenotypeData.getMetaData() != null && StringUtils.isNotBlank(phenotypeData.getMetaData().getRelease())) { - bulkLoadFile.setAllianceMemberReleaseVersion(phenotypeData.getMetaData().getRelease()); + bulkLoadFileHistory.getBulkLoadFile().setAllianceMemberReleaseVersion(phenotypeData.getMetaData().getRelease()); } - bulkLoadFileDAO.merge(bulkLoadFile); + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); + + bulkLoadFileHistory.setCount(phenotypeData.getData().size()); + updateHistory(bulkLoadFileHistory); - BulkLoadFileHistory history = new BulkLoadFileHistory(phenotypeData.getData().size()); - createHistory(history, bulkLoadFile); Set annotationIdsLoaded = new HashSet<>(); List annotationIdsBefore = phenotypeAnnotationService.getAnnotationIdsByDataProvider(dataProvider); - runLoad(history, phenotypeData.getData(), annotationIdsLoaded, dataProvider); + runLoad(bulkLoadFileHistory, phenotypeData.getData(), annotationIdsLoaded, dataProvider); - runCleanup(phenotypeAnnotationService, history, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded.stream().collect(Collectors.toList()), "phenotype annotation", bulkLoadFile.getMd5Sum()); + runCleanup(phenotypeAnnotationService, bulkLoadFileHistory, dataProvider.name(), annotationIdsBefore, annotationIdsLoaded.stream().collect(Collectors.toList()), "phenotype annotation"); - history.finishLoad(); - finalSaveHistory(history); + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); } catch (Exception e) { + failLoad(bulkLoadFileHistory, e); e.printStackTrace(); } } // Gets called from the API directly - public APIResponse runLoad(String dataProviderName, List annotations) { + public APIResponse runLoadApi(String dataProviderName, List annotations) { Set annotationIdsLoaded = new HashSet<>(); - BulkLoadFileHistory history = new BulkLoadFileHistory(annotations.size()); + history = bulkLoadFileHistoryDAO.persist(history); BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(dataProviderName); runLoad(history, annotations, annotationIdsLoaded, dataProvider); history.finishLoad(); @@ -109,10 +111,10 @@ private void loadSecondaryAnnotations(BulkLoadFileHistory history, List annotations, Set idsAdded, BackendBulkDataProvider dataProvider, ProcessDisplayHelper ph) { @@ -137,9 +139,10 @@ private void loadPrimaryAnnotations(BulkLoadFileHistory history, List dtos = mapper.readValue(new GZIPInputStream(new FileInputStream(rdFile)), listType); List rdNamesBefore = resourceDescriptorService.getAllNames(); List rdNamesAfter = new ArrayList<>(); - BulkLoadFileHistory history = new BulkLoadFileHistory(dtos.size()); - createHistory(history, bulkLoadFile); - - dtos.forEach(dto -> { + + bulkLoadFileHistory.setCount(dtos.size()); + + updateHistory(bulkLoadFileHistory); + for (ResourceDescriptorDTO dto : dtos) { try { ResourceDescriptor rd = resourceDescriptorService.upsert(dto); - history.incrementCompleted(); - updateHistory(history); + bulkLoadFileHistory.incrementCompleted(); rdNamesAfter.add(rd.getName()); } catch (ObjectUpdateException e) { - addException(history, e.getData()); + bulkLoadFileHistory.incrementFailed(); + addException(bulkLoadFileHistory, e.getData()); } catch (Exception e) { - addException(history, new ObjectUpdateExceptionData(dto, e.getMessage(), e.getStackTrace())); + bulkLoadFileHistory.incrementFailed(); + addException(bulkLoadFileHistory, new ObjectUpdateExceptionData(dto, e.getMessage(), e.getStackTrace())); } - }); - history.finishLoad(); - finalSaveHistory(history); + } + updateHistory(bulkLoadFileHistory); + + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); resourceDescriptorService.removeNonUpdatedResourceDescriptors(rdNamesBefore, rdNamesAfter); log.info("Loading ResourceDescriptorFileFinished"); diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/SequenceTargetingReagentExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/SequenceTargetingReagentExecutor.java index fc16b5cab..453ffbd75 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/SequenceTargetingReagentExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/SequenceTargetingReagentExecutor.java @@ -13,7 +13,6 @@ import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.model.entities.SequenceTargetingReagent; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkFMSLoad; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.ingest.dto.fms.SequenceTargetingReagentFmsDTO; import org.alliancegenome.curation_api.model.ingest.dto.fms.SequenceTargetingReagentIngestFmsDTO; @@ -34,24 +33,20 @@ public class SequenceTargetingReagentExecutor extends LoadFileExecutor { @Inject SequenceTargetingReagentGeneAssociationService sqtrGeneAssociationService; - public void execLoad(BulkLoadFile bulkLoadFile) { + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory) { try { - BulkFMSLoad fms = (BulkFMSLoad) bulkLoadFile.getBulkLoad(); + BulkFMSLoad fms = (BulkFMSLoad) bulkLoadFileHistory.getBulkLoad(); - SequenceTargetingReagentIngestFmsDTO sqtrIngestFmsDTO = mapper.readValue( - new GZIPInputStream(new FileInputStream(bulkLoadFile.getLocalFilePath())), - SequenceTargetingReagentIngestFmsDTO.class); - bulkLoadFile.setRecordCount(sqtrIngestFmsDTO.getData().size()); + SequenceTargetingReagentIngestFmsDTO sqtrIngestFmsDTO = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath())), SequenceTargetingReagentIngestFmsDTO.class); + bulkLoadFileHistory.getBulkLoadFile().setRecordCount(sqtrIngestFmsDTO.getData().size()); - AGRCurationSchemaVersion version = SequenceTargetingReagent.class - .getAnnotation(AGRCurationSchemaVersion.class); - bulkLoadFile.setLinkMLSchemaVersion(version.max()); + AGRCurationSchemaVersion version = SequenceTargetingReagent.class.getAnnotation(AGRCurationSchemaVersion.class); + bulkLoadFileHistory.getBulkLoadFile().setLinkMLSchemaVersion(version.max()); - if (sqtrIngestFmsDTO.getMetaData() != null - && StringUtils.isNotBlank(sqtrIngestFmsDTO.getMetaData().getRelease())) { - bulkLoadFile.setAllianceMemberReleaseVersion(sqtrIngestFmsDTO.getMetaData().getRelease()); + if (sqtrIngestFmsDTO.getMetaData() != null && StringUtils.isNotBlank(sqtrIngestFmsDTO.getMetaData().getRelease())) { + bulkLoadFileHistory.getBulkLoadFile().setAllianceMemberReleaseVersion(sqtrIngestFmsDTO.getMetaData().getRelease()); } BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(fms.getFmsDataSubType()); @@ -62,20 +57,22 @@ public void execLoad(BulkLoadFile bulkLoadFile) { Map> previousIds = getPreviouslyLoadedIds(dataProvider); - bulkLoadFileDAO.merge(bulkLoadFile); + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); - BulkLoadFileHistory history = new BulkLoadFileHistory(sqtrIngestFmsDTO.getData().size() * 2); + bulkLoadFileHistory.setCount((long) sqtrIngestFmsDTO.getData().size() * 2); + updateHistory(bulkLoadFileHistory); + + runLoad(bulkLoadFileHistory, dataProvider, sqtrIngestFmsDTO.getData(), idsAdded.get("SQTR"), idsAdded.get("SQTRGeneAssociation")); - runLoad(history, dataProvider, sqtrIngestFmsDTO.getData(), idsAdded.get("SQTR"), idsAdded.get("SQTRGeneAssociation")); + runCleanup(sqtrService, bulkLoadFileHistory, dataProvider.name(), previousIds.get("SQTR"), idsAdded.get("SQTR"), "SQTR"); + runCleanup(sqtrService, bulkLoadFileHistory, dataProvider.name(), previousIds.get("SQTRGeneAssociation"), idsAdded.get("SQTRGeneAssociation"), "SQTR Gene Associations"); - runCleanup(sqtrService, history, dataProvider.name(), previousIds.get("SQTR"), idsAdded.get("SQTR"), "SQTR", bulkLoadFile.getMd5Sum()); - runCleanup(sqtrService, history, dataProvider.name(), previousIds.get("SQTRGeneAssociation"), idsAdded.get("SQTRGeneAssociation"), "SQTR Gene Associations", bulkLoadFile.getMd5Sum()); + bulkLoadFileHistory.finishLoad(); - history.finishLoad(); - - updateHistory(history); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); } catch (Exception e) { - failLoad(bulkLoadFile, e); + failLoad(bulkLoadFileHistory, e); e.printStackTrace(); } } @@ -94,6 +91,7 @@ public APIResponse runLoadApi(String dataProviderName, List sqtrGeneAssociationIdsLoaded = new ArrayList<>(); BulkLoadFileHistory history = new BulkLoadFileHistory(sqtrDTOs.size() * 2); + history = bulkLoadFileHistoryDAO.persist(history); BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(dataProviderName); runLoad(history, dataProvider, sqtrDTOs, sqtrIdsLoaded, sqtrGeneAssociationIdsLoaded); history.finishLoad(); diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/VariantExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/VariantExecutor.java index f6da35942..65d6b91f2 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/VariantExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/VariantExecutor.java @@ -5,7 +5,6 @@ import org.alliancegenome.curation_api.dao.VariantDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkManualLoad; import org.alliancegenome.curation_api.model.ingest.dto.IngestDTO; @@ -22,12 +21,12 @@ public class VariantExecutor extends LoadFileExecutor { @Inject VariantDAO variantDAO; @Inject VariantService variantService; - public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory, Boolean cleanUp) { - BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + BulkManualLoad manual = (BulkManualLoad) bulkLoadFileHistory.getBulkLoad(); Log.info("Running with: " + manual.getDataProvider().name()); - IngestDTO ingestDto = readIngestFile(bulkLoadFile, VariantDTO.class); + IngestDTO ingestDto = readIngestFile(bulkLoadFileHistory, VariantDTO.class); if (ingestDto == null) { return; } @@ -46,17 +45,19 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { Log.debug("runLoad: Before: total " + variantIdsBefore.size()); } - bulkLoadFile.setRecordCount(variants.size() + bulkLoadFile.getRecordCount()); - bulkLoadFileDAO.merge(bulkLoadFile); + bulkLoadFileHistory.getBulkLoadFile().setRecordCount(variants.size() + bulkLoadFileHistory.getBulkLoadFile().getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); - BulkLoadFileHistory history = new BulkLoadFileHistory(variants.size()); - createHistory(history, bulkLoadFile); - boolean success = runLoad(variantService, history, dataProvider, variants, variantIdsLoaded); + bulkLoadFileHistory.setCount(variants.size()); + updateHistory(bulkLoadFileHistory); + + boolean success = runLoad(variantService, bulkLoadFileHistory, dataProvider, variants, variantIdsLoaded); if (success && cleanUp) { - runCleanup(variantService, history, dataProvider.name(), variantIdsBefore, variantIdsLoaded, "variant", bulkLoadFile.getMd5Sum()); + runCleanup(variantService, bulkLoadFileHistory, dataProvider.name(), variantIdsBefore, variantIdsLoaded, "variant"); } - history.finishLoad(); - finalSaveHistory(history); + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/VariantFmsExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/VariantFmsExecutor.java new file mode 100644 index 000000000..8f55a3778 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/VariantFmsExecutor.java @@ -0,0 +1,145 @@ +package org.alliancegenome.curation_api.jobs.executors; + +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.zip.GZIPInputStream; + +import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ObjectUpdateException.ObjectUpdateExceptionData; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkFMSLoad; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; +import org.alliancegenome.curation_api.model.ingest.dto.fms.VariantFmsDTO; +import org.alliancegenome.curation_api.model.ingest.dto.fms.VariantIngestFmsDTO; +import org.alliancegenome.curation_api.response.APIResponse; +import org.alliancegenome.curation_api.response.LoadHistoryResponce; +import org.alliancegenome.curation_api.services.VariantService; +import org.alliancegenome.curation_api.services.associations.alleleAssociations.AlleleVariantAssociationService; +import org.alliancegenome.curation_api.services.associations.variantAssociations.CuratedVariantGenomicLocationAssociationService; +import org.alliancegenome.curation_api.services.validation.dto.fms.VariantFmsDTOValidator; +import org.alliancegenome.curation_api.util.ProcessDisplayHelper; +import org.apache.commons.lang3.StringUtils; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; + +@ApplicationScoped +public class VariantFmsExecutor extends LoadFileExecutor { + + @Inject VariantService variantService; + @Inject CuratedVariantGenomicLocationAssociationService curatedVariantGenomicLocationAssociationService; + @Inject AlleleVariantAssociationService alleleVariantAssociationService; + @Inject VariantFmsDTOValidator variantFmsDtoValidator; + + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory) { + try { + BulkFMSLoad fms = (BulkFMSLoad) bulkLoadFileHistory.getBulkLoad(); + + VariantIngestFmsDTO variantData = mapper.readValue(new GZIPInputStream(new FileInputStream(bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath())), VariantIngestFmsDTO.class); + + if (variantData.getMetaData() != null && StringUtils.isNotBlank(variantData.getMetaData().getRelease())) { + bulkLoadFileHistory.getBulkLoadFile().setAllianceMemberReleaseVersion(variantData.getMetaData().getRelease()); + } + + BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(fms.getFmsDataSubType()); + + List entityIdsAdded = new ArrayList<>(); + List locationIdsAdded = new ArrayList<>(); + List associationIdsAdded = new ArrayList<>(); + + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); + + updateHistory(bulkLoadFileHistory); + + boolean success = runLoad(bulkLoadFileHistory, variantData.getData(), entityIdsAdded, locationIdsAdded, associationIdsAdded, dataProvider); + if (success) { + runCleanup(variantService, bulkLoadFileHistory, dataProvider.name(), variantService.getIdsByDataProvider(dataProvider.name()), entityIdsAdded, "Variant"); + runCleanup(curatedVariantGenomicLocationAssociationService, bulkLoadFileHistory, dataProvider.name(), curatedVariantGenomicLocationAssociationService.getIdsByDataProvider(dataProvider), locationIdsAdded, "Curated variant genomic location association"); + runCleanup(alleleVariantAssociationService, bulkLoadFileHistory, dataProvider.name(), alleleVariantAssociationService.getAssociationsByDataProvider(dataProvider), associationIdsAdded, "Allele variant association"); + } + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); + } catch (Exception e) { + failLoad(bulkLoadFileHistory, e); + e.printStackTrace(); + } + } + + private boolean runLoad( + BulkLoadFileHistory history, + List data, + List entityIdsAdded, + List locationIdsAdded, + List associationIdsAdded, + BackendBulkDataProvider dataProvider) { + + ProcessDisplayHelper ph = new ProcessDisplayHelper(); + ph.addDisplayHandler(loadProcessDisplayService); + ph.startProcess("Variant update for " + dataProvider.name(), data.size()); + + history.setCount("Entities", data.size()); + history.setCount("Locations", data.size()); + history.setCount("Associations", data.size()); + updateHistory(history); + + String countType = null; + for (VariantFmsDTO dto : data) { + countType = "Entities"; + Long variantId = null; + try { + variantId = variantFmsDtoValidator.validateVariant(dto, entityIdsAdded, dataProvider); + history.incrementCompleted(countType); + } catch (ObjectUpdateException e) { + history.incrementFailed(countType); + addException(history, e.getData()); + } catch (Exception e) { + e.printStackTrace(); + history.incrementFailed(countType); + addException(history, new ObjectUpdateExceptionData(dto, e.getMessage(), e.getStackTrace())); + } + countType = "Locations"; + try { + variantFmsDtoValidator.validateCuratedVariantGenomicLocationAssociation(dto, locationIdsAdded, variantId); + history.incrementCompleted(countType); + } catch (ObjectUpdateException e) { + history.incrementFailed(countType); + addException(history, e.getData()); + } catch (Exception e) { + e.printStackTrace(); + history.incrementFailed(countType); + addException(history, new ObjectUpdateExceptionData(dto, e.getMessage(), e.getStackTrace())); + } + countType = "Associations"; + try { + variantFmsDtoValidator.validateAlleleVariantAssociation(dto, associationIdsAdded, variantId); + history.incrementCompleted(countType); + } catch (ObjectUpdateException e) { + history.incrementFailed(countType); + addException(history, e.getData()); + } catch (Exception e) { + e.printStackTrace(); + history.incrementFailed(countType); + addException(history, new ObjectUpdateExceptionData(dto, e.getMessage(), e.getStackTrace())); + } + ph.progressProcess(); + } + + updateHistory(history); + ph.finishProcess(); + + return true; + } + + public APIResponse runLoadApi(String dataProviderName, List gffData) { + List idsAdded = new ArrayList<>(); + BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(dataProviderName); + BulkLoadFileHistory history = new BulkLoadFileHistory(); + history = bulkLoadFileHistoryDAO.persist(history); + runLoad(history, gffData, idsAdded, idsAdded, idsAdded, dataProvider); + history.finishLoad(); + + return new LoadHistoryResponce(history); + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/alleleAssociations/AlleleGeneAssociationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/alleleAssociations/AlleleGeneAssociationExecutor.java index 627597ad9..92b817b13 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/alleleAssociations/AlleleGeneAssociationExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/alleleAssociations/AlleleGeneAssociationExecutor.java @@ -6,7 +6,6 @@ import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.jobs.executors.LoadFileExecutor; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkManualLoad; import org.alliancegenome.curation_api.model.ingest.dto.IngestDTO; @@ -23,13 +22,13 @@ public class AlleleGeneAssociationExecutor extends LoadFileExecutor { @Inject AlleleGeneAssociationService alleleGeneAssociationService; - public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory, Boolean cleanUp) { - BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + BulkManualLoad manual = (BulkManualLoad) bulkLoadFileHistory.getBulkLoad(); BackendBulkDataProvider dataProvider = manual.getDataProvider(); log.info("Running with dataProvider: " + dataProvider.name()); - IngestDTO ingestDto = readIngestFile(bulkLoadFile, AlleleGeneAssociationDTO.class); + IngestDTO ingestDto = readIngestFile(bulkLoadFileHistory, AlleleGeneAssociationDTO.class); if (ingestDto == null) { return; } @@ -46,17 +45,19 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { associationIdsBefore.removeIf(Objects::isNull); } - bulkLoadFile.setRecordCount(associations.size() + bulkLoadFile.getRecordCount()); - bulkLoadFileDAO.merge(bulkLoadFile); + bulkLoadFileHistory.getBulkLoadFile().setRecordCount(associations.size() + bulkLoadFileHistory.getBulkLoadFile().getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); - BulkLoadFileHistory history = new BulkLoadFileHistory(associations.size()); - createHistory(history, bulkLoadFile); - boolean success = runLoad(alleleGeneAssociationService, history, dataProvider, associations, associationIdsLoaded); + bulkLoadFileHistory.setCount(associations.size()); + updateHistory(bulkLoadFileHistory); + + boolean success = runLoad(alleleGeneAssociationService, bulkLoadFileHistory, dataProvider, associations, associationIdsLoaded); if (success && cleanUp) { - runCleanup(alleleGeneAssociationService, history, dataProvider.name(), associationIdsBefore, associationIdsLoaded, "allele gene association", bulkLoadFile.getMd5Sum()); + runCleanup(alleleGeneAssociationService, bulkLoadFileHistory, dataProvider.name(), associationIdsBefore, associationIdsLoaded, "allele gene association"); } - history.finishLoad(); - finalSaveHistory(history); + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); } } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/constructAssociations/ConstructGenomicEntityAssociationExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/constructAssociations/ConstructGenomicEntityAssociationExecutor.java index 6e9f0a485..5e94cadaf 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/constructAssociations/ConstructGenomicEntityAssociationExecutor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/associations/constructAssociations/ConstructGenomicEntityAssociationExecutor.java @@ -7,7 +7,6 @@ import org.alliancegenome.curation_api.dao.associations.constructAssociations.ConstructGenomicEntityAssociationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.jobs.executors.LoadFileExecutor; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkManualLoad; import org.alliancegenome.curation_api.model.ingest.dto.IngestDTO; @@ -25,13 +24,13 @@ public class ConstructGenomicEntityAssociationExecutor extends LoadFileExecutor @Inject ConstructGenomicEntityAssociationDAO constructGenomicEntityAssociationDAO; @Inject ConstructGenomicEntityAssociationService constructGenomicEntityAssociationService; - public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory, Boolean cleanUp) { - BulkManualLoad manual = (BulkManualLoad) bulkLoadFile.getBulkLoad(); + BulkManualLoad manual = (BulkManualLoad) bulkLoadFileHistory.getBulkLoad(); BackendBulkDataProvider dataProvider = manual.getDataProvider(); log.info("Running with dataProvider: " + dataProvider.name()); - IngestDTO ingestDto = readIngestFile(bulkLoadFile, ConstructGenomicEntityAssociationDTO.class); + IngestDTO ingestDto = readIngestFile(bulkLoadFileHistory, ConstructGenomicEntityAssociationDTO.class); if (ingestDto == null) { return; } @@ -48,17 +47,19 @@ public void execLoad(BulkLoadFile bulkLoadFile, Boolean cleanUp) { associationIdsBefore.removeIf(Objects::isNull); } - bulkLoadFile.setRecordCount(associations.size() + bulkLoadFile.getRecordCount()); - bulkLoadFileDAO.merge(bulkLoadFile); + bulkLoadFileHistory.getBulkLoadFile().setRecordCount(associations.size() + bulkLoadFileHistory.getBulkLoadFile().getRecordCount()); + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); - BulkLoadFileHistory history = new BulkLoadFileHistory(associations.size()); - createHistory(history, bulkLoadFile); - runLoad(constructGenomicEntityAssociationService, history, dataProvider, associations, associationIdsLoaded); + bulkLoadFileHistory.setCount(associations.size()); + updateHistory(bulkLoadFileHistory); + + runLoad(constructGenomicEntityAssociationService, bulkLoadFileHistory, dataProvider, associations, associationIdsLoaded); if (cleanUp) { - runCleanup(constructGenomicEntityAssociationService, history, dataProvider.name(), associationIdsBefore, associationIdsLoaded, "construct genomic entity association", bulkLoadFile.getMd5Sum()); + runCleanup(constructGenomicEntityAssociationService, bulkLoadFileHistory, dataProvider.name(), associationIdsBefore, associationIdsLoaded, "construct genomic entity association"); } - history.finishLoad(); - finalSaveHistory(history); + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); } } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/gff/Gff3CDSExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/gff/Gff3CDSExecutor.java new file mode 100644 index 000000000..a8466063d --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/gff/Gff3CDSExecutor.java @@ -0,0 +1,172 @@ +package org.alliancegenome.curation_api.jobs.executors.gff; + +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.zip.GZIPInputStream; + +import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ObjectUpdateException.ObjectUpdateExceptionData; +import org.alliancegenome.curation_api.jobs.util.CsvSchemaBuilder; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkFMSLoad; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; +import org.alliancegenome.curation_api.model.ingest.dto.fms.Gff3DTO; +import org.alliancegenome.curation_api.response.APIResponse; +import org.alliancegenome.curation_api.response.LoadHistoryResponce; +import org.alliancegenome.curation_api.services.CodingSequenceService; +import org.alliancegenome.curation_api.services.Gff3Service; +import org.alliancegenome.curation_api.services.associations.codingSequenceAssociations.CodingSequenceGenomicLocationAssociationService; +import org.alliancegenome.curation_api.services.associations.transcriptAssociations.TranscriptCodingSequenceAssociationService; +import org.alliancegenome.curation_api.services.helpers.gff3.Gff3AttributesHelper; +import org.alliancegenome.curation_api.services.validation.dto.Gff3DtoValidator; +import org.alliancegenome.curation_api.util.ProcessDisplayHelper; +import org.apache.commons.lang3.tuple.ImmutablePair; + +import com.fasterxml.jackson.databind.MappingIterator; +import com.fasterxml.jackson.dataformat.csv.CsvMapper; +import com.fasterxml.jackson.dataformat.csv.CsvParser; +import com.fasterxml.jackson.dataformat.csv.CsvSchema; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; + +@ApplicationScoped +public class Gff3CDSExecutor extends Gff3Executor { + + @Inject Gff3Service gff3Service; + @Inject CodingSequenceService cdsService; + @Inject Gff3DtoValidator gff3DtoValidator; + @Inject CodingSequenceGenomicLocationAssociationService cdsLocationService; + @Inject TranscriptCodingSequenceAssociationService transcriptCdsService; + + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory) { + try { + + CsvSchema gff3Schema = CsvSchemaBuilder.gff3Schema(); + CsvMapper csvMapper = new CsvMapper(); + MappingIterator it = csvMapper.enable(CsvParser.Feature.INSERT_NULLS_FOR_MISSING_COLUMNS).readerFor(Gff3DTO.class).with(gff3Schema).readValues(new GZIPInputStream(new FileInputStream(bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath()))); + List gffData = it.readAll(); + List gffHeaderData = new ArrayList<>(); + for (Gff3DTO gffLine : gffData) { + if (gffLine.getSeqId().startsWith("#")) { + gffHeaderData.add(gffLine.getSeqId()); + } else { + break; + } + } + gffData.subList(0, gffHeaderData.size()).clear(); + + BulkFMSLoad fmsLoad = (BulkFMSLoad) bulkLoadFileHistory.getBulkLoad(); + BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(fmsLoad.getFmsDataSubType()); + + List>> preProcessedCDSGffData = Gff3AttributesHelper.getCDSGffData(gffData, dataProvider); + + gffData.clear(); + + List entityIdsAdded = new ArrayList<>(); + List locationIdsAdded = new ArrayList<>(); + List associationIdsAdded = new ArrayList<>(); + + String assemblyId = loadGenomeAssemblyFromGFF(gffHeaderData); + + if (assemblyId == null) { + addException(bulkLoadFileHistory, new ObjectUpdateExceptionData(null, "GFF Header does not contain assembly", null)); + } + + boolean success = runLoad(bulkLoadFileHistory, gffHeaderData, preProcessedCDSGffData, entityIdsAdded, locationIdsAdded, associationIdsAdded, dataProvider, assemblyId); + + if (success) { + runCleanup(cdsService, bulkLoadFileHistory, dataProvider.name(), cdsService.getIdsByDataProvider(dataProvider), entityIdsAdded, "GFF coding sequence"); + runCleanup(cdsLocationService, bulkLoadFileHistory, dataProvider.name(), cdsLocationService.getIdsByDataProvider(dataProvider), locationIdsAdded, "GFF coding sequence genomic location association"); + runCleanup(transcriptCdsService, bulkLoadFileHistory, dataProvider.name(), transcriptCdsService.getIdsByDataProvider(dataProvider), associationIdsAdded, "GFF transcript coding sequence association"); + } + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + private boolean runLoad( + BulkLoadFileHistory history, + List gffHeaderData, + List>> gffData, + List entityIdsAdded, + List locationIdsAdded, + List associationIdsAdded, + BackendBulkDataProvider dataProvider, String assemblyId) { + + ProcessDisplayHelper ph = new ProcessDisplayHelper(); + ph.addDisplayHandler(loadProcessDisplayService); + ph.startProcess("GFF CDS update for " + dataProvider.name(), gffData.size()); + + history.setCount("Entities", gffData.size()); + history.setCount("Locations", gffData.size()); + history.setCount("Associations", gffData.size()); + updateHistory(history); + + String countType = null; + for (ImmutablePair> gff3EntryPair : gffData) { + + countType = "Entities"; + try { + gff3DtoValidator.validateCdsEntry(gff3EntryPair.getKey(), gff3EntryPair.getValue(), entityIdsAdded, dataProvider); + history.incrementCompleted(countType); + } catch (ObjectUpdateException e) { + history.incrementFailed(countType); + addException(history, e.getData()); + } catch (Exception e) { + e.printStackTrace(); + history.incrementFailed(countType); + addException(history, new ObjectUpdateExceptionData(gff3EntryPair.getKey(), e.getMessage(), e.getStackTrace())); + } + if (assemblyId != null) { + countType = "Locations"; + try { + gff3Service.loadCDSLocationAssociations(gff3EntryPair, locationIdsAdded, dataProvider, assemblyId); + history.incrementCompleted(countType); + } catch (ObjectUpdateException e) { + history.incrementFailed(countType); + addException(history, e.getData()); + } catch (Exception e) { + e.printStackTrace(); + history.incrementFailed(countType); + addException(history, new ObjectUpdateExceptionData(gff3EntryPair.getKey(), e.getMessage(), e.getStackTrace())); + } + } + countType = "Associations"; + try { + gff3Service.loadCDSParentChildAssociations(gff3EntryPair, associationIdsAdded, dataProvider); + history.incrementCompleted(countType); + } catch (ObjectUpdateException e) { + history.incrementFailed(countType); + addException(history, e.getData()); + } catch (Exception e) { + e.printStackTrace(); + history.incrementFailed(countType); + addException(history, new ObjectUpdateExceptionData(gff3EntryPair.getKey(), e.getMessage(), e.getStackTrace())); + } + ph.progressProcess(); + } + updateHistory(history); + ph.finishProcess(); + return true; + } + + public APIResponse runLoadApi(String dataProviderName, String assemblyName, List gffData) { + List idsAdded = new ArrayList<>(); + BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(dataProviderName); + List>> preProcessedCDSGffData = Gff3AttributesHelper.getCDSGffData(gffData, dataProvider); + BulkLoadFileHistory history = new BulkLoadFileHistory(); + history = bulkLoadFileHistoryDAO.persist(history); + runLoad(history, null, preProcessedCDSGffData, idsAdded, idsAdded, idsAdded, dataProvider, assemblyName); + history.finishLoad(); + + return new LoadHistoryResponce(history); + } + +} diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/gff/Gff3Executor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/gff/Gff3Executor.java new file mode 100644 index 000000000..f4183aced --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/gff/Gff3Executor.java @@ -0,0 +1,27 @@ +package org.alliancegenome.curation_api.jobs.executors.gff; + +import java.util.List; + +import org.alliancegenome.curation_api.exceptions.ValidationException; +import org.alliancegenome.curation_api.jobs.executors.LoadFileExecutor; +import org.alliancegenome.curation_api.services.Gff3Service; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; + +@ApplicationScoped +public class Gff3Executor extends LoadFileExecutor { + + @Inject Gff3Service gff3Service; + + public String loadGenomeAssemblyFromGFF(List gffHeaderData) throws ValidationException { + for (String header : gffHeaderData) { + if (header.startsWith("#!assembly")) { + String assemblyName = header.split(" ")[1]; + return assemblyName; + } + } + return null; + } + +} diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/gff/Gff3ExonExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/gff/Gff3ExonExecutor.java new file mode 100644 index 000000000..74454531e --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/gff/Gff3ExonExecutor.java @@ -0,0 +1,177 @@ +package org.alliancegenome.curation_api.jobs.executors.gff; + +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.zip.GZIPInputStream; + +import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ObjectUpdateException.ObjectUpdateExceptionData; +import org.alliancegenome.curation_api.jobs.util.CsvSchemaBuilder; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkFMSLoad; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; +import org.alliancegenome.curation_api.model.ingest.dto.fms.Gff3DTO; +import org.alliancegenome.curation_api.response.APIResponse; +import org.alliancegenome.curation_api.response.LoadHistoryResponce; +import org.alliancegenome.curation_api.services.ExonService; +import org.alliancegenome.curation_api.services.associations.exonAssociations.ExonGenomicLocationAssociationService; +import org.alliancegenome.curation_api.services.associations.transcriptAssociations.TranscriptExonAssociationService; +import org.alliancegenome.curation_api.services.helpers.gff3.Gff3AttributesHelper; +import org.alliancegenome.curation_api.services.validation.dto.Gff3DtoValidator; +import org.alliancegenome.curation_api.util.ProcessDisplayHelper; +import org.apache.commons.lang3.tuple.ImmutablePair; + +import com.fasterxml.jackson.databind.MappingIterator; +import com.fasterxml.jackson.dataformat.csv.CsvMapper; +import com.fasterxml.jackson.dataformat.csv.CsvParser; +import com.fasterxml.jackson.dataformat.csv.CsvSchema; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; + +@ApplicationScoped +public class Gff3ExonExecutor extends Gff3Executor { + + @Inject ExonService exonService; + @Inject ExonGenomicLocationAssociationService exonLocationService; + @Inject TranscriptExonAssociationService transcriptExonService; + @Inject Gff3DtoValidator gff3DtoValidator; + + + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory) { + try { + + CsvSchema gff3Schema = CsvSchemaBuilder.gff3Schema(); + CsvMapper csvMapper = new CsvMapper(); + MappingIterator it = csvMapper.enable(CsvParser.Feature.INSERT_NULLS_FOR_MISSING_COLUMNS).readerFor(Gff3DTO.class).with(gff3Schema).readValues(new GZIPInputStream(new FileInputStream(bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath()))); + List gffData = it.readAll(); + List gffHeaderData = new ArrayList<>(); + for (Gff3DTO gffLine : gffData) { + if (gffLine.getSeqId().startsWith("#")) { + gffHeaderData.add(gffLine.getSeqId()); + } else { + break; + } + } + gffData.subList(0, gffHeaderData.size()).clear(); + + BulkFMSLoad fmsLoad = (BulkFMSLoad) bulkLoadFileHistory.getBulkLoad(); + BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(fmsLoad.getFmsDataSubType()); + + List>> preProcessedExonGffData = Gff3AttributesHelper.getExonGffData(gffData, dataProvider); + + gffData.clear(); + + List entityIdsAdded = new ArrayList<>(); + List locationIdsAdded = new ArrayList<>(); + List associationIdsAdded = new ArrayList<>(); + + + String assemblyId = loadGenomeAssemblyFromGFF(gffHeaderData); + + if (assemblyId == null) { + addException(bulkLoadFileHistory, new ObjectUpdateExceptionData(null, "GFF Header does not contain assembly", null)); + } + + boolean success = runLoad(bulkLoadFileHistory, gffHeaderData, preProcessedExonGffData, entityIdsAdded, locationIdsAdded, associationIdsAdded, dataProvider, assemblyId); + if (success) { + runCleanup(exonService, bulkLoadFileHistory, dataProvider.name(), exonService.getIdsByDataProvider(dataProvider), entityIdsAdded, "GFF exon"); + runCleanup(exonLocationService, bulkLoadFileHistory, dataProvider.name(), exonLocationService.getIdsByDataProvider(dataProvider), locationIdsAdded, "GFF exon genomic location association"); + runCleanup(transcriptExonService, bulkLoadFileHistory, dataProvider.name(), transcriptExonService.getIdsByDataProvider(dataProvider), associationIdsAdded, "GFF transcript exon association"); + } + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + + private boolean runLoad( + BulkLoadFileHistory history, + List gffHeaderData, + List>> gffData, + List entityIdsAdded, + List locationIdsAdded, + List associationIdsAdded, + BackendBulkDataProvider dataProvider, String assemblyId) { + + ProcessDisplayHelper ph = new ProcessDisplayHelper(); + ph.addDisplayHandler(loadProcessDisplayService); + ph.startProcess("GFF Exon update for " + dataProvider.name(), gffData.size()); + + history.setCount("Entities", gffData.size()); + history.setCount("Locations", gffData.size()); + history.setCount("Associations", gffData.size()); + updateHistory(history); + + String countType = null; + for (ImmutablePair> gff3EntryPair : gffData) { + + countType = "Entities"; + try { + gff3DtoValidator.validateExonEntry(gff3EntryPair.getKey(), gff3EntryPair.getValue(), entityIdsAdded, dataProvider); + + history.incrementCompleted(countType); + } catch (ObjectUpdateException e) { + history.incrementFailed(countType); + addException(history, e.getData()); + } catch (Exception e) { + e.printStackTrace(); + history.incrementFailed(countType); + addException(history, new ObjectUpdateExceptionData(gff3EntryPair.getKey(), e.getMessage(), e.getStackTrace())); + } + + if (assemblyId != null) { + countType = "Locations"; + try { + gff3Service.loadExonLocationAssociations(gff3EntryPair, locationIdsAdded, dataProvider, assemblyId); + history.incrementCompleted(countType); + } catch (ObjectUpdateException e) { + history.incrementFailed(countType); + addException(history, e.getData()); + } catch (Exception e) { + e.printStackTrace(); + history.incrementFailed(countType); + addException(history, new ObjectUpdateExceptionData(gff3EntryPair.getKey(), e.getMessage(), e.getStackTrace())); + } + } + + countType = "Associations"; + try { + gff3Service.loadExonParentChildAssociations(gff3EntryPair, associationIdsAdded, dataProvider); + history.incrementCompleted(countType); + } catch (ObjectUpdateException e) { + history.incrementFailed(countType); + addException(history, e.getData()); + } catch (Exception e) { + e.printStackTrace(); + history.incrementFailed(countType); + addException(history, new ObjectUpdateExceptionData(gff3EntryPair.getKey(), e.getMessage(), e.getStackTrace())); + } + + ph.progressProcess(); + } + updateHistory(history); + ph.finishProcess(); + return true; + } + + public APIResponse runLoadApi(String dataProviderName, String assemblyName, List gffData) { + List idsAdded = new ArrayList(); + BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(dataProviderName); + List>> preProcessedExonGffData = Gff3AttributesHelper.getExonGffData(gffData, dataProvider); + BulkLoadFileHistory history = new BulkLoadFileHistory(); + history = bulkLoadFileHistoryDAO.persist(history); + runLoad(history, null, preProcessedExonGffData, idsAdded, idsAdded, idsAdded, dataProvider, assemblyName); + history.finishLoad(); + + return new LoadHistoryResponce(history); + } + + +} diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/executors/gff/Gff3TranscriptExecutor.java b/src/main/java/org/alliancegenome/curation_api/jobs/executors/gff/Gff3TranscriptExecutor.java new file mode 100644 index 000000000..d08d391d9 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/jobs/executors/gff/Gff3TranscriptExecutor.java @@ -0,0 +1,175 @@ +package org.alliancegenome.curation_api.jobs.executors.gff; + +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.zip.GZIPInputStream; + +import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ObjectUpdateException.ObjectUpdateExceptionData; +import org.alliancegenome.curation_api.jobs.util.CsvSchemaBuilder; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkFMSLoad; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; +import org.alliancegenome.curation_api.model.ingest.dto.fms.Gff3DTO; +import org.alliancegenome.curation_api.response.APIResponse; +import org.alliancegenome.curation_api.response.LoadHistoryResponce; +import org.alliancegenome.curation_api.services.TranscriptService; +import org.alliancegenome.curation_api.services.associations.transcriptAssociations.TranscriptGeneAssociationService; +import org.alliancegenome.curation_api.services.associations.transcriptAssociations.TranscriptGenomicLocationAssociationService; +import org.alliancegenome.curation_api.services.helpers.gff3.Gff3AttributesHelper; +import org.alliancegenome.curation_api.services.validation.dto.Gff3DtoValidator; +import org.alliancegenome.curation_api.util.ProcessDisplayHelper; +import org.apache.commons.lang3.tuple.ImmutablePair; + +import com.fasterxml.jackson.databind.MappingIterator; +import com.fasterxml.jackson.dataformat.csv.CsvMapper; +import com.fasterxml.jackson.dataformat.csv.CsvParser; +import com.fasterxml.jackson.dataformat.csv.CsvSchema; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; + +@ApplicationScoped +public class Gff3TranscriptExecutor extends Gff3Executor { + + @Inject TranscriptService transcriptService; + @Inject TranscriptGenomicLocationAssociationService transcriptLocationService; + @Inject TranscriptGeneAssociationService transcriptGeneService; + @Inject Gff3DtoValidator gff3DtoValidator; + + public void execLoad(BulkLoadFileHistory bulkLoadFileHistory) { + try { + + CsvSchema gff3Schema = CsvSchemaBuilder.gff3Schema(); + CsvMapper csvMapper = new CsvMapper(); + MappingIterator it = csvMapper.enable(CsvParser.Feature.INSERT_NULLS_FOR_MISSING_COLUMNS).readerFor(Gff3DTO.class).with(gff3Schema).readValues(new GZIPInputStream(new FileInputStream(bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath()))); + List gffData = it.readAll(); + List gffHeaderData = new ArrayList<>(); + for (Gff3DTO gffLine : gffData) { + if (gffLine.getSeqId().startsWith("#")) { + gffHeaderData.add(gffLine.getSeqId()); + } else { + break; + } + } + gffData.subList(0, gffHeaderData.size()).clear(); + + BulkFMSLoad fmsLoad = (BulkFMSLoad) bulkLoadFileHistory.getBulkLoad(); + BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(fmsLoad.getFmsDataSubType()); + + List>> preProcessedTranscriptGffData = Gff3AttributesHelper.getTranscriptGffData(gffData, dataProvider); + Map geneIdCurieMap = gff3Service.getGeneIdCurieMap(gffData, dataProvider); + + gffData.clear(); + + List entityIdsAdded = new ArrayList<>(); + List locationIdsAdded = new ArrayList<>(); + List associationIdsAdded = new ArrayList<>(); + + String assemblyId = loadGenomeAssemblyFromGFF(gffHeaderData); + + if (assemblyId == null) { + addException(bulkLoadFileHistory, new ObjectUpdateExceptionData(null, "GFF Header does not contain assembly", null)); + } + + boolean success = runLoad(bulkLoadFileHistory, gffHeaderData, preProcessedTranscriptGffData, geneIdCurieMap, entityIdsAdded, locationIdsAdded, associationIdsAdded, dataProvider, assemblyId); + + if (success) { + runCleanup(transcriptService, bulkLoadFileHistory, dataProvider.name(), transcriptService.getIdsByDataProvider(dataProvider), entityIdsAdded, "GFF transcript"); + runCleanup(transcriptLocationService, bulkLoadFileHistory, dataProvider.name(), transcriptLocationService.getIdsByDataProvider(dataProvider), locationIdsAdded, "GFF transcript genomic location association"); + runCleanup(transcriptGeneService, bulkLoadFileHistory, dataProvider.name(), transcriptGeneService.getIdsByDataProvider(dataProvider), associationIdsAdded, "GFF transcript gene association"); + } + bulkLoadFileHistory.finishLoad(); + updateHistory(bulkLoadFileHistory); + updateExceptions(bulkLoadFileHistory); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + private boolean runLoad( + BulkLoadFileHistory history, + List gffHeaderData, + List>> gffData, + Map geneIdCurieMap, + List entityIdsAdded, + List locationIdsAdded, + List associationIdsAdded, + BackendBulkDataProvider dataProvider, + String assemblyId) { + + ProcessDisplayHelper ph = new ProcessDisplayHelper(); + ph.addDisplayHandler(loadProcessDisplayService); + ph.startProcess("GFF Transcript update for " + dataProvider.name(), gffData.size()); + + history.setCount("Entities", gffData.size()); + history.setCount("Locations", gffData.size()); + history.setCount("Associations", gffData.size()); + updateHistory(history); + + String countType = null; + for (ImmutablePair> gff3EntryPair : gffData) { + countType = "Entities"; + try { + gff3DtoValidator.validateTranscriptEntry(gff3EntryPair.getKey(), gff3EntryPair.getValue(), entityIdsAdded, dataProvider); + history.incrementCompleted(countType); + } catch (ObjectUpdateException e) { + history.incrementFailed(countType); + addException(history, e.getData()); + } catch (Exception e) { + e.printStackTrace(); + history.incrementFailed(countType); + addException(history, new ObjectUpdateExceptionData(gff3EntryPair.getKey(), e.getMessage(), e.getStackTrace())); + } + + if (assemblyId != null) { + countType = "Locations"; + try { + gff3Service.loadTranscriptLocationAssociations(gff3EntryPair, locationIdsAdded, dataProvider, assemblyId); + history.incrementCompleted(countType); + } catch (ObjectUpdateException e) { + history.incrementFailed(countType); + addException(history, e.getData()); + } catch (Exception e) { + e.printStackTrace(); + history.incrementFailed(countType); + addException(history, new ObjectUpdateExceptionData(gff3EntryPair.getKey(), e.getMessage(), e.getStackTrace())); + } + } + countType = "Associations"; + try { + gff3Service.loadGeneParentChildAssociations(gff3EntryPair, associationIdsAdded, dataProvider, geneIdCurieMap); + history.incrementCompleted(countType); + } catch (ObjectUpdateException e) { + history.incrementFailed(countType); + addException(history, e.getData()); + } catch (Exception e) { + e.printStackTrace(); + history.incrementFailed(countType); + addException(history, new ObjectUpdateExceptionData(gff3EntryPair.getKey(), e.getMessage(), e.getStackTrace())); + } + ph.progressProcess(); + } + updateHistory(history); + ph.finishProcess(); + return true; + } + + public APIResponse runLoadApi(String dataProviderName, String assemblyName, List gffData) { + List idsAdded = new ArrayList<>(); + BackendBulkDataProvider dataProvider = BackendBulkDataProvider.valueOf(dataProviderName); + List>> preProcessedTranscriptGffData = Gff3AttributesHelper.getTranscriptGffData(gffData, dataProvider); + Map geneIdCurieMap = gff3Service.getGeneIdCurieMap(gffData, dataProvider); + BulkLoadFileHistory history = new BulkLoadFileHistory(); + history = bulkLoadFileHistoryDAO.persist(history); + runLoad(history, null, preProcessedTranscriptGffData, geneIdCurieMap, idsAdded, idsAdded, idsAdded, dataProvider, assemblyName); + history.finishLoad(); + + return new LoadHistoryResponce(history); + } + + +} diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadFMSProcessor.java b/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadFMSProcessor.java index ddc80dd89..295447b90 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadFMSProcessor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadFMSProcessor.java @@ -10,18 +10,18 @@ import io.quarkus.logging.Log; import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.event.Observes; +import jakarta.enterprise.event.ObservesAsync; import lombok.extern.jbosslog.JBossLog; @JBossLog @ApplicationScoped public class BulkLoadFMSProcessor extends BulkLoadProcessor { - public void processBulkFMSLoad(@Observes StartedBulkLoadJobEvent load) { + public void processBulkFMSLoad(@ObservesAsync StartedBulkLoadJobEvent load) { BulkLoad bulkLoad = bulkLoadDAO.find(load.getId()); if (bulkLoad instanceof BulkFMSLoad bulkFMSLoad) { - Log.info("processBulkFMSLoad: " + load.getId()); + Log.debug("processBulkFMSLoad: " + load.getId()); startLoad(bulkFMSLoad); if (bulkFMSLoad.getFmsDataType() != null && bulkFMSLoad.getFmsDataSubType() != null) { diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadManualProcessor.java b/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadManualProcessor.java index 2108f9159..7017f9efc 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadManualProcessor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadManualProcessor.java @@ -16,17 +16,15 @@ import io.quarkus.logging.Log; import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.event.Observes; -import lombok.extern.jbosslog.JBossLog; +import jakarta.enterprise.event.ObservesAsync; -@JBossLog @ApplicationScoped public class BulkLoadManualProcessor extends BulkLoadProcessor { - public void processBulkManualLoad(@Observes StartedBulkLoadJobEvent load) { + public void processBulkManualLoad(@ObservesAsync StartedBulkLoadJobEvent load) { BulkLoad bulkLoad = bulkLoadDAO.find(load.getId()); if (bulkLoad instanceof BulkManualLoad bulkURLLoad) { - Log.info("processBulkManualLoad: " + load.getId()); + Log.debug("processBulkManualLoad: " + load.getId()); // We do nothing because at the load level we don't try to figure out what the // next file to run is } @@ -36,7 +34,7 @@ public void processBulkManualLoadFromDQM(MultipartFormDataInput input, BackendBu Map> form = input.getFormDataMap(); if (form.containsKey(loadType)) { - log.warn("Key not found: " + loadType); + Log.warn("Key not found: " + loadType); return; } @@ -59,7 +57,7 @@ public void processBulkManualLoadFromDQM(MultipartFormDataInput input, BackendBu endLoad(bulkManualLoad, null, JobStatus.FINISHED); } else { - log.warn("BulkManualLoad not found: " + loadType); + Log.warn("BulkManualLoad not found: " + loadType); endLoad(bulkManualLoad, "BulkManualLoad not found: " + loadType, JobStatus.FAILED); } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadProcessor.java b/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadProcessor.java index d67a683b7..86c18ec11 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadProcessor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadProcessor.java @@ -1,20 +1,22 @@ package org.alliancegenome.curation_api.jobs.processors; import java.io.File; -import java.time.OffsetDateTime; +import java.time.LocalDateTime; import org.alliancegenome.curation_api.dao.loads.BulkFMSLoadDAO; import org.alliancegenome.curation_api.dao.loads.BulkLoadDAO; import org.alliancegenome.curation_api.dao.loads.BulkLoadFileDAO; +import org.alliancegenome.curation_api.dao.loads.BulkLoadFileHistoryDAO; import org.alliancegenome.curation_api.dao.loads.BulkManualLoadDAO; import org.alliancegenome.curation_api.dao.loads.BulkURLLoadDAO; import org.alliancegenome.curation_api.enums.BulkLoadCleanUp; import org.alliancegenome.curation_api.enums.JobStatus; -import org.alliancegenome.curation_api.jobs.events.PendingBulkLoadFileJobEvent; +import org.alliancegenome.curation_api.jobs.events.PendingLoadJobEvent; import org.alliancegenome.curation_api.jobs.executors.BulkLoadJobExecutor; import org.alliancegenome.curation_api.jobs.util.SlackNotifier; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoad; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.response.SearchResponse; import org.alliancegenome.curation_api.services.fms.DataFileService; import org.alliancegenome.curation_api.util.FileTransferHelper; @@ -34,8 +36,11 @@ public class BulkLoadProcessor { @Inject DataFileService fmsDataFileService; @Inject BulkLoadDAO bulkLoadDAO; - @Inject BulkManualLoadDAO bulkManualLoadDAO; @Inject BulkLoadFileDAO bulkLoadFileDAO; + @Inject BulkLoadFileHistoryDAO bulkLoadFileHistoryDAO; + + + @Inject BulkManualLoadDAO bulkManualLoadDAO; @Inject BulkFMSLoadDAO bulkFMSLoadDAO; @Inject BulkURLLoadDAO bulkURLLoadDAO; @@ -43,53 +48,45 @@ public class BulkLoadProcessor { @Inject SlackNotifier slackNotifier; - @Inject Event pendingFileJobEvents; + @Inject Event pendingFileJobEvents; protected FileTransferHelper fileHelper = new FileTransferHelper(); -// private String processFMS(String dataType, String dataSubType) { -// List files = fmsDataFileService.getDataFiles(dataType, dataSubType); -// -// if (files.size() == 1) { -// DataFile df = files.get(0); -// return df.getS3Url(); -// } else { -// Log.warn("Files: " + files); -// Log.warn("Issue pulling files from the FMS: " + dataType + " " + dataSubType); -// } -// return null; -// } - - public void syncWithS3(BulkLoadFile bulkLoadFile) { - Log.info("Syncing with S3"); - Log.info("Local: " + bulkLoadFile.getLocalFilePath()); - Log.info("S3: " + bulkLoadFile.getS3Path()); - - if ((bulkLoadFile.getS3Path() != null || bulkLoadFile.generateS3MD5Path() != null) && bulkLoadFile.getLocalFilePath() == null) { + public void syncWithS3(BulkLoadFileHistory bulkLoadFileHistory) { + BulkLoad bulkLoad = bulkLoadFileHistory.getBulkLoad(); + BulkLoadFile bulkLoadFile = bulkLoadFileHistory.getBulkLoadFile(); + Log.info("Starting Syncing with S3: Local File: " + bulkLoadFile.getLocalFilePath() + " S3 File: " + bulkLoadFile.getS3Path()); + + if ((bulkLoadFile.getS3Path() != null || bulkLoadFile.generateS3MD5Path(bulkLoad) != null) && bulkLoadFile.getLocalFilePath() == null) { File outfile = fileHelper.downloadFileFromS3(s3AccessKey, s3SecretKey, s3Bucket, bulkLoadFile.getS3Path()); if (outfile != null) { // log.info(outfile + " is of size: " + outfile.length()); bulkLoadFile.setFileSize(outfile.length()); bulkLoadFile.setLocalFilePath(outfile.getAbsolutePath()); + bulkLoadFileDAO.merge(bulkLoadFile); } else { // log.error("Failed to download file from S3 Path: " + s3PathPrefix + "/" + // bulkLoadFile.generateS3MD5Path()); - bulkLoadFile.setErrorMessage("Failed to download file from S3 Path: " + s3PathPrefix + "/" + bulkLoadFile.generateS3MD5Path()); - bulkLoadFile.setBulkloadStatus(JobStatus.FAILED); - slackNotifier.slackalert(bulkLoadFile); + bulkLoadFileHistory.setErrorMessage("Failed to download file from S3 Path: " + s3PathPrefix + "/" + bulkLoadFile.generateS3MD5Path(bulkLoad)); + bulkLoadFileHistory.setBulkloadStatus(JobStatus.FAILED); + slackNotifier.slackalert(bulkLoadFileHistory); + bulkLoadFileHistoryDAO.merge(bulkLoadFileHistory); } // log.info("Saving File: " + bulkLoadFile); - bulkLoadFileDAO.merge(bulkLoadFile); + } else if (bulkLoadFile.getS3Path() == null && bulkLoadFile.getLocalFilePath() != null) { if (s3AccessKey != null && s3AccessKey.length() > 0) { - String s3Path = fileHelper.uploadFileToS3(s3AccessKey, s3SecretKey, s3Bucket, s3PathPrefix, bulkLoadFile.generateS3MD5Path(), new File(bulkLoadFile.getLocalFilePath())); + String s3Path = fileHelper.uploadFileToS3(s3AccessKey, s3SecretKey, s3Bucket, s3PathPrefix, bulkLoadFile.generateS3MD5Path(bulkLoad), new File(bulkLoadFile.getLocalFilePath())); bulkLoadFile.setS3Path(s3Path); } bulkLoadFileDAO.merge(bulkLoadFile); } else if (bulkLoadFile.getS3Path() == null && bulkLoadFile.getLocalFilePath() == null) { - bulkLoadFile.setErrorMessage("Failed to download or upload file with S3 Path: " + s3PathPrefix + "/" + bulkLoadFile.generateS3MD5Path() + " Local and remote file missing"); - bulkLoadFile.setBulkloadStatus(JobStatus.FAILED); - slackNotifier.slackalert(bulkLoadFile); + bulkLoadFileHistory.setErrorMessage("Failed to download or upload file with S3 Path: " + s3PathPrefix + "/" + bulkLoadFile.generateS3MD5Path(bulkLoad) + " Local and remote file missing"); + bulkLoadFileHistory.setBulkloadStatus(JobStatus.FAILED); + slackNotifier.slackalert(bulkLoadFileHistory); + bulkLoadFileHistoryDAO.merge(bulkLoadFileHistory); + } else { + Log.info("No S3 syncing required"); } Log.info("Syncing with S3 Finished"); } @@ -108,21 +105,23 @@ protected void processFilePath(BulkLoad bulkLoad, String localFilePath, Boolean SearchResponse bulkLoadFiles = bulkLoadFileDAO.findByField("md5Sum", md5Sum); BulkLoadFile bulkLoadFile; + + BulkLoadFileHistory history = new BulkLoadFileHistory(); if (bulkLoadFiles == null || bulkLoadFiles.getResults().size() == 0) { Log.info("Bulk File does not exist creating it"); bulkLoadFile = new BulkLoadFile(); - bulkLoadFile.setBulkLoad(load); bulkLoadFile.setMd5Sum(md5Sum); bulkLoadFile.setFileSize(inputFile.length()); + if (load.getBulkloadStatus() == JobStatus.FORCED_RUNNING) { - bulkLoadFile.setBulkloadStatus(JobStatus.FORCED_PENDING); + history.setBulkloadStatus(JobStatus.FORCED_PENDING); } if (load.getBulkloadStatus() == JobStatus.SCHEDULED_RUNNING) { - bulkLoadFile.setBulkloadStatus(JobStatus.SCHEDULED_PENDING); + history.setBulkloadStatus(JobStatus.SCHEDULED_PENDING); } if (load.getBulkloadStatus() == JobStatus.MANUAL_RUNNING) { - bulkLoadFile.setBulkloadStatus(JobStatus.MANUAL_PENDING); + history.setBulkloadStatus(JobStatus.MANUAL_PENDING); } Log.info(load.getBulkloadStatus()); @@ -134,10 +133,10 @@ protected void processFilePath(BulkLoad bulkLoad, String localFilePath, Boolean bulkLoadFileDAO.persist(bulkLoadFile); } else if (load.getBulkloadStatus().isForced()) { bulkLoadFile = bulkLoadFiles.getResults().get(0); - if (bulkLoadFile.getBulkloadStatus().isNotRunning()) { + if (history.getBulkloadStatus().isNotRunning()) { bulkLoadFile.setLocalFilePath(localFilePath); - bulkLoadFile.setErrorMessage(null); - bulkLoadFile.setBulkloadStatus(JobStatus.FORCED_PENDING); + history.setErrorMessage(null); + history.setBulkloadStatus(JobStatus.FORCED_PENDING); } else { Log.warn("Bulk File is already running: " + bulkLoadFile.getMd5Sum()); Log.info("Cleaning up downloaded file: " + localFilePath); @@ -150,17 +149,18 @@ protected void processFilePath(BulkLoad bulkLoad, String localFilePath, Boolean new File(localFilePath).delete(); bulkLoadFile.setLocalFilePath(null); } + + history.setBulkLoad(bulkLoad); + history.setBulkLoadFile(bulkLoadFile); + bulkLoadFileHistoryDAO.persist(history); - if (!load.getLoadFiles().contains(bulkLoadFile)) { - load.getLoadFiles().add(bulkLoadFile); - } if (cleanUp) { bulkLoadFile.setBulkloadCleanUp(BulkLoadCleanUp.YES); } bulkLoadFileDAO.merge(bulkLoadFile); bulkLoadDAO.merge(load); - Log.info("Firing Pending Bulk File Event: " + bulkLoadFile.getId()); - pendingFileJobEvents.fire(new PendingBulkLoadFileJobEvent(bulkLoadFile.getId())); + Log.info("Firing Pending Bulk File History Event: " + history.getId()); + pendingFileJobEvents.fireAsync(new PendingLoadJobEvent(history.getId())); } protected void startLoad(BulkLoad load) { @@ -187,26 +187,34 @@ protected void endLoad(BulkLoad load, String message, JobStatus status) { Log.info("Load: " + bulkLoad.getName() + " is finished"); } - protected void startLoadFile(BulkLoadFile bulkLoadFile) { - bulkLoadFile.setBulkloadStatus(bulkLoadFile.getBulkloadStatus().getNextStatus()); - bulkLoadFileDAO.merge(bulkLoadFile); - Log.info("Load File: " + bulkLoadFile.getMd5Sum() + " is running with file: " + bulkLoadFile.getLocalFilePath()); + protected void startLoad(BulkLoadFileHistory bulkLoadFileHistory) { + bulkLoadFileHistory.setBulkloadStatus(bulkLoadFileHistory.getBulkloadStatus().getNextStatus()); + bulkLoadFileHistory.setLoadStarted(LocalDateTime.now()); + bulkLoadFileHistory.setErrorMessage(null); + bulkLoadFileHistory.setLoadFinished(null); + bulkLoadFileHistoryDAO.merge(bulkLoadFileHistory); + bulkLoadFileHistory.getBulkLoad().setBulkloadStatus(bulkLoadFileHistory.getBulkloadStatus()); + bulkLoadDAO.merge(bulkLoadFileHistory.getBulkLoad()); + Log.info("Load File: " + bulkLoadFileHistory.getBulkLoadFile().getMd5Sum() + " is running with file: " + bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath()); } - protected void endLoadFile(BulkLoadFile bulkLoadFile, String message, JobStatus status) { - if (bulkLoadFile.getLocalFilePath() != null) { - Log.info("Removing old input file: " + bulkLoadFile.getLocalFilePath()); - new File(bulkLoadFile.getLocalFilePath()).delete(); - bulkLoadFile.setLocalFilePath(null); + protected void endLoad(BulkLoadFileHistory bulkLoadFileHistory, String message, JobStatus status) { + if (bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath() != null) { + Log.info("Removing old input file: " + bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath()); + new File(bulkLoadFileHistory.getBulkLoadFile().getLocalFilePath()).delete(); + bulkLoadFileHistory.getBulkLoadFile().setLocalFilePath(null); + bulkLoadFileDAO.merge(bulkLoadFileHistory.getBulkLoadFile()); } - bulkLoadFile.setErrorMessage(message); - bulkLoadFile.setBulkloadStatus(status); - bulkLoadFile.setDateLastLoaded(OffsetDateTime.now()); + bulkLoadFileHistory.setErrorMessage(message); + bulkLoadFileHistory.setBulkloadStatus(status); + bulkLoadFileHistory.setLoadFinished(LocalDateTime.now()); if (status != JobStatus.FINISHED) { - slackNotifier.slackalert(bulkLoadFile); + slackNotifier.slackalert(bulkLoadFileHistory); } - bulkLoadFileDAO.merge(bulkLoadFile); - Log.info("Load File: " + bulkLoadFile.getMd5Sum() + " is finished. Message: " + message + " Status: " + status); + bulkLoadFileHistoryDAO.merge(bulkLoadFileHistory); + bulkLoadFileHistory.getBulkLoad().setBulkloadStatus(status); + bulkLoadDAO.merge(bulkLoadFileHistory.getBulkLoad()); + Log.info("Load File: " + bulkLoadFileHistory.getBulkLoadFile().getMd5Sum() + " is finished. Message: " + message + " Status: " + status); } } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadURLProcessor.java b/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadURLProcessor.java index 822cc5a79..3a46f9a22 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadURLProcessor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/processors/BulkLoadURLProcessor.java @@ -8,17 +8,15 @@ import io.quarkus.logging.Log; import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.event.Observes; +import jakarta.enterprise.event.ObservesAsync; import jakarta.inject.Inject; -import lombok.extern.jbosslog.JBossLog; -@JBossLog @ApplicationScoped public class BulkLoadURLProcessor extends BulkLoadProcessor { @Inject BulkLoadDAO bulkLoadDAO; - public void processBulkURLLoad(@Observes StartedBulkLoadJobEvent load) { + public void processBulkURLLoad(@ObservesAsync StartedBulkLoadJobEvent load) { BulkLoad bulkLoad = bulkLoadDAO.find(load.getId()); if (bulkLoad instanceof BulkURLLoad bulkURLLoad) { @@ -31,17 +29,17 @@ public void processBulkURLLoad(@Observes StartedBulkLoadJobEvent load) { String localFilePath = fileHelper.compressInputFile(filePath); if (filePath == null) { - log.info("Load: " + bulkURLLoad.getName() + " failed"); + Log.info("Load: " + bulkURLLoad.getName() + " failed"); endLoad(bulkURLLoad, "Load: " + bulkURLLoad.getName() + " failed: to download URL: " + bulkURLLoad.getBulkloadUrl(), JobStatus.FAILED); } else if (localFilePath == null) { - log.info("Load: " + bulkURLLoad.getName() + " failed"); + Log.info("Load: " + bulkURLLoad.getName() + " failed"); endLoad(bulkURLLoad, "Load: " + bulkURLLoad.getName() + " failed: to save local file: " + filePath, JobStatus.FAILED); } else { processFilePath(bulkURLLoad, localFilePath); endLoad(bulkURLLoad, null, JobStatus.FINISHED); } } else { - log.info("Load: " + bulkURLLoad.getName() + " failed: URL is missing"); + Log.info("Load: " + bulkURLLoad.getName() + " failed: URL is missing"); endLoad(bulkURLLoad, "Load: " + bulkURLLoad.getName() + " failed: URL is missing", JobStatus.FAILED); } } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/processors/StartLoadProcessor.java b/src/main/java/org/alliancegenome/curation_api/jobs/processors/StartLoadProcessor.java index 62b163f9b..ba6fcbf6d 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/processors/StartLoadProcessor.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/processors/StartLoadProcessor.java @@ -1,44 +1,42 @@ package org.alliancegenome.curation_api.jobs.processors; -import org.alliancegenome.curation_api.dao.loads.BulkLoadFileDAO; +import org.alliancegenome.curation_api.dao.loads.BulkLoadFileHistoryDAO; import org.alliancegenome.curation_api.enums.BulkLoadCleanUp; import org.alliancegenome.curation_api.enums.JobStatus; -import org.alliancegenome.curation_api.jobs.events.StartedBulkLoadFileJobEvent; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; +import org.alliancegenome.curation_api.jobs.events.StartedLoadJobEvent; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import io.quarkus.logging.Log; import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.event.Observes; +import jakarta.enterprise.event.ObservesAsync; import jakarta.inject.Inject; @ApplicationScoped public class StartLoadProcessor extends BulkLoadProcessor { - @Inject BulkLoadFileDAO bulkLoadFileDAO; + @Inject BulkLoadFileHistoryDAO bulkLoadFileHistoryDAO; - public void bulkLoadFile(@Observes StartedBulkLoadFileJobEvent event) { // An @Observes method should not be in a super class as then it gets run for - // every child class - BulkLoadFile bulkLoadFile = bulkLoadFileDAO.find(event.getId()); - if (!bulkLoadFile.getBulkloadStatus().isStarted()) { - Log.warn("bulkLoadFile: Job is not started returning: " + bulkLoadFile.getBulkloadStatus()); + public void bulkLoadFile(@ObservesAsync StartedLoadJobEvent event) { // An @Observes method should not be in a super class as then it gets run for every child class + BulkLoadFileHistory bulkLoadFileHistory = bulkLoadFileHistoryDAO.find(event.getId()); + + if (!bulkLoadFileHistory.getBulkloadStatus().isStarted()) { + Log.warn("bulkLoadFileHistory: Job is not started returning: " + bulkLoadFileHistory.getBulkloadStatus()); // endLoad(bulkLoadFile, "Finished ended due to status: " + // bulkLoadFile.getBulkloadStatus(), bulkLoadFile.getBulkloadStatus()); return; } else { - startLoadFile(bulkLoadFile); + startLoad(bulkLoadFileHistory); } try { - if (bulkLoadFile.getLocalFilePath() == null || bulkLoadFile.getS3Path() == null) { - syncWithS3(bulkLoadFile); - } - bulkLoadJobExecutor.process(bulkLoadFile, bulkLoadFile.getBulkloadCleanUp() == BulkLoadCleanUp.YES); - JobStatus status = bulkLoadFile.getBulkloadStatus().equals(JobStatus.FAILED) ? JobStatus.FAILED : JobStatus.FINISHED; - endLoadFile(bulkLoadFile, bulkLoadFile.getErrorMessage(), status); + syncWithS3(bulkLoadFileHistory); + bulkLoadJobExecutor.process(bulkLoadFileHistory, bulkLoadFileHistory.getBulkLoadFile().getBulkloadCleanUp() == BulkLoadCleanUp.YES); + JobStatus status = bulkLoadFileHistory.getBulkloadStatus().equals(JobStatus.FAILED) ? JobStatus.FAILED : JobStatus.FINISHED; + endLoad(bulkLoadFileHistory, bulkLoadFileHistory.getErrorMessage(), status); } catch (Exception e) { - endLoadFile(bulkLoadFile, "Failed loading: " + bulkLoadFile.getBulkLoad().getName() + " please check the logs for more info. " + bulkLoadFile.getErrorMessage(), JobStatus.FAILED); - Log.error("Load File: " + bulkLoadFile.getBulkLoad().getName() + " is failed"); + endLoad(bulkLoadFileHistory, "Failed loading: " + bulkLoadFileHistory.getBulkLoad().getName() + " please check the logs for more info. " + bulkLoadFileHistory.getErrorMessage(), JobStatus.FAILED); + Log.error("Load File: " + bulkLoadFileHistory.getBulkLoad().getName() + " is failed"); e.printStackTrace(); } diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/util/CsvSchemaBuilder.java b/src/main/java/org/alliancegenome/curation_api/jobs/util/CsvSchemaBuilder.java index 677f4579c..28c4bfca0 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/util/CsvSchemaBuilder.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/util/CsvSchemaBuilder.java @@ -59,6 +59,32 @@ public static CsvSchema psiMiTabSchema() { return schema; } + + public static CsvSchema biogridOrcFmsSchema() { + CsvSchema schema = CsvSchema.builder() + .setColumnSeparator('\t') + .setArrayElementSeparator("|") + .setAllowComments(true) + .setNullValue("-") + .disableQuoteChar() + .addColumn("screenId") + .addColumn("identifierId") + .addColumn("identifierType") + .addColumn("officialSymbol") + .addColumn("aliases") + .addColumn("organismId") + .addColumn("organismOfficial") + .addColumn("score1") + .addColumn("score2") + .addColumn("score3") + .addColumn("score4") + .addColumn("score5") + .addColumn("hit") + .addColumn("source") + .build(); + + return schema; + } public static CsvSchema gff3Schema() { CsvSchema schema = CsvSchema.builder() diff --git a/src/main/java/org/alliancegenome/curation_api/jobs/util/SlackNotifier.java b/src/main/java/org/alliancegenome/curation_api/jobs/util/SlackNotifier.java index fd8cbeb32..1a2099773 100644 --- a/src/main/java/org/alliancegenome/curation_api/jobs/util/SlackNotifier.java +++ b/src/main/java/org/alliancegenome/curation_api/jobs/util/SlackNotifier.java @@ -7,7 +7,7 @@ import org.alliancegenome.curation_api.enums.BackendBulkLoadType; import org.alliancegenome.curation_api.enums.JobStatus; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoad; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.eclipse.microprofile.config.inject.ConfigProperty; import com.slack.api.Slack; @@ -84,24 +84,24 @@ public void slackalert(BulkLoad bulkLoad) { } } - public void slackalert(BulkLoadFile bulkLoadFile) { + public void slackalert(BulkLoadFileHistory bulkLoadFileHistory) { - if (bulkLoadFile.getBulkloadStatus() == JobStatus.FAILED) { + if (bulkLoadFileHistory.getBulkloadStatus() == JobStatus.FAILED) { List fields = new ArrayList<>(); - fields.add(new Field("Load Type", String.valueOf(bulkLoadFile.getBulkLoad().getBackendBulkLoadType()), true)); - if (bulkLoadFile.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.ONTOLOGY) { - fields.add(new Field("Ontology Type", String.valueOf(bulkLoadFile.getBulkLoad().getOntologyType()), true)); + fields.add(new Field("Load Type", String.valueOf(bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType()), true)); + if (bulkLoadFileHistory.getBulkLoad().getBackendBulkLoadType() == BackendBulkLoadType.ONTOLOGY) { + fields.add(new Field("Ontology Type", String.valueOf(bulkLoadFileHistory.getBulkLoad().getOntologyType()), true)); } - fields.add(new Field("MD5Sum", bulkLoadFile.getMd5Sum(), true)); - fields.add(new Field("File Size", String.valueOf(bulkLoadFile.getFileSize()), true)); - if (bulkLoadFile.getLinkMLSchemaVersion() != null) { - fields.add(new Field("LinkML Version", bulkLoadFile.getLinkMLSchemaVersion(), true)); + fields.add(new Field("MD5Sum", bulkLoadFileHistory.getBulkLoadFile().getMd5Sum(), true)); + fields.add(new Field("File Size", String.valueOf(bulkLoadFileHistory.getBulkLoadFile().getFileSize()), true)); + if (bulkLoadFileHistory.getBulkLoadFile().getLinkMLSchemaVersion() != null) { + fields.add(new Field("LinkML Version", bulkLoadFileHistory.getBulkLoadFile().getLinkMLSchemaVersion(), true)); } - if (bulkLoadFile.getAllianceMemberReleaseVersion() != null) { - fields.add(new Field("Alliance Member Release Version", bulkLoadFile.getAllianceMemberReleaseVersion(), false)); + if (bulkLoadFileHistory.getBulkLoadFile().getAllianceMemberReleaseVersion() != null) { + fields.add(new Field("Alliance Member Release Version", bulkLoadFileHistory.getBulkLoadFile().getAllianceMemberReleaseVersion(), false)); } - slackalert(bulkLoadFile.getBulkLoad().getGroup().getName(), bulkLoadFile.getBulkLoad().getName(), bulkLoadFile.getErrorMessage(), fields); + slackalert(bulkLoadFileHistory.getBulkLoad().getGroup().getName(), bulkLoadFileHistory.getBulkLoad().getName(), bulkLoadFileHistory.getErrorMessage(), fields); } } } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/main/Main.java b/src/main/java/org/alliancegenome/curation_api/main/Main.java index e3da100a3..7b1c960ee 100644 --- a/src/main/java/org/alliancegenome/curation_api/main/Main.java +++ b/src/main/java/org/alliancegenome/curation_api/main/Main.java @@ -6,14 +6,8 @@ @QuarkusMain public class Main { - - private Main() { - // Hidden from view, as it is a utility class - } - public static void main(String[] args) { Log.info("Running main method of quarkus"); Quarkus.run(args); } - } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/AGMDiseaseAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/AGMDiseaseAnnotation.java index 04a191917..873fc46fb 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/AGMDiseaseAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/AGMDiseaseAnnotation.java @@ -6,8 +6,6 @@ import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.view.View; import org.eclipse.microprofile.openapi.annotations.media.Schema; -import org.hibernate.annotations.Fetch; -import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.OnDelete; import org.hibernate.annotations.OnDeleteAction; import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; @@ -21,6 +19,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToOne; @@ -35,21 +34,19 @@ @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @Schema(name = "AGM_Disease_Annotation", description = "Annotation class representing a agm disease annotation") @JsonTypeName("AGMDiseaseAnnotation") -@OnDelete(action = OnDeleteAction.CASCADE) @AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { DiseaseAnnotation.class }) + @Table(indexes = { - @Index(name = "AGMDiseaseAnnotation_inferredGene_index", columnList = "inferredGene_id"), + @Index(name = "AGMDiseaseAnnotation_diseaseAnnotationSubject_index", columnList = "diseaseAnnotationSubject_id"), @Index(name = "AGMDiseaseAnnotation_inferredAllele_index", columnList = "inferredAllele_id"), - @Index(name = "AGMDiseaseAnnotation_assertedAllele_index", columnList = "assertedAllele_id"), - @Index(name = "AGMDiseaseAnnotation_DiseaseAnnotationSubject_index", columnList = "diseaseAnnotationSubject_id") + @Index(name = "AGMDiseaseAnnotation_inferredGene_index", columnList = "inferredGene_id") }) public class AGMDiseaseAnnotation extends DiseaseAnnotation { @IndexedEmbedded(includePaths = {"name", "name_keyword", "curie", "curie_keyword", "modEntityId", "modEntityId_keyword", "modInternalId", "modInternalId_keyword"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne - @Fetch(FetchMode.SELECT) - @org.hibernate.annotations.OnDelete(action = org.hibernate.annotations.OnDeleteAction.CASCADE) + @OnDelete(action = OnDeleteAction.CASCADE) @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) private AffectedGenomicModel diseaseAnnotationSubject; @@ -63,7 +60,6 @@ public class AGMDiseaseAnnotation extends DiseaseAnnotation { }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne - @Fetch(FetchMode.SELECT) @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) private Gene inferredGene; @@ -76,7 +72,6 @@ public class AGMDiseaseAnnotation extends DiseaseAnnotation { }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne - @Fetch(FetchMode.SELECT) @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) private Allele inferredAllele; @@ -90,8 +85,14 @@ public class AGMDiseaseAnnotation extends DiseaseAnnotation { }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany - @Fetch(FetchMode.SELECT) - @JoinTable(indexes = @Index(name = "agmdiseaseannotation_gene_agmdiseaseannotation_index", columnList = "agmdiseaseannotation_id")) + @JoinTable( + joinColumns = @JoinColumn(name = "agmdiseaseannotation_id"), + inverseJoinColumns = @JoinColumn(name = "assertedgenes_id"), + indexes = { + @Index(name = "agmdiseaseannotation_gene_agmda_index", columnList = "agmdiseaseannotation_id"), + @Index(name = "agmdiseaseannotation_gene_assertedgenes_index", columnList = "assertedgenes_id") + } + ) @JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class }) private List assertedGenes; @@ -104,7 +105,6 @@ public class AGMDiseaseAnnotation extends DiseaseAnnotation { }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne - @Fetch(FetchMode.SELECT) @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) private Allele assertedAllele; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/AGMPhenotypeAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/AGMPhenotypeAnnotation.java index a4b288a67..d23d9dc19 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/AGMPhenotypeAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/AGMPhenotypeAnnotation.java @@ -19,6 +19,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToOne; @@ -34,12 +35,14 @@ @Schema(name = "AGM_Phenotype_Annotation", description = "Annotation class representing a agm phenotype annotation") @JsonTypeName("AGMPhenotypeAnnotation") @AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { PhenotypeAnnotation.class }) + @Table(indexes = { - @Index(name = "AGMPhenotypeAnnotation_inferredGene_index", columnList = "inferredGene_id"), - @Index(name = "AGMPhenotypeAnnotation_inferredAllele_index", columnList = "inferredAllele_id"), @Index(name = "AGMPhenotypeAnnotation_assertedAllele_index", columnList = "assertedAllele_id"), - @Index(name = "AGMPhenotypeAnnotation_PhenotypeAnnotationSubject_index", columnList = "phenotypeAnnotationSubject_id") + @Index(name = "AGMPhenotypeAnnotation_inferredAllele_index", columnList = "inferredAllele_id"), + @Index(name = "AGMPhenotypeAnnotation_inferredGene_index", columnList = "inferredGene_id"), + @Index(name = "AGMPhenotypeAnnotation_phenotypeAnnotationSubject_index", columnList = "phenotypeAnnotationSubject_id") }) + public class AGMPhenotypeAnnotation extends PhenotypeAnnotation { @IndexedEmbedded(includePaths = {"name", "name_keyword", "curie", "curie_keyword", "modEntityId", "modEntityId_keyword", "modInternalId", "modInternalId_keyword"}) @@ -88,11 +91,15 @@ public class AGMPhenotypeAnnotation extends PhenotypeAnnotation { @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany @Fetch(FetchMode.SELECT) - @JoinTable(indexes = { - @Index(name = "agmphenotypeannotation_gene_agmphenotypeannotation_index", columnList = "agmphenotypeannotation_id"), - @Index(name = "agmphenotypeannotation_gene_assertedgenes_index", columnList = "assertedgenes_id") - }) @JsonView({ View.FieldsAndLists.class, View.PhenotypeAnnotationView.class, View.ForPublic.class }) + @JoinTable( + joinColumns = @JoinColumn(name = "agmphenotypeannotation_id"), + inverseJoinColumns = @JoinColumn(name = "assertedgenes_id"), + indexes = { + @Index(name = "agmphenotypeannotation_gene_agmpa_index", columnList = "agmphenotypeannotation_id"), + @Index(name = "agmphenotypeannotation_gene_assertedgenes_index", columnList = "assertedgenes_id") + } + ) private List assertedGenes; @IndexedEmbedded(includePaths = { @@ -153,4 +160,4 @@ public String getSubjectSpeciesName() { } return phenotypeAnnotationSubject.getTaxon().getGenusSpecies(); } -} \ No newline at end of file +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Allele.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Allele.java index 6033c5acc..d5d9a1bbc 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Allele.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Allele.java @@ -6,6 +6,7 @@ import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.model.bridges.BooleanAndNullValueBridge; import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleGeneAssociation; +import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleVariantAssociation; import org.alliancegenome.curation_api.model.entities.slotAnnotations.alleleSlotAnnotations.AlleleDatabaseStatusSlotAnnotation; import org.alliancegenome.curation_api.model.entities.slotAnnotations.alleleSlotAnnotations.AlleleFullNameSlotAnnotation; import org.alliancegenome.curation_api.model.entities.slotAnnotations.alleleSlotAnnotations.AlleleFunctionalImpactSlotAnnotation; @@ -52,7 +53,7 @@ @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @ToString( exclude = { - "alleleGeneAssociations", "alleleDiseaseAnnotations", "alleleMutationTypes", "alleleSymbol", "alleleFullName", "alleleSynonyms", + "alleleGeneAssociations", "alleleVariantAssociations", "alleleDiseaseAnnotations", "alleleMutationTypes", "alleleSymbol", "alleleFullName", "alleleSynonyms", "alleleSecondaryIds", "alleleInheritanceModes", "alleleFunctionalImpacts", "alleleGermlineTransmissionStatus", "alleleDatabaseStatus", "alleleNomenclatureEvents" }, @@ -191,6 +192,17 @@ public class Allele extends GenomicEntity { @JsonView({ View.FieldsAndLists.class, View.AlleleDetailView.class }) private List alleleGeneAssociations; + @IndexedEmbedded( + includePaths = { + "alleleVariantAssociationObject.curie", "alleleGeneAssociationObject.curie_keyword", + "alleleVariantAssociationObject.modEntityId", "alleleVariantAssociationObject.modEntityId_keyword", + "alleleVariantAssociationObject.modInternalId", "alleleVariantAssociationObject.modInternalId_keyword" + } + ) + @OneToMany(mappedBy = "alleleAssociationSubject", cascade = CascadeType.ALL, orphanRemoval = true) + @JsonView({ View.FieldsAndLists.class, View.AlleleDetailView.class }) + private List alleleVariantAssociations; + @IndexedEmbedded(includePaths = {"freeText", "freeText_keyword"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/AlleleDiseaseAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/AlleleDiseaseAnnotation.java index 0be4353c5..c373723fd 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/AlleleDiseaseAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/AlleleDiseaseAnnotation.java @@ -8,8 +8,6 @@ import org.eclipse.microprofile.openapi.annotations.media.Schema; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; -import org.hibernate.annotations.OnDelete; -import org.hibernate.annotations.OnDeleteAction; import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; @@ -21,6 +19,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToOne; @@ -35,12 +34,13 @@ @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @Schema(name = "Allele_Disease_Annotation", description = "Annotation class representing a allele disease annotation") @JsonTypeName("AlleleDiseaseAnnotation") -@OnDelete(action = OnDeleteAction.CASCADE) @AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { DiseaseAnnotation.class }) + @Table(indexes = { - @Index(name = "AlleleDiseaseAnnotation_inferredGene_index", columnList = "inferredGene_id"), - @Index(name = "AlleleDiseaseAnnotation_DiseaseAnnotationSubject_index", columnList = "diseaseAnnotationSubject_id") + @Index(name = "AlleleDiseaseAnnotation_diseaseAnnotationSubject_index", columnList = "diseaseAnnotationSubject_id"), + @Index(name = "AlleleDiseaseAnnotation_inferredGene_index", columnList = "inferredGene_id") }) + public class AlleleDiseaseAnnotation extends DiseaseAnnotation { @IndexedEmbedded(includePaths = { @@ -82,11 +82,15 @@ public class AlleleDiseaseAnnotation extends DiseaseAnnotation { @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany @Fetch(FetchMode.SELECT) - @JoinTable(indexes = { - @Index(name = "allelediseaseannotationgene_diseaseannotation_index", columnList = "allelediseaseannotation_id"), - @Index(name = "allelediseaseannotationgene_assertedgenes_index", columnList = "assertedgenes_id") - }) @JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class }) + @JoinTable( + joinColumns = @JoinColumn(name = "allelediseaseannotation_id"), + inverseJoinColumns = @JoinColumn(name = "assertedgenes_id"), + indexes = { + @Index(name = "allelediseaseannotation_gene_alleleda_index", columnList = "allelediseaseannotation_id"), + @Index(name = "allelediseaseannotation_gene_assertedgenes_index", columnList = "assertedgenes_id") + } + ) private List assertedGenes; @Transient diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/AllelePhenotypeAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/AllelePhenotypeAnnotation.java index ddee7fca3..b3a893e3a 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/AllelePhenotypeAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/AllelePhenotypeAnnotation.java @@ -19,6 +19,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToOne; @@ -34,10 +35,12 @@ @Schema(name = "Allele_Phenotype_Annotation", description = "Annotation class representing a allele phenotype annotation") @JsonTypeName("AllelePhenotypeAnnotation") @AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { PhenotypeAnnotation.class }) + @Table(indexes = { @Index(name = "AllelePhenotypeAnnotation_inferredGene_index", columnList = "inferredGene_id"), - @Index(name = "AllelePhenotypeAnnotation_PhenotypeAnnotationSubject_index", columnList = "phenotypeAnnotationSubject_id") + @Index(name = "AllelePhenotypeAnnotation_phenotypeAnnotationSubject_index", columnList = "phenotypeAnnotationSubject_id") }) + public class AllelePhenotypeAnnotation extends PhenotypeAnnotation { @IndexedEmbedded(includePaths = { @@ -79,11 +82,15 @@ public class AllelePhenotypeAnnotation extends PhenotypeAnnotation { @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany @Fetch(FetchMode.SELECT) - @JoinTable(indexes = { - @Index(name = "allelephenotypeannotationgene_phenotypeannotation_index", columnList = "allelephenotypeannotation_id"), - @Index(name = "allelephenotypeannotationgene_assertedgenes_index", columnList = "assertedgenes_id") - }) @JsonView({ View.FieldsAndLists.class, View.PhenotypeAnnotationView.class, View.ForPublic.class }) + @JoinTable( + joinColumns = @JoinColumn(name = "allelephenotypeannotation_id"), + inverseJoinColumns = @JoinColumn(name = "assertedgenes_id"), + indexes = { + @Index(name = "allelephenotypeannotation_gene_allelepa_index", columnList = "allelephenotypeannotation_id"), + @Index(name = "allelephenotypeannotation_gene_assertedgenes_index", columnList = "assertedgenes_id") + } + ) private List assertedGenes; @Transient @@ -131,4 +138,4 @@ public String getSubjectSpeciesName() { } return phenotypeAnnotationSubject.getTaxon().getGenusSpecies(); } -} \ No newline at end of file +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/AnatomicalSite.java b/src/main/java/org/alliancegenome/curation_api/model/entities/AnatomicalSite.java new file mode 100644 index 000000000..ad8acc703 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/AnatomicalSite.java @@ -0,0 +1,132 @@ +package org.alliancegenome.curation_api.model.entities; + +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonView; +import jakarta.persistence.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.bridges.BooleanValueBridge; +import org.alliancegenome.curation_api.model.entities.base.AuditedObject; +import org.alliancegenome.curation_api.model.entities.ontology.AnatomicalTerm; +import org.alliancegenome.curation_api.model.entities.ontology.GOTerm; +import org.alliancegenome.curation_api.model.entities.ontology.OntologyTerm; +import org.alliancegenome.curation_api.model.entities.ontology.UBERONTerm; +import org.alliancegenome.curation_api.view.View; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.hibernate.search.engine.backend.types.Aggregable; +import org.hibernate.search.engine.backend.types.Searchable; +import org.hibernate.search.engine.backend.types.Sortable; +import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; +import org.hibernate.search.mapper.pojo.bridge.mapping.annotation.ValueBridgeRef; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; + +import java.util.List; + +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") +@Entity +@Data +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +@AGRCurationSchemaVersion(min = "2.7.0", max = LinkMLSchemaConstants.LATEST_RELEASE) +@Schema(name = "Anatomical_Site", description = "Anatomical part of an expression pattern") +@Table(indexes = { + @Index(name = "anatomicalsite_anatomicalstructure_index ", columnList = "anatomicalstructure_id"), + @Index(name = "anatomicalsite_anatomicalsubstructure_index", columnList = "anatomicalsubstructure_id"), + @Index(name = "anatomicalsite_cellularcomponentterm_index", columnList = "cellularcomponentterm_id")} +) +public class AnatomicalSite extends AuditedObject { + @IndexedEmbedded(includePaths = {"name", "name_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({View.FieldsOnly.class}) + private AnatomicalTerm anatomicalStructure; + + @IndexedEmbedded(includePaths = {"name", "name_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({View.FieldsOnly.class}) + private AnatomicalTerm anatomicalSubstructure; + + @IndexedEmbedded(includePaths = {"name", "name_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({View.FieldsOnly.class}) + private GOTerm cellularComponentTerm; + + //celullar compoent ribbon -- slim + @IndexedEmbedded(includePaths = {"name", "name_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({View.FieldsOnly.class}) + private GOTerm cellularComponentRibbonTerm; + + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer", valueBridge = @ValueBridgeRef(type = BooleanValueBridge.class)) + @KeywordField(name = "cellularComponentOther_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, valueBridge = @ValueBridgeRef(type = BooleanValueBridge.class)) + @JsonView({ View.FieldsOnly.class }) + @Column(columnDefinition = "boolean default false", nullable = false) + private Boolean cellularComponentOther = false; + + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "anatomicalstructurequalifiers_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @ManyToMany + @JsonView({View.FieldsOnly.class}) + @JoinTable( + name = "anatomicalsite_anatomicalstructurequalifiers", + indexes = { + @Index(name = "anatomicalstructurequalifiers_anatomicalsite_index", columnList = "anatomicalsite_id"), + @Index(name = "anatomicalstructurequalifiers_structurequalifiers_index", columnList = "anatomicalstructurequalifiers_id")} + ) + private List anatomicalStructureQualifiers; + + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "anatomicalsubstructurequalifiers_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @ManyToMany + @JsonView({View.FieldsOnly.class}) + @JoinTable( + name = "anatomicalsite_anatomicalsubstructurequalifiers", + indexes = { + @Index(name = "anatomicalsubstructurequalifiers_anatomicalsite_index", columnList = "anatomicalsite_id"), + @Index(name = "anatomicalsubstructurequalifiers_qualifiers_index", columnList = "anatomicalsubstructurequalifiers_id")} + ) + private List anatomicalSubstructureQualifiers; + + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "cellularcomponentqualifiers_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @ManyToMany + @JsonView({View.FieldsOnly.class}) + @JoinTable( + name = "anatomicalsite_cellularcomponentqualifiers", + indexes = { + @Index(name = "cellularcomponentqualifiers_anatomicalsite_index", columnList = "anatomicalsite_id"), + @Index(name = "cellularcomponentqualifiers_cellularcomponentqualifiers_index", columnList = "cellularcomponentqualifiers_id")} + ) + private List cellularComponentQualifiers; + + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "anatomicalstructureuberonterms_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @ManyToMany + @JsonView({View.FieldsOnly.class}) + @JoinTable( + name = "anatomicalsite_anatomicalstructureuberonterms", + indexes = { + @Index(name = "anatomicalstructureuberonterms_anatomicalsite_index", columnList = "anatomicalsite_id"), + @Index(name = "anatomicalstructureuberonterms_uberonterms_index", columnList = "anatomicalstructureuberonterms_id")} + ) + private List anatomicalStructureUberonTerms; + + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "anatomicalsubstructureuberonterms_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @ManyToMany + @JsonView({View.FieldsOnly.class}) + @JoinTable( + name = "anatomicalsite_anatomicalsubstructureuberonterms", + indexes = { + @Index(name = "anatomicalsubstructureuberonterms_anatomicalsite_index", columnList = "anatomicalsite_id"), + @Index(name = "anatomicalsubstructureuberonterms_uberonterms_index", columnList = "anatomicalsubstructureuberonterms_id")} + ) + private List anatomicalSubstructureUberonTerms; +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Annotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Annotation.java index 2ca9a3fa7..64a8a74b7 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Annotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Annotation.java @@ -7,8 +7,6 @@ import org.alliancegenome.curation_api.model.entities.base.AuditedObject; import org.alliancegenome.curation_api.view.View; import org.eclipse.microprofile.openapi.annotations.media.Schema; -import org.hibernate.annotations.Fetch; -import org.hibernate.annotations.FetchMode; import org.hibernate.search.engine.backend.types.Aggregable; import org.hibernate.search.engine.backend.types.Searchable; import org.hibernate.search.engine.backend.types.Sortable; @@ -22,36 +20,23 @@ import jakarta.persistence.CascadeType; import jakarta.persistence.Column; -import jakarta.persistence.Entity; import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToOne; +import jakarta.persistence.MappedSuperclass; import jakarta.persistence.OneToMany; -import jakarta.persistence.Table; -import jakarta.persistence.UniqueConstraint; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -@Entity +@MappedSuperclass @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @ToString(callSuper = true) @Schema(name = "annotation", description = "POJO that represents an annotation") @AGRCurationSchemaVersion(min = "1.9.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AuditedObject.class }) -@Table( - indexes = { - @Index(name = "annotation_curie_index", columnList = "curie"), - @Index(name = "annotation_uniqueId_index", columnList = "uniqueId"), - @Index(name = "annotation_modEntityId_index", columnList = "modEntityId"), - @Index(name = "annotation_modInternalId_index", columnList = "modInternalId"), - @Index(name = "annotation_dataprovider_index", columnList = "dataProvider_id") - }, uniqueConstraints = { - @UniqueConstraint(name = "annotation_modentityid_uk", columnNames = "modEntityId"), - @UniqueConstraint(name = "annotation_modinternalid_uk", columnNames = "modInternalId") - } -) public class Annotation extends SingleReferenceAssociation { @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") @@ -86,7 +71,14 @@ public class Annotation extends SingleReferenceAssociation { @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany @JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.PhenotypeAnnotationView.class, View.ForPublic.class }) - @JoinTable(indexes = { @Index(name = "annotation_conditionrelation_annotation_index", columnList = "annotation_id"), @Index(name = "annotation_conditionrelation_conditionrelations_index", columnList = "conditionrelations_id")}) + @JoinTable( + joinColumns = @JoinColumn(name = "annotation_id"), + inverseJoinColumns = @JoinColumn(name = "conditionRelations_id"), + indexes = { + @Index(columnList = "annotation_id"), + @Index(columnList = "conditionRelations_id") + } + ) private List conditionRelations; @IndexedEmbedded(includePaths = {"freeText", "noteType.name", "references.curie", @@ -96,14 +88,20 @@ public class Annotation extends SingleReferenceAssociation { @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) @JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class }) - @JoinTable(indexes = { @Index(name = "annotation_note_annotation_index", columnList = "annotation_id"), @Index(name = "annotation_note_relatednotes_index", columnList = "relatednotes_id")}) + @JoinTable( + joinColumns = @JoinColumn(name = "annotation_id"), + inverseJoinColumns = @JoinColumn(name = "relatedNotes_id"), + indexes = { + @Index(columnList = "annotation_id"), + @Index(columnList = "relatedNotes_id") + } + ) private List relatedNotes; @IndexedEmbedded(includePaths = {"sourceOrganization.abbreviation", "sourceOrganization.fullName", "sourceOrganization.shortName", "crossReference.displayName", "crossReference.referencedCurie", "sourceOrganization.abbreviation_keyword", "sourceOrganization.fullName_keyword", "sourceOrganization.shortName_keyword", "crossReference.displayName_keyword", "crossReference.referencedCurie_keyword"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne - @Fetch(FetchMode.SELECT) @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) protected DataProvider dataProvider; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/AssemblyComponent.java b/src/main/java/org/alliancegenome/curation_api/model/entities/AssemblyComponent.java index 862c73da6..a0a58a63e 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/AssemblyComponent.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/AssemblyComponent.java @@ -5,7 +5,6 @@ import org.alliancegenome.curation_api.view.View; import org.eclipse.microprofile.openapi.annotations.media.Schema; import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; -import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; @@ -19,7 +18,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; -@Indexed +//@Indexed @Entity @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @@ -28,7 +27,9 @@ @AGRCurationSchemaVersion(min = "2.4.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { GenomicEntity.class }) @Table( indexes = { - @Index(name = "assemblycomponent_genomeassembly_index", columnList = "genomeassembly_id") + @Index(name = "assemblycomponent_genomeassembly_index", columnList = "genomeassembly_id"), + @Index(name = "assemblycomponent_mapsToChromosome_index", columnList = "mapsToChromosome_id"), + @Index(name = "assemblycomponent_name_index", columnList = "name") } ) public class AssemblyComponent extends GenomicEntity { diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Association.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Association.java index f06fccbc2..b7e2247e1 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Association.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Association.java @@ -5,26 +5,17 @@ import org.alliancegenome.curation_api.model.entities.base.AuditedObject; import org.eclipse.microprofile.openapi.annotations.media.Schema; -import jakarta.persistence.Entity; -import jakarta.persistence.Index; -import jakarta.persistence.Inheritance; -import jakarta.persistence.InheritanceType; -import jakarta.persistence.Table; +import jakarta.persistence.MappedSuperclass; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -@Inheritance(strategy = InheritanceType.JOINED) -@Entity +@MappedSuperclass @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @ToString(callSuper = true) @Schema(name = "association", description = "POJO that represents an association") -@Table(indexes = { - @Index(name = "association_createdby_index", columnList = "createdBy_id"), - @Index(name = "association_updatedby_index", columnList = "updatedBy_id") -}) @AGRCurationSchemaVersion(min = "1.9.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AuditedObject.class }) public class Association extends AuditedObject { -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/BioSampleAge.java b/src/main/java/org/alliancegenome/curation_api/model/entities/BioSampleAge.java new file mode 100644 index 000000000..d359e8e83 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/BioSampleAge.java @@ -0,0 +1,51 @@ +package org.alliancegenome.curation_api.model.entities; + +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.model.entities.base.AuditedObject; +import org.alliancegenome.curation_api.view.View; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.hibernate.search.engine.backend.types.Aggregable; +import org.hibernate.search.engine.backend.types.Searchable; +import org.hibernate.search.engine.backend.types.Sortable; +import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; + +import com.fasterxml.jackson.annotation.JsonView; + +import jakarta.persistence.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Entity +@Data +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +@ToString(callSuper = true) +@Schema(name = "BioSampleAge", description = "POJO that represents the BioSampleAge") +@AGRCurationSchemaVersion(min = "2.7.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AuditedObject.class }) +@Table(indexes = { + @Index(name = "biosampleage_stage_index", columnList = "stage_id") +}) +public class BioSampleAge extends AuditedObject { + + @IndexedEmbedded(includePaths = {"age", "age_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + private TemporalContext stage; + + @JsonView({ View.FieldsOnly.class }) + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "age_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + private String age; + + @JsonView({ View.FieldsOnly.class }) + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "whenexpressedstagename_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + private String whenExpressedStageName; + +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/BioSampleGenomicInformation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/BioSampleGenomicInformation.java new file mode 100644 index 000000000..986e06e92 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/BioSampleGenomicInformation.java @@ -0,0 +1,68 @@ +package org.alliancegenome.curation_api.model.entities; + +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.entities.base.AuditedObject; +import org.alliancegenome.curation_api.view.View; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.hibernate.search.engine.backend.types.Aggregable; +import org.hibernate.search.engine.backend.types.Searchable; +import org.hibernate.search.engine.backend.types.Sortable; +import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; + +import com.fasterxml.jackson.annotation.JsonView; + +import jakarta.persistence.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Entity +@Data +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +@ToString(callSuper = true) +@Schema(name = "BioSampleGenomicInformation", description = "POJO that represents the BioSampleGenomicInformation") +@AGRCurationSchemaVersion(min = "2.7.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AuditedObject.class }) +@Indexed +@Table(indexes = { + @Index(name = "biosamplegenomicinfo_bioSampleAllele_index", columnList = "bioSampleAllele_id"), + @Index(name = "biosamplegenomicinfo_bioSampleAgm_index", columnList = "bioSampleAgm_id"), + @Index(name = "biosamplegenomicinfo_bioSampleAgmType_index", columnList = "bioSampleAgmType_id") +}) +public class BioSampleGenomicInformation extends AuditedObject { + + @IndexedEmbedded(includePaths = { + "curie", "modEntityId", "modInternalId", "curie_keyword", "modEntityId_keyword", "modInternalId_keyword", + "alleleSymbol.formatText", "alleleSymbol.displayText", "alleleSymbol.formatText_keyword", "alleleSymbol.displayText_keyword", + "alleleFullName.formatText", "alleleFullName.displayText", "alleleFullName.formatText_keyword", "alleleFullName.displayText_keyword", + "alleleSynonyms.formatText", "alleleSynonyms.displayText", "alleleSynonyms.formatText_keyword", "alleleSynonyms.displayText_keyword", + "alleleSecondaryIds.secondaryId", "alleleSecondaryIds.secondaryId_keyword" + }) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView(View.FieldsOnly.class) + private Allele bioSampleAllele; + + @IndexedEmbedded(includePaths = {"name", "name_keyword", "curie", "curie_keyword", "modEntityId", "modEntityId_keyword", "modInternalId", "modInternalId_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView(View.FieldsOnly.class) + private AffectedGenomicModel bioSampleAgm; + + @IndexedEmbedded(includePaths = {"name", "name_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + private VocabularyTerm bioSampleAgmType; + + @JsonView(View.FieldsOnly.class) + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "biosampletext_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + private String bioSampleText; + +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/CodingSequence.java b/src/main/java/org/alliancegenome/curation_api/model/entities/CodingSequence.java index f72677f3b..0d3cb4924 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/CodingSequence.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/CodingSequence.java @@ -5,6 +5,7 @@ import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.model.entities.associations.codingSequenceAssociations.CodingSequenceGenomicLocationAssociation; +import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptCodingSequenceAssociation; import org.alliancegenome.curation_api.model.entities.ontology.SOTerm; import org.alliancegenome.curation_api.view.View; import org.eclipse.microprofile.openapi.annotations.media.Schema; @@ -13,7 +14,6 @@ import org.hibernate.search.engine.backend.types.Sortable; import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; -import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; @@ -30,14 +30,17 @@ import lombok.EqualsAndHashCode; import lombok.ToString; -@Indexed +//@Indexed @Entity @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) -@ToString(exclude = "codingSequenceGenomicLocationAssociations", callSuper = true) +@ToString(exclude = {"codingSequenceGenomicLocationAssociations", "transcriptCodingSequenceAssociations"}, callSuper = true) @Schema(name = "CodingSequence", description = "POJO that represents the CodingSequence (CDS)") @AGRCurationSchemaVersion(min = "2.4.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { GenomicEntity.class }) -@Table(indexes = {@Index(name = "codingsequence_uniqueid_index", columnList = "uniqueid")}) +@Table(indexes = { + @Index(name = "codingsequence_uniqueid_index", columnList = "uniqueid"), + @Index(name = "codingsequence_cdsType_index", columnList = "cdsType_id") +}) public class CodingSequence extends GenomicEntity { @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") @@ -66,5 +69,9 @@ public class CodingSequence extends GenomicEntity { @OneToMany(mappedBy = "codingSequenceAssociationSubject", cascade = CascadeType.ALL, orphanRemoval = true) @JsonView({ View.FieldsAndLists.class }) private List codingSequenceGenomicLocationAssociations; + + @OneToMany(mappedBy = "transcriptCodingSequenceAssociationObject", cascade = CascadeType.ALL, orphanRemoval = true) + @JsonView({ View.FieldsAndLists.class }) + private List transcriptCodingSequenceAssociations; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/CrossReference.java b/src/main/java/org/alliancegenome/curation_api/model/entities/CrossReference.java index 58da2a1a1..982ea293f 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/CrossReference.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/CrossReference.java @@ -60,7 +60,7 @@ public class CrossReference extends AuditedObject { private ResourceDescriptorPage resourceDescriptorPage; public String getPrefix() { - if (referencedCurie.indexOf(":") == -1) { + if (!referencedCurie.contains(":")) { return referencedCurie; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/DiseaseAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/DiseaseAnnotation.java index d25f6bc63..96b84b062 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/DiseaseAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/DiseaseAnnotation.java @@ -9,8 +9,6 @@ import org.alliancegenome.curation_api.model.entities.ontology.ECOTerm; import org.alliancegenome.curation_api.view.View; import org.eclipse.microprofile.openapi.annotations.media.Schema; -import org.hibernate.annotations.Fetch; -import org.hibernate.annotations.FetchMode; import org.hibernate.search.engine.backend.types.Aggregable; import org.hibernate.search.engine.backend.types.Searchable; import org.hibernate.search.engine.backend.types.Sortable; @@ -30,6 +28,9 @@ import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.Index; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToOne; @@ -38,31 +39,43 @@ import lombok.Data; import lombok.EqualsAndHashCode; +@Inheritance(strategy = InheritanceType.JOINED) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") -@JsonSubTypes({ @Type(value = AGMDiseaseAnnotation.class, name = "AGMDiseaseAnnotation"), @Type(value = AlleleDiseaseAnnotation.class, name = "AlleleDiseaseAnnotation"), - @Type(value = GeneDiseaseAnnotation.class, name = "GeneDiseaseAnnotation") }) +@JsonSubTypes({ + @Type(value = AGMDiseaseAnnotation.class, name = "AGMDiseaseAnnotation"), + @Type(value = AlleleDiseaseAnnotation.class, name = "AlleleDiseaseAnnotation"), + @Type(value = GeneDiseaseAnnotation.class, name = "GeneDiseaseAnnotation") +}) @Entity @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) -@AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { Annotation.class }) +@AGRCurationSchemaVersion(min = "2.8.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { Annotation.class }) @Schema(name = "Disease_Annotation", description = "Annotation class representing a disease annotation") - @Table(indexes = { - @Index(name = "DiseaseAnnotation_diseaseAnnotationObject_index", columnList = "diseaseannotationobject_id"), - @Index(name = "DiseaseAnnotation_relation_index", columnList = "relation_id"), + @Index(name = "DiseaseAnnotation_internal_index", columnList = "internal"), + @Index(name = "DiseaseAnnotation_obsolete_index", columnList = "obsolete"), + @Index(name = "DiseaseAnnotation_curie_index", columnList = "curie"), + @Index(name = "DiseaseAnnotation_modEntityId_index", columnList = "modEntityId"), + @Index(name = "DiseaseAnnotation_modInternalId_index", columnList = "modInternalId"), + @Index(name = "DiseaseAnnotation_uniqueId_index", columnList = "uniqueId"), + @Index(name = "DiseaseAnnotation_diseaseAnnotationObject_index", columnList = "diseaseAnnotationObject_id"), + @Index(name = "DiseaseAnnotation_negated_index", columnList = "negated"), + @Index(name = "DiseaseAnnotation_createdBy_index", columnList = "createdBy_id"), + @Index(name = "DiseaseAnnotation_updatedBy_index", columnList = "updatedBy_id"), + @Index(name = "DiseaseAnnotation_singleReference_index", columnList = "singleReference_id"), + @Index(name = "DiseaseAnnotation_dataProvider_index", columnList = "dataProvider_id"), @Index(name = "DiseaseAnnotation_annotationType_index", columnList = "annotationType_id"), + @Index(name = "DiseaseAnnotation_diseaseGeneticModifierRelation_index", columnList = "diseaseGeneticModifierRelation_id"), @Index(name = "DiseaseAnnotation_geneticSex_index", columnList = "geneticSex_id"), - @Index(name = "DiseaseAnnotation_secondaryDataProvider_index", columnList = "secondaryDataProvider_id"), - @Index(name = "DiseaseAnnotation_diseaseGeneticModifierRelation_index", columnList = "diseaseGeneticModifierRelation_id") + @Index(name = "DiseaseAnnotation_relation_index", columnList = "relation_id"), + @Index(name = "DiseaseAnnotation_secondaryDataProvider_index", columnList = "secondaryDataProvider_id") }) - public abstract class DiseaseAnnotation extends Annotation { @IndexedEmbedded(includePaths = {"curie", "name", "secondaryIdentifiers", "synonyms.name", "namespace", "curie_keyword", "name_keyword", "secondaryIdentifiers_keyword", "synonyms.name_keyword", "namespace_keyword" }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne - @Fetch(FetchMode.SELECT) @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) private DOTerm diseaseAnnotationObject; @@ -83,10 +96,14 @@ public abstract class DiseaseAnnotation extends Annotation { @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany @JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class }) - @JoinTable(indexes = { - @Index(name = "diseaseannotation_ecoterm_diseaseannotation_index", columnList = "diseaseannotation_id"), - @Index(name = "diseaseannotation_ecoterm_evidencecodes_index", columnList = "evidencecodes_id") - }) + @JoinTable( + joinColumns = @JoinColumn(name = "diseaseannotation_id"), + inverseJoinColumns = @JoinColumn(name = "evidencecodes_id"), + indexes = { + @Index(name = "diseaseannotation_ontologyterm_da_index", columnList = "diseaseannotation_id"), + @Index(name = "diseaseannotation_ontologyterm_evidencecodes_index", columnList = "evidencecodes_id") + } + ) private List evidenceCodes; @IndexedEmbedded(includePaths = { @@ -99,12 +116,15 @@ public abstract class DiseaseAnnotation extends Annotation { }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany - @Fetch(FetchMode.SELECT) - @JoinTable(indexes = { - @Index(name = "diseaseannotation_gene_diseaseannotation_index", columnList = "diseaseannotation_id"), - @Index(name = "diseaseannotation_gene_with_index", columnList = "with_id") - }) @JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class }) + @JoinTable( + joinColumns = @JoinColumn(name = "diseaseannotation_id"), + inverseJoinColumns = @JoinColumn(name = "with_id"), + indexes = { + @Index(name = "diseaseannotation_gene_da_index", columnList = "diseaseannotation_id"), + @Index(name = "diseaseannotation_gene_with_index", columnList = "with_id") + } + ) private List with; @IndexedEmbedded(includePaths = {"name", "name_keyword"}) @@ -117,10 +137,14 @@ public abstract class DiseaseAnnotation extends Annotation { @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany @JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class }) - @JoinTable(indexes = { - @Index(name = "diseaseannotation_vocabularyterm_diseaseannotation_index", columnList = "diseaseannotation_id"), - @Index(name = "diseaseannotation_vocabularyterm_diseasequalifiers_index", columnList = "diseasequalifiers_id") - }) + @JoinTable( + joinColumns = @JoinColumn(name = "diseaseannotation_id"), + inverseJoinColumns = @JoinColumn(name = "diseasequalifiers_id"), + indexes = { + @Index(name = "diseaseannotation_vocabularyterm_da_index", columnList = "diseaseannotation_id"), + @Index(name = "diseaseannotation_vocabularyterm_dq_index", columnList = "diseasequalifiers_id") + } + ) private List diseaseQualifiers; @IndexedEmbedded(includePaths = {"name", "name_keyword"}) @@ -133,20 +157,66 @@ public abstract class DiseaseAnnotation extends Annotation { "sourceOrganization.abbreviation_keyword", "sourceOrganization.fullName_keyword", "sourceOrganization.shortName_keyword", "crossReference.displayName_keyword", "crossReference.referencedCurie_keyword"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne - @Fetch(FetchMode.SELECT) @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) private DataProvider secondaryDataProvider; - @IndexedEmbedded(includeDepth = 1) + @IndexedEmbedded(includePaths = { + "curie", "modEntityId", "modInternalId", "curie_keyword", "modEntityId_keyword", "modInternalId_keyword", + "geneSymbol.formatText", "geneSymbol.displayText", "geneSymbol.formatText_keyword", "geneSymbol.displayText_keyword", + "geneFullName.formatText", "geneFullName.displayText", "geneFullName.formatText_keyword", "geneFullName.displayText_keyword", + "geneSystematicName.formatText", "geneSystematicName.displayText", "geneSystematicName.formatText_keyword", "geneSystematicName.displayText_keyword", + "geneSynonyms.formatText", "geneSynonyms.displayText", "geneSynonyms.formatText_keyword", "geneSynonyms.displayText_keyword", + "geneSecondaryIds.secondaryId", "geneSecondaryIds.secondaryId_keyword", "name", "name_keyword", "symbol", "symbol_keyword" + }) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany - @Fetch(FetchMode.SELECT) @JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class }) - @JoinTable(indexes = { - @Index(name = "diseaseannotation_biologicalentity_diseaseannotation_index", columnList = "diseaseannotation_id"), - @Index(name = "diseaseannotation_biologicalentity_dgms_index", columnList = "diseasegeneticmodifiers_id") + @JoinTable( + name = "diseaseannotation_modifiergene", + joinColumns = @JoinColumn(name = "diseaseannotation_id"), + inverseJoinColumns = @JoinColumn(name = "diseasegeneticmodifiergenes_id"), + indexes = { + @Index(name = "diseaseannotation_modifiergene_da_index", columnList = "diseaseannotation_id"), + @Index(name = "diseaseannotation_modifiergene_dgmg_index", columnList = "diseasegeneticmodifiergenes_id") + } + ) + private List diseaseGeneticModifierGenes; + + @IndexedEmbedded(includePaths = { + "curie", "modEntityId", "modInternalId", "curie_keyword", "modEntityId_keyword", "modInternalId_keyword", + "alleleSymbol.formatText", "alleleSymbol.displayText", "alleleSymbol.formatText_keyword", "alleleSymbol.displayText_keyword", + "alleleFullName.formatText", "alleleFullName.displayText", "alleleFullName.formatText_keyword", "alleleFullName.displayText_keyword", + "alleleSynonyms.formatText", "alleleSynonyms.displayText", "alleleSynonyms.formatText_keyword", "alleleSynonyms.displayText_keyword", + "alleleSecondaryIds.secondaryId", "alleleSecondaryIds.secondaryId_keyword" }) - private List diseaseGeneticModifiers; + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToMany + @JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class }) + @JoinTable( + name = "diseaseannotation_modifierallele", + joinColumns = @JoinColumn(name = "diseaseannotation_id"), + inverseJoinColumns = @JoinColumn(name = "diseasegeneticmodifieralleles_id"), + indexes = { + @Index(name = "diseaseannotation_modifierallele_da_index", columnList = "diseaseannotation_id"), + @Index(name = "diseaseannotation_modifierallele_dgma_index", columnList = "diseasegeneticmodifieralleles_id") + } + ) + private List diseaseGeneticModifierAlleles; + + @IndexedEmbedded(includePaths = {"name", "name_keyword", "curie", "curie_keyword", "modEntityId", "modEntityId_keyword", "modInternalId", "modInternalId_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToMany + @JsonView({ View.FieldsAndLists.class, View.DiseaseAnnotation.class, View.ForPublic.class }) + @JoinTable( + name = "diseaseannotation_modifieragm", + joinColumns = @JoinColumn(name = "diseaseannotation_id"), + inverseJoinColumns = @JoinColumn(name = "diseasegeneticmodifieragms_id"), + indexes = { + @Index(name = "diseaseannotation_modifieragm_da_index", columnList = "diseaseannotation_id"), + @Index(name = "diseaseannotation_modifieragm_dgma_index", columnList = "diseasegeneticmodifieragms_id") + } + ) + private List diseaseGeneticModifierAgms; @IndexedEmbedded(includePaths = {"name", "name_keyword"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/EvidenceAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/EvidenceAssociation.java index ca519f252..62c66ca2d 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/EvidenceAssociation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/EvidenceAssociation.java @@ -12,14 +12,15 @@ import com.fasterxml.jackson.annotation.JsonView; -import jakarta.persistence.Entity; import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToMany; +import jakarta.persistence.MappedSuperclass; import lombok.Data; import lombok.EqualsAndHashCode; -@Entity +@MappedSuperclass @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @Schema(name = "evidenceAssociation", description = "POJO that represents an association supported by any number of information content entities") @@ -30,11 +31,14 @@ public class EvidenceAssociation extends Association { @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany @JsonView({ View.FieldsAndLists.class, View.AlleleView.class, View.GeneView.class, View.ConstructView.class, View.GeneInteractionView.class }) - @JoinTable(indexes = { - @Index(name = "evidenceassociation_infocontent_evidenceassociation_index", columnList = "evidenceassociation_id"), - @Index(name = "evidenceassociation_infocontent_evidence_index", columnList = "evidence_id") - }) + @JoinTable( + joinColumns = @JoinColumn(name = "association_id"), + inverseJoinColumns = @JoinColumn(name = "evidence_id"), + indexes = { + @Index(columnList = "association_id"), + @Index(columnList = "evidence_id") + } + ) private List evidence; } - diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Exon.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Exon.java index 8a55175ba..2882ad164 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Exon.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Exon.java @@ -5,6 +5,7 @@ import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.model.entities.associations.exonAssociations.ExonGenomicLocationAssociation; +import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptExonAssociation; import org.alliancegenome.curation_api.model.entities.ontology.SOTerm; import org.alliancegenome.curation_api.view.View; import org.eclipse.microprofile.openapi.annotations.media.Schema; @@ -13,7 +14,6 @@ import org.hibernate.search.engine.backend.types.Sortable; import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; -import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; @@ -30,14 +30,17 @@ import lombok.EqualsAndHashCode; import lombok.ToString; -@Indexed +//@Indexed @Entity @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) -@ToString(exclude = "exonGenomicLocationAssociations", callSuper = true) +@ToString(exclude = {"exonGenomicLocationAssociations", "transcriptExonAssociations"}, callSuper = true) @Schema(name = "Exon", description = "POJO that represents the Exon") @AGRCurationSchemaVersion(min = "2.4.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { GenomicEntity.class }) -@Table(indexes = {@Index(name = "exon_uniqueid_index", columnList = "uniqueid")}) +@Table(indexes = { + @Index(name = "exon_uniqueid_index", columnList = "uniqueid"), + @Index(name = "exon_exonType_index", columnList = "exonType_id") +}) public class Exon extends GenomicEntity { @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") @@ -66,5 +69,9 @@ public class Exon extends GenomicEntity { @OneToMany(mappedBy = "exonAssociationSubject", cascade = CascadeType.ALL, orphanRemoval = true) @JsonView({ View.FieldsAndLists.class }) private List exonGenomicLocationAssociations; + + @OneToMany(mappedBy = "transcriptExonAssociationObject", cascade = CascadeType.ALL, orphanRemoval = true) + @JsonView({ View.FieldsAndLists.class }) + private List transcriptExonAssociations; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/ExpressionAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/ExpressionAnnotation.java index cec8c128b..0700dd185 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/ExpressionAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/ExpressionAnnotation.java @@ -1,12 +1,5 @@ package org.alliancegenome.curation_api.model.entities; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonView; -import jakarta.persistence.*; -import lombok.Data; -import lombok.EqualsAndHashCode; import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.view.View; @@ -20,36 +13,49 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonView; + +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.MappedSuperclass; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Transient; +import lombok.Data; +import lombok.EqualsAndHashCode; -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") -@JsonSubTypes({ @JsonSubTypes.Type(value = GeneExpressionAnnotation.class, name = "GeneExpressionAnnotation") }) -@Entity +@MappedSuperclass @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @AGRCurationSchemaVersion(min = "2.2.3", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { Annotation.class }) @Schema(name = "Expression_Annotation", description = "Annotation class representing an expression annotation") -@Table(indexes = { - @Index(name = "expressionannotation_whenexpressedstagename_index ", columnList = "whenexpressedstagename"), - @Index(name = "expressionannotation_whereexpressedstatement_index", columnList = "whereexpressedstatement") -}) public abstract class ExpressionAnnotation extends Annotation { @IndexedEmbedded(includePaths = {"name", "name_keyword"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne - @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) + @JsonView({View.FieldsOnly.class}) private VocabularyTerm relation; @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") @KeywordField(name = "whenExpressedStageName_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") - @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) + @JsonView({View.FieldsOnly.class}) + @Column(length = 2000) private String whenExpressedStageName; @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") @KeywordField(name = "whereExpressedStatement_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") - @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) + @JsonView({ View.FieldsOnly.class}) + @Column(length = 2000) private String whereExpressedStatement; + @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) + @JoinColumn(name = "expressionpattern_id", referencedColumnName = "id") + @JsonView({ View.FieldsOnly.class}) + private ExpressionPattern expressionPattern; + @Transient @JsonIgnore public String getDataProviderString() { diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/ExpressionPattern.java b/src/main/java/org/alliancegenome/curation_api/model/entities/ExpressionPattern.java new file mode 100644 index 000000000..240b2ff44 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/ExpressionPattern.java @@ -0,0 +1,38 @@ +package org.alliancegenome.curation_api.model.entities; + +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonView; +import jakarta.persistence.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.entities.base.AuditedObject; +import org.alliancegenome.curation_api.view.View; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; + +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") +@Entity +@Data +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +@AGRCurationSchemaVersion(min = "2.2.3", max = LinkMLSchemaConstants.LATEST_RELEASE) +@Schema(name = "Expression_Pattern", description = "Annotation class representing an expression pattern") + +@Table(indexes = { + @Index(name = "expressionpattern_whenexpressed_index", columnList = "whenexpressed_id"), + @Index(name = "expressionpattern_whereexpressed_index", columnList = "whereexpressed_id") +}) +public class ExpressionPattern extends AuditedObject { + + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) + @JsonView({ View.FieldsOnly.class}) + private TemporalContext whenExpressed; + + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) + @JsonView({ View.FieldsOnly.class}) + private AnatomicalSite whereExpressed; +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/ExternalDataBaseEntity.java b/src/main/java/org/alliancegenome/curation_api/model/entities/ExternalDataBaseEntity.java index 87c0b26d7..8d1df2821 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/ExternalDataBaseEntity.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/ExternalDataBaseEntity.java @@ -2,6 +2,8 @@ import java.util.List; +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.model.entities.base.CurieObject; import org.alliancegenome.curation_api.view.View; import org.eclipse.microprofile.openapi.annotations.media.Schema; @@ -37,6 +39,7 @@ @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @ToString(callSuper = true) @Schema(name = "ExternalDataBaseEntity", description = "POJO that represents the ExternalDataBaseEntity") +@AGRCurationSchemaVersion(min = "2.6.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { CurieObject.class }) public class ExternalDataBaseEntity extends CurieObject { @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Gene.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Gene.java index fbb6dff68..a2ed18954 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Gene.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Gene.java @@ -5,8 +5,8 @@ import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleGeneAssociation; -import org.alliancegenome.curation_api.model.entities.associations.geneAssociations.GeneGeneAssociation; import org.alliancegenome.curation_api.model.entities.associations.sequenceTargetingReagentAssociations.SequenceTargetingReagentGeneAssociation; +import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptGeneAssociation; import org.alliancegenome.curation_api.model.entities.ontology.SOTerm; import org.alliancegenome.curation_api.model.entities.slotAnnotations.geneSlotAnnotations.GeneFullNameSlotAnnotation; import org.alliancegenome.curation_api.model.entities.slotAnnotations.geneSlotAnnotations.GeneSecondaryIdSlotAnnotation; @@ -38,7 +38,7 @@ @Entity @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) -@ToString(exclude = { "geneDiseaseAnnotations", "geneGeneAssociations", "geneSymbol", "geneFullName", "geneSystematicName", "geneSynonyms", "geneSecondaryIds", "alleleGeneAssociations", "sequenceTargetingReagentGeneAssociations" }, callSuper = true) +@ToString(exclude = { "geneDiseaseAnnotations", "geneGeneAssociations", "geneSymbol", "geneFullName", "geneSystematicName", "geneSynonyms", "geneSecondaryIds", "alleleGeneAssociations", "sequenceTargetingReagentGeneAssociations", "transcriptGeneAssociations" }, callSuper = true) @Schema(name = "Gene", description = "POJO that represents the Gene") @AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { GenomicEntity.class }, partial = true) @Table(indexes = { @Index(name = "gene_genetype_index", columnList = "geneType_id") }) @@ -54,8 +54,8 @@ public class Gene extends GenomicEntity { @OneToMany(mappedBy = "diseaseAnnotationSubject", cascade = CascadeType.ALL, orphanRemoval = true) private List geneDiseaseAnnotations; - @OneToMany(mappedBy = "geneAssociationSubject", cascade = CascadeType.ALL, orphanRemoval = true) - private List geneGeneAssociations; + //@OneToMany(mappedBy = "geneAssociationSubject", cascade = CascadeType.ALL, orphanRemoval = true) + //private List geneGeneAssociations; @IndexedEmbedded(includePaths = { "displayText", "formatText", "nameType.name", "synonymScope.name", "evidence.curie", "displayText_keyword", "formatText_keyword", "nameType.name_keyword", "synonymScope.name_keyword", "evidence.curie_keyword"}) @OneToOne(mappedBy = "singleGene", cascade = CascadeType.ALL, orphanRemoval = true) @@ -101,4 +101,8 @@ public class Gene extends GenomicEntity { @OneToMany(mappedBy = "sequenceTargetingReagentGeneAssociationObject", cascade = CascadeType.ALL, orphanRemoval = true) @JsonView({ View.FieldsAndLists.class, View.GeneDetailView.class }) private List sequenceTargetingReagentGeneAssociations; + + @OneToMany(mappedBy = "transcriptGeneAssociationObject", cascade = CascadeType.ALL, orphanRemoval = true) + @JsonView({ View.FieldsAndLists.class, View.GeneDetailView.class }) + private List transcriptGeneAssociations; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/GeneDiseaseAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/GeneDiseaseAnnotation.java index 61754add1..3c2617943 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/GeneDiseaseAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/GeneDiseaseAnnotation.java @@ -4,8 +4,6 @@ import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.view.View; import org.eclipse.microprofile.openapi.annotations.media.Schema; -import org.hibernate.annotations.OnDelete; -import org.hibernate.annotations.OnDeleteAction; import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; @@ -29,11 +27,13 @@ @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @Schema(name = "Gene_Disease_Annotation", description = "Annotation class representing a gene disease annotation") @JsonTypeName("GeneDiseaseAnnotation") -@OnDelete(action = OnDeleteAction.CASCADE) @AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { DiseaseAnnotation.class }) + @Table(indexes = { - @Index(name = "GeneDiseaseAnnotation_DiseaseAnnotationSubject_index", columnList = "diseaseAnnotationSubject_id") + @Index(name = "GeneDiseaseAnnotation_diseaseAnnotationSubject_index", columnList = "diseaseAnnotationSubject_id"), + @Index(name = "GeneDiseaseAnnotation_sgdStrainBackground_index", columnList = "sgdStrainBackground_id") }) + public class GeneDiseaseAnnotation extends DiseaseAnnotation { @IndexedEmbedded(includePaths = { diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/GeneExpressionAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/GeneExpressionAnnotation.java index 83711b3f7..e5af5a562 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/GeneExpressionAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/GeneExpressionAnnotation.java @@ -1,13 +1,5 @@ package org.alliancegenome.curation_api.model.entities; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonView; -import jakarta.persistence.Entity; -import jakarta.persistence.Index; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.Table; -import lombok.Data; -import lombok.EqualsAndHashCode; import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.model.entities.ontology.MMOTerm; @@ -18,6 +10,16 @@ import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonView; + +import jakarta.persistence.Entity; +import jakarta.persistence.Index; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import lombok.Data; +import lombok.EqualsAndHashCode; + @Indexed @Entity @Data @@ -25,22 +27,36 @@ @Schema(name = "Gene_Expression_Annotation", description = "Annotation class representing a gene expression annotation") @JsonTypeName("GeneExpressionAnnotation") @AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { ExpressionAnnotation.class }) + @Table(indexes = { - @Index(name = "geneexpressionannotation_expression_annotation_subject_index", columnList = "expressionannotationsubject_id"), - @Index(name = "geneexpressionannotation_expression_assay_used_index", columnList = "expressionassayused_id") + @Index(name = "GeneExpressionAnnotation_internal_index", columnList = "internal"), + @Index(name = "GeneExpressionAnnotation_obsolete_index", columnList = "obsolete"), + @Index(name = "GeneExpressionAnnotation_curie_index", columnList = "curie"), + @Index(name = "GeneExpressionAnnotation_modEntityId_index", columnList = "modEntityId"), + @Index(name = "GeneExpressionAnnotation_modInternalId_index", columnList = "modInternalId"), + @Index(name = "GeneExpressionAnnotation_uniqueId_index", columnList = "uniqueId"), + @Index(name = "GeneExpressionAnnotation_createdBy_index", columnList = "createdBy_id"), + @Index(name = "GeneExpressionAnnotation_updatedBy_index", columnList = "updatedBy_id"), + @Index(name = "GeneExpressionAnnotation_singleReference_index", columnList = "singleReference_id"), + @Index(name = "GeneExpressionAnnotation_dataProvider_index", columnList = "dataProvider_id"), + @Index(name = "GeneExpressionAnnotation_expressionPattern_index", columnList = "expressionPattern_id"), + @Index(name = "GeneExpressionAnnotation_relation_index", columnList = "relation_id"), + @Index(name = "GeneExpressionAnnotation_expressionAnnotationSubject_index", columnList = "expressionAnnotationSubject_id"), + @Index(name = "GeneExpressionAnnotation_expressionAssayUsed_index", columnList = "expressionAssayUsed_id") }) + public class GeneExpressionAnnotation extends ExpressionAnnotation { @IndexedEmbedded(includePaths = {"geneSymbol.displayText", "geneSymbol.formatText", "geneSymbol.displayText_keyword", "geneSymbol.formatText_keyword", "curie", "curie_keyword", "taxon.curie", "taxon.name", "taxon.curie_keyword", "taxon.name_keyword"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne - @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) + @JsonView({View.FieldsOnly.class }) private Gene expressionAnnotationSubject; @IndexedEmbedded(includePaths = {"name", "name_keyword"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne - @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) + @JsonView({View.FieldsOnly.class}) private MMOTerm expressionAssayUsed; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/GeneGeneticInteraction.java b/src/main/java/org/alliancegenome/curation_api/model/entities/GeneGeneticInteraction.java index 4e23d0c64..00b8a32f9 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/GeneGeneticInteraction.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/GeneGeneticInteraction.java @@ -23,6 +23,7 @@ import jakarta.persistence.ElementCollection; import jakarta.persistence.Entity; import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; @@ -37,10 +38,27 @@ @EqualsAndHashCode(callSuper = true) @Schema(name = "Gene_Genetic_Interaction", description = "Class representing an interaction between genes") @AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { GeneInteraction.class }) + @Table(indexes = { - @Index(name = "genegeneticinteraction_interactorageneticperturbarion_index", columnList = "interactorageneticperturbation_id"), - @Index(name = "genegeneticinteraction_interactorbgeneticperturbarion_index", columnList = "interactorbgeneticperturbation_id") + @Index(name = "GeneGeneticInteraction_internal_index", columnList = "internal"), + @Index(name = "GeneGeneticInteraction_obsolete_index", columnList = "obsolete"), + @Index(name = "GeneGeneticInteraction_interactionId_index", columnList = "interactionId"), + @Index(name = "GeneGeneticInteraction_uniqueId_index", columnList = "uniqueId"), + @Index(name = "GeneGeneticInteraction_createdBy_index", columnList = "createdBy_id"), + @Index(name = "GeneGeneticInteraction_updatedBy_index", columnList = "updatedBy_id"), + @Index(name = "GeneGeneticInteraction_geneAssociationSubject_index", columnList = "geneAssociationSubject_id"), + @Index(name = "GeneGeneticInteraction_geneGeneAssociationObject_index", columnList = "geneGeneAssociationObject_id"), + @Index(name = "GeneGeneticInteraction_relation_index", columnList = "relation_id"), + @Index(name = "GeneGeneticInteraction_interactionSource_index", columnList = "interactionSource_id"), + @Index(name = "GeneGeneticInteraction_interactionType_index", columnList = "interactionType_id"), + @Index(name = "GeneGeneticInteraction_interactorARole_index", columnList = "interactorARole_id"), + @Index(name = "GeneGeneticInteraction_interactorAType_index", columnList = "interactorAType_id"), + @Index(name = "GeneGeneticInteraction_interactorBRole_index", columnList = "interactorBRole_id"), + @Index(name = "GeneGeneticInteraction_interactorBType_index", columnList = "interactorBType_id"), + @Index(name = "GeneGeneticInteraction_interactorAGeneticPerturbation_index", columnList = "interactorAGeneticPerturbation_id"), + @Index(name = "GeneGeneticInteraction_interactorBGeneticPerturbation_index", columnList = "interactorBGeneticPerturbation_id") }) + public class GeneGeneticInteraction extends GeneInteraction { @IndexedEmbedded(includePaths = { @@ -75,6 +93,12 @@ public class GeneGeneticInteraction extends GeneInteraction { @KeywordField(name = "phenotypesOrTraits_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") @ElementCollection @JsonView({View.FieldsAndLists.class, View.GeneInteractionView.class}) - @JoinTable(indexes = @Index(name = "genegeneticinteraction_phenotypesortraits_interaction_index", columnList = "genegeneticinteraction_id")) + @JoinTable( + joinColumns = @JoinColumn(name = "genegeneticinteraction_id"), + indexes = { + @Index(name = "genegeneticinteraction_phenotypesortraits_interaction_index", columnList = "genegeneticinteraction_id"), + @Index(name = "genegeneticinteraction_phenotypesortraits_pt_index", columnList = "phenotypesOrTraits") + } + ) private List phenotypesOrTraits; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/GeneInteraction.java b/src/main/java/org/alliancegenome/curation_api/model/entities/GeneInteraction.java index 9cd463267..ea9482c3d 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/GeneInteraction.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/GeneInteraction.java @@ -23,33 +23,22 @@ import jakarta.persistence.CascadeType; import jakarta.persistence.Column; -import jakarta.persistence.Entity; import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToOne; +import jakarta.persistence.MappedSuperclass; import jakarta.persistence.OneToMany; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -@Entity +@MappedSuperclass @Data @EqualsAndHashCode(callSuper = true) @AGRCurationSchemaVersion(min = "2.2.2", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { Annotation.class }) @ToString(callSuper = true) @Schema(name = "Gene_Interaction", description = "Annotation class representing a gene interaction") -@Table(indexes = { - @Index(name = "geneinteraction_interactionId_index", columnList = "interactionid"), - @Index(name = "geneinteraction_uniqueId_index", columnList = "uniqueid"), - @Index(name = "geneinteraction_interactionsource_index", columnList = "interactionsource_id"), - @Index(name = "geneinteraction_interactiontype_index", columnList = "interactiontype_id"), - @Index(name = "geneinteraction_interactorarole_index", columnList = "interactorarole_id"), - @Index(name = "geneinteraction_interactorbrole_index", columnList = "interactorbrole_id"), - @Index(name = "geneinteraction_interactoratype_index", columnList = "interactoratype_id"), - @Index(name = "geneinteraction_interactorbtype_index", columnList = "interactorbtype_id") -}) - public abstract class GeneInteraction extends GeneGeneAssociation { @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") @@ -67,12 +56,15 @@ public abstract class GeneInteraction extends GeneGeneAssociation { @IndexedEmbedded(includePaths = {"referencedCurie", "displayName", "referencedCurie_keyword", "displayName_keyword"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) - @JoinTable(indexes = { - @Index(columnList = "geneinteraction_id, crossreferences_id", name = "geneinteraction_crossreference_gi_xref_index"), - @Index(columnList = "geneinteraction_id", name = "geneinteraction_crossreference_geneinteraction_index"), - @Index(columnList = "crossreferences_id", name = "geneinteraction_crossreference_crossreferences_index") - }) @JsonView({ View.FieldsAndLists.class, View.GeneInteractionView.class }) + @JoinTable( + joinColumns = @JoinColumn(name = "geneinteraction_id"), + inverseJoinColumns = @JoinColumn(name = "crossReferences_id"), + indexes = { + @Index(columnList = "geneinteraction_id"), + @Index(columnList = "crossReferences_id") + } + ) private List crossReferences; @IndexedEmbedded(includePaths = {"curie", "name", "secondaryIdentifiers", "synonyms.name", "namespace", diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/GeneMolecularInteraction.java b/src/main/java/org/alliancegenome/curation_api/model/entities/GeneMolecularInteraction.java index db8708524..3107c4ce3 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/GeneMolecularInteraction.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/GeneMolecularInteraction.java @@ -29,10 +29,27 @@ @EqualsAndHashCode(callSuper = true) @Schema(name = "Gene_Molecular_Interaction", description = "Class representing an interaction between gene products") @AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { GeneInteraction.class }) + @Table(indexes = { - @Index(name = "genemolecularinteraction_aggregationdatabase_index", columnList = "aggregationdatabase_id"), - @Index(name = "genemolecularinteraction_detectionmethod_index", columnList = "detectionmethod_id") + @Index(name = "GeneMolecularInteraction_internal_index", columnList = "internal"), + @Index(name = "GeneMolecularInteraction_obsolete_index", columnList = "obsolete"), + @Index(name = "GeneMolecularInteraction_interactionId_index", columnList = "interactionId"), + @Index(name = "GeneMolecularInteraction_uniqueId_index", columnList = "uniqueId"), + @Index(name = "GeneMolecularInteraction_createdBy_index", columnList = "createdBy_id"), + @Index(name = "GeneMolecularInteraction_updatedBy_index", columnList = "updatedBy_id"), + @Index(name = "GeneMolecularInteraction_geneAssociationSubject_index", columnList = "geneAssociationSubject_id"), + @Index(name = "GeneMolecularInteraction_geneGeneAssociationObject_index", columnList = "geneGeneAssociationObject_id"), + @Index(name = "GeneMolecularInteraction_relation_index", columnList = "relation_id"), + @Index(name = "GeneMolecularInteraction_interactionSource_index", columnList = "interactionSource_id"), + @Index(name = "GeneMolecularInteraction_interactionType_index", columnList = "interactionType_id"), + @Index(name = "GeneMolecularInteraction_interactorARole_index", columnList = "interactorARole_id"), + @Index(name = "GeneMolecularInteraction_interactorAType_index", columnList = "interactorAType_id"), + @Index(name = "GeneMolecularInteraction_interactorBRole_index", columnList = "interactorBRole_id"), + @Index(name = "GeneMolecularInteraction_interactorBType_index", columnList = "interactorBType_id"), + @Index(name = "GeneMolecularInteraction_aggregationDatabase_index", columnList = "aggregationDatabase_id"), + @Index(name = "GeneMolecularInteraction_detectionMethod_index", columnList = "detectionMethod_id") }) + public class GeneMolecularInteraction extends GeneInteraction { @IndexedEmbedded(includePaths = {"curie", "name", "secondaryIdentifiers", "synonyms.name", "namespace", @@ -50,4 +67,4 @@ public class GeneMolecularInteraction extends GeneInteraction { @Fetch(FetchMode.SELECT) @JsonView({ View.FieldsOnly.class }) private MITerm detectionMethod; -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/GenePhenotypeAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/GenePhenotypeAnnotation.java index ad9fc2d83..f8f9ad158 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/GenePhenotypeAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/GenePhenotypeAnnotation.java @@ -28,10 +28,12 @@ @Schema(name = "Gene_Phenotype_Annotation", description = "Annotation class representing a gene phenotype annotation") @JsonTypeName("GenePhenotypeAnnotation") @AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { PhenotypeAnnotation.class }) + @Table(indexes = { - @Index(name = "genephenotypeannotation_phenotypeannotationsubject_index", columnList = "phenotypeannotationsubject_id"), - @Index(name = "genephenotypeannotation_sgdstrainbackground_index", columnList = "sgdstrainbackground_id") + @Index(name = "GenePhenotypeAnnotation_phenotypeAnnotationSubject_index", columnList = "phenotypeAnnotationSubject_id"), + @Index(name = "GenePhenotypeAnnotation_sgdStrainBackground_index", columnList = "sgdStrainBackground_id") }) + public class GenePhenotypeAnnotation extends PhenotypeAnnotation { @IndexedEmbedded(includePaths = { @@ -99,4 +101,4 @@ public String getSubjectSpeciesName() { } return phenotypeAnnotationSubject.getTaxon().getGenusSpecies(); } -} \ No newline at end of file +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/GenomicEntity.java b/src/main/java/org/alliancegenome/curation_api/model/entities/GenomicEntity.java index c4e973e04..3bc9a17c8 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/GenomicEntity.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/GenomicEntity.java @@ -37,7 +37,7 @@ public class GenomicEntity extends BiologicalEntity { @Index(columnList = "crossreferences_id", name = "genomicentity_crossreference_crossreferences_index") }) @EqualsAndHashCode.Include - @JsonView({ View.FieldsAndLists.class, View.AlleleView.class, View.GeneView.class, View.AffectedGenomicModelView.class }) + @JsonView({ View.FieldsAndLists.class, View.AlleleView.class, View.GeneView.class, View.AffectedGenomicModelView.class, View.VariantView.class }) private List crossReferences; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/HTPExpressionDatasetAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/HTPExpressionDatasetAnnotation.java index ca9d7a342..c0956e3ed 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/HTPExpressionDatasetAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/HTPExpressionDatasetAnnotation.java @@ -4,11 +4,13 @@ import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; -import org.alliancegenome.curation_api.model.entities.base.SubmittedObject; +import org.alliancegenome.curation_api.model.entities.base.AuditedObject; import org.alliancegenome.curation_api.view.View; import org.eclipse.microprofile.openapi.annotations.media.Schema; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; import org.hibernate.search.engine.backend.types.Aggregable; import org.hibernate.search.engine.backend.types.Projectable; import org.hibernate.search.engine.backend.types.Searchable; @@ -26,14 +28,21 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; + @Entity @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @ToString(callSuper = true) -@Table(name = "htpexpressiondatasetannotation") @Schema(name = "HTPExpressionDatasetAnnotation", description = "POJO that represents the HighThroughputExpressionDatasetAnnotation") -@AGRCurationSchemaVersion(min = "2.6.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { SubmittedObject.class }) -public class HTPExpressionDatasetAnnotation extends SubmittedObject { +@AGRCurationSchemaVersion(min = "2.6.2", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AuditedObject.class }) +@Table(indexes = { + @Index(name = "htpdatasetannotation_htpExpressionDataset_index", columnList = "htpExpressionDataset_id"), + @Index(name = "htpdatasetannotation_relatednote_index", columnList = "relatednote_id"), + @Index(name = "htpdatasetannotation_dataprovider_index", columnList = "dataprovider_id"), + @Index(name = "htpdatasetannotation_createdby_index", columnList = "createdby_id"), + @Index(name = "htpdatasetannotation_updatedby_index", columnList = "updatedby_id") +}) +public class HTPExpressionDatasetAnnotation extends AuditedObject { @IndexedEmbedded(includeDepth = 1) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @@ -81,8 +90,18 @@ public class HTPExpressionDatasetAnnotation extends SubmittedObject { @IndexedEmbedded(includePaths = {"name", "name_keyword"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany + @OnDelete(action = OnDeleteAction.CASCADE) @JsonView({ View.FieldsAndLists.class }) @JoinTable(name = "htpexpressiondatasetannotation_categorytags", indexes = { @Index(name = "htpdatasetannotation_htpdatasetid_index", columnList = "htpexpressiondatasetannotation_id"), @Index(name = "htpdatasetannotation_categorytags_index", columnList = "categorytags_id")}) List categoryTags; -} + @IndexedEmbedded(includePaths = { + "sourceOrganization.abbreviation", "sourceOrganization.fullName", "sourceOrganization.shortName", "crossReference.displayName", "crossReference.referencedCurie", + "sourceOrganization.abbreviation_keyword", "sourceOrganization.fullName_keyword", "sourceOrganization.shortName_keyword", "crossReference.displayName_keyword", "crossReference.referencedCurie_keyword" + }) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + DataProvider dataProvider; + +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/HTPExpressionDatasetSampleAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/HTPExpressionDatasetSampleAnnotation.java new file mode 100644 index 000000000..4941d6d84 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/HTPExpressionDatasetSampleAnnotation.java @@ -0,0 +1,171 @@ +package org.alliancegenome.curation_api.model.entities; + +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; + +import java.util.List; + +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.model.entities.base.AuditedObject; +import org.alliancegenome.curation_api.model.entities.ontology.MMOTerm; +import org.alliancegenome.curation_api.model.entities.ontology.NCBITaxonTerm; +import org.alliancegenome.curation_api.model.entities.ontology.OBITerm; +import org.alliancegenome.curation_api.view.View; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; +import org.hibernate.search.engine.backend.types.Aggregable; +import org.hibernate.search.engine.backend.types.Searchable; +import org.hibernate.search.engine.backend.types.Sortable; +import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; + +import com.fasterxml.jackson.annotation.JsonView; + +import jakarta.persistence.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Entity +@Data +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +@ToString(callSuper = true) +@Schema(name = "HTPExpressionDatasetSampleAnnotation", description = "POJO that represents the HighThroughputExpressionDatasetSampleAnnotation") +@AGRCurationSchemaVersion(min = "2.7.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AuditedObject.class }) +@Table(indexes = { + @Index(name = "htpdatasample_htpExpressionSample_index", columnList = "htpExpressionSample_id"), + @Index(name = "htpdatasample_htpExpressionSampleType_index", columnList = "htpExpressionSampleType_id"), + @Index(name = "htpdatasample_expressionAssayUsed_index", columnList = "expressionAssayUsed_id"), + @Index(name = "htpdatasample_htpExpressionSampleAge_index", columnList = "htpExpressionSampleAge_id"), + @Index(name = "htpdatasample_genomicInformation_index", columnList = "genomicInformation_id"), + @Index(name = "htpdatasample_microarraySampleDetails_index", columnList = "microarraySampleDetails_id"), + @Index(name = "htpdatasample_geneticSex_index", columnList = "geneticSex_id"), + @Index(name = "htpdatasample_sequencingFormat_index", columnList = "sequencingFormat_id"), + @Index(name = "htpdatasample_taxon_index", columnList = "taxon_id"), + @Index(name = "htpdatasample_dataprovider_index", columnList = "dataprovider_id"), + @Index(name = "htpdatasample_createdby_index", columnList = "createdby_id"), + @Index(name = "htpdatasample_updatedby_index", columnList = "updatedby_id") +}) +public class HTPExpressionDatasetSampleAnnotation extends AuditedObject { + + @IndexedEmbedded(includePaths = {"curie", "preferredCrossReference.referencedCurie", "secondaryIdentifiers", + "curie_keyword", "preferredCrossReference.referencedCurie_keyword", "secondaryIdentifiers_keyword" }) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) + @JsonView({ View.FieldsOnly.class }) + private ExternalDataBaseEntity htpExpressionSample; + + @IndexedEmbedded(includePaths = {"curie", "name", "secondaryIdentifiers", "synonyms.name", "abbreviation", + "curie_keyword", "name_keyword", "secondaryIdentifiers_keyword", "synonyms.name_keyword", "abbreviation_keyword" }) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView(View.FieldsOnly.class) + private OBITerm htpExpressionSampleType; + + @IndexedEmbedded(includePaths = {"curie", "name", "secondaryIdentifiers", "synonyms.name", "abbreviation", + "curie_keyword", "name_keyword", "secondaryIdentifiers_keyword", "synonyms.name_keyword", "abbreviation_keyword" }) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView(View.FieldsAndLists.class) + private MMOTerm expressionAssayUsed; + + @IndexedEmbedded(includePaths = {"age", "whenExpressedStageName", "age_keyword", "whenExpressedStageName_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) + @JsonView({ View.FieldsOnly.class }) + private BioSampleAge htpExpressionSampleAge; + + @IndexedEmbedded(includePaths = {"bioSampleAllele.curie", "bioSampleAllele.modInternalId", "bioSampleAllele.modEntityId", "bioSampleAllele.modEntityId_keyword", + "bioSampleAllele.modInternalId_keyword", "bioSampleAgm.curie", "bioSampleAgm.modInternalId", "bioSampleAgm.modEntityId", "bioSampleAgm.modInternalId_keyword", + "bioSampleAgm.modEntityId_keyword", "bioSampleAllele.curie_keyword", "bioSampleAgm.curie_keyword", "bioSampleText", "bioSampleText_keyword" + }) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) + @JsonView({ View.FieldsOnly.class }) + private BioSampleGenomicInformation genomicInformation; + + @IndexedEmbedded(includePaths = {"channelId", "channelId_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true) + @JsonView({ View.FieldsOnly.class }) + private MicroarraySampleDetails microarraySampleDetails; + + @IndexedEmbedded(includePaths = { + "sourceOrganization.abbreviation", "sourceOrganization.fullName", "sourceOrganization.shortName", "crossReference.displayName", "crossReference.referencedCurie", + "sourceOrganization.abbreviation_keyword", "sourceOrganization.fullName_keyword", "sourceOrganization.shortName_keyword", "crossReference.displayName_keyword", "crossReference.referencedCurie_keyword" + }) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + DataProvider dataProvider; + + @IndexedEmbedded(includePaths = {"name", "name_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + private VocabularyTerm geneticSex; + + @IndexedEmbedded(includePaths = {"name", "name_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + private VocabularyTerm sequencingFormat; + + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToMany + @JoinTable(indexes = { + @Index(name = "htpdatasample_anatomicalsite_htpdatasample_index", columnList = "htpexpressiondatasetsampleannotation_id"), + @Index(name = "htpdatasample_anatomicalsite_samplelocations_index", columnList = "htpexpressionsamplelocations_id") + }) + @JsonView({ View.FieldsAndLists.class }) + @Fetch(FetchMode.JOIN) + private List htpExpressionSampleLocations; + + @IndexedEmbedded(includePaths = {"freeText", "freeText_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @JsonView({ View.FieldsAndLists.class, View.AlleleView.class }) + @JoinTable(indexes = { + @Index(name = "htpdatasample_note_htpdatasample_index", columnList = "htpexpressiondatasetsampleannotation_id"), + @Index(name = "htpdatasample_note_relatednotes_index", columnList = "relatednotes_id")}) + private List relatedNotes; + + @IndexedEmbedded(includePaths = {"name", "curie", "name_keyword", "curie_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + private NCBITaxonTerm taxon; + + @JsonView({ View.FieldsOnly.class }) + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "htpexpressionsampletitle_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + private String htpExpressionSampleTitle; + + @JsonView({ View.FieldsOnly.class }) + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "abundance_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + private String abundance; + + @JsonView({ View.FieldsOnly.class }) + @ElementCollection + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "assemblyversions_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @JoinTable(indexes = @Index(name = "htpdatasample_assemblyversions_htpdatasample_index", columnList = "htpexpressiondatasetsampleannotation_id")) + private List assemblyVersions; + + @IndexedEmbedded(includePaths = {"curie", "preferredCrossReference.referencedCurie", "secondaryIdentifiers", + "curie_keyword", "preferredCrossReference.referencedCurie_keyword", "secondaryIdentifiers_keyword" }) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToMany + @Fetch(FetchMode.JOIN) + @JoinTable(indexes = { + @Index(name = "htpdatasample_externaldatabaseentity_htpdatasample_index", columnList = "htpexpressiondatasetsampleannotation_id"), + @Index(name = "htpdatasample_externaldatabaseentity_datasetids_index", columnList = "datasetids_id") + }) + @JsonView({ View.FieldsAndLists.class }) + private List datasetIds; + +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/MicroarraySampleDetails.java b/src/main/java/org/alliancegenome/curation_api/model/entities/MicroarraySampleDetails.java new file mode 100644 index 000000000..0546dea73 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/MicroarraySampleDetails.java @@ -0,0 +1,42 @@ +package org.alliancegenome.curation_api.model.entities; + +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.entities.base.AuditedObject; +import org.alliancegenome.curation_api.view.View; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.hibernate.search.engine.backend.types.Aggregable; +import org.hibernate.search.engine.backend.types.Projectable; +import org.hibernate.search.engine.backend.types.Searchable; +import org.hibernate.search.engine.backend.types.Sortable; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; + +import com.fasterxml.jackson.annotation.JsonView; + +import jakarta.persistence.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Entity +@Data +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +@ToString(callSuper = true) +@Schema(name = "MicroarraySampleDetails", description = "POJO that represents the MicroarraySampleDetails") +@AGRCurationSchemaVersion(min = "2.7.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AuditedObject.class }) +@Indexed +public class MicroarraySampleDetails extends AuditedObject { + + @JsonView({ View.FieldsOnly.class }) + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "channelid_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + private String channelId; + + @JsonView({ View.FieldsOnly.class }) + @GenericField(projectable = Projectable.YES, sortable = Sortable.YES) + private Integer channelNumber; + +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Organization.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Organization.java index 8520a597b..6ed8573a7 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Organization.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Organization.java @@ -33,6 +33,7 @@ @AGRCurationSchemaVersion(min = "1.4.1", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { Agent.class }) @Table(indexes = { @Index(name = "organization_homepageresourcedescriptorpage_id_index", columnList = "homepageresourcedescriptorpage_id"), + @Index(name = "organization_abbreviation_index", columnList = "abbreviation"), @Index(name = "organization_createdby_index", columnList = "createdBy_id"), @Index(name = "organization_updatedby_index", columnList = "updatedBy_id") }) diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/PhenotypeAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/PhenotypeAnnotation.java index 785411533..3c9fcbeb8 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/PhenotypeAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/PhenotypeAnnotation.java @@ -25,6 +25,9 @@ import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; import jakarta.persistence.Index; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToOne; @@ -34,6 +37,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; +@Inheritance(strategy = InheritanceType.JOINED) @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") @JsonSubTypes({ @Type(value = AGMPhenotypeAnnotation.class, name = "AGMPhenotypeAnnotation"), @Type(value = AllelePhenotypeAnnotation.class, name = "AllelePhenotypeAnnotation"), @Type(value = GenePhenotypeAnnotation.class, name = "GenePhenotypeAnnotation") }) @@ -43,7 +47,18 @@ @AGRCurationSchemaVersion(min = "2.2.3", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { Annotation.class }) @Schema(name = "Phenotype_Annotation", description = "Annotation class representing a phenotype annotation") @Table(indexes = { - @Index(name = "phenotypeannotation_relation_index", columnList = "relation_id") + @Index(name = "PhenotypeAnnotation_internal_index", columnList = "internal"), + @Index(name = "PhenotypeAnnotation_obsolete_index", columnList = "obsolete"), + @Index(name = "PhenotypeAnnotation_curie_index", columnList = "curie"), + @Index(name = "PhenotypeAnnotation_modEntityId_index", columnList = "modEntityId"), + @Index(name = "PhenotypeAnnotation_modInternalId_index", columnList = "modInternalId"), + @Index(name = "PhenotypeAnnotation_uniqueId_index", columnList = "uniqueId"), + @Index(name = "PhenotypeAnnotation_createdBy_index", columnList = "createdBy_id"), + @Index(name = "PhenotypeAnnotation_updatedBy_index", columnList = "updatedBy_id"), + @Index(name = "PhenotypeAnnotation_singleReference_index", columnList = "singleReference_id"), + @Index(name = "PhenotypeAnnotation_dataProvider_index", columnList = "dataProvider_id"), + @Index(name = "PhenotypeAnnotation_crossReference_index", columnList = "crossReference_id"), + @Index(name = "PhenotypeAnnotation_relation_index", columnList = "relation_id") }) public abstract class PhenotypeAnnotation extends Annotation { @@ -57,10 +72,14 @@ public abstract class PhenotypeAnnotation extends Annotation { @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany @JsonView({ View.FieldsAndLists.class, View.PhenotypeAnnotationView.class, View.ForPublic.class }) - @JoinTable(indexes = { - @Index(name = "phenotypeannotation_ontologyterm_phenotypeannotation_index", columnList = "phenotypeannotation_id"), - @Index(name = "phenotypeannotation_ontologyterm_phenotypeterms_index", columnList = "phenotypeterms_id") - }) + @JoinTable( + joinColumns = @JoinColumn(name = "phenotypeannotation_id"), + inverseJoinColumns = @JoinColumn(name = "phenotypeTerms_id"), + indexes = { + @Index(name = "phenotypeannotation_ontologyterm_pa_index", columnList = "phenotypeannotation_id"), + @Index(name = "phenotypeannotation_ontologyterm_phenotypeterms_index", columnList = "phenotypeTerms_id") + } + ) private List phenotypeTerms; @IndexedEmbedded(includePaths = {"name", "name_keyword"}) diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Reference.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Reference.java index 555ffdfa1..dc53a3bf2 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Reference.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Reference.java @@ -28,6 +28,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonView; +import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.Index; import jakarta.persistence.JoinTable; @@ -61,7 +62,9 @@ public class Reference extends InformationContentEntity { @JsonView({ View.FieldsOnly.class }) @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") - @KeywordField(name = "shortCitation_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") private String shortCitation; + @KeywordField(name = "shortCitation_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @Column(columnDefinition = "TEXT") + private String shortCitation; /** * Retrieve PMID if available in the crossReference collection otherwise MOD ID diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/ResourceDescriptor.java b/src/main/java/org/alliancegenome/curation_api/model/entities/ResourceDescriptor.java index f1a5e0b6c..434faa2c1 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/ResourceDescriptor.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/ResourceDescriptor.java @@ -7,6 +7,8 @@ import org.alliancegenome.curation_api.model.entities.base.AuditedObject; import org.alliancegenome.curation_api.view.View; import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; import org.hibernate.search.engine.backend.types.Aggregable; import org.hibernate.search.engine.backend.types.Searchable; import org.hibernate.search.engine.backend.types.Sortable; @@ -61,6 +63,7 @@ public class ResourceDescriptor extends AuditedObject { @KeywordField(name = "synoynyms_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES) @ElementCollection @JoinTable(indexes = @Index(columnList = "resourcedescriptor_id")) + @Fetch(FetchMode.JOIN) @JsonView({ View.ResourceDescriptorView.class, View.FieldsAndLists.class }) private List synonyms; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/SequenceTargetingReagent.java b/src/main/java/org/alliancegenome/curation_api/model/entities/SequenceTargetingReagent.java index 6fb8a4510..2256187be 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/SequenceTargetingReagent.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/SequenceTargetingReagent.java @@ -59,14 +59,14 @@ public class SequenceTargetingReagent extends GenomicEntity { @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") @KeywordField(name = "synonyms_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") @ElementCollection - @JoinTable(indexes = @Index(name = "sequencetargetingreagent_synonyms_sequencetargetingreagent_index", columnList = "sequencetargetingreagent_id")) + @JoinTable(indexes = @Index(name = "sqtr_synonyms_sqtr_index", columnList = "sequencetargetingreagent_id")) @JsonView({ View.FieldsAndLists.class, View.SequenceTargetingReagentView.class }) private List synonyms; @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") @KeywordField(name = "secondaryIdentifiers_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") @ElementCollection - @JoinTable(indexes = @Index(name = "sequencetargetingreagent_secondaryIdentifiers_sequencetargetingreagent_index", columnList = "sequencetargetingreagent_id")) + @JoinTable(indexes = @Index(name = "sqtr_secondaryIdentifiers_sqtr_index", columnList = "sequencetargetingreagent_id")) @JsonView({ View.FieldsAndLists.class, View.SequenceTargetingReagentView.class }) private List secondaryIdentifiers; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/SingleReferenceAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/SingleReferenceAssociation.java index a75062653..eb5b122e2 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/SingleReferenceAssociation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/SingleReferenceAssociation.java @@ -10,23 +10,16 @@ import com.fasterxml.jackson.annotation.JsonView; -import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.ManyToOne; -import jakarta.persistence.Table; +import jakarta.persistence.MappedSuperclass; import lombok.Data; import lombok.EqualsAndHashCode; -@Entity +@MappedSuperclass @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @Schema(name = "singleReferenceAssociation", description = "POJO that represents an association supported by a single reference") @AGRCurationSchemaVersion(min = "1.9.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { Association.class }) - -@Table(indexes = { - @Index(name = "singlereferenceassociation_singlereference_index", columnList = "singleReference_id") -}) - public class SingleReferenceAssociation extends Association { @IndexedEmbedded(includePaths = {"curie", "primaryCrossReferenceCurie", "crossReferences.referencedCurie", diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/TemporalContext.java b/src/main/java/org/alliancegenome/curation_api/model/entities/TemporalContext.java new file mode 100644 index 000000000..293eee1ab --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/TemporalContext.java @@ -0,0 +1,87 @@ +package org.alliancegenome.curation_api.model.entities; + +import java.util.List; + +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.entities.base.AuditedObject; +import org.alliancegenome.curation_api.model.entities.ontology.StageTerm; +import org.alliancegenome.curation_api.view.View; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.hibernate.search.engine.backend.types.Aggregable; +import org.hibernate.search.engine.backend.types.Searchable; +import org.hibernate.search.engine.backend.types.Sortable; +import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; + +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonView; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Index; +import jakarta.persistence.JoinTable; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") +@Entity +@Data +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +@AGRCurationSchemaVersion(min = "2.2.3", max = LinkMLSchemaConstants.LATEST_RELEASE) +@Schema(name = "Temporal_Context", description = "Temporal expression pattern") +@Table(indexes = { + @Index(name = "temporalcontext_developmentalstagestart_index ", columnList = "developmentalstagestart_id"), + @Index(name = "temporalcontext_developmentalstagestop_index ", columnList = "developmentalstagestop_id"), + @Index(name = "temporalcontext_age_index ", columnList = "age") +}) +public class TemporalContext extends AuditedObject { + + @IndexedEmbedded(includePaths = {"name", "name_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({View.FieldsOnly.class}) + private StageTerm developmentalStageStart; + + @IndexedEmbedded(includePaths = {"name", "name_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({View.FieldsOnly.class}) + private StageTerm developmentalStageStop; + + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "age_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @JsonView({View.FieldsOnly.class}) + @Column(length = 1000) + private String age; + + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "temporalqualifiers_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @ManyToMany + @JsonView({View.FieldsOnly.class}) + @JoinTable( + name = "temporalcontext_temporalqualifiers", + indexes = { + @Index(name = "temporalqualifiers_temporalcontext_index", columnList = "temporalcontext_id"), + @Index(name = "temporalqualifiers_temporalqualifiers_index", columnList = "temporalqualifiers_id")} + ) + private List temporalQualifiers; + + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "stageuberonslimterms_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @ManyToMany + @JsonView({View.FieldsOnly.class}) + @JoinTable( + name = "temporalcontext_stageuberonslimterms", + indexes = { + @Index(name = "stageuberonslimterms_temporalcontext_index", columnList = "temporalcontext_id"), + @Index(name = "stageuberonslimterms_uberonterms_index", columnList = "stageuberonslimterms_id")} + ) + private List stageUberonSlimTerms; +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Transcript.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Transcript.java index 8c8f5efe2..46254b04e 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Transcript.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Transcript.java @@ -4,12 +4,14 @@ import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptCodingSequenceAssociation; +import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptExonAssociation; +import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptGeneAssociation; import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptGenomicLocationAssociation; import org.alliancegenome.curation_api.model.entities.ontology.SOTerm; import org.alliancegenome.curation_api.view.View; import org.eclipse.microprofile.openapi.annotations.media.Schema; import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; -import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; @@ -17,19 +19,24 @@ import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; +import jakarta.persistence.Index; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -@Indexed +//@Indexed @Entity @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) -@ToString(exclude = "transcriptGenomicLocationAssociations", callSuper = true) +@ToString(exclude = { "transcriptGenomicLocationAssociations", "transcriptGeneAssociations", "transcriptCodingSequenceAssociations", "transcriptExonAssociations" }, callSuper = true) @Schema(name = "Transcript", description = "POJO that represents the Transcript") @AGRCurationSchemaVersion(min = "2.4.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { GenomicEntity.class }) +@Table(indexes = { + @Index(name = "transcript_transcriptType_index", columnList = "transcriptType_id") +}) public class Transcript extends GenomicEntity { @JsonView({ View.FieldsOnly.class }) @@ -53,4 +60,39 @@ public class Transcript extends GenomicEntity { @JsonView({ View.FieldsAndLists.class }) private List transcriptGenomicLocationAssociations; + @IndexedEmbedded( + includePaths = { + "transcriptCodingSequenceAssociationObject.curie", "transcriptCodingSequenceAssociationObject.name", "transcriptCodingSequenceAssociationObject.modEntityId", + "transcriptCodingSequenceAssociationObject.modInternalId", "transcriptCodingSequenceAssociationObject.uniqueId", + "transcriptCodingSequenceAssociationObject.curie_keyword", "transcriptCodingSequenceAssociationObject.name_keyword", "transcriptCodingSequenceAssociationObject.modEntityId_keyword", + "transcriptCodingSequenceAssociationObject.modInternalId_keyword", "transcriptCodingSequenceAssociationObject.uniqueId_keyword" + } + ) + @OneToMany(mappedBy = "transcriptAssociationSubject", cascade = CascadeType.ALL, orphanRemoval = true) + @JsonView({ View.FieldsAndLists.class }) + private List transcriptCodingSequenceAssociations; + + @IndexedEmbedded( + includePaths = { + "transcriptExonAssociationObject.curie", "transcriptExonAssociationObject.name", "transcriptExonAssociationObject.modEntityId", + "transcriptExonAssociationObject.modInternalId", "transcriptExonAssociationObject.uniqueId", + "transcriptExonAssociationObject.curie_keyword", "transcriptExonAssociationObject.name_keyword", "transcriptExonAssociationObject.modEntityId_keyword", + "transcriptExonAssociationObject.modInternalId_keyword", "transcriptExonAssociationObject.uniqueId_keyword" + } + ) + @OneToMany(mappedBy = "transcriptAssociationSubject", cascade = CascadeType.ALL, orphanRemoval = true) + @JsonView({ View.FieldsAndLists.class }) + private List transcriptExonAssociations; + + @IndexedEmbedded( + includePaths = { + "transcriptGeneAssociationObject.curie", "transcriptGeneAssociationObject.geneSymbol.displayText", "transcriptGeneAssociationObject.geneSymbol.formatText", "transcriptGeneAssociationObject.geneFullName.displayText", + "transcriptGeneAssociationObject.geneFullName.formatText", "transcriptGeneAssociationObject.curie_keyword", "transcriptGeneAssociationObject.geneSymbol.displayText_keyword", + "transcriptGeneAssociationObject.geneSymbol.formatText_keyword", "transcriptGeneAssociationObject.geneFullName.displayText_keyword", "transcriptGeneAssociationObject.geneFullName.formatText_keyword", + "transcriptGeneAssociationObject.modEntityId", "transcriptGeneAssociationObject.modInternalId", "transcriptGeneAssociationObject.modEntityId_keyword", "transcriptGeneAssociationObject.modInternalId_keyword" + } + ) + @OneToMany(mappedBy = "transcriptAssociationSubject", cascade = CascadeType.ALL, orphanRemoval = true) + @JsonView({ View.FieldsAndLists.class }) + private List transcriptGeneAssociations; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/Variant.java b/src/main/java/org/alliancegenome/curation_api/model/entities/Variant.java index ea95566ea..fd9e50323 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/Variant.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/Variant.java @@ -4,6 +4,8 @@ import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleVariantAssociation; +import org.alliancegenome.curation_api.model.entities.associations.variantAssociations.CuratedVariantGenomicLocationAssociation; import org.alliancegenome.curation_api.model.entities.ontology.SOTerm; import org.alliancegenome.curation_api.view.View; import org.hibernate.annotations.Fetch; @@ -30,7 +32,7 @@ @Entity @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) -@ToString(exclude = { }, callSuper = true) +@ToString(exclude = { "curatedVariantGenomicLocations", "alleleVariantAssociations" }, callSuper = true) @AGRCurationSchemaVersion(min = "1.10.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { GenomicEntity.class }) @Table(indexes = { @Index(name = "variant_varianttype_index", columnList = "varianttype_id"), @@ -70,5 +72,21 @@ public class Variant extends GenomicEntity { @Index(name = "variant_note_relatednotes_index", columnList = "relatedNotes_id") }) private List relatedNotes; + + @IndexedEmbedded( + includePaths = { + "variantGenomicLocationAssociationObject.curie", "variantGenomicLocationAssociationObject.curie_keyword", + "variantGenomicLocationAssociationObject.modEntityId", "variantGenomicLocationAssociationObject.modEntityId_keyword", + "variantGenomicLocationAssociationObject.modInternalId", "variantGenomicLocationAssociationObject.modInternalId_keyword", + "start", "end" + } + ) + @OneToMany(mappedBy = "variantAssociationSubject", cascade = CascadeType.ALL, orphanRemoval = true) + @JsonView({ View.FieldsAndLists.class, View.VariantView.class }) + private List curatedVariantGenomicLocations; + + @OneToMany(mappedBy = "alleleVariantAssociationObject", cascade = CascadeType.ALL, orphanRemoval = true) + @JsonView({ View.FieldsAndLists.class, View.VariantDetailView.class }) + private List alleleVariantAssociations; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/VocabularyTerm.java b/src/main/java/org/alliancegenome/curation_api/model/entities/VocabularyTerm.java index fa5961687..4aa2dcb3d 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/VocabularyTerm.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/VocabularyTerm.java @@ -59,6 +59,7 @@ public class VocabularyTerm extends AuditedObject { @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") @KeywordField(name = "definition_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") @JsonView({ View.FieldsOnly.class }) + @Column(columnDefinition = "TEXT") private String definition; @IndexedEmbedded(includeDepth = 1) diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGeneAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGeneAssociation.java index 9e7e01a3b..57897898c 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGeneAssociation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGeneAssociation.java @@ -29,12 +29,19 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AlleleGenomicEntityAssociation.class }) @Schema(name = "AlleleGeneAssociation", description = "POJO representing an association between an allele and a gene") -@Table( - indexes = { - @Index(name = "allelegeneassociation_alleleassociationsubject_index", columnList = "alleleassociationsubject_id"), - @Index(name = "allelegeneassociation_allelegeneassociationobject_index", columnList = "allelegeneassociationobject_id") - } -) + +@Table(indexes = { + @Index(name = "AlleleGeneAssociation_internal_index", columnList = "internal"), + @Index(name = "AlleleGeneAssociation_obsolete_index", columnList = "obsolete"), + @Index(name = "AlleleGeneAssociation_createdBy_index", columnList = "createdBy_id"), + @Index(name = "AlleleGeneAssociation_updatedBy_index", columnList = "updatedBy_id"), + @Index(name = "AlleleGeneAssociation_evidenceCode_index", columnList = "evidencecode_id"), + @Index(name = "AlleleGeneAssociation_relatedNote_index", columnList = "relatedNote_id"), + @Index(name = "AlleleGeneAssociation_relation_index", columnList = "relation_id"), + @Index(name = "AlleleGeneAssociation_alleleAssociationSubject_index", columnList = "alleleAssociationSubject_id"), + @Index(name = "AlleleGeneAssociation_alleleGeneAssociationObject_index", columnList = "alleleGeneAssociationObject_id") +}) + public class AlleleGeneAssociation extends AlleleGenomicEntityAssociation { @IndexedEmbedded(includePaths = { @@ -43,7 +50,7 @@ public class AlleleGeneAssociation extends AlleleGenomicEntityAssociation { "alleleFullName.formatText_keyword", "modEntityId", "modEntityId_keyword", "modInternalId", "modInternalId_keyword" }) @ManyToOne @JsonView({ View.FieldsOnly.class }) - @JsonIgnoreProperties("alleleGeneAssociations") + @JsonIgnoreProperties({"alleleGeneAssociations", "alleleVariantAssociations"}) @Fetch(FetchMode.JOIN) private Allele alleleAssociationSubject; @@ -54,6 +61,6 @@ public class AlleleGeneAssociation extends AlleleGenomicEntityAssociation { @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne @JsonView({ View.FieldsOnly.class, View.AlleleView.class }) - @JsonIgnoreProperties({ "alleleGeneAssociations", "constructGenomicEntityAssociations" }) + @JsonIgnoreProperties({ "alleleGeneAssociations", "constructGenomicEntityAssociations", "sequenceTargetingReagentGeneAssociations", "transcriptGeneAssociations" }) private Gene alleleGeneAssociationObject; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGenomicEntityAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGenomicEntityAssociation.java index db25b7827..8b546b8ea 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGenomicEntityAssociation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleGenomicEntityAssociation.java @@ -15,26 +15,19 @@ import com.fasterxml.jackson.annotation.JsonView; import jakarta.persistence.CascadeType; -import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.ManyToOne; +import jakarta.persistence.MappedSuperclass; import jakarta.persistence.OneToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -@Entity +@MappedSuperclass @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.9.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { EvidenceAssociation.class }) @Schema(name = "AlleleGenomicEntityAssociation", description = "POJO representing an association between an allele and a genomic entity") -@Table( - indexes = { - @Index(name = "allelegenomicentityassociation_relation_index", columnList = "relation_id") - } -) public class AlleleGenomicEntityAssociation extends EvidenceAssociation { @IndexedEmbedded(includePaths = { "name", "name_keyword" }) diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleVariantAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleVariantAssociation.java new file mode 100644 index 000000000..4293c5b57 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/alleleAssociations/AlleleVariantAssociation.java @@ -0,0 +1,64 @@ +package org.alliancegenome.curation_api.model.entities.associations.alleleAssociations; + +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.entities.Allele; +import org.alliancegenome.curation_api.model.entities.Variant; +import org.alliancegenome.curation_api.view.View; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; +import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonView; + +import jakarta.persistence.Entity; +import jakarta.persistence.Index; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Entity +@Data +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +@ToString(callSuper = true) +@AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AlleleGenomicEntityAssociation.class }) +@Schema(name = "AlleleVariantAssociation", description = "POJO representing an association between an allele and a gene") + +@Table(indexes = { + @Index(name = "AlleleVariantAssociation_internal_index", columnList = "internal"), + @Index(name = "AlleleVariantAssociation_obsolete_index", columnList = "obsolete"), + @Index(name = "AlleleVariantAssociation_createdBy_index", columnList = "createdBy_id"), + @Index(name = "AlleleVariantAssociation_updatedBy_index", columnList = "updatedBy_id"), + @Index(name = "AlleleVariantAssociation_evidenceCode_index", columnList = "evidencecode_id"), + @Index(name = "AlleleVariantAssociation_relatedNote_index", columnList = "relatedNote_id"), + @Index(name = "AlleleVariantAssociation_relation_index", columnList = "relation_id"), + @Index(name = "AlleleVariantAssociation_alleleAssociationSubject_index", columnList = "alleleAssociationSubject_id"), + @Index(name = "AlleleVariantAssociation_alleleVariantAssociationObject_index", columnList = "alleleVariantAssociationObject_id") +}) + +public class AlleleVariantAssociation extends AlleleGenomicEntityAssociation { + + @IndexedEmbedded(includePaths = { + "curie", "alleleSymbol.displayText", "alleleSymbol.formatText", "alleleFullName.displayText", "alleleFullName.formatText", + "curie_keyword", "alleleSymbol.displayText_keyword", "alleleSymbol.formatText_keyword", "alleleFullName.displayText_keyword", + "alleleFullName.formatText_keyword", "modEntityId", "modEntityId_keyword", "modInternalId", "modInternalId_keyword" }) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + @JsonIgnoreProperties({"alleleGeneAssociations", "alleleVariantAssociations"}) + @Fetch(FetchMode.JOIN) + private Allele alleleAssociationSubject; + + @IndexedEmbedded(includePaths = { "curie", "curie_keyword", "modEntityId", "modEntityId_keyword", + "modInternalId", "modInternalId_keyword" }) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({ View.FieldsOnly.class, View.AlleleView.class }) + @JsonIgnoreProperties({ "alleleVariantAssociations", "constructGenomicEntityAssociations", "curatedVariantGenomicLocations" }) + private Variant alleleVariantAssociationObject; +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/codingSequenceAssociations/CodingSequenceGenomicLocationAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/codingSequenceAssociations/CodingSequenceGenomicLocationAssociation.java index 322734ab5..3d3bb1330 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/codingSequenceAssociations/CodingSequenceGenomicLocationAssociation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/codingSequenceAssociations/CodingSequenceGenomicLocationAssociation.java @@ -38,13 +38,21 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "2.4.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { LocationAssociation.class }) @Schema(name = "CodingSequenceGenomicLocationAssociation", description = "POJO representing an association between a CDS and a genomic location") + @Table( indexes = { - @Index(name = "codingsequencelocationassociation_relation_index", columnList = "relation_id"), - @Index(name = "codingsequencelocationassociation_subject_index", columnList = "codingsequenceassociationsubject_id"), - @Index(name = "codingsequencelocationassociation_object_index", columnList = "codingsequencegenomiclocationassociationobject_id") - } + @Index(columnList = "internal"), + @Index(columnList = "obsolete"), + @Index(columnList = "phase"), + @Index(columnList = "strand"), + @Index(columnList = "createdBy_id"), + @Index(columnList = "updatedBy_id"), + @Index(columnList = "relation_id"), + @Index(columnList = "codingsequenceassociationsubject_id"), + @Index(columnList = "codingsequencegenomiclocationassociationobject_id") + }, name = "CDSGLAssociation" // Need to trim the name ) + public class CodingSequenceGenomicLocationAssociation extends LocationAssociation { @IndexedEmbedded(includePaths = { @@ -72,7 +80,7 @@ public class CodingSequenceGenomicLocationAssociation extends LocationAssociatio private Integer phase; @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") - @KeywordField(name = "phenotypeAnnotationObject_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @KeywordField(name = "strand_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") @JsonView({ View.FieldsOnly.class }) @Column(length = 1) private String strand; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/constructAssociations/ConstructGenomicEntityAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/constructAssociations/ConstructGenomicEntityAssociation.java index 5ed1f0721..b848b3b0c 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/constructAssociations/ConstructGenomicEntityAssociation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/constructAssociations/ConstructGenomicEntityAssociation.java @@ -23,10 +23,10 @@ import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; -import jakarta.persistence.OneToOne; import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; @@ -38,11 +38,17 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { EvidenceAssociation.class }) @Schema(name = "ConstructGenomicEntityAssociation", description = "POJO representing an association between a construct and a genomic entity") + @Table(indexes = { - @Index(name = "constructgenomicentityassociation_subject_index", columnList = "constructassociationsubject_id"), - @Index(name = "constructgenomicentityassociation_object_index", columnList = "constructgenomicentityassociationobject_id"), - @Index(name = "constructgenomicentityassociation_relation_index", columnList = "relation_id") + @Index(columnList = "internal"), + @Index(columnList = "obsolete"), + @Index(columnList = "createdBy_id"), + @Index(columnList = "updatedBy_id"), + @Index(columnList = "constructassociationsubject_id"), + @Index(columnList = "constructgenomicentityassociationobject_id"), + @Index(columnList = "relation_id") }) + public class ConstructGenomicEntityAssociation extends EvidenceAssociation { @IndexedEmbedded(includePaths = { @@ -64,7 +70,7 @@ public class ConstructGenomicEntityAssociation extends EvidenceAssociation { @IndexedEmbedded(includeDepth = 1) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) - @OneToOne + @ManyToOne @JsonView({ View.FieldsOnly.class }) @JsonIgnoreProperties({ "alleleGeneAssociations", "constructGenomicEntityAssociations", "sequenceTargetingReagentGeneAssociations", @@ -79,9 +85,13 @@ public class ConstructGenomicEntityAssociation extends EvidenceAssociation { @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) @JsonView({ View.FieldsAndLists.class, View.ConstructView.class }) - @JoinTable(indexes = { - @Index(name = "cgeassociation_note_cgeassociation_index", columnList = "constructgenomicentityassociation_id"), - @Index(name = "cgeassociation_note_relatednotes_index", columnList = "relatedNotes_id") - }) + @JoinTable( + joinColumns = @JoinColumn(name = "constructgenomicentityassociation_id"), + inverseJoinColumns = @JoinColumn(name = "relatedNotes_id"), + indexes = { + @Index(name = "constructgeassociation_note_cgea_index", columnList = "constructgenomicentityassociation_id"), + @Index(name = "constructgeassociation_note_relatednotes_index", columnList = "relatedNotes_id") + } + ) private List relatedNotes; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/exonAssociations/ExonGenomicLocationAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/exonAssociations/ExonGenomicLocationAssociation.java index 7db787478..43bf25182 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/exonAssociations/ExonGenomicLocationAssociation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/exonAssociations/ExonGenomicLocationAssociation.java @@ -36,13 +36,18 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "2.4.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { LocationAssociation.class }) @Schema(name = "ExonGenomicLocationAssociation", description = "POJO representing an association between an exon and a genomic location") -@Table( - indexes = { - @Index(name = "exonlocationassociation_relation_index", columnList = "relation_id"), - @Index(name = "exonlocationassociation_subject_index", columnList = "exonassociationsubject_id"), - @Index(name = "exonlocationassociation_object_index", columnList = "exongenomiclocationassociationobject_id") - } -) + +@Table(indexes = { + @Index(columnList = "internal"), + @Index(columnList = "obsolete"), + @Index(columnList = "strand"), + @Index(columnList = "createdBy_id"), + @Index(columnList = "updatedBy_id"), + @Index(columnList = "relation_id"), + @Index(columnList = "exonassociationsubject_id"), + @Index(columnList = "exongenomiclocationassociationobject_id") +}) + public class ExonGenomicLocationAssociation extends LocationAssociation { @IndexedEmbedded(includePaths = { @@ -66,7 +71,7 @@ public class ExonGenomicLocationAssociation extends LocationAssociation { private AssemblyComponent exonGenomicLocationAssociationObject; @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") - @KeywordField(name = "phenotypeAnnotationObject_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @KeywordField(name = "strand_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") @JsonView({ View.FieldsOnly.class }) @Column(length = 1) private String strand; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/geneAssociations/GeneGeneAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/geneAssociations/GeneGeneAssociation.java index d1dde5333..d627dc7d4 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/geneAssociations/GeneGeneAssociation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/geneAssociations/GeneGeneAssociation.java @@ -13,30 +13,24 @@ import com.fasterxml.jackson.annotation.JsonView; -import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.ManyToOne; -import jakarta.persistence.Table; +import jakarta.persistence.MappedSuperclass; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -@Entity +@MappedSuperclass @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { EvidenceAssociation.class }) @Schema(name = "GeneGeneAssociation", description = "POJO representing an association between a gene and a gene") -@Table(indexes = { - @Index(name = "genegeneassociation_geneassociationsubject_index", columnList = "geneassociationsubject_id"), - @Index(name = "genegeneassociation_relation_index", columnList = "relation_id"), - @Index(name = "genegeneassociation_genegeneassociationobject_index", columnList = "genegeneassociationobject_id") -}) public class GeneGeneAssociation extends EvidenceAssociation { @IndexedEmbedded(includePaths = {"curie", "geneSymbol.displayText", "geneSymbol.formatText", "geneFullName.displayText", "geneFullName.formatText", "curie_keyword", "geneSymbol.displayText_keyword", "geneSymbol.formatText_keyword", "geneFullName.displayText_keyword", "geneFullName.formatText_keyword", "modEntityId", "modEntityId_keyword", "modInternalId", "modInternalId_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne @JsonView({ View.FieldsOnly.class }) private Gene geneAssociationSubject; @@ -54,4 +48,4 @@ public class GeneGeneAssociation extends EvidenceAssociation { @ManyToOne @JsonView({ View.FieldsOnly.class }) private VocabularyTerm relation; -} +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/sequenceTargetingReagentAssociations/SequenceTargetingReagentGeneAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/sequenceTargetingReagentAssociations/SequenceTargetingReagentGeneAssociation.java index 836ed15cc..7f79ce10b 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/sequenceTargetingReagentAssociations/SequenceTargetingReagentGeneAssociation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/sequenceTargetingReagentAssociations/SequenceTargetingReagentGeneAssociation.java @@ -1,10 +1,13 @@ package org.alliancegenome.curation_api.model.entities.associations.sequenceTargetingReagentAssociations; +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.model.entities.EvidenceAssociation; import org.alliancegenome.curation_api.model.entities.Gene; import org.alliancegenome.curation_api.model.entities.SequenceTargetingReagent; import org.alliancegenome.curation_api.model.entities.VocabularyTerm; import org.alliancegenome.curation_api.view.View; +import org.eclipse.microprofile.openapi.annotations.media.Schema; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; @@ -15,13 +18,8 @@ import com.fasterxml.jackson.annotation.JsonView; import jakarta.persistence.Entity; -import jakarta.persistence.ManyToOne; - -import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; -import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; -import org.eclipse.microprofile.openapi.annotations.media.Schema; - import jakarta.persistence.Index; +import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; @@ -34,13 +32,19 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "2.3.1", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { EvidenceAssociation.class }) @Schema(name = "SequenceTargetingReagentGeneAssociation", description = "POJO representing an association between an SQTR and a gene") + @Table( indexes = { - @Index(name = "sequencetargetingreagentassociation_subject_index", columnList = "sequencetargetingreagentassociationsubject_id"), - @Index(name = "sequencetargetingreagentgeneassociation_relation_index", columnList = "relation_id"), - @Index(name = "sequencetargetingreagentgeneassociation_sequencetargetingreagentgeneassociationobject_index", columnList = "sequencetargetingreagentgeneassociationobject_id") - } -) + @Index(name = "SQTRGeneAssociation_internal_index", columnList = "internal"), + @Index(name = "SQTRGeneAssociation_obsolete_index", columnList = "obsolete"), + @Index(name = "SQTRGeneAssociation_createdBy_index", columnList = "createdBy_id"), + @Index(name = "SQTRGeneAssociation_updatedBy_index", columnList = "updatedBy_id"), + @Index(name = "SQTRGeneAssociation_relation_index", columnList = "relation_id"), + @Index(name = "SQTRGeneAssociation_sqtrAssociationSubject_index", columnList = "sequencetargetingreagentassociationsubject_id"), + @Index(name = "SQTRGeneAssociation_sqtrGeneAssociationObject_index", columnList = "sequencetargetingreagentgeneassociationobject_id") + }, name = "SQTRGeneAssociation" + ) + public class SequenceTargetingReagentGeneAssociation extends EvidenceAssociation { @IndexedEmbedded(includePaths = {"name", "synonyms", "secondaryIdentifiers"}) @@ -63,6 +67,6 @@ public class SequenceTargetingReagentGeneAssociation extends EvidenceAssociation @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToOne @JsonView({ View.FieldsOnly.class }) - @JsonIgnoreProperties({ "alleleGeneAssociations", "constructGenomicEntityAssociations", "sequenceTargetingReagentGeneAssociations" }) + @JsonIgnoreProperties({ "alleleGeneAssociations", "constructGenomicEntityAssociations", "sequenceTargetingReagentGeneAssociations", "transcriptGeneAssociations" }) private Gene sequenceTargetingReagentGeneAssociationObject; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/transcriptAssociations/TranscriptCodingSequenceAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/transcriptAssociations/TranscriptCodingSequenceAssociation.java new file mode 100644 index 000000000..cd24ca3d7 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/transcriptAssociations/TranscriptCodingSequenceAssociation.java @@ -0,0 +1,74 @@ +package org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations; + +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.entities.CodingSequence; +import org.alliancegenome.curation_api.model.entities.EvidenceAssociation; +import org.alliancegenome.curation_api.model.entities.Transcript; +import org.alliancegenome.curation_api.model.entities.VocabularyTerm; +import org.alliancegenome.curation_api.view.View; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonView; + +import jakarta.persistence.Entity; +import jakarta.persistence.Index; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Entity +@Data +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +@ToString(callSuper = true) +@AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { EvidenceAssociation.class }) +@Schema(name = "TranscriptCodingSequenceAssociation", description = "POJO representing an association between a transcript and a CDS") + +@Table(indexes = { + @Index(columnList = "internal"), + @Index(columnList = "obsolete"), + @Index(columnList = "createdBy_id"), + @Index(columnList = "updatedBy_id"), + @Index(columnList = "relation_id"), + @Index(columnList = "transcriptassociationsubject_id"), + @Index(columnList = "transcriptcodingsequenceassociationobject_id") +}) + +public class TranscriptCodingSequenceAssociation extends EvidenceAssociation { + + @IndexedEmbedded(includePaths = {"curie", "name", "modEntityId", "modInternalId", + "curie_keyword", "name_keyword", "modEntityId_keyword", "modInternalId_keyword"}) + @ManyToOne + @JsonIgnoreProperties({ + "transcriptCodingSequenceAssociations", + "transcriptExonAssociations", + "transcriptGeneAssociations", + "transcriptGenomicLocationAssociations" + }) + @JsonView({ View.FieldsOnly.class }) + private Transcript transcriptAssociationSubject; + + @IndexedEmbedded(includePaths = {"curie", "name", "modEntityId", "modInternalId", "uniqueId", + "curie_keyword", "name_keyword", "modEntityId_keyword", "modInternalId_keyword", "uniqueId_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonIgnoreProperties({ + "transcriptCodingSequenceAssociations", + "codingSequenceGenomicLocationAssociations", + "constructGenomicEntityAssociations" + }) + @JsonView({ View.FieldsOnly.class }) + private CodingSequence transcriptCodingSequenceAssociationObject; + + @IndexedEmbedded(includePaths = {"name", "name_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + private VocabularyTerm relation; +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/transcriptAssociations/TranscriptExonAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/transcriptAssociations/TranscriptExonAssociation.java new file mode 100644 index 000000000..4ea3370b4 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/transcriptAssociations/TranscriptExonAssociation.java @@ -0,0 +1,74 @@ +package org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations; + +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.entities.EvidenceAssociation; +import org.alliancegenome.curation_api.model.entities.Exon; +import org.alliancegenome.curation_api.model.entities.Transcript; +import org.alliancegenome.curation_api.model.entities.VocabularyTerm; +import org.alliancegenome.curation_api.view.View; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonView; + +import jakarta.persistence.Entity; +import jakarta.persistence.Index; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Entity +@Data +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +@ToString(callSuper = true) +@AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { EvidenceAssociation.class }) +@Schema(name = "TranscriptExonAssociation", description = "POJO representing an association between a transcript and an exon") + +@Table(indexes = { + @Index(columnList = "internal"), + @Index(columnList = "obsolete"), + @Index(columnList = "createdBy_id"), + @Index(columnList = "updatedBy_id"), + @Index(columnList = "relation_id"), + @Index(columnList = "transcriptassociationsubject_id"), + @Index(columnList = "transcriptexonassociationobject_id") +}) + +public class TranscriptExonAssociation extends EvidenceAssociation { + + @IndexedEmbedded(includePaths = {"curie", "name", "modEntityId", "modInternalId", + "curie_keyword", "name_keyword", "modEntityId_keyword", "modInternalId_keyword"}) + @ManyToOne + @JsonIgnoreProperties({ + "transcriptCodingSequenceAssociations", + "transcriptExonAssociations", + "transcriptGeneAssociations", + "transcriptGenomicLocationAssociations" + }) + @JsonView({ View.FieldsOnly.class }) + private Transcript transcriptAssociationSubject; + + @IndexedEmbedded(includePaths = {"curie", "name", "modEntityId", "modInternalId", "uniqueId", + "curie_keyword", "name_keyword", "modEntityId_keyword", "modInternalId_keyword", "uniqueId_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonIgnoreProperties({ + "transcriptExonAssociations", + "constructGenomicEntityAssociations", + "exonGenomicLocationAssociations" + }) + @JsonView({ View.FieldsOnly.class }) + private Exon transcriptExonAssociationObject; + + @IndexedEmbedded(includePaths = {"name", "name_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + private VocabularyTerm relation; +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/transcriptAssociations/TranscriptGeneAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/transcriptAssociations/TranscriptGeneAssociation.java new file mode 100644 index 000000000..3001b9f9c --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/transcriptAssociations/TranscriptGeneAssociation.java @@ -0,0 +1,76 @@ +package org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations; + +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.entities.EvidenceAssociation; +import org.alliancegenome.curation_api.model.entities.Gene; +import org.alliancegenome.curation_api.model.entities.Transcript; +import org.alliancegenome.curation_api.model.entities.VocabularyTerm; +import org.alliancegenome.curation_api.view.View; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonView; + +import jakarta.persistence.Entity; +import jakarta.persistence.Index; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Entity +@Data +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +@ToString(callSuper = true) +@AGRCurationSchemaVersion(min = "2.2.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { EvidenceAssociation.class }) +@Schema(name = "TranscriptGeneAssociation", description = "POJO representing an association between a transcript and a gene") + +@Table(indexes = { + @Index(name = "TranscriptGeneAssociation_internal_index", columnList = "internal"), + @Index(name = "TranscriptGeneAssociation_obsolete_index", columnList = "obsolete"), + @Index(name = "TranscriptGeneAssociation_createdBy_index", columnList = "createdBy_id"), + @Index(name = "TranscriptGeneAssociation_updatedBy_index", columnList = "updatedBy_id"), + @Index(name = "TranscriptGeneAssociation_relation_index", columnList = "relation_id"), + @Index(name = "TranscriptGeneAssociation_transcriptAssociationSubject_index", columnList = "transcriptassociationsubject_id"), + @Index(name = "TranscriptGeneAssociation_transcriptGeneAssociationObject_index", columnList = "transcriptgeneassociationobject_id") +}) + +public class TranscriptGeneAssociation extends EvidenceAssociation { + + @IndexedEmbedded(includePaths = {"curie", "name", "modEntityId", "modInternalId", + "curie_keyword", "name_keyword", "modEntityId_keyword", "modInternalId_keyword"}) + @ManyToOne + @JsonIgnoreProperties({ + "transcriptCodingSequenceAssociations", + "transcriptExonAssociations", + "transcriptGeneAssociations", + "transcriptGenomicLocationAssociations" + }) + @JsonView({ View.FieldsOnly.class }) + private Transcript transcriptAssociationSubject; + + @IndexedEmbedded(includePaths = {"curie", "geneSymbol.displayText", "geneSymbol.formatText", "geneFullName.displayText", "geneFullName.formatText", + "curie_keyword", "geneSymbol.displayText_keyword", "geneSymbol.formatText_keyword", "geneFullName.displayText_keyword", "geneFullName.formatText_keyword", + "modEntityId", "modEntityId_keyword", "modInternalId", "modInternalId_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonIgnoreProperties({ + "alleleGeneAssociations", + "constructGenomicEntityAssociations", + "sequenceTargetingReagentGeneAssociations", + "transcriptGeneAssociations" + }) + @JsonView({ View.FieldsOnly.class }) + private Gene transcriptGeneAssociationObject; + + @IndexedEmbedded(includePaths = {"name", "name_keyword"}) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + private VocabularyTerm relation; +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/transcriptAssociations/TranscriptGenomicLocationAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/transcriptAssociations/TranscriptGenomicLocationAssociation.java index 0669ae276..6fc08ca74 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/transcriptAssociations/TranscriptGenomicLocationAssociation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/transcriptAssociations/TranscriptGenomicLocationAssociation.java @@ -38,13 +38,19 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "2.4.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { LocationAssociation.class }) @Schema(name = "TranscriptGenomicLocationAssociation", description = "POJO representing an association between a transcript and a genomic location") -@Table( - indexes = { - @Index(name = "transcriptlocationassociation_relation_index", columnList = "relation_id"), - @Index(name = "transcriptlocationassociation_subject_index", columnList = "transcriptassociationsubject_id"), - @Index(name = "transcriptlocationassociation_object_index", columnList = "transcriptgenomiclocationassociationobject_id") - } -) + +@Table(indexes = { + @Index(columnList = "internal"), + @Index(columnList = "obsolete"), + @Index(columnList = "phase"), + @Index(columnList = "strand"), + @Index(columnList = "createdBy_id"), + @Index(columnList = "updatedBy_id"), + @Index(columnList = "relation_id"), + @Index(columnList = "transcriptassociationsubject_id"), + @Index(columnList = "transcriptgenomiclocationassociationobject_id") +}) + public class TranscriptGenomicLocationAssociation extends LocationAssociation { @IndexedEmbedded(includePaths = { @@ -53,7 +59,12 @@ public class TranscriptGenomicLocationAssociation extends LocationAssociation { }) @ManyToOne @JsonView({ View.FieldsOnly.class }) - @JsonIgnoreProperties("transcriptGenomicLocationAssociations") + @JsonIgnoreProperties({ + "transcriptCodingSequenceAssociations", + "transcriptExonAssociations", + "transcriptGeneAssociations", + "transcriptGenomicLocationAssociations" + }) @Fetch(FetchMode.JOIN) private Transcript transcriptAssociationSubject; @@ -72,7 +83,7 @@ public class TranscriptGenomicLocationAssociation extends LocationAssociation { private Integer phase; @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") - @KeywordField(name = "phenotypeAnnotationObject_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @KeywordField(name = "strand_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") @JsonView({ View.FieldsOnly.class }) @Column(length = 1) private String strand; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/variantAssociations/CuratedVariantGenomicLocationAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/variantAssociations/CuratedVariantGenomicLocationAssociation.java new file mode 100644 index 000000000..82508a178 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/variantAssociations/CuratedVariantGenomicLocationAssociation.java @@ -0,0 +1,39 @@ +package org.alliancegenome.curation_api.model.entities.associations.variantAssociations; + +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.eclipse.microprofile.openapi.annotations.media.Schema; + +import jakarta.persistence.Entity; +import jakarta.persistence.Index; +import jakarta.persistence.Table; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Entity +@Data +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +@ToString(callSuper = true) +@AGRCurationSchemaVersion(min = "2.4.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { VariantGenomicLocationAssociation.class }) +@Schema(name = "CuratedVariantGenomicLocationAssociation", description = "POJO representing an association between a variant and a curated genomic location") + +@Table(indexes = { + @Index(name = "cvgla_internal_index", columnList = "internal"), + @Index(name = "cvgla_obsolete_index", columnList = "obsolete"), + @Index(name = "cvgla_hgvs_index", columnList = "hgvs"), + @Index(name = "cvgla_createdby_index", columnList = "createdBy_id"), + @Index(name = "cvgla_updatedby_index", columnList = "updatedBy_id"), + @Index(name = "cvgla_relation_index", columnList = "relation_id"), + @Index(name = "cvgla_dnamutationtype_index", columnList = "dnaMutationType_id"), + @Index(name = "cvgla_genelocalizationtype_index", columnList = "geneLocalizationType_id"), + @Index(name = "cvgla_consequence_index", columnList = "consequence_id"), + @Index(name = "cvgla_curatedconsequence_index", columnList = "curatedConsequence_id"), + @Index(name = "cvgla_variantassociationsubject_index", columnList = "variantassociationsubject_id"), + @Index(name = "cvgla_vglaobject_index", columnList = "variantgenomiclocationassociationobject_id") + }, name = "CuratedVariantGenomicLocation" +) + +public class CuratedVariantGenomicLocationAssociation extends VariantGenomicLocationAssociation { + +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/variantAssociations/VariantGenomicLocationAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/variantAssociations/VariantGenomicLocationAssociation.java new file mode 100644 index 000000000..d070e6faf --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/variantAssociations/VariantGenomicLocationAssociation.java @@ -0,0 +1,94 @@ +package org.alliancegenome.curation_api.model.entities.associations.variantAssociations; + +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.entities.AssemblyComponent; +import org.alliancegenome.curation_api.model.entities.ontology.SOTerm; +import org.alliancegenome.curation_api.view.View; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; +import org.hibernate.search.engine.backend.types.Aggregable; +import org.hibernate.search.engine.backend.types.Projectable; +import org.hibernate.search.engine.backend.types.Searchable; +import org.hibernate.search.engine.backend.types.Sortable; +import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; + +import com.fasterxml.jackson.annotation.JsonView; + +import jakarta.persistence.Column; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.MappedSuperclass; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@MappedSuperclass +@Data +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +@ToString(callSuper = true) +@AGRCurationSchemaVersion(min = "2.4.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { VariantLocationAssociation.class }) +@Schema(name = "VariantGenomicLocationAssociation", description = "POJO representing an association between a variant and a genomic location") +public abstract class VariantGenomicLocationAssociation extends VariantLocationAssociation { + + @IndexedEmbedded(includePaths = { + "curie", "curie_keyword", "modEntityId", "modEntityId_keyword", + "modInternalId", "modInternalId_keyword", "name", "name_keyword" + }) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @Fetch(FetchMode.JOIN) + private AssemblyComponent variantGenomicLocationAssociationObject; + + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "variationStrand_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @JsonView({ View.FieldsOnly.class }) + @Column(length = 1) + private String variationStrand; + + @GenericField(projectable = Projectable.YES, sortable = Sortable.YES) + @JsonView({ View.FieldsOnly.class }) + private Integer numberAdditionalDnaBasePairs; + + @GenericField(projectable = Projectable.YES, sortable = Sortable.YES) + @JsonView({ View.FieldsOnly.class }) + private Integer numberRemovedDnaBasePairs; + + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "paddedBase_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @JsonView({ View.FieldsOnly.class }) + @Column(length = 1) + private String paddedBase; + + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "insertedSequence_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @JsonView({ View.FieldsOnly.class }) + @Column(columnDefinition = "TEXT") + private String insertedSequence; + + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "deletedSequence_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @JsonView({ View.FieldsOnly.class }) + @Column(columnDefinition = "TEXT") + private String deletedSequence; + + @IndexedEmbedded(includePaths = {"curie", "name", "secondaryIdentifiers", "synonyms.name", "namespace", + "curie_keyword", "name_keyword", "secondaryIdentifiers_keyword", "synonyms.name_keyword", "namespace_keyword" }) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + private SOTerm dnaMutationType; + + @IndexedEmbedded(includePaths = {"curie", "name", "secondaryIdentifiers", "synonyms.name", "namespace", + "curie_keyword", "name_keyword", "secondaryIdentifiers_keyword", "synonyms.name_keyword", "namespace_keyword" }) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + private SOTerm geneLocalizationType; +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/associations/variantAssociations/VariantLocationAssociation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/variantAssociations/VariantLocationAssociation.java new file mode 100644 index 000000000..602e48636 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/associations/variantAssociations/VariantLocationAssociation.java @@ -0,0 +1,80 @@ +package org.alliancegenome.curation_api.model.entities.associations.variantAssociations; + +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.model.entities.LocationAssociation; +import org.alliancegenome.curation_api.model.entities.Variant; +import org.alliancegenome.curation_api.model.entities.ontology.SOTerm; +import org.alliancegenome.curation_api.view.View; +import org.eclipse.microprofile.openapi.annotations.media.Schema; +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; +import org.hibernate.search.engine.backend.types.Aggregable; +import org.hibernate.search.engine.backend.types.Searchable; +import org.hibernate.search.engine.backend.types.Sortable; +import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexedEmbedded; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.IndexingDependency; +import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonView; + +import jakarta.persistence.Column; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.MappedSuperclass; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@MappedSuperclass +@Data +@EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) +@ToString(callSuper = true) +@AGRCurationSchemaVersion(min = "2.4.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { LocationAssociation.class }) +@Schema(name = "VariantLocationAssociation", description = "POJO representing an association between a variant and a location") +public abstract class VariantLocationAssociation extends LocationAssociation { + + @IndexedEmbedded(includePaths = { + "curie", "curie_keyword", "modEntityId", "modEntityId_keyword", + "modInternalId", "modInternalId_keyword", "name", "name_keyword" + }) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + @JsonIgnoreProperties({"curatedVariantGenomicLocations", "alleleVariantAssociations"}) + @Fetch(FetchMode.JOIN) + private Variant variantAssociationSubject; + + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "hgvs_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @JsonView({ View.FieldsOnly.class }) + @Column(columnDefinition = "TEXT") + private String hgvs; + + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "referenceSequence_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @JsonView({ View.FieldsOnly.class }) + @Column(columnDefinition = "TEXT") + private String referenceSequence; + + @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") + @KeywordField(name = "variantSequence_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") + @JsonView({ View.FieldsOnly.class }) + @Column(columnDefinition = "TEXT") + private String variantSequence; + + @IndexedEmbedded(includePaths = {"curie", "name", "secondaryIdentifiers", "synonyms.name", "namespace", + "curie_keyword", "name_keyword", "secondaryIdentifiers_keyword", "synonyms.name_keyword", "namespace_keyword" }) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + private SOTerm consequence; + + @IndexedEmbedded(includePaths = {"curie", "name", "secondaryIdentifiers", "synonyms.name", "namespace", + "curie_keyword", "name_keyword", "secondaryIdentifiers_keyword", "synonyms.name_keyword", "namespace_keyword" }) + @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) + @ManyToOne + @JsonView({ View.FieldsOnly.class }) + private SOTerm curatedConsequence; +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoad.java b/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoad.java index 6e437f466..626252464 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoad.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoad.java @@ -71,10 +71,10 @@ public abstract class BulkLoad extends AuditedObject { @ManyToOne private BulkLoadGroup group; - + @JsonView({ View.FieldsOnly.class }) @OneToMany(mappedBy = "bulkLoad", fetch = FetchType.EAGER) - @OrderBy("dateUpdated DESC") - private List loadFiles; + @OrderBy("loadFinished DESC") + private List history; } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFile.java b/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFile.java index 49a4d5551..50bd4293b 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFile.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFile.java @@ -1,21 +1,12 @@ package org.alliancegenome.curation_api.model.entities.bulkloads; -import java.time.OffsetDateTime; import java.util.List; import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; import org.alliancegenome.curation_api.enums.BulkLoadCleanUp; -import org.alliancegenome.curation_api.enums.JobStatus; import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; -import org.alliancegenome.curation_api.model.bridges.OffsetDateTimeValueBridge; import org.alliancegenome.curation_api.model.entities.base.AuditedObject; import org.alliancegenome.curation_api.view.View; -import org.hibernate.search.engine.backend.types.Aggregable; -import org.hibernate.search.engine.backend.types.Searchable; -import org.hibernate.search.engine.backend.types.Sortable; -import org.hibernate.search.mapper.pojo.bridge.mapping.annotation.ValueBridgeRef; -import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; -import org.hibernate.search.mapper.pojo.mapping.definition.annotation.KeywordField; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonView; @@ -24,11 +15,8 @@ import jakarta.persistence.Entity; import jakarta.persistence.EnumType; import jakarta.persistence.Enumerated; -import jakarta.persistence.FetchType; import jakarta.persistence.Index; -import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; -import jakarta.persistence.OrderBy; import jakarta.persistence.Table; import jakarta.persistence.Transient; import lombok.Data; @@ -38,27 +26,16 @@ @Entity @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) -@ToString(exclude = { "bulkLoad" }) +@ToString(exclude = { "history" }) @AGRCurationSchemaVersion(min = "1.3.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AuditedObject.class }) @Table( indexes = { - @Index(name = "bulkloadfile_bulkLoad_index", columnList = "bulkLoad_id"), @Index(name = "bulkloadfile_createdby_index", columnList = "createdBy_id"), - @Index(name = "bulkloadfile_updatedby_index", columnList = "updatedBy_id"), - @Index(name = "bulkloadfile_bulkloadStatus_index", columnList = "bulkloadStatus") + @Index(name = "bulkloadfile_updatedby_index", columnList = "updatedBy_id") } ) public class BulkLoadFile extends AuditedObject { - @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer", valueBridge = @ValueBridgeRef(type = OffsetDateTimeValueBridge.class)) - @KeywordField(name = "dateLastLoaded_keyword", sortable = Sortable.YES, searchable = Searchable.YES, aggregable = Aggregable.YES, valueBridge = @ValueBridgeRef(type = OffsetDateTimeValueBridge.class)) - @JsonView(View.FieldsOnly.class) - private OffsetDateTime dateLastLoaded; - - @JsonView({ View.FieldsOnly.class }) - @Enumerated(EnumType.STRING) - private JobStatus bulkloadStatus; - @JsonView({ View.FieldsOnly.class }) @Enumerated(EnumType.STRING) private BulkLoadCleanUp bulkloadCleanUp; @@ -77,11 +54,7 @@ public class BulkLoadFile extends AuditedObject { private String s3Path; @JsonView({ View.FieldsOnly.class }) - private Integer recordCount; - - @JsonView({ View.FieldsOnly.class }) - @Column(columnDefinition = "TEXT") - private String errorMessage; + private Integer recordCount = 0; @JsonView({ View.FieldsOnly.class }) private String linkMLSchemaVersion; @@ -89,12 +62,7 @@ public class BulkLoadFile extends AuditedObject { @JsonView({ View.FieldsOnly.class }) private String allianceMemberReleaseVersion; - @ManyToOne - private BulkLoad bulkLoad; - - @JsonView({ View.FieldsOnly.class }) - @OneToMany(mappedBy = "bulkLoadFile", fetch = FetchType.EAGER) - @OrderBy("loadFinished DESC") + @OneToMany(mappedBy = "bulkLoadFile") private List history; @Transient @@ -106,7 +74,7 @@ public String getS3Url() { @Transient @JsonIgnore @JsonView({ View.FieldsOnly.class }) - public String generateS3MD5Path() { + public String generateS3MD5Path(BulkLoad bulkLoad) { if (md5Sum != null && md5Sum.length() > 0) { return md5Sum.charAt(0) + "/" + md5Sum.charAt(1) + "/" + md5Sum.charAt(2) + "/" + md5Sum.charAt(3) + "/" + md5Sum + "." + bulkLoad.getBackendBulkLoadType().fileExtension + ".gz"; } else { diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFileHistory.java b/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFileHistory.java index 187386aa0..ca460a27f 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFileHistory.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/bulkloads/BulkLoadFileHistory.java @@ -2,112 +2,168 @@ import java.time.LocalDateTime; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.enums.JobStatus; import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; import org.alliancegenome.curation_api.model.entities.base.AuditedObject; +import org.alliancegenome.curation_api.model.output.ProcessCount; import org.alliancegenome.curation_api.view.View; -import org.hibernate.annotations.OnDelete; -import org.hibernate.annotations.OnDeleteAction; +import org.hibernate.annotations.JdbcTypeCode; +import org.hibernate.type.SqlTypes; import com.fasterxml.jackson.annotation.JsonView; +import jakarta.persistence.Column; import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; import jakarta.persistence.Index; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; import jakarta.persistence.Table; import jakarta.persistence.Transient; -import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; import lombok.ToString; @Entity @Data -@AllArgsConstructor -@NoArgsConstructor @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) -@ToString(exclude = { "bulkLoadFile", "exceptions" }, callSuper = true) +@ToString(exclude = { "bulkLoadFile", "bulkLoad", "exceptions" }, callSuper = true) @AGRCurationSchemaVersion(min = "1.2.4", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AuditedObject.class }) -@Table( - indexes = { - @Index(name = "bulkloadfilehistory_bulkLoadFile_index", columnList = "bulkLoadFile_id"), - @Index(name = "bulkloadfilehistory_createdby_index", columnList = "createdBy_id"), - @Index(name = "bulkloadfilehistory_updatedby_index", columnList = "updatedBy_id") - } -) +@Table(indexes = { @Index(name = "bulkloadfilehistory_bulkLoadFile_index", columnList = "bulkLoadFile_id"), @Index(name = "bulkloadfilehistory_createdby_index", columnList = "createdBy_id"), @Index(name = "bulkloadfilehistory_updatedby_index", columnList = "updatedBy_id") }) public class BulkLoadFileHistory extends AuditedObject { - @JsonView({ View.FieldsOnly.class }) - private LocalDateTime loadStarted; - - @JsonView({ View.FieldsOnly.class }) - private LocalDateTime loadFinished; - - @JsonView({ View.FieldsOnly.class }) - private Long totalRecords = 0L; + private static final String COUNT_TYPE = "Records"; @JsonView({ View.FieldsOnly.class }) - private Long failedRecords = 0L; + private LocalDateTime loadStarted = LocalDateTime.now(); @JsonView({ View.FieldsOnly.class }) - private Long completedRecords = 0L; + private LocalDateTime loadFinished; @JsonView({ View.FieldsOnly.class }) - private Long totalDeleteRecords = 0L; + @JdbcTypeCode(SqlTypes.JSON) + private Map counts = new HashMap<>(); @JsonView({ View.FieldsOnly.class }) - private Long deletedRecords = 0L; + @Enumerated(EnumType.STRING) + private JobStatus bulkloadStatus = JobStatus.STOPPED; @JsonView({ View.FieldsOnly.class }) - private Long deleteFailedRecords = 0L; - - @JsonView({ View.FieldsOnly.class }) - private Double errorRate = 0.0; + @Column(columnDefinition = "TEXT") + private String errorMessage; @ManyToOne - @OnDelete(action = OnDeleteAction.CASCADE) + @JsonView({ View.FieldsOnly.class }) private BulkLoadFile bulkLoadFile; + @ManyToOne private BulkLoad bulkLoad; + @OneToMany(mappedBy = "bulkLoadFileHistory") @JsonView(View.BulkLoadFileHistoryView.class) private List exceptions = new ArrayList<>(); - public BulkLoadFileHistory(long totalRecords) { - this.totalRecords = totalRecords; + public BulkLoadFileHistory(String countType, Long count) { + counts.put(countType, new ProcessCount(count)); + loadStarted = LocalDateTime.now(); + } + public BulkLoadFileHistory(Long count) { + counts.put(COUNT_TYPE, new ProcessCount(count)); + loadStarted = LocalDateTime.now(); + } + public BulkLoadFileHistory(Integer count) { + counts.put(COUNT_TYPE, new ProcessCount(Long.valueOf(count))); + loadStarted = LocalDateTime.now(); + } + public BulkLoadFileHistory() { loadStarted = LocalDateTime.now(); } @Transient - public void incrementCompleted() { - if (errorRate > 0) { - errorRate -= 1d / 1000d; + public void finishLoad() { + loadFinished = LocalDateTime.now(); + } + + + @Transient + public void addCounts2(BulkLoadFileHistory history) { + for (Entry entry: history.getCounts().entrySet()) { + String key = entry.getKey(); + if (counts.containsKey(key)) { + counts.get(key).add(entry.getValue()); + } else { + counts.put(key, history.getCounts().get(key)); + } } - completedRecords++; } + @Transient + public void setCount(long count) { + setCount(COUNT_TYPE, count); + } + @Transient + public void setCount(String countType, long count) { + counts.put(countType, new ProcessCount(count)); + } + @Transient + public ProcessCount getCount() { + return getCount(COUNT_TYPE); + } + @Transient + public ProcessCount getCount(String countType) { + return getProcessCount(countType); + } + @Transient + public void incrementCompleted() { + incrementCompleted(COUNT_TYPE); + } + @Transient + public void incrementCompleted(String countType) { + getProcessCount(countType).incrementCompleted(); + } @Transient public void incrementFailed() { - errorRate += 1d / 1000d; - failedRecords++; + incrementFailed(COUNT_TYPE); } - @Transient - public void incrementDeleted() { - deletedRecords++; + public void incrementFailed(String countType) { + getProcessCount(countType).incrementFailed(); } - @Transient - public void incrementDeleteFailed() { - deleteFailedRecords++; + public void incrementSkipped() { + incrementSkipped(COUNT_TYPE); } - @Transient - public void finishLoad() { - loadFinished = LocalDateTime.now(); + public void incrementSkipped(String countType) { + getProcessCount(countType).incrementSkipped(); + } + @Transient + public void setTotalCount(long total) { + getProcessCount(COUNT_TYPE).setTotal(total); + } + @Transient + public double getErrorRate() { + return getErrorRate(COUNT_TYPE); + } + @Transient + public double getErrorRate(String countType) { + return getProcessCount(countType).getErrorRate(); + } + @Transient + private ProcessCount getProcessCount(String countType) { + if (counts.containsKey(countType)) { + return counts.get(countType); + } else { + ProcessCount count = new ProcessCount(0); + counts.put(countType, count); + return count; + } } } diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/ontology/OntologyTerm.java b/src/main/java/org/alliancegenome/curation_api/model/entities/ontology/OntologyTerm.java index 134613a09..787804245 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/ontology/OntologyTerm.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/ontology/OntologyTerm.java @@ -38,7 +38,7 @@ import lombok.ToString; @Inheritance(strategy = InheritanceType.SINGLE_TABLE) -@DiscriminatorColumn(name = "OntologyTermType") +@DiscriminatorColumn(name = "OntologyTermType", length = 64) @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @Entity @@ -47,6 +47,7 @@ @Table( indexes = { @Index(name = "ontologyterm_curie_index", columnList = "curie"), + @Index(name = "ontologyterm_name_index", columnList = "name"), @Index(name = "ontologyterm_createdby_index", columnList = "createdBy_id"), @Index(name = "ontologyterm_updatedby_index", columnList = "updatedBy_id") }, diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/NameSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/NameSlotAnnotation.java index 1337d5176..fefcffbc9 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/NameSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/NameSlotAnnotation.java @@ -18,10 +18,9 @@ import com.fasterxml.jackson.annotation.JsonView; +import jakarta.persistence.Column; import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.ManyToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -32,10 +31,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { SlotAnnotation.class }) @Schema(name = "NameSlotAnnotation", description = "POJO representing a name slot annotation") -@Table(indexes = { - @Index(name = "nameslotannotation_nametype_index", columnList = "nameType_id"), - @Index(name = "nameslotannotation_synonymscope_index", columnList = "synonymScope_id") -}) public abstract class NameSlotAnnotation extends SlotAnnotation { @IndexedEmbedded(includeDepth = 1) @@ -49,12 +44,14 @@ public abstract class NameSlotAnnotation extends SlotAnnotation { @KeywordField(name = "formatText_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) @EqualsAndHashCode.Include + @Column(columnDefinition = "TEXT") protected String formatText; @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") @KeywordField(name = "displayText_keyword", aggregable = Aggregable.YES, sortable = Sortable.YES, searchable = Searchable.YES, normalizer = "sortNormalizer") @JsonView({ View.FieldsOnly.class, View.ForPublic.class }) @EqualsAndHashCode.Include + @Column(columnDefinition = "TEXT") protected String displayText; @FullTextField(analyzer = "autocompleteAnalyzer", searchAnalyzer = "autocompleteSearchAnalyzer") diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/SlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/SlotAnnotation.java index 4bcfa0423..8bd39c8a1 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/SlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/SlotAnnotation.java @@ -14,6 +14,7 @@ import com.fasterxml.jackson.annotation.JsonView; +import jakarta.persistence.DiscriminatorColumn; import jakarta.persistence.Entity; import jakarta.persistence.Index; import jakarta.persistence.Inheritance; @@ -25,16 +26,33 @@ import lombok.EqualsAndHashCode; import lombok.ToString; -@Inheritance(strategy = InheritanceType.JOINED) +@Inheritance(strategy = InheritanceType.SINGLE_TABLE) +@DiscriminatorColumn(name = "SlotAnnotationType", length = 96) @Entity @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true, callSuper = true) @Schema(name = "SlotAnnotation", description = "POJO that represents a SlotAnnotation") @ToString(callSuper = true) @Table(indexes = { - @Index(name = "slotannotation_createdby_index", columnList = "createdBy_id"), - @Index(name = "slotannotation_updatedby_index", columnList = "updatedBy_id") + @Index(name = "slotannotation_createdby_index", columnList = "createdBy_id"), + @Index(name = "slotannotation_updatedby_index", columnList = "updatedBy_id"), + @Index(name = "slotannotation_singleallele_index", columnList = "singleallele_id"), + @Index(name = "slotannotation_singleconstruct_index", columnList = "singleConstruct_id"), + @Index(name = "slotannotation_singlegene_index", columnList = "singlegene_id"), + @Index(name = "slotannotation_inheritancemode_index", columnList = "inheritancemode_id"), + @Index(name = "slotannotation_phenotypeterm_index", columnList = "phenotypeterm_id"), + @Index(name = "slotannotation_status_index", columnList = "germlinetransmissionstatus_id"), + @Index(name = "slotannotation_nomenclatureevent_index", columnList = "nomenclatureevent_id"), + @Index(name = "slotannotation_databasestatus_index", columnList = "databasestatus_id"), + @Index(name = "slotannotation_componentsymbol_index", columnList = "componentSymbol"), + @Index(name = "slotannotation_taxon_index", columnList = "taxon_id"), + @Index(name = "slotannotation_relation_index", columnList = "relation_id"), + @Index(name = "slotannotation_nametype_index", columnList = "nameType_id"), + @Index(name = "slotannotation_synonymscope_index", columnList = "synonymScope_id") }) + + + @AGRCurationSchemaVersion(min = "1.4.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AuditedObject.class }) public class SlotAnnotation extends AuditedObject { diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleDatabaseStatusSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleDatabaseStatusSlotAnnotation.java index ad40fc984..aa3018a19 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleDatabaseStatusSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleDatabaseStatusSlotAnnotation.java @@ -15,10 +15,8 @@ import com.fasterxml.jackson.annotation.JsonView; import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -29,8 +27,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { SlotAnnotation.class }) @Schema(name = "AlleleDatabaseStatusSlotAnnotation", description = "POJO representing an allele database status slot annotation") -@Table(indexes = { @Index(name = "alleledatabasestatus_singleallele_index", columnList = "singleallele_id"), - @Index(name = "alleledatabasestatus_databasestatus_index", columnList = "databasestatus_id")}) public class AlleleDatabaseStatusSlotAnnotation extends SlotAnnotation { @OneToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotation.java index 5086889cb..d6803bb4f 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleFullNameSlotAnnotation.java @@ -9,9 +9,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference; import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.OneToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -22,7 +20,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "AlleleFullNameSlotAnnotation", description = "POJO representing an allele full name slot annotation") -@Table(indexes = { @Index(name = "allelefullname_singleallele_index", columnList = "singleallele_id") }) public class AlleleFullNameSlotAnnotation extends NameSlotAnnotation { @OneToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotation.java index 6ea256d75..bcbbde846 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleFunctionalImpactSlotAnnotation.java @@ -27,10 +27,10 @@ import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -41,8 +41,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.5.1", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { SlotAnnotation.class }) @Schema(name = "AlleleFunctionalImpactSlotAnnotation", description = "POJO representing an allele functional impact slot annotation") -@Table(indexes = { @Index(name = "allelefunctionalimpact_singleallele_index", columnList = "singleallele_id"), - @Index(name = "allelefunctionalimpact_phenotypeterm_index", columnList = "phenotypeterm_id")}) public class AlleleFunctionalImpactSlotAnnotation extends SlotAnnotation { @ManyToOne @@ -53,8 +51,14 @@ public class AlleleFunctionalImpactSlotAnnotation extends SlotAnnotation { @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany @Fetch(FetchMode.SELECT) - @JoinTable(indexes = { @Index(name = "allelefunctionalimpactsa_vocabterm_afisa_index", columnList = "allelefunctionalimpactslotannotation_id"), - @Index(name = "allelefunctionalimpactsa_vocabterm_functionalimpacts_index", columnList = "functionalimpacts_id") }) + @JoinTable( + joinColumns = @JoinColumn(name = "slotannotation_id"), + inverseJoinColumns = @JoinColumn(name = "functionalimpacts_id"), + indexes = { + @Index(name = "slotannotation_id_index", columnList = "slotannotation_id"), + @Index(name = "slotannotation_functionalimpacts_index", columnList = "functionalimpacts_id") + } + ) @JsonView({ View.FieldsAndLists.class, View.AlleleView.class }) private List functionalImpacts; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotation.java index cb8a284c7..80380a0e1 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleGermlineTransmissionStatusSlotAnnotation.java @@ -15,9 +15,7 @@ import com.fasterxml.jackson.annotation.JsonView; import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.ManyToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -28,8 +26,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.4.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { SlotAnnotation.class }) @Schema(name = "AlleleGermlineTransmissionStatusSlotAnnotation", description = "POJO representing an allele germline transmission status slot annotation") -@Table(indexes = { @Index(name = "allelegermlinetransmissionstatus_singleallele_index", columnList = "singleallele_id"), - @Index(name = "allelegermlinetransmissionstatus_status_index", columnList = "germlinetransmissionstatus_id")}) public class AlleleGermlineTransmissionStatusSlotAnnotation extends SlotAnnotation { @ManyToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotation.java index 97cee9787..67940fe2a 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleInheritanceModeSlotAnnotation.java @@ -22,9 +22,7 @@ import jakarta.persistence.Column; import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.ManyToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -35,9 +33,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.5.1", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { SlotAnnotation.class }) @Schema(name = "AlleleInheritanceModeSlotAnnotation", description = "POJO representing an allele inheritance mode slot annotation") -@Table(indexes = { @Index(name = "alleleinheritancemode_singleallele_index", columnList = "singleallele_id"), - @Index(name = "alleleinheritancemode_inheritancemode_index", columnList = "inheritancemode_id"), - @Index(name = "alleleinheritancemode_phenotypeterm_index", columnList = "phenotypeterm_id")}) public class AlleleInheritanceModeSlotAnnotation extends SlotAnnotation { @ManyToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotation.java index d23436f00..c43e3c438 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleMutationTypeSlotAnnotation.java @@ -20,10 +20,10 @@ import jakarta.persistence.Entity; import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -34,7 +34,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.4.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { SlotAnnotation.class }) @Schema(name = "AlleleMutationtTypeSlotAnnotation", description = "POJO representing an allele mutation type slot annotation") -@Table(indexes = { @Index(name = "allelemutationtype_singleallele_index", columnList = "singleallele_id") }) public class AlleleMutationTypeSlotAnnotation extends SlotAnnotation { @ManyToOne @@ -45,8 +44,14 @@ public class AlleleMutationTypeSlotAnnotation extends SlotAnnotation { @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @ManyToMany @Fetch(FetchMode.SELECT) - @JoinTable(indexes = { @Index(name = "allelemutationtypesa_soterm_amsa_index", columnList = "allelemutationtypeslotannotation_id"), - @Index(name = "allelemutationtypesa_soterm_mutationtypes_index", columnList = "mutationtypes_id") }) + @JoinTable( + joinColumns = @JoinColumn(name = "slotannotation_id"), + inverseJoinColumns = @JoinColumn(name = "mutationtypes_id"), + indexes = { + @Index(name = "slotannotation_soterm_amsa_index", columnList = "slotannotation_id"), + @Index(name = "slotannotation_soterm_mutationtypes_index", columnList = "mutationtypes_id") + } + ) @JsonView({ View.FieldsAndLists.class, View.AlleleView.class }) private List mutationTypes; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotation.java index b626d523f..4b5632328 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleNomenclatureEventSlotAnnotation.java @@ -15,9 +15,7 @@ import com.fasterxml.jackson.annotation.JsonView; import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.ManyToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -28,8 +26,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { SlotAnnotation.class }) @Schema(name = "AlleleNomenclatureSlotAnnotation", description = "POJO representing an allele nomenclature event slot annotation") -@Table(indexes = { @Index(name = "allelenomenclatureevent_singleallele_index", columnList = "singleallele_id"), - @Index(name = "allelenomenclatureevent_nomenclatureevent_index", columnList = "nomenclatureevent_id")}) public class AlleleNomenclatureEventSlotAnnotation extends SlotAnnotation { @ManyToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotation.java index c61be7b64..4d8027919 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSecondaryIdSlotAnnotation.java @@ -10,9 +10,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference; import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.ManyToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -23,7 +21,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.4.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { SlotAnnotation.class }) @Schema(name = "AlleleSecondaryIdSlotAnnotation", description = "POJO representing an allele secondary ID slot annotation") -@Table(indexes = { @Index(name = "allelesecondaryid_singleallele_index", columnList = "singleallele_id") }) public class AlleleSecondaryIdSlotAnnotation extends SecondaryIdSlotAnnotation { @ManyToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotation.java index c384b2836..f14bec427 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSymbolSlotAnnotation.java @@ -9,9 +9,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference; import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.OneToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -22,7 +20,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "AlleleSymbolSlotAnnotation", description = "POJO representing an allele symbol slot annotation") -@Table(indexes = { @Index(name = "allelesymbol_singleallele_index", columnList = "singleallele_id") }) public class AlleleSymbolSlotAnnotation extends NameSlotAnnotation { @OneToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotation.java index d04b130da..227634f25 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/alleleSlotAnnotations/AlleleSynonymSlotAnnotation.java @@ -9,9 +9,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference; import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.ManyToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -22,7 +20,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "AlleleSynonymSlotAnnotation", description = "POJO representing an allele synonym slot annotation") -@Table(indexes = { @Index(name = "allelesynonym_singleallele_index", columnList = "singleallele_id") }) public class AlleleSynonymSlotAnnotation extends NameSlotAnnotation { @ManyToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotation.java index eb0422054..8a77ec356 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructComponentSlotAnnotation.java @@ -27,10 +27,10 @@ import jakarta.persistence.Entity; import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinTable; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -41,12 +41,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.10.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { SlotAnnotation.class }) @Schema(name = "ConstructComponentSlotAnnotation", description = "POJO representing a construct component slot annotation") -@Table(indexes = { - @Index(name = "constructcomponentslotannotation_singleconstruct_index", columnList = "singleConstruct_id"), - @Index(name = "constructcomponentslotannotation_componentsymbol_index", columnList = "componentSymbol"), - @Index(name = "constructcomponentslotannotation_taxon_index", columnList = "taxon_id"), - @Index(name = "constructcomponentslotannotation_relation_index", columnList = "relation_id") -}) public class ConstructComponentSlotAnnotation extends SlotAnnotation { @ManyToOne @@ -84,9 +78,11 @@ public class ConstructComponentSlotAnnotation extends SlotAnnotation { @OneToMany @JsonView({ View.FieldsAndLists.class, View.ConstructView.class }) @JoinTable( + joinColumns = @JoinColumn(name = "slotannotation_id"), + inverseJoinColumns = @JoinColumn(name = "relatednotes_id"), indexes = { - @Index(name = "constructcomponentsa_note_ccsa_index", columnList = "constructcomponentslotannotation_id"), - @Index(name = "constructcomponentsa_note_relatednotes_index", columnList = "relatednotes_id") + @Index(name = "slotannotation_note_ccsa_index", columnList = "slotannotation_id"), + @Index(name = "slotannotation_note_relatednotes_index", columnList = "relatednotes_id") } ) private List relatedNotes; diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotation.java index 6eca7ca3d..5d4be1bcf 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructFullNameSlotAnnotation.java @@ -9,9 +9,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference; import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.OneToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -22,7 +20,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.10.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "ConstructFullNameSlotAnnotation", description = "POJO representing a construct full name slot annotation") -@Table(indexes = { @Index(name = "constructfullname_singleconstruct_index", columnList = "singleconstruct_id") }) public class ConstructFullNameSlotAnnotation extends NameSlotAnnotation { @OneToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotation.java index fe6926c4a..aa0614176 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructSymbolSlotAnnotation.java @@ -9,9 +9,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference; import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.OneToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -22,7 +20,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.10.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "ConstructSymbolSlotAnnotation", description = "POJO representing a construct symbol slot annotation") -@Table(indexes = { @Index(name = "constructsymbol_singleconstruct_index", columnList = "singleconstruct_id") }) public class ConstructSymbolSlotAnnotation extends NameSlotAnnotation { @OneToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotation.java index 82f895f76..6c803d16a 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/constructSlotAnnotations/ConstructSynonymSlotAnnotation.java @@ -9,9 +9,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference; import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.ManyToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -22,7 +20,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.10.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "ConstructSynonymSlotAnnotation", description = "POJO representing a construct synonym slot annotation") -@Table(indexes = { @Index(name = "constructsynonym_singleconstruct_index", columnList = "singleconstruct_id") }) public class ConstructSynonymSlotAnnotation extends NameSlotAnnotation { @ManyToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotation.java index 630da4b8c..fe3f53f7d 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneFullNameSlotAnnotation.java @@ -9,9 +9,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference; import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.OneToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -22,7 +20,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "GeneFullNameSlotAnnotation", description = "POJO representing a gene full name slot annotation") -@Table(indexes = { @Index(name = "genefullname_singlegene_index", columnList = "singlegene_id") }) public class GeneFullNameSlotAnnotation extends NameSlotAnnotation { @OneToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotation.java index de66ef259..3d1f0c332 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSecondaryIdSlotAnnotation.java @@ -10,9 +10,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference; import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.ManyToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -23,7 +21,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.7.2", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { SlotAnnotation.class }) @Schema(name = "GeneSecondaryIdSlotAnnotation", description = "POJO representing a gene secondary ID slot annotation") -@Table(indexes = { @Index(name = "genesecondaryid_singlegene_index", columnList = "singlegene_id") }) public class GeneSecondaryIdSlotAnnotation extends SecondaryIdSlotAnnotation { @ManyToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotation.java index b55cf3898..6b1bd54b1 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSymbolSlotAnnotation.java @@ -9,9 +9,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference; import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.OneToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -22,7 +20,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "GeneSymbolSlotAnnotation", description = "POJO representing a gene symbol slot annotation") -@Table(indexes = { @Index(name = "genesymbol_singlegene_index", columnList = "singlegene_id") }) public class GeneSymbolSlotAnnotation extends NameSlotAnnotation { @OneToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotation.java index 22ee85268..52067a5b2 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSynonymSlotAnnotation.java @@ -9,9 +9,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference; import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.ManyToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -22,7 +20,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "GeneSynonymSlotAnnotation", description = "POJO representing a gene synonym slot annotation") -@Table(indexes = { @Index(name = "genesynonym_singlegene_index", columnList = "singlegene_id") }) public class GeneSynonymSlotAnnotation extends NameSlotAnnotation { @ManyToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotation.java b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotation.java index 72042e3b0..074464f0a 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotation.java +++ b/src/main/java/org/alliancegenome/curation_api/model/entities/slotAnnotations/geneSlotAnnotations/GeneSystematicNameSlotAnnotation.java @@ -9,9 +9,7 @@ import com.fasterxml.jackson.annotation.JsonBackReference; import jakarta.persistence.Entity; -import jakarta.persistence.Index; import jakarta.persistence.OneToOne; -import jakarta.persistence.Table; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -22,7 +20,6 @@ @ToString(callSuper = true) @AGRCurationSchemaVersion(min = "1.5.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { NameSlotAnnotation.class }) @Schema(name = "GeneSystematicNameSlotAnnotation", description = "POJO representing a gene systematic name slot annotation") -@Table(indexes = { @Index(name = "genesystematicname_singlegene_index", columnList = "singlegene_id") }) public class GeneSystematicNameSlotAnnotation extends NameSlotAnnotation { @OneToOne diff --git a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/IngestDTO.java b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/IngestDTO.java index e745081c7..8599fd9de 100644 --- a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/IngestDTO.java +++ b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/IngestDTO.java @@ -3,6 +3,7 @@ import java.util.List; import org.alliancegenome.curation_api.model.ingest.dto.associations.alleleAssociations.AlleleGeneAssociationDTO; +import org.alliancegenome.curation_api.model.ingest.dto.associations.alleleAssociations.AlleleVariantAssociationDTO; import org.alliancegenome.curation_api.model.ingest.dto.associations.constructAssociations.ConstructGenomicEntityAssociationDTO; import org.alliancegenome.curation_api.view.View; @@ -58,6 +59,10 @@ public class IngestDTO { @JsonProperty("allele_gene_association_ingest_set") private List alleleGeneAssociationIngestSet; + @JsonView({ View.FieldsAndLists.class }) + @JsonProperty("allele_variant_association_ingest_set") + private List alleleVariantAssociationIngestSet; + @JsonView({ View.FieldsAndLists.class }) @JsonProperty("construct_genomic_entity_association_ingest_set") private List constructGenomicEntityAssociationIngestSet; diff --git a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/alleleAssociations/AlleleVariantAssociationDTO.java b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/alleleAssociations/AlleleVariantAssociationDTO.java new file mode 100644 index 000000000..b01e6332b --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/associations/alleleAssociations/AlleleVariantAssociationDTO.java @@ -0,0 +1,22 @@ +package org.alliancegenome.curation_api.model.ingest.dto.associations.alleleAssociations; + +import org.alliancegenome.curation_api.constants.LinkMLSchemaConstants; +import org.alliancegenome.curation_api.interfaces.AGRCurationSchemaVersion; +import org.alliancegenome.curation_api.view.View; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonView; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +@AGRCurationSchemaVersion(min = "2.0.0", max = LinkMLSchemaConstants.LATEST_RELEASE, dependencies = { AlleleGenomicEntityAssociationDTO.class }, submitted = true) +public class AlleleVariantAssociationDTO extends AlleleGenomicEntityAssociationDTO { + + @JsonView({ View.FieldsOnly.class }) + @JsonProperty("variant_identifier") + private String variantIdentifier; + +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/BiogridOrcFmsDTO.java b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/BiogridOrcFmsDTO.java new file mode 100644 index 000000000..6742ac634 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/BiogridOrcFmsDTO.java @@ -0,0 +1,29 @@ +package org.alliancegenome.curation_api.model.ingest.dto.fms; + +import java.util.List; + +import org.alliancegenome.curation_api.model.ingest.dto.CrossReferenceDTO; +import org.alliancegenome.curation_api.model.ingest.dto.base.BaseDTO; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class BiogridOrcFmsDTO extends BaseDTO { + private Integer screenId; + private String identifierId; + private String identifierType; + private String officialSymbol; + private String aliases; + private Integer organismId; + private String organismOfficial; + private Double score1; + private Double score2; + private Double score3; + private Double score4; + private Double score5; + private String hit; + private String source; + private List crossReferenceDtos; +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/HTPExpressionDatasetAnnotationFmsDTO.java b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/HTPExpressionDatasetAnnotationFmsDTO.java new file mode 100644 index 000000000..7f38be69b --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/HTPExpressionDatasetAnnotationFmsDTO.java @@ -0,0 +1,22 @@ +package org.alliancegenome.curation_api.model.ingest.dto.fms; + +import java.util.List; + +import org.alliancegenome.curation_api.model.ingest.dto.base.BaseDTO; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class HTPExpressionDatasetAnnotationFmsDTO extends BaseDTO { + + private HTPIdFmsDTO datasetId; + private List publications; + private String title; + private String summary; + private Integer numChannels; + private List subSeries; + private String dateAssigned; + private List categoryTags; +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/HTPExpressionDatasetAnnotationIngestFmsDTO.java b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/HTPExpressionDatasetAnnotationIngestFmsDTO.java new file mode 100644 index 000000000..2862e84d7 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/HTPExpressionDatasetAnnotationIngestFmsDTO.java @@ -0,0 +1,15 @@ +package org.alliancegenome.curation_api.model.ingest.dto.fms; + +import java.util.List; + +import org.alliancegenome.curation_api.model.ingest.dto.base.BaseDTO; + +import lombok.Data; +import lombok.EqualsAndHashCode; +@Data +@EqualsAndHashCode(callSuper = true) +public class HTPExpressionDatasetAnnotationIngestFmsDTO extends BaseDTO { + + private MetaDataFmsDTO metaData; + private List data; +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/HTPIdFmsDTO.java b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/HTPIdFmsDTO.java new file mode 100644 index 000000000..5cc78241f --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/HTPIdFmsDTO.java @@ -0,0 +1,18 @@ +package org.alliancegenome.curation_api.model.ingest.dto.fms; + +import java.util.List; + +import org.alliancegenome.curation_api.model.ingest.dto.base.BaseDTO; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class HTPIdFmsDTO extends BaseDTO { + + private String primaryId; + private List alternateIds; + private CrossReferenceFmsDTO preferredCrossReference; + private List crossReferences; +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/VariantFmsDTO.java b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/VariantFmsDTO.java new file mode 100644 index 000000000..3614eedd3 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/VariantFmsDTO.java @@ -0,0 +1,26 @@ +package org.alliancegenome.curation_api.model.ingest.dto.fms; + +import java.util.List; + +import org.alliancegenome.curation_api.model.ingest.dto.base.BaseDTO; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class VariantFmsDTO extends BaseDTO { + private String alleleId; + private String assembly; + private String chromosome; + private Integer start; + private Integer end; + private String sequenceOfReferenceAccessionNumber; + private String genomicReferenceSequence; + private String genomicVariantSequence; + private String type; + private String consequence; + private List notes; + private List references; + private List crossReferences; +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/VariantIngestFmsDTO.java b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/VariantIngestFmsDTO.java new file mode 100644 index 000000000..008caf726 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/VariantIngestFmsDTO.java @@ -0,0 +1,15 @@ +package org.alliancegenome.curation_api.model.ingest.dto.fms; + +import java.util.List; + +import org.alliancegenome.curation_api.model.ingest.dto.base.BaseDTO; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class VariantIngestFmsDTO extends BaseDTO { + private MetaDataFmsDTO metaData; + private List data; +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/VariantNoteFmsDTO.java b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/VariantNoteFmsDTO.java new file mode 100644 index 000000000..34a2117bd --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/ingest/dto/fms/VariantNoteFmsDTO.java @@ -0,0 +1,15 @@ +package org.alliancegenome.curation_api.model.ingest.dto.fms; + +import java.util.List; + +import org.alliancegenome.curation_api.model.ingest.dto.base.BaseDTO; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class VariantNoteFmsDTO extends BaseDTO { + private String note; + private List references; +} diff --git a/src/main/java/org/alliancegenome/curation_api/model/output/ProcessCount.java b/src/main/java/org/alliancegenome/curation_api/model/output/ProcessCount.java new file mode 100644 index 000000000..28bcb785a --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/model/output/ProcessCount.java @@ -0,0 +1,53 @@ +package org.alliancegenome.curation_api.model.output; + +import org.alliancegenome.curation_api.view.View; + +import com.fasterxml.jackson.annotation.JsonView; + +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data @NoArgsConstructor +@JsonView({ View.FieldsOnly.class }) +public class ProcessCount { + private Long total = 0L; + private Long failed = 0L; + private Long skipped = 0L; + private Long completed = 0L; + private Long error = 0L; + + public ProcessCount(Long total) { + this.total = total; + } + public ProcessCount(Integer total) { + this.total = Long.valueOf(total); + } + + public void incrementCompleted() { + completed++; + if (error > 0) { + error--; + } + } + + public void incrementSkipped() { + skipped++; + } + + public void incrementFailed() { + failed++; + error++; + } + public double getErrorRate() { + return error / 1000; + } + + public void add(ProcessCount count) { + total += count.getTotal(); + failed += count.getFailed(); + skipped += count.getSkipped(); + completed += count.getCompleted(); + error += count.getError(); + } + +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/AGMDiseaseAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/AGMDiseaseAnnotationService.java index 749aecd0d..5ef94e4f1 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AGMDiseaseAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AGMDiseaseAnnotationService.java @@ -5,7 +5,7 @@ import org.alliancegenome.curation_api.dao.AGMDiseaseAnnotationDAO; import org.alliancegenome.curation_api.dao.ConditionRelationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.AGMDiseaseAnnotation; import org.alliancegenome.curation_api.model.ingest.dto.AGMDiseaseAnnotationDTO; import org.alliancegenome.curation_api.response.ObjectResponse; @@ -48,7 +48,7 @@ public ObjectResponse create(AGMDiseaseAnnotation uiEntity } @Transactional - public AGMDiseaseAnnotation upsert(AGMDiseaseAnnotationDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public AGMDiseaseAnnotation upsert(AGMDiseaseAnnotationDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { AGMDiseaseAnnotation annotation = agmDiseaseAnnotationDtoValidator.validateAGMDiseaseAnnotationDTO(dto, dataProvider); return agmDiseaseAnnotationDAO.persist(annotation); diff --git a/src/main/java/org/alliancegenome/curation_api/services/AGMPhenotypeAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/AGMPhenotypeAnnotationService.java index fbcf98f70..afdb82612 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AGMPhenotypeAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AGMPhenotypeAnnotationService.java @@ -5,7 +5,7 @@ import org.alliancegenome.curation_api.dao.AGMPhenotypeAnnotationDAO; import org.alliancegenome.curation_api.dao.ConditionRelationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.AGMPhenotypeAnnotation; import org.alliancegenome.curation_api.model.entities.AffectedGenomicModel; import org.alliancegenome.curation_api.model.ingest.dto.fms.PhenotypeFmsDTO; @@ -45,13 +45,13 @@ public ObjectResponse create(AGMPhenotypeAnnotation uiEn } @Transactional - public AGMPhenotypeAnnotation upsertPrimaryAnnotation(AffectedGenomicModel subject, PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public AGMPhenotypeAnnotation upsertPrimaryAnnotation(AffectedGenomicModel subject, PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { AGMPhenotypeAnnotation annotation = agmPhenotypeAnnotationFmsDtoValidator.validatePrimaryAnnotation(subject, dto, dataProvider); return agmPhenotypeAnnotationDAO.persist(annotation); } @Transactional - public List addInferredOrAssertedEntities(AffectedGenomicModel primaryAnnotationSubject, PhenotypeFmsDTO secondaryAnnotationDto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public List addInferredOrAssertedEntities(AffectedGenomicModel primaryAnnotationSubject, PhenotypeFmsDTO secondaryAnnotationDto, BackendBulkDataProvider dataProvider) throws ValidationException { List annotations = agmPhenotypeAnnotationFmsDtoValidator.validateInferredOrAssertedEntities(primaryAnnotationSubject, secondaryAnnotationDto, dataProvider); for (AGMPhenotypeAnnotation annotation : annotations) { agmPhenotypeAnnotationDAO.persist(annotation); diff --git a/src/main/java/org/alliancegenome/curation_api/services/AffectedGenomicModelService.java b/src/main/java/org/alliancegenome/curation_api/services/AffectedGenomicModelService.java index 864322e57..c8c706a4f 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AffectedGenomicModelService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AffectedGenomicModelService.java @@ -11,7 +11,7 @@ import org.alliancegenome.curation_api.dao.AlleleDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ApiErrorException; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.AffectedGenomicModel; import org.alliancegenome.curation_api.model.ingest.dto.AffectedGenomicModelDTO; import org.alliancegenome.curation_api.response.ObjectResponse; @@ -60,7 +60,7 @@ public ObjectResponse create(AffectedGenomicModel uiEntity } @Transactional - public AffectedGenomicModel upsert(AffectedGenomicModelDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public AffectedGenomicModel upsert(AffectedGenomicModelDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { AffectedGenomicModel agm = agmDtoValidator.validateAffectedGenomicModelDTO(dto, dataProvider); if (agm == null) { diff --git a/src/main/java/org/alliancegenome/curation_api/services/AlleleDiseaseAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/AlleleDiseaseAnnotationService.java index c37106298..33d24d3a8 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AlleleDiseaseAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AlleleDiseaseAnnotationService.java @@ -4,7 +4,7 @@ import org.alliancegenome.curation_api.dao.AlleleDiseaseAnnotationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.AlleleDiseaseAnnotation; import org.alliancegenome.curation_api.model.ingest.dto.AlleleDiseaseAnnotationDTO; import org.alliancegenome.curation_api.response.ObjectResponse; @@ -46,7 +46,7 @@ public ObjectResponse create(AlleleDiseaseAnnotation ui } @Transactional - public AlleleDiseaseAnnotation upsert(AlleleDiseaseAnnotationDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public AlleleDiseaseAnnotation upsert(AlleleDiseaseAnnotationDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { AlleleDiseaseAnnotation annotation = alleleDiseaseAnnotationDtoValidator.validateAlleleDiseaseAnnotationDTO(dto, dataProvider); return alleleDiseaseAnnotationDAO.persist(annotation); diff --git a/src/main/java/org/alliancegenome/curation_api/services/AllelePhenotypeAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/AllelePhenotypeAnnotationService.java index 98df22cf6..598981b22 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AllelePhenotypeAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AllelePhenotypeAnnotationService.java @@ -5,7 +5,7 @@ import org.alliancegenome.curation_api.dao.AllelePhenotypeAnnotationDAO; import org.alliancegenome.curation_api.dao.ConditionRelationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.Allele; import org.alliancegenome.curation_api.model.entities.AllelePhenotypeAnnotation; import org.alliancegenome.curation_api.model.ingest.dto.fms.PhenotypeFmsDTO; @@ -45,13 +45,13 @@ public ObjectResponse create(AllelePhenotypeAnnotatio } @Transactional - public AllelePhenotypeAnnotation upsertPrimaryAnnotation(Allele subject, PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public AllelePhenotypeAnnotation upsertPrimaryAnnotation(Allele subject, PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { AllelePhenotypeAnnotation annotation = allelePhenotypeAnnotationFmsDtoValidator.validatePrimaryAnnotation(subject, dto, dataProvider); return allelePhenotypeAnnotationDAO.persist(annotation); } @Transactional - public List addInferredOrAssertedEntities(Allele primaryAnnotationSubject, PhenotypeFmsDTO secondaryAnnotationDto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public List addInferredOrAssertedEntities(Allele primaryAnnotationSubject, PhenotypeFmsDTO secondaryAnnotationDto, BackendBulkDataProvider dataProvider) throws ValidationException { List annotations = allelePhenotypeAnnotationFmsDtoValidator.validateInferredOrAssertedEntities(primaryAnnotationSubject, secondaryAnnotationDto, dataProvider); for (AllelePhenotypeAnnotation annotation : annotations) { allelePhenotypeAnnotationDAO.persist(annotation); diff --git a/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java b/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java index 3a5ed3d90..f16ff0f67 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AlleleService.java @@ -10,7 +10,7 @@ import org.alliancegenome.curation_api.dao.AlleleDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ApiErrorException; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.Allele; import org.alliancegenome.curation_api.model.ingest.dto.AlleleDTO; import org.alliancegenome.curation_api.response.ObjectResponse; @@ -65,7 +65,7 @@ public ObjectResponse create(Allele uiEntity) { return new ObjectResponse(dbEntity); } - public Allele upsert(AlleleDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public Allele upsert(AlleleDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { return alleleDtoValidator.validateAlleleDTO(dto, dataProvider); } @@ -85,6 +85,7 @@ public Allele deprecateOrDelete(Long id, Boolean throwApiError, String requestSo if (forceDeprecate || alleleDAO.hasReferencingDiseaseAnnotationIds(id) || alleleDAO.hasReferencingPhenotypeAnnotations(id) || CollectionUtils.isNotEmpty(allele.getAlleleGeneAssociations()) + || CollectionUtils.isNotEmpty(allele.getAlleleVariantAssociations()) || CollectionUtils.isNotEmpty(allele.getConstructGenomicEntityAssociations())) { if (!allele.getObsolete()) { allele.setUpdatedBy(personService.fetchByUniqueIdOrCreate(requestSource)); diff --git a/src/main/java/org/alliancegenome/curation_api/services/AssemblyComponentService.java b/src/main/java/org/alliancegenome/curation_api/services/AssemblyComponentService.java index 50d797d3c..e944e140d 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/AssemblyComponentService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/AssemblyComponentService.java @@ -2,12 +2,16 @@ import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.dao.AssemblyComponentDAO; +import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.enums.ChromosomeAccessionEnum; import org.alliancegenome.curation_api.model.entities.AssemblyComponent; import org.alliancegenome.curation_api.model.entities.GenomeAssembly; +import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.response.SearchResponse; import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; import org.alliancegenome.curation_api.services.helpers.UniqueIdGeneratorHelper; @@ -37,48 +41,57 @@ protected void init() { } @Transactional - public AssemblyComponent fetchOrCreate(String name, String assemblyId, String taxonCurie, String dataProviderAbbreviation) { + public AssemblyComponent fetchOrCreate(String name, String assemblyId, String taxonCurie, BackendBulkDataProvider dataProvider) { AssemblyComponent assemblyComponent = null; if (assemblyComponentRequest != null) { UniqueIdGeneratorHelper uniqueIdGen = new UniqueIdGeneratorHelper(); uniqueIdGen.add(name); uniqueIdGen.add(assemblyId); uniqueIdGen.add(taxonCurie); - uniqueIdGen.add(dataProviderAbbreviation); + uniqueIdGen.add(dataProvider.sourceOrganization); String uniqueId = uniqueIdGen.getUniqueId(); if (assemblyComponentCacheMap.containsKey(uniqueId)) { assemblyComponent = assemblyComponentCacheMap.get(uniqueId); } else { Log.debug("AssemblyComponent not cached, caching name|assembly: (" + uniqueId + ")"); - assemblyComponent = findAssemblyComponentOrCreateDB(name, assemblyId, taxonCurie, dataProviderAbbreviation); + assemblyComponent = findAssemblyComponentOrCreateDB(name, assemblyId, taxonCurie, dataProvider); assemblyComponentCacheMap.put(uniqueId, assemblyComponent); } } else { - assemblyComponent = findAssemblyComponentOrCreateDB(name, assemblyId, taxonCurie, dataProviderAbbreviation); + assemblyComponent = findAssemblyComponentOrCreateDB(name, assemblyId, taxonCurie, dataProvider); assemblyComponentRequest = new Date(); } return assemblyComponent; } - private AssemblyComponent findAssemblyComponentOrCreateDB(String name, String assemblyId, String taxonCurie, String dataProviderAbbreviation) { + private AssemblyComponent findAssemblyComponentOrCreateDB(String name, String assemblyId, String taxonCurie, BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); params.put("name", name); params.put(EntityFieldConstants.ASSEMBLY, assemblyId); params.put(EntityFieldConstants.TAXON, taxonCurie); - params.put(EntityFieldConstants.DATA_PROVIDER, dataProviderAbbreviation); + params.put(EntityFieldConstants.DATA_PROVIDER, dataProvider.sourceOrganization); SearchResponse assemblyComponentResponse = assemblyComponentDAO.findByParams(params); if (assemblyComponentResponse != null && assemblyComponentResponse.getResults().size() > 0) { return assemblyComponentResponse.getSingleResult(); } AssemblyComponent assemblyComponent = new AssemblyComponent(); assemblyComponent.setName(name); - SearchResponse assemblyResponse = genomeAssemblyService.findByField("modEntityId", assemblyId); - if (assemblyResponse != null && assemblyResponse.getSingleResult() != null) { - assemblyComponent.setGenomeAssembly(assemblyResponse.getSingleResult()); - } + GenomeAssembly genomeAssembly = genomeAssemblyService.getOrCreate(assemblyId, dataProvider); + assemblyComponent.setGenomeAssembly(genomeAssembly); assemblyComponent.setTaxon(ncbiTaxonTermService.getByCurie(taxonCurie).getEntity()); - assemblyComponent.setDataProvider(dataProviderService.createOrganizationDataProvider(dataProviderAbbreviation)); + assemblyComponent.setDataProvider(dataProviderService.getDefaultDataProvider(dataProvider.sourceOrganization)); + String modEntityId = ChromosomeAccessionEnum.getChromosomeAccession(name, assemblyId); + assemblyComponent.setModEntityId(modEntityId); return assemblyComponentDAO.persist(assemblyComponent); } + public ObjectResponse deleteByIdentifier(String identifierString) { + AssemblyComponent assemblyComponent = findByAlternativeFields(List.of("modEntityId", "modInternalId"), identifierString); + if (assemblyComponent != null) { + assemblyComponentDAO.remove(assemblyComponent.getId()); + } + ObjectResponse ret = new ObjectResponse<>(assemblyComponent); + return ret; + } + } diff --git a/src/main/java/org/alliancegenome/curation_api/services/BiologicalEntityService.java b/src/main/java/org/alliancegenome/curation_api/services/BiologicalEntityService.java index 3cc6c4127..891e98540 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/BiologicalEntityService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/BiologicalEntityService.java @@ -2,7 +2,7 @@ import org.alliancegenome.curation_api.dao.BiologicalEntityDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.BiologicalEntity; import org.alliancegenome.curation_api.model.ingest.dto.BiologicalEntityDTO; import org.alliancegenome.curation_api.services.base.SubmittedObjectCrudService; @@ -23,7 +23,7 @@ protected void init() { } @Override - public BiologicalEntity upsert(BiologicalEntityDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public BiologicalEntity upsert(BiologicalEntityDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { return null; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/CodingSequenceService.java b/src/main/java/org/alliancegenome/curation_api/services/CodingSequenceService.java index 879737409..badc7798b 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/CodingSequenceService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/CodingSequenceService.java @@ -42,8 +42,15 @@ public List getIdsByDataProvider(BackendBulkDataProvider dataProvider) { return ids; } + @Override + public ObjectResponse getByIdentifier(String identifier) { + CodingSequence object = findByAlternativeFields(List.of("curie", "modEntityId", "modInternalId", "uniqueId"), identifier); + ObjectResponse ret = new ObjectResponse(object); + return ret; + } + public ObjectResponse deleteByIdentifier(String identifierString) { - CodingSequence codingSequence = findByAlternativeFields(List.of("modEntityId", "modInternalId", "uniqueId"), identifierString); + CodingSequence codingSequence = findByAlternativeFields(List.of("curie", "modEntityId", "modInternalId", "uniqueId"), identifierString); if (codingSequence != null) { codingSequenceDAO.remove(codingSequence.getId()); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/ConstructService.java b/src/main/java/org/alliancegenome/curation_api/services/ConstructService.java index bd985dcd3..5b7dbd368 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/ConstructService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/ConstructService.java @@ -1,17 +1,16 @@ package org.alliancegenome.curation_api.services; -import java.time.OffsetDateTime; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - +import io.quarkus.logging.Log; +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.dao.ConstructDAO; import org.alliancegenome.curation_api.dao.slotAnnotations.constructSlotAnnotations.ConstructComponentSlotAnnotationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ApiErrorException; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.AffectedGenomicModel; import org.alliancegenome.curation_api.model.entities.Construct; import org.alliancegenome.curation_api.model.ingest.dto.ConstructDTO; @@ -23,22 +22,29 @@ import org.alliancegenome.curation_api.services.validation.dto.ConstructDTOValidator; import org.apache.commons.collections.CollectionUtils; -import io.quarkus.logging.Log; -import jakarta.annotation.PostConstruct; -import jakarta.enterprise.context.RequestScoped; -import jakarta.inject.Inject; -import jakarta.transaction.Transactional; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; @RequestScoped public class ConstructService extends SubmittedObjectCrudService { - @Inject ConstructDAO constructDAO; - @Inject ConstructValidator constructValidator; - @Inject ConstructDTOValidator constructDtoValidator; - @Inject ConstructService constructService; - @Inject PersonService personService; - @Inject ConstructComponentSlotAnnotationDAO constructComponentDAO; - @Inject ConstructGenomicEntityAssociationService constructGenomicEntityAssociationService; + @Inject + ConstructDAO constructDAO; + @Inject + ConstructValidator constructValidator; + @Inject + ConstructDTOValidator constructDtoValidator; + @Inject + ConstructService constructService; + @Inject + PersonService personService; + @Inject + ConstructComponentSlotAnnotationDAO constructComponentDAO; + @Inject + ConstructGenomicEntityAssociationService constructGenomicEntityAssociationService; @Override @PostConstruct @@ -55,7 +61,7 @@ public ObjectResponse getByIdentifier(String identifier) { construct = response.getSingleResult(); } } - return new ObjectResponse(construct); + return new ObjectResponse<>(construct); } @Override @@ -73,7 +79,7 @@ public ObjectResponse create(Construct uiEntity) { } @Transactional - public Construct upsert(ConstructDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public Construct upsert(ConstructDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { Construct construct = constructDtoValidator.validateConstructDTO(dto, dataProvider); return constructDAO.persist(construct); @@ -91,7 +97,7 @@ public ObjectResponse deleteById(Long id) { @Transactional public Construct deprecateOrDelete(Long id, Boolean throwApiError, String requestSource, Boolean forceDeprecate) { Construct construct = constructDAO.find(id); - + if (construct != null) { if (forceDeprecate || CollectionUtils.isNotEmpty(construct.getConstructGenomicEntityAssociations())) { if (!construct.getObsolete()) { @@ -125,4 +131,22 @@ public List getConstructIdsByDataProvider(BackendBulkDataProvider dataProv return constructIds; } + + public Map getConstructIdMap() { + if (constructIdMap.size() > 0) { + return constructIdMap; + } + constructIdMap = constructDAO.getConstructIdMap(); + return constructIdMap; + } + + private Map constructIdMap = new HashMap<>(); + + public Long getIdByModID(String modID) { + return getConstructIdMap().get(modID); + } + + public Construct getShallowEntity(Long id) { + return constructDAO.getShallowEntity(Construct.class, id); + } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/CrossReferenceService.java b/src/main/java/org/alliancegenome/curation_api/services/CrossReferenceService.java index 1b5263011..eff5ba8d7 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/CrossReferenceService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/CrossReferenceService.java @@ -1,10 +1,9 @@ package org.alliancegenome.curation_api.services; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; import org.alliancegenome.curation_api.dao.CrossReferenceDAO; import org.alliancegenome.curation_api.model.entities.CrossReference; import org.alliancegenome.curation_api.model.entities.ResourceDescriptorPage; @@ -13,16 +12,18 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import jakarta.annotation.PostConstruct; -import jakarta.enterprise.context.RequestScoped; -import jakarta.inject.Inject; -import jakarta.transaction.Transactional; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; @RequestScoped public class CrossReferenceService extends BaseEntityCrudService { - @Inject CrossReferenceDAO crossReferenceDAO; - @Inject ResourceDescriptorPageService resourceDescriptorPageService; + @Inject + CrossReferenceDAO crossReferenceDAO; + @Inject + ResourceDescriptorPageService resourceDescriptorPageService; @Override @PostConstruct @@ -104,4 +105,8 @@ public String getCrossReferenceUniqueId(CrossReference xref) { } return StringUtils.join(List.of(xref.getReferencedCurie(), xref.getResourceDescriptorPage().getId()), "|"); } + + public Map getGenomicEntityCrossRefMap(ResourceDescriptorPage page) { + return crossReferenceDAO.getGenesWithCrossRefs(page); + } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/DataProviderService.java b/src/main/java/org/alliancegenome/curation_api/services/DataProviderService.java index cb0807349..f19f2e68f 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/DataProviderService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/DataProviderService.java @@ -1,34 +1,49 @@ package org.alliancegenome.curation_api.services; +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; import org.alliancegenome.curation_api.auth.AuthenticatedUser; -import org.alliancegenome.curation_api.dao.CrossReferenceDAO; -import org.alliancegenome.curation_api.dao.DataProviderDAO; -import org.alliancegenome.curation_api.dao.OrganizationDAO; -import org.alliancegenome.curation_api.model.entities.AllianceMember; -import org.alliancegenome.curation_api.model.entities.CrossReference; -import org.alliancegenome.curation_api.model.entities.DataProvider; -import org.alliancegenome.curation_api.model.entities.Organization; -import org.alliancegenome.curation_api.model.entities.Person; +import org.alliancegenome.curation_api.dao.*; +import org.alliancegenome.curation_api.model.entities.*; import org.alliancegenome.curation_api.response.ObjectResponse; -import org.alliancegenome.curation_api.response.SearchResponse; import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; import org.alliancegenome.curation_api.services.validation.DataProviderValidator; +import org.jetbrains.annotations.NotNull; -import jakarta.annotation.PostConstruct; -import jakarta.enterprise.context.RequestScoped; -import jakarta.inject.Inject; -import jakarta.transaction.Transactional; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; @RequestScoped public class DataProviderService extends BaseEntityCrudService { + public static final String RESOURCE_DESCRIPTOR_PREFIX = "ENSEMBL"; + public static final String RESOURCE_DESCRIPTOR_PAGE_NAME = "default"; + // + Map accessionGeneMap = new HashMap<>(); + HashMap dataProviderMap = new HashMap<>(); + + + @Inject + @AuthenticatedUser + protected Person authenticatedPerson; + @Inject + SpeciesDAO speciesDAO; + @Inject + DataProviderDAO dataProviderDAO; + @Inject + CrossReferenceDAO crossReferenceDAO; + @Inject + ResourceDescriptorPageService resourceDescriptorPageService; + @Inject + OrganizationDAO organizationDAO; @Inject - @AuthenticatedUser protected Person authenticatedPerson; - @Inject PersonService personService; - @Inject DataProviderDAO dataProviderDAO; - @Inject OrganizationDAO organizationDAO; - @Inject DataProviderValidator dataProviderValidator; - @Inject CrossReferenceDAO crossReferenceDAO; + GeneDAO geneDAO; + @Inject + DataProviderValidator dataProviderValidator; @Override @PostConstruct @@ -40,39 +55,90 @@ protected void init() { public DataProvider createAffiliatedModDataProvider() { AllianceMember member = authenticatedPerson.getAllianceMember(); if (member == null) { - return createAllianceDataProvider(); + return getAllianceDataProvider(); + } else { + return dataProviderDAO.getOrCreateDataProvider(member); } + } + + public DataProvider getAllianceDataProvider() { + return getDefaultDataProvider("Alliance"); + } - return createDataProvider(member); + @Transactional + public DataProvider getDefaultDataProvider(String sourceOrganizationAbbreviation) { + return dataProviderDAO.getOrCreateDataProvider(organizationDAO.getOrCreateOrganization(sourceOrganizationAbbreviation)); } @Transactional - public DataProvider createOrganizationDataProvider(String organizationAbbreviation) { - SearchResponse orgResponse = organizationDAO.findByField("abbreviation", organizationAbbreviation); - if (orgResponse == null || orgResponse.getSingleResult() == null) { - return null; + public ObjectResponse insertExpressionAtlasDataProvider(DataProvider entity) { + String referencedCurie = entity.getCrossReference().getReferencedCurie(); + // find associated gene + Long geneID = getAssociatedGeneId(referencedCurie, entity.getSourceOrganization()); + // if no gene found skip (= don't import) the accession + if (geneID == null) { + return new ObjectResponse<>(); } - Organization member = orgResponse.getSingleResult(); - return createDataProvider(member); + DataProvider dbEntity = getDataProvider(entity.getSourceOrganization(), referencedCurie, entity.getCrossReference().getResourceDescriptorPage()); + // we only create new records, no updates + if (dbEntity == null) { + dataProviderDAO.persist(entity); + if (!List.of("FB", "SGD").contains(entity.getSourceOrganization().getAbbreviation())) { + crossReferenceDAO.persistAccessionGeneAssociated(entity.getCrossReference().getId(), geneID); + } + return new ObjectResponse<>(entity); + } + return new ObjectResponse<>(dbEntity); } - public DataProvider createAllianceDataProvider() { - return createOrganizationDataProvider("Alliance"); + @NotNull + public static String getFullReferencedCurie(String localReferencedCurie) { + return RESOURCE_DESCRIPTOR_PREFIX + ":" + localReferencedCurie; } - private DataProvider createDataProvider(Organization member) { - DataProvider dataProvider = new DataProvider(); + private Long getAssociatedGeneId(String fullReferencedCurie, Organization sourceOrganization) { + String orgAbbreviation = sourceOrganization.getAbbreviation(); + if (orgAbbreviation.equals("FB")) { + fullReferencedCurie = orgAbbreviation + ":" + fullReferencedCurie; + } + if (accessionGeneMap.size() == 0) { + if (List.of("FB", "SGD").contains(orgAbbreviation)) { + Map map = new HashMap<>(); + map.put("displayName", orgAbbreviation); + Species species = speciesDAO.findByParams(map).getSingleResult(); + accessionGeneMap = geneDAO.getAllGeneIdsPerSpecies(species); + } else { + ResourceDescriptorPage page = resourceDescriptorPageService.getPageForResourceDescriptor(RESOURCE_DESCRIPTOR_PREFIX, RESOURCE_DESCRIPTOR_PAGE_NAME); + accessionGeneMap = crossReferenceDAO.getGenesWithCrossRefs(page); + } + } + return accessionGeneMap.get(fullReferencedCurie); + } - dataProvider.setSourceOrganization(member); + private DataProvider getDataProvider(Organization sourceOrganization, String crossReferenceCurie, ResourceDescriptorPage page) { + if (dataProviderMap.size() > 0) { + return dataProviderMap.get(crossReferenceCurie); + } + populateDataProviderMap(sourceOrganization, page); + return dataProviderMap.get(crossReferenceCurie); + } - CrossReference xref = new CrossReference(); - xref.setDisplayName(member.getAbbreviation()); - xref.setReferencedCurie(member.getAbbreviation()); - xref.setResourceDescriptorPage(member.getHomepageResourceDescriptorPage()); - dataProvider.setCrossReference(crossReferenceDAO.persist(xref)); + private void populateDataProviderMap(Organization sourceOrganization, ResourceDescriptorPage page) { + List allOrgProvider = dataProviderDAO.getAllDataProvider(sourceOrganization, page); + allOrgProvider.stream() + .filter(dataProvider -> dataProvider.getCrossReference() != null && Objects.equals(dataProvider.getCrossReference().getResourceDescriptorPage().getId(), page.getId())) + .forEach(dataProvider -> { + dataProviderMap.put(dataProvider.getCrossReference().getReferencedCurie(), dataProvider); + }); + } - return dataProviderDAO.persist(dataProvider); + public HashMap getDataProviderMap(Organization sourceOrganization, ResourceDescriptorPage page) { + if (dataProviderMap.size() > 0) { + return dataProviderMap; + } + populateDataProviderMap(sourceOrganization, page); + return dataProviderMap; } @Transactional @@ -81,10 +147,12 @@ public ObjectResponse upsert(DataProvider uiEntity) { if (response.getEntity() == null) { return response; } - return new ObjectResponse(response.getEntity()); + return new ObjectResponse<>(response.getEntity()); } public ObjectResponse validate(DataProvider uiEntity) { return dataProviderValidator.validateDataProvider(uiEntity, null, true); } + + } diff --git a/src/main/java/org/alliancegenome/curation_api/services/ExonService.java b/src/main/java/org/alliancegenome/curation_api/services/ExonService.java index f65601743..d5cbfddda 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/ExonService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/ExonService.java @@ -40,6 +40,13 @@ public List getIdsByDataProvider(BackendBulkDataProvider dataProvider) { return ids; } + @Override + public ObjectResponse getByIdentifier(String identifier) { + Exon object = findByAlternativeFields(List.of("curie", "modEntityId", "modInternalId", "uniqueId"), identifier); + ObjectResponse ret = new ObjectResponse(object); + return ret; + } + public ObjectResponse deleteByIdentifier(String identifierString) { Exon exon = findByAlternativeFields(List.of("modEntityId", "modInternalId", "uniqueId"), identifierString); if (exon != null) { diff --git a/src/main/java/org/alliancegenome/curation_api/services/ExternalDataBaseEntityService.java b/src/main/java/org/alliancegenome/curation_api/services/ExternalDataBaseEntityService.java new file mode 100644 index 000000000..393e170f6 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/ExternalDataBaseEntityService.java @@ -0,0 +1,21 @@ +package org.alliancegenome.curation_api.services; + +import org.alliancegenome.curation_api.dao.ExternalDataBaseEntityDAO; +import org.alliancegenome.curation_api.model.entities.ExternalDataBaseEntity; +import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; + +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; + +@RequestScoped +public class ExternalDataBaseEntityService extends BaseEntityCrudService { + + @Inject ExternalDataBaseEntityDAO externalDataBaseEntityDAO; + + @Override + @PostConstruct + protected void init() { + setSQLDao(externalDataBaseEntityDAO); + } +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/GeneDiseaseAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/GeneDiseaseAnnotationService.java index a59e770a3..7e3747345 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GeneDiseaseAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GeneDiseaseAnnotationService.java @@ -4,7 +4,7 @@ import org.alliancegenome.curation_api.dao.GeneDiseaseAnnotationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.GeneDiseaseAnnotation; import org.alliancegenome.curation_api.model.ingest.dto.GeneDiseaseAnnotationDTO; import org.alliancegenome.curation_api.response.ObjectResponse; @@ -46,7 +46,7 @@ public ObjectResponse create(GeneDiseaseAnnotation uiEnti } @Transactional - public GeneDiseaseAnnotation upsert(GeneDiseaseAnnotationDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public GeneDiseaseAnnotation upsert(GeneDiseaseAnnotationDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { GeneDiseaseAnnotation annotation = geneDiseaseAnnotationDtoValidator.validateGeneDiseaseAnnotationDTO(dto, dataProvider); return geneDiseaseAnnotationDAO.persist(annotation); diff --git a/src/main/java/org/alliancegenome/curation_api/services/GeneExpressionAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/GeneExpressionAnnotationService.java index 226d8798d..1ffe515ac 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GeneExpressionAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GeneExpressionAnnotationService.java @@ -7,7 +7,7 @@ import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.dao.GeneExpressionAnnotationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.interfaces.crud.BaseUpsertServiceInterface; import org.alliancegenome.curation_api.model.entities.GeneExpressionAnnotation; import org.alliancegenome.curation_api.model.ingest.dto.fms.GeneExpressionFmsDTO; @@ -43,7 +43,7 @@ public List getAnnotationIdsByDataProvider(BackendBulkDataProvider dataPro @Transactional @Override - public GeneExpressionAnnotation upsert(GeneExpressionFmsDTO geneExpressionFmsDTO, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public GeneExpressionAnnotation upsert(GeneExpressionFmsDTO geneExpressionFmsDTO, BackendBulkDataProvider dataProvider) throws ValidationException { GeneExpressionAnnotation geneExpressionAnnotation = geneExpressionAnnotationFmsDTOValidator.validateAnnotation(geneExpressionFmsDTO, dataProvider); return geneExpressionAnnotationDAO.persist(geneExpressionAnnotation); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/GeneGeneticInteractionService.java b/src/main/java/org/alliancegenome/curation_api/services/GeneGeneticInteractionService.java index af65d76cc..906341741 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GeneGeneticInteractionService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GeneGeneticInteractionService.java @@ -4,7 +4,7 @@ import org.alliancegenome.curation_api.dao.GeneGeneticInteractionDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.interfaces.crud.BaseUpsertServiceInterface; import org.alliancegenome.curation_api.model.entities.GeneGeneticInteraction; import org.alliancegenome.curation_api.model.ingest.dto.fms.PsiMiTabDTO; @@ -35,7 +35,7 @@ public ObjectResponse getByIdentifier(String identifier) } @Transactional - public GeneGeneticInteraction upsert(PsiMiTabDTO dto, BackendBulkDataProvider backendBulkDataProvider) throws ObjectUpdateException { + public GeneGeneticInteraction upsert(PsiMiTabDTO dto, BackendBulkDataProvider backendBulkDataProvider) throws ValidationException { GeneGeneticInteraction interaction = geneGeneticInteractionValidator.validateGeneGeneticInteractionFmsDTO(dto); return geneGeneticInteractionDAO.persist(interaction); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/GeneMolecularInteractionService.java b/src/main/java/org/alliancegenome/curation_api/services/GeneMolecularInteractionService.java index c0ff26fab..dbbc33b2f 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GeneMolecularInteractionService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GeneMolecularInteractionService.java @@ -4,7 +4,7 @@ import org.alliancegenome.curation_api.dao.GeneMolecularInteractionDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.interfaces.crud.BaseUpsertServiceInterface; import org.alliancegenome.curation_api.model.entities.GeneMolecularInteraction; import org.alliancegenome.curation_api.model.ingest.dto.fms.PsiMiTabDTO; @@ -34,7 +34,7 @@ public ObjectResponse getByIdentifier(String identifie } @Transactional - public GeneMolecularInteraction upsert(PsiMiTabDTO dto, BackendBulkDataProvider backendBulkDataProvider) throws ObjectUpdateException { + public GeneMolecularInteraction upsert(PsiMiTabDTO dto, BackendBulkDataProvider backendBulkDataProvider) throws ValidationException { GeneMolecularInteraction interaction = geneMolInteractionValidator.validateGeneMolecularInteractionFmsDTO(dto); return geneMolecularInteractionDAO.persist(interaction); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/GenePhenotypeAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/GenePhenotypeAnnotationService.java index 4b72fc0f5..5b9f13f28 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GenePhenotypeAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GenePhenotypeAnnotationService.java @@ -5,7 +5,7 @@ import org.alliancegenome.curation_api.dao.ConditionRelationDAO; import org.alliancegenome.curation_api.dao.GenePhenotypeAnnotationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.Gene; import org.alliancegenome.curation_api.model.entities.GenePhenotypeAnnotation; import org.alliancegenome.curation_api.model.ingest.dto.fms.PhenotypeFmsDTO; @@ -45,7 +45,7 @@ public ObjectResponse create(GenePhenotypeAnnotation ui } @Transactional - public GenePhenotypeAnnotation upsertPrimaryAnnotation(Gene subject, PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public GenePhenotypeAnnotation upsertPrimaryAnnotation(Gene subject, PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { GenePhenotypeAnnotation annotation = genePhenotypeAnnotationFmsDtoValidator.validatePrimaryAnnotation(subject, dto, dataProvider); return genePhenotypeAnnotationDAO.persist(annotation); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/GeneService.java b/src/main/java/org/alliancegenome/curation_api/services/GeneService.java index 0203641b4..fb9bf1ab3 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GeneService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GeneService.java @@ -10,7 +10,7 @@ import org.alliancegenome.curation_api.dao.GeneDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ApiErrorException; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.Gene; import org.alliancegenome.curation_api.model.ingest.dto.GeneDTO; import org.alliancegenome.curation_api.response.ObjectResponse; @@ -64,12 +64,12 @@ public ObjectResponse create(Gene uiEntity) { } @Override - public Gene upsert(GeneDTO dto) throws ObjectUpdateException { + public Gene upsert(GeneDTO dto) throws ValidationException { return upsert(dto, null); } @Override - public Gene upsert(GeneDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public Gene upsert(GeneDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { return geneDtoValidator.validateGeneDTO(dto, dataProvider); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/GeneToGeneParalogyService.java b/src/main/java/org/alliancegenome/curation_api/services/GeneToGeneParalogyService.java index 40bb57c20..b2fb2509b 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GeneToGeneParalogyService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GeneToGeneParalogyService.java @@ -7,7 +7,7 @@ import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.dao.GeneToGeneParalogyDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.interfaces.crud.BaseUpsertServiceInterface; import org.alliancegenome.curation_api.model.entities.GeneToGeneParalogy; import org.alliancegenome.curation_api.model.ingest.dto.fms.ParalogyFmsDTO; @@ -31,7 +31,7 @@ protected void init() { setSQLDao(geneToGeneParalogyDAO); } - public GeneToGeneParalogy upsert(ParalogyFmsDTO paralogyData, BackendBulkDataProvider backendBulkDataProvider) throws ObjectUpdateException { + public GeneToGeneParalogy upsert(ParalogyFmsDTO paralogyData, BackendBulkDataProvider backendBulkDataProvider) throws ValidationException { return paralogyFmsDtoValidator.validateParalogyFmsDTO(paralogyData); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/GenomeAssemblyService.java b/src/main/java/org/alliancegenome/curation_api/services/GenomeAssemblyService.java index 8c826d5ac..c6ed5b6eb 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GenomeAssemblyService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GenomeAssemblyService.java @@ -1,8 +1,18 @@ package org.alliancegenome.curation_api.services; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.dao.GenomeAssemblyDAO; +import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.model.entities.GenomeAssembly; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.response.SearchResponse; import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; +import org.alliancegenome.curation_api.services.ontology.NcbiTaxonTermService; +import org.apache.commons.lang3.StringUtils; import jakarta.annotation.PostConstruct; import jakarta.enterprise.context.RequestScoped; @@ -12,12 +22,46 @@ public class GenomeAssemblyService extends BaseEntityCrudService { @Inject GenomeAssemblyDAO genomeAssemblyDAO; + @Inject DataProviderService dataProviderService; + @Inject NcbiTaxonTermService ncbiTaxonTermService; @Override @PostConstruct protected void init() { setSQLDao(genomeAssemblyDAO); } + + public GenomeAssembly getOrCreate(String assemblyName, BackendBulkDataProvider dataProvider) { + if (StringUtils.isNotBlank(assemblyName)) { + Map params = new HashMap<>(); + params.put("modEntityId", assemblyName); + params.put(EntityFieldConstants.DATA_PROVIDER, dataProvider.sourceOrganization); + params.put(EntityFieldConstants.TAXON, dataProvider.canonicalTaxonCurie); + + SearchResponse resp = genomeAssemblyDAO.findByParams(params); + if (resp == null || resp.getSingleResult() == null) { + GenomeAssembly assembly = new GenomeAssembly(); + assembly.setModEntityId(assemblyName); + assembly.setDataProvider(dataProviderService.getDefaultDataProvider(dataProvider.sourceOrganization)); + assembly.setTaxon(ncbiTaxonTermService.getByCurie(dataProvider.canonicalTaxonCurie).getEntity()); + + return genomeAssemblyDAO.persist(assembly); + } else { + return resp.getSingleResult(); + } + } else { + return null; + } + } + + public ObjectResponse deleteByIdentifier(String identifierString) { + GenomeAssembly assembly = findByAlternativeFields(List.of("modEntityId", "modInternalId"), identifierString); + if (assembly != null) { + genomeAssemblyDAO.remove(assembly.getId()); + } + ObjectResponse ret = new ObjectResponse<>(assembly); + return ret; + } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/GenomicEntityService.java b/src/main/java/org/alliancegenome/curation_api/services/GenomicEntityService.java index 5eb528dc7..a0887dca4 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/GenomicEntityService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/GenomicEntityService.java @@ -1,20 +1,23 @@ package org.alliancegenome.curation_api.services; +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; import org.alliancegenome.curation_api.dao.GenomicEntityDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.GenomicEntity; import org.alliancegenome.curation_api.model.ingest.dto.GenomicEntityDTO; import org.alliancegenome.curation_api.services.base.SubmittedObjectCrudService; -import jakarta.annotation.PostConstruct; -import jakarta.enterprise.context.RequestScoped; -import jakarta.inject.Inject; +import java.util.HashMap; +import java.util.Map; @RequestScoped public class GenomicEntityService extends SubmittedObjectCrudService { - @Inject GenomicEntityDAO genomicEntityDAO; + @Inject + GenomicEntityDAO genomicEntityDAO; @Override @PostConstruct @@ -23,12 +26,12 @@ protected void init() { } @Override - public GenomicEntity upsert(GenomicEntityDTO dto) throws ObjectUpdateException { + public GenomicEntity upsert(GenomicEntityDTO dto) throws ValidationException { return null; } @Override - public GenomicEntity upsert(GenomicEntityDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public GenomicEntity upsert(GenomicEntityDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { return null; } @@ -37,4 +40,21 @@ public GenomicEntity deprecateOrDelete(Long id, Boolean throwApiError, String re return null; } + public Map getGenomicEntityIdMap() { + if (genomicEntityIdMap.size() > 0) { + return genomicEntityIdMap; + } + genomicEntityIdMap = genomicEntityDAO.getGenomicEntityIdMap(); + return genomicEntityIdMap; + } + + private Map genomicEntityIdMap = new HashMap<>(); + + public Long getIdByModID(String modID) { + return getGenomicEntityIdMap().get(modID); + } + + public GenomicEntity getShallowEntity(Long id) { + return genomicEntityDAO.getShallowEntity(GenomicEntity.class, id); + } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/Gff3Service.java b/src/main/java/org/alliancegenome/curation_api/services/Gff3Service.java index 0de400d57..4b41cfec2 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/Gff3Service.java +++ b/src/main/java/org/alliancegenome/curation_api/services/Gff3Service.java @@ -4,7 +4,6 @@ import java.util.List; import java.util.Map; -import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.constants.Gff3Constants; import org.alliancegenome.curation_api.constants.ValidationConstants; import org.alliancegenome.curation_api.dao.CodingSequenceDAO; @@ -12,26 +11,31 @@ import org.alliancegenome.curation_api.dao.GenomeAssemblyDAO; import org.alliancegenome.curation_api.dao.TranscriptDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; import org.alliancegenome.curation_api.model.entities.CodingSequence; import org.alliancegenome.curation_api.model.entities.Exon; -import org.alliancegenome.curation_api.model.entities.GenomeAssembly; import org.alliancegenome.curation_api.model.entities.Transcript; import org.alliancegenome.curation_api.model.entities.associations.codingSequenceAssociations.CodingSequenceGenomicLocationAssociation; import org.alliancegenome.curation_api.model.entities.associations.exonAssociations.ExonGenomicLocationAssociation; +import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptCodingSequenceAssociation; +import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptExonAssociation; +import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptGeneAssociation; import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptGenomicLocationAssociation; -import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; import org.alliancegenome.curation_api.model.ingest.dto.fms.Gff3DTO; import org.alliancegenome.curation_api.response.SearchResponse; import org.alliancegenome.curation_api.services.associations.codingSequenceAssociations.CodingSequenceGenomicLocationAssociationService; import org.alliancegenome.curation_api.services.associations.exonAssociations.ExonGenomicLocationAssociationService; +import org.alliancegenome.curation_api.services.associations.transcriptAssociations.TranscriptCodingSequenceAssociationService; +import org.alliancegenome.curation_api.services.associations.transcriptAssociations.TranscriptExonAssociationService; +import org.alliancegenome.curation_api.services.associations.transcriptAssociations.TranscriptGeneAssociationService; import org.alliancegenome.curation_api.services.associations.transcriptAssociations.TranscriptGenomicLocationAssociationService; import org.alliancegenome.curation_api.services.helpers.gff3.Gff3AttributesHelper; import org.alliancegenome.curation_api.services.helpers.gff3.Gff3UniqueIdHelper; import org.alliancegenome.curation_api.services.ontology.NcbiTaxonTermService; import org.alliancegenome.curation_api.services.validation.dto.Gff3DtoValidator; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.ImmutablePair; import jakarta.enterprise.context.RequestScoped; import jakarta.inject.Inject; @@ -47,117 +51,180 @@ public class Gff3Service { @Inject ExonGenomicLocationAssociationService exonLocationService; @Inject CodingSequenceGenomicLocationAssociationService cdsLocationService; @Inject TranscriptGenomicLocationAssociationService transcriptLocationService; + @Inject TranscriptGeneAssociationService transcriptGeneService; + @Inject TranscriptCodingSequenceAssociationService transcriptCdsService; + @Inject TranscriptExonAssociationService transcriptExonService; @Inject DataProviderService dataProviderService; @Inject NcbiTaxonTermService ncbiTaxonTermService; @Inject Gff3DtoValidator gff3DtoValidator; - + @Transactional - public String loadGenomeAssembly(String assemblyName, List gffHeaderData, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { - - if (StringUtils.isBlank(assemblyName)) { - for (String header : gffHeaderData) { - if (header.startsWith("#!assembly")) { - assemblyName = header.split(" ")[1]; - } - } + public void loadExonLocationAssociations(ImmutablePair> gffEntryPair, List idsAdded, BackendBulkDataProvider dataProvider, String assemblyId) throws ValidationException { + Gff3DTO gffEntry = gffEntryPair.getKey(); + + if (StringUtils.isBlank(assemblyId)) { + throw new ObjectValidationException(gffEntry, "Cannot load associations without assembly"); } - if (StringUtils.isNotBlank(assemblyName)) { - Map params = new HashMap<>(); - params.put("modEntityId", assemblyName); - params.put(EntityFieldConstants.DATA_PROVIDER, dataProvider.sourceOrganization); - params.put(EntityFieldConstants.TAXON, dataProvider.canonicalTaxonCurie); - - SearchResponse resp = genomeAssemblyDAO.findByParams(params); - if (resp == null || resp.getSingleResult() == null) { - GenomeAssembly assembly = new GenomeAssembly(); - assembly.setModEntityId(assemblyName); - assembly.setDataProvider(dataProviderService.createOrganizationDataProvider(dataProvider.sourceOrganization)); - assembly.setTaxon(ncbiTaxonTermService.getByCurie(dataProvider.canonicalTaxonCurie).getEntity()); - - genomeAssemblyDAO.persist(assembly); - } - - return assemblyName; - } else { - throw new ObjectValidationException(gffHeaderData, "#!assembly - " + ValidationConstants.REQUIRED_MESSAGE); + + if (!StringUtils.equals(gffEntry.getType(), "exon") && !StringUtils.equals(gffEntry.getType(), "noncoding_exon")) { + throw new ObjectValidationException(gffEntry, "Invalid Type: " + gffEntry.getType() + " for Exon Location"); + } + + String uniqueId = Gff3UniqueIdHelper.getExonOrCodingSequenceUniqueId(gffEntry, gffEntryPair.getValue(), dataProvider); + SearchResponse response = exonDAO.findByField("uniqueId", uniqueId); + if (response == null || response.getSingleResult() == null) { + throw new ObjectValidationException(gffEntry, "uniqueId - " + ValidationConstants.INVALID_MESSAGE + " (" + uniqueId + ")"); } + Exon exon = response.getSingleResult(); + + ExonGenomicLocationAssociation exonLocation = gff3DtoValidator.validateExonLocation(gffEntry, exon, assemblyId, dataProvider); + if (exonLocation != null) { + idsAdded.add(exonLocation.getId()); + exonLocationService.addAssociationToSubject(exonLocation); + } + } - - public Map> loadEntity(BulkLoadFileHistory history, Gff3DTO gffEntry, Map> idsAdded, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { - if (StringUtils.equals(gffEntry.getType(), "exon") || StringUtils.equals(gffEntry.getType(), "noncoding_exon")) { - Exon exon = gff3DtoValidator.validateExonEntry(gffEntry, dataProvider); - if (exon != null) { - idsAdded.get("Exon").add(exon.getId()); - } - } else if (StringUtils.equals(gffEntry.getType(), "CDS")) { - CodingSequence cds = gff3DtoValidator.validateCdsEntry(gffEntry, dataProvider); - if (cds != null) { - idsAdded.get("CodingSequence").add(cds.getId()); - } - } else if (Gff3Constants.TRANSCRIPT_TYPES.contains(gffEntry.getType())) { - if (StringUtils.equals(gffEntry.getType(), "lnc_RNA")) { - gffEntry.setType("lncRNA"); - } - Transcript transcript = gff3DtoValidator.validateTranscriptEntry(gffEntry, dataProvider); - if (transcript != null) { - idsAdded.get("Transcript").add(transcript.getId()); - } + + @Transactional + public void loadCDSLocationAssociations(ImmutablePair> gffEntryPair, List idsAdded, BackendBulkDataProvider dataProvider, String assemblyId) throws ValidationException { + Gff3DTO gffEntry = gffEntryPair.getKey(); + Map attributes = gffEntryPair.getValue(); + if (StringUtils.isBlank(assemblyId)) { + throw new ObjectValidationException(gffEntry, "Cannot load associations without assembly"); + } + + if (!StringUtils.equals(gffEntry.getType(), "CDS")) { + throw new ObjectValidationException(gffEntry, "Invalid Type: " + gffEntry.getType() + " for CDS Location"); + } + + String uniqueId = Gff3UniqueIdHelper.getExonOrCodingSequenceUniqueId(gffEntry, attributes, dataProvider); + SearchResponse response = cdsDAO.findByField("uniqueId", uniqueId); + if (response == null || response.getSingleResult() == null) { + throw new ObjectValidationException(gffEntry, "uniqueId - " + ValidationConstants.INVALID_MESSAGE + " (" + uniqueId + ")"); } - return idsAdded; + CodingSequence cds = response.getSingleResult(); + + CodingSequenceGenomicLocationAssociation cdsLocation = gff3DtoValidator.validateCdsLocation(gffEntry, cds, assemblyId, dataProvider); + if (cdsLocation != null) { + idsAdded.add(cdsLocation.getId()); + cdsLocationService.addAssociationToSubject(cdsLocation); + } + } - + @Transactional - public Map> loadAssociations(BulkLoadFileHistory history, Gff3DTO gffEntry, Map> idsAdded, BackendBulkDataProvider dataProvider, String assemblyId) throws ObjectUpdateException { + public void loadTranscriptLocationAssociations(ImmutablePair> gffEntryPair, List idsAdded, BackendBulkDataProvider dataProvider, String assemblyId) throws ValidationException { + Gff3DTO gffEntry = gffEntryPair.getKey(); + Map attributes = gffEntryPair.getValue(); if (StringUtils.isBlank(assemblyId)) { throw new ObjectValidationException(gffEntry, "Cannot load associations without assembly"); } - - Map attributes = Gff3AttributesHelper.getAttributes(gffEntry, dataProvider); - if (StringUtils.equals(gffEntry.getType(), "exon") || StringUtils.equals(gffEntry.getType(), "noncoding_exon")) { - String uniqueId = Gff3UniqueIdHelper.getExonOrCodingSequenceUniqueId(gffEntry, attributes, dataProvider); - SearchResponse response = exonDAO.findByField("uniqueId", uniqueId); - if (response == null || response.getSingleResult() == null) { - throw new ObjectValidationException(gffEntry, "uniqueId - " + ValidationConstants.INVALID_MESSAGE + " (" + uniqueId + ")"); - } - Exon exon = response.getSingleResult(); - - ExonGenomicLocationAssociation exonLocation = gff3DtoValidator.validateExonLocation(gffEntry, exon, assemblyId, dataProvider); - if (exonLocation != null) { - idsAdded.get("ExonGenomicLocationAssociation").add(exonLocation.getId()); - exonLocationService.addAssociationToSubject(exonLocation); - } - } else if (StringUtils.equals(gffEntry.getType(), "CDS")) { - String uniqueId = Gff3UniqueIdHelper.getExonOrCodingSequenceUniqueId(gffEntry, attributes, dataProvider); - SearchResponse response = cdsDAO.findByField("uniqueId", uniqueId); - if (response == null || response.getSingleResult() == null) { - throw new ObjectValidationException(gffEntry, "uniqueId - " + ValidationConstants.INVALID_MESSAGE + " (" + uniqueId + ")"); - } - CodingSequence cds = response.getSingleResult(); - CodingSequenceGenomicLocationAssociation cdsLocation = gff3DtoValidator.validateCdsLocation(gffEntry, cds, assemblyId, dataProvider); - if (cdsLocation != null) { - idsAdded.get("CodingSequenceGenomicLocationAssociation").add(cdsLocation.getId()); - cdsLocationService.addAssociationToSubject(cdsLocation); - } - } else if (Gff3Constants.TRANSCRIPT_TYPES.contains(gffEntry.getType())) { - if (StringUtils.equals(gffEntry.getType(), "lnc_RNA")) { - gffEntry.setType("lncRNA"); - } - if (!attributes.containsKey("ID")) { - throw new ObjectValidationException(gffEntry, "attributes - ID - " + ValidationConstants.REQUIRED_MESSAGE); - } - SearchResponse response = transcriptDAO.findByField("modInternalId", attributes.get("ID")); - if (response == null || response.getSingleResult() == null) { - throw new ObjectValidationException(gffEntry, "attributes - ID - " + ValidationConstants.INVALID_MESSAGE + " (" + attributes.get("ID") + ")"); - } - Transcript transcript = response.getSingleResult(); - TranscriptGenomicLocationAssociation transcriptLocation = gff3DtoValidator.validateTranscriptLocation(gffEntry, transcript, assemblyId, dataProvider); - if (transcriptLocation != null) { - idsAdded.get("TranscriptGenomicLocationAssociation").add(transcriptLocation.getId()); - transcriptLocationService.addAssociationToSubject(transcriptLocation); + + if (!Gff3Constants.TRANSCRIPT_TYPES.contains(gffEntry.getType())) { + throw new ObjectValidationException(gffEntry, "Invalid Type: " + gffEntry.getType() + " for Transcript Location"); + } + + if (!attributes.containsKey("ID")) { + throw new ObjectValidationException(gffEntry, "attributes - ID - " + ValidationConstants.REQUIRED_MESSAGE); + } + SearchResponse response = transcriptDAO.findByField("modInternalId", attributes.get("ID")); + if (response == null || response.getSingleResult() == null) { + throw new ObjectValidationException(gffEntry, "attributes - ID - " + ValidationConstants.INVALID_MESSAGE + " (" + attributes.get("ID") + ")"); + } + Transcript transcript = response.getSingleResult(); + + TranscriptGenomicLocationAssociation transcriptLocation = gff3DtoValidator.validateTranscriptLocation(gffEntry, transcript, assemblyId, dataProvider); + if (transcriptLocation != null) { + idsAdded.add(transcriptLocation.getId()); + transcriptLocationService.addAssociationToSubject(transcriptLocation); + } + } + + @Transactional + public void loadExonParentChildAssociations(ImmutablePair> gffEntryPair, List idsAdded, BackendBulkDataProvider dataProvider) throws ValidationException { + Gff3DTO gffEntry = gffEntryPair.getKey(); + + if (!StringUtils.equals(gffEntry.getType(), "exon") && !StringUtils.equals(gffEntry.getType(), "noncoding_exon")) { + throw new ObjectValidationException(gffEntry, "Invalid Type: " + gffEntry.getType() + " for Exon Transcript Associations"); + } + + Map attributes = gffEntryPair.getValue(); + String uniqueId = Gff3UniqueIdHelper.getExonOrCodingSequenceUniqueId(gffEntry, attributes, dataProvider); + SearchResponse response = exonDAO.findByField("uniqueId", uniqueId); + if (response == null || response.getSingleResult() == null) { + throw new ObjectValidationException(gffEntry, "uniqueId - " + ValidationConstants.INVALID_MESSAGE + " (" + uniqueId + ")"); + } + Exon exon = response.getSingleResult(); + + TranscriptExonAssociation transcriptAssociation = gff3DtoValidator.validateTranscriptExonAssociation(gffEntry, exon, attributes); + if (transcriptAssociation != null) { + idsAdded.add(transcriptAssociation.getId()); + transcriptExonService.addAssociationToSubjectAndObject(transcriptAssociation); + } + + } + + @Transactional + public void loadCDSParentChildAssociations(ImmutablePair> gffEntryPair, List idsAdded, BackendBulkDataProvider dataProvider) throws ValidationException { + Gff3DTO gffEntry = gffEntryPair.getKey(); + Map attributes = gffEntryPair.getValue(); + + if (!StringUtils.equals(gffEntry.getType(), "CDS")) { + throw new ObjectValidationException(gffEntry, "Invalid Type: " + gffEntry.getType() + " for CDS Transcript Associations"); + } + + String uniqueId = Gff3UniqueIdHelper.getExonOrCodingSequenceUniqueId(gffEntry, attributes, dataProvider); + SearchResponse response = cdsDAO.findByField("uniqueId", uniqueId); + if (response == null || response.getSingleResult() == null) { + throw new ObjectValidationException(gffEntry, "uniqueId - " + ValidationConstants.INVALID_MESSAGE + " (" + uniqueId + ")"); + } + CodingSequence cds = response.getSingleResult(); + + TranscriptCodingSequenceAssociation transcriptAssociation = gff3DtoValidator.validateTranscriptCodingSequenceAssociation(gffEntry, cds, attributes); + if (transcriptAssociation != null) { + idsAdded.add(transcriptAssociation.getId()); + transcriptCdsService.addAssociationToSubjectAndObject(transcriptAssociation); + } + } + + @Transactional + public void loadGeneParentChildAssociations(ImmutablePair> gffEntryPair, List idsAdded, BackendBulkDataProvider dataProvider, Map geneIdCurieMap) throws ValidationException { + Gff3DTO gffEntry = gffEntryPair.getKey(); + if (!Gff3Constants.TRANSCRIPT_TYPES.contains(gffEntry.getType())) { + throw new ObjectValidationException(gffEntry, "Invalid Type: " + gffEntry.getType() + " for Gene Transcript Associations"); + } + + Map attributes = gffEntryPair.getValue(); + if (!attributes.containsKey("ID")) { + throw new ObjectValidationException(gffEntry, "attributes - ID - " + ValidationConstants.REQUIRED_MESSAGE); + } + + SearchResponse response = transcriptDAO.findByField("modInternalId", attributes.get("ID")); + if (response == null || response.getSingleResult() == null) { + throw new ObjectValidationException(gffEntry, "attributes - ID - " + ValidationConstants.INVALID_MESSAGE + " (" + attributes.get("ID") + ")"); + } + Transcript transcript = response.getSingleResult(); + + TranscriptGeneAssociation geneAssociation = gff3DtoValidator.validateTranscriptGeneAssociation(gffEntry, transcript, attributes, geneIdCurieMap); + if (geneAssociation != null) { + idsAdded.add(geneAssociation.getId()); + transcriptGeneService.addAssociationToSubjectAndObject(geneAssociation); + } + } + + public Map getGeneIdCurieMap(List gffData, BackendBulkDataProvider dataProvider) { + Map geneIdCurieMap = new HashMap<>(); + + for (Gff3DTO gffEntry : gffData) { + if (gffEntry.getType().contains("gene")) { + Map attributes = Gff3AttributesHelper.getAttributes(gffEntry, dataProvider); + if (attributes.containsKey("gene_id") && attributes.containsKey("ID")) { + geneIdCurieMap.put(attributes.get("ID"), attributes.get("gene_id")); + } } } - - return idsAdded; + + return geneIdCurieMap; } - + } diff --git a/src/main/java/org/alliancegenome/curation_api/services/HTPExpressionDatasetAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/HTPExpressionDatasetAnnotationService.java new file mode 100644 index 000000000..75a29ed17 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/HTPExpressionDatasetAnnotationService.java @@ -0,0 +1,46 @@ +package org.alliancegenome.curation_api.services; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import org.alliancegenome.curation_api.constants.EntityFieldConstants; +import org.alliancegenome.curation_api.dao.HTPExpressionDatasetAnnotationDAO; +import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.exceptions.ValidationException; +import org.alliancegenome.curation_api.interfaces.crud.BaseUpsertServiceInterface; +import org.alliancegenome.curation_api.model.entities.HTPExpressionDatasetAnnotation; +import org.alliancegenome.curation_api.model.ingest.dto.fms.HTPExpressionDatasetAnnotationFmsDTO; +import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; +import org.alliancegenome.curation_api.services.validation.dto.fms.HTPExpressionDatasetAnnotationFmsDTOValidator; + +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; + +@RequestScoped +public class HTPExpressionDatasetAnnotationService extends BaseEntityCrudService implements BaseUpsertServiceInterface { + + @Inject HTPExpressionDatasetAnnotationDAO htpExpressionDatasetAnnotationDAO; + @Inject HTPExpressionDatasetAnnotationFmsDTOValidator htpExpressionDatasetAnnotationFmsDtoValidator; + + @Override + @PostConstruct + protected void init() { + setSQLDao(htpExpressionDatasetAnnotationDAO); + } + + public HTPExpressionDatasetAnnotation upsert(HTPExpressionDatasetAnnotationFmsDTO htpExpressionDatasetAnnotationData, BackendBulkDataProvider backendBulkDataProvider) throws ValidationException { + return htpExpressionDatasetAnnotationFmsDtoValidator.validateHTPExpressionDatasetAnnotationFmsDTO(htpExpressionDatasetAnnotationData, backendBulkDataProvider); + } + + public List getAnnotationIdsByDataProvider(String dataProvider) { + Map params = new HashMap<>(); + params.put(EntityFieldConstants.DATA_PROVIDER, dataProvider); + List ids = htpExpressionDatasetAnnotationDAO.findIdsByParams(params); + ids.removeIf(Objects::isNull); + return ids; + } + +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/MoleculeService.java b/src/main/java/org/alliancegenome/curation_api/services/MoleculeService.java index 4d9fa076e..8c23a6c58 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/MoleculeService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/MoleculeService.java @@ -9,7 +9,9 @@ import org.alliancegenome.curation_api.dao.ResourceDescriptorPageDAO; import org.alliancegenome.curation_api.dao.SynonymDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.exceptions.KnownIssueValidationException; import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.interfaces.crud.BaseUpsertServiceInterface; import org.alliancegenome.curation_api.model.entities.CrossReference; import org.alliancegenome.curation_api.model.entities.Molecule; @@ -61,7 +63,7 @@ public ObjectResponse update(Molecule uiEntity) { } @Transactional - public Molecule upsert(MoleculeFmsDTO dto, BackendBulkDataProvider backendBulkDataProvider) throws ObjectUpdateException { + public Molecule upsert(MoleculeFmsDTO dto, BackendBulkDataProvider backendBulkDataProvider) throws ValidationException { log.debug("processUpdate Molecule: "); if (StringUtils.isBlank(dto.getId())) { @@ -71,7 +73,7 @@ public Molecule upsert(MoleculeFmsDTO dto, BackendBulkDataProvider backendBulkDa if (dto.getId().startsWith("CHEBI:")) { log.debug("Skipping processing of " + dto.getId()); - throw new ObjectUpdateException(dto, "Skipping processing of " + dto.getId()); + throw new KnownIssueValidationException("Skipping processing of " + dto.getId()); } if (StringUtils.isBlank(dto.getName())) { diff --git a/src/main/java/org/alliancegenome/curation_api/services/PhenotypeAnnotationService.java b/src/main/java/org/alliancegenome/curation_api/services/PhenotypeAnnotationService.java index aaf95f4d8..b27f56562 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/PhenotypeAnnotationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/PhenotypeAnnotationService.java @@ -15,7 +15,7 @@ import org.alliancegenome.curation_api.dao.PhenotypeAnnotationDAO; import org.alliancegenome.curation_api.dao.base.BaseSQLDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; import org.alliancegenome.curation_api.model.entities.AGMPhenotypeAnnotation; import org.alliancegenome.curation_api.model.entities.AffectedGenomicModel; @@ -91,7 +91,7 @@ protected > List getAnnotationIdsByDataProvider(D return annotationIds; } - public Long upsertPrimaryAnnotation(PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public Long upsertPrimaryAnnotation(PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { if (StringUtils.isBlank(dto.getObjectId())) { throw new ObjectValidationException(dto, "objectId - " + ValidationConstants.REQUIRED_MESSAGE); } @@ -115,7 +115,7 @@ public Long upsertPrimaryAnnotation(PhenotypeFmsDTO dto, BackendBulkDataProvider } - public List addInferredOrAssertedEntities(PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public List addInferredOrAssertedEntities(PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { List primaryAnnotationIds = new ArrayList<>(); for (String primaryGeneticEntityCurie : dto.getPrimaryGeneticEntityIds()) { GenomicEntity primaryAnnotationSubject = genomicEntityService.findByIdentifierString(primaryGeneticEntityCurie); diff --git a/src/main/java/org/alliancegenome/curation_api/services/ReferenceService.java b/src/main/java/org/alliancegenome/curation_api/services/ReferenceService.java index db4455628..4d8d97576 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/ReferenceService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/ReferenceService.java @@ -1,6 +1,8 @@ package org.alliancegenome.curation_api.services; import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; import java.util.List; import org.alliancegenome.curation_api.dao.ReferenceDAO; @@ -10,6 +12,7 @@ import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; import org.alliancegenome.curation_api.services.helpers.references.ReferenceSynchronisationHelper; +import io.quarkus.logging.Log; import jakarta.annotation.PostConstruct; import jakarta.enterprise.context.RequestScoped; import jakarta.inject.Inject; @@ -20,6 +23,9 @@ public class ReferenceService extends BaseEntityCrudService referenceCacheMap = new HashMap<>(); @Override @PostConstruct @@ -45,6 +51,23 @@ public ObjectResponse getByCurie(String curie) { @Transactional public Reference retrieveFromDbOrLiteratureService(String curieOrXref) { Reference reference = null; + if (referenceRequest != null) { + if (referenceCacheMap.containsKey(curieOrXref)) { + reference = referenceCacheMap.get(curieOrXref); + } else { + Log.debug("Reference not cached, caching reference: (" + curieOrXref + ")"); + reference = findOrCreateReference(curieOrXref); + referenceCacheMap.put(curieOrXref, reference); + } + } else { + reference = findOrCreateReference(curieOrXref); + referenceRequest = new Date(); + } + return reference; + } + + private Reference findOrCreateReference(String curieOrXref) { + Reference reference = null; if (curieOrXref.startsWith("AGRKB:")) { reference = findByCurie(curieOrXref); diff --git a/src/main/java/org/alliancegenome/curation_api/services/ResourceDescriptorService.java b/src/main/java/org/alliancegenome/curation_api/services/ResourceDescriptorService.java index 545ff6d59..30cfd1d80 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/ResourceDescriptorService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/ResourceDescriptorService.java @@ -6,7 +6,7 @@ import java.util.Objects; import org.alliancegenome.curation_api.dao.ResourceDescriptorDAO; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.ResourceDescriptor; import org.alliancegenome.curation_api.model.ingest.dto.ResourceDescriptorDTO; import org.alliancegenome.curation_api.response.ObjectResponse; @@ -43,7 +43,7 @@ public List getAllNames() { } @Transactional - public ResourceDescriptor upsert(ResourceDescriptorDTO dto) throws ObjectUpdateException { + public ResourceDescriptor upsert(ResourceDescriptorDTO dto) throws ValidationException { ResourceDescriptor rd = resourceDescriptorDtoValidator.validateResourceDescriptorDTO(dto); if (rd == null) { diff --git a/src/main/java/org/alliancegenome/curation_api/services/SequenceTargetingReagentService.java b/src/main/java/org/alliancegenome/curation_api/services/SequenceTargetingReagentService.java index 14d3fa63b..6fe61cffe 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/SequenceTargetingReagentService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/SequenceTargetingReagentService.java @@ -8,11 +8,11 @@ import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.dao.SequenceTargetingReagentDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.interfaces.crud.BaseUpsertServiceInterface; import org.alliancegenome.curation_api.model.entities.SequenceTargetingReagent; import org.alliancegenome.curation_api.model.ingest.dto.fms.SequenceTargetingReagentFmsDTO; -import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; +import org.alliancegenome.curation_api.services.base.SubmittedObjectCrudService; import org.alliancegenome.curation_api.services.validation.dto.fms.SequenceTargetingReagentFmsDTOValidator; import jakarta.annotation.PostConstruct; @@ -21,7 +21,7 @@ import jakarta.transaction.Transactional; @RequestScoped -public class SequenceTargetingReagentService extends BaseEntityCrudService implements BaseUpsertServiceInterface { +public class SequenceTargetingReagentService extends SubmittedObjectCrudService implements BaseUpsertServiceInterface { @Inject SequenceTargetingReagentFmsDTOValidator sqtrDtoValidator; @Inject SequenceTargetingReagentDAO sqtrDAO; @@ -33,7 +33,7 @@ protected void init() { } @Transactional - public SequenceTargetingReagent upsert(SequenceTargetingReagentFmsDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public SequenceTargetingReagent upsert(SequenceTargetingReagentFmsDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { SequenceTargetingReagent sqtr = sqtrDtoValidator.validateSQTRFmsDTO(dto, dataProvider); return sqtrDAO.persist(sqtr); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/TranscriptService.java b/src/main/java/org/alliancegenome/curation_api/services/TranscriptService.java index 9cf7b422b..abc9f8fbf 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/TranscriptService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/TranscriptService.java @@ -42,15 +42,8 @@ public List getIdsByDataProvider(BackendBulkDataProvider dataProvider) { return ids; } - @Override - public ObjectResponse getByIdentifier(String identifier) { - Transcript object = findByAlternativeFields(List.of("curie", "modEntityId", "modInternalId"), identifier); - ObjectResponse ret = new ObjectResponse(object); - return ret; - } - public ObjectResponse deleteByIdentifier(String identifierString) { - Transcript transcript = findByAlternativeFields(List.of("modEntityId", "modInternalId"), identifierString); + Transcript transcript = findByAlternativeFields(List.of("curie", "modEntityId", "modInternalId"), identifierString); if (transcript != null) { transcriptDAO.remove(transcript.getId()); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/VariantService.java b/src/main/java/org/alliancegenome/curation_api/services/VariantService.java index fd8b1808b..7c8a8b754 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/VariantService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/VariantService.java @@ -10,14 +10,14 @@ import org.alliancegenome.curation_api.dao.VariantDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ApiErrorException; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; -import org.alliancegenome.curation_api.model.entities.AffectedGenomicModel; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.Variant; import org.alliancegenome.curation_api.model.ingest.dto.VariantDTO; import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.services.base.SubmittedObjectCrudService; import org.alliancegenome.curation_api.services.validation.VariantValidator; import org.alliancegenome.curation_api.services.validation.dto.VariantDTOValidator; +import org.apache.commons.collections.CollectionUtils; import io.quarkus.logging.Log; import jakarta.annotation.PostConstruct; @@ -55,7 +55,7 @@ public ObjectResponse create(Variant uiEntity) { return new ObjectResponse(dbEntity); } - public Variant upsert(VariantDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public Variant upsert(VariantDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { return variantDtoValidator.validateVariantDTO(dto, dataProvider); } @@ -64,7 +64,8 @@ public Variant upsert(VariantDTO dto, BackendBulkDataProvider dataProvider) thro public Variant deprecateOrDelete(Long id, Boolean throwApiError, String requestSource, Boolean forceDeprecate) { Variant variant = variantDAO.find(id); if (variant != null) { - if (forceDeprecate || variantDAO.hasReferencingDiseaseAnnotationIds(id)) { + if (forceDeprecate || variantDAO.hasReferencingDiseaseAnnotationIds(id) + || CollectionUtils.isNotEmpty(variant.getAlleleVariantAssociations())) { if (!variant.getObsolete()) { variant.setUpdatedBy(personService.fetchByUniqueIdOrCreate(requestSource)); variant.setDateUpdated(OffsetDateTime.now()); @@ -79,7 +80,7 @@ public Variant deprecateOrDelete(Long id, Boolean throwApiError, String requestS } else { String errorMessage = "Could not find Variant with id: " + id; if (throwApiError) { - ObjectResponse response = new ObjectResponse<>(); + ObjectResponse response = new ObjectResponse<>(); response.addErrorMessage("id", errorMessage); throw new ApiErrorException(response); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/SequenceTargetingReagentGeneAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/SequenceTargetingReagentGeneAssociationService.java index feeef193a..25e767f6f 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/associations/SequenceTargetingReagentGeneAssociationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/SequenceTargetingReagentGeneAssociationService.java @@ -10,7 +10,7 @@ import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.dao.associations.SequenceTargetingReagentGeneAssociationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.Gene; import org.alliancegenome.curation_api.model.entities.SequenceTargetingReagent; import org.alliancegenome.curation_api.model.entities.associations.sequenceTargetingReagentAssociations.SequenceTargetingReagentGeneAssociation; @@ -40,7 +40,7 @@ protected void init() { } @Transactional - public List loadGeneAssociations(SequenceTargetingReagentFmsDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public List loadGeneAssociations(SequenceTargetingReagentFmsDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { List associations = sequenceTargetingReagentGeneAssociationFmsDTOValidator .validateSQTRGeneAssociationFmsDTO(dto, dataProvider); diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java index 0cc75b83f..9b3b46f04 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleGeneAssociationService.java @@ -15,7 +15,7 @@ import org.alliancegenome.curation_api.dao.associations.alleleAssociations.AlleleGeneAssociationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ApiErrorException; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.interfaces.crud.BaseUpsertServiceInterface; import org.alliancegenome.curation_api.model.entities.Allele; import org.alliancegenome.curation_api.model.entities.Gene; @@ -72,7 +72,7 @@ public ObjectResponse validate(AlleleGeneAssociation uiEn @Override @Transactional - public AlleleGeneAssociation upsert(AlleleGeneAssociationDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public AlleleGeneAssociation upsert(AlleleGeneAssociationDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { AlleleGeneAssociation association = alleleGeneAssociationDtoValidator.validateAlleleGeneAssociationDTO(dto, dataProvider); if (association != null) { addAssociationToAllele(association); diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleVariantAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleVariantAssociationService.java new file mode 100644 index 000000000..b585c1494 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/alleleAssociations/AlleleVariantAssociationService.java @@ -0,0 +1,177 @@ +package org.alliancegenome.curation_api.services.associations.alleleAssociations; + +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import org.alliancegenome.curation_api.constants.EntityFieldConstants; +import org.alliancegenome.curation_api.dao.AlleleDAO; +import org.alliancegenome.curation_api.dao.GeneDAO; +import org.alliancegenome.curation_api.dao.NoteDAO; +import org.alliancegenome.curation_api.dao.PersonDAO; +import org.alliancegenome.curation_api.dao.VariantDAO; +import org.alliancegenome.curation_api.dao.associations.alleleAssociations.AlleleVariantAssociationDAO; +import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.exceptions.ApiErrorException; +import org.alliancegenome.curation_api.model.entities.Allele; +import org.alliancegenome.curation_api.model.entities.Variant; +import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleVariantAssociation; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.response.SearchResponse; +import org.alliancegenome.curation_api.services.PersonService; +import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; +import org.alliancegenome.curation_api.services.validation.associations.alleleAssociations.AlleleVariantAssociationValidator; +import org.alliancegenome.curation_api.services.validation.dto.associations.alleleAssociations.AlleleVariantAssociationDTOValidator; + +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; +import lombok.extern.jbosslog.JBossLog; + +@JBossLog +@RequestScoped +public class AlleleVariantAssociationService extends BaseEntityCrudService { + + @Inject AlleleVariantAssociationDAO alleleVariantAssociationDAO; + @Inject AlleleVariantAssociationValidator alleleVariantAssociationValidator; + @Inject AlleleVariantAssociationDTOValidator alleleVariantAssociationDtoValidator; + @Inject AlleleDAO alleleDAO; + @Inject VariantDAO variantDAO; + @Inject NoteDAO noteDAO; + @Inject GeneDAO geneDAO; + @Inject PersonService personService; + @Inject PersonDAO personDAO; + + @Override + @PostConstruct + protected void init() { + setSQLDao(alleleVariantAssociationDAO); + } + + @Transactional + public ObjectResponse upsert(AlleleVariantAssociation uiEntity) { + AlleleVariantAssociation dbEntity = alleleVariantAssociationValidator.validateAlleleVariantAssociation(uiEntity, true, true); + if (dbEntity == null) { + return null; + } + dbEntity = alleleVariantAssociationDAO.persist(dbEntity); + addAssociationToAllele(dbEntity); + addAssociationToVariant(dbEntity); + return new ObjectResponse(dbEntity); + } + + public ObjectResponse validate(AlleleVariantAssociation uiEntity) { + AlleleVariantAssociation aga = alleleVariantAssociationValidator.validateAlleleVariantAssociation(uiEntity, true, false); + return new ObjectResponse(aga); + } + + public List getAssociationsByDataProvider(BackendBulkDataProvider dataProvider) { + Map params = new HashMap<>(); + params.put(EntityFieldConstants.ALLELE_ASSOCIATION_SUBJECT_DATA_PROVIDER, dataProvider.sourceOrganization); + List associationIds = alleleVariantAssociationDAO.findIdsByParams(params); + associationIds.removeIf(Objects::isNull); + + return associationIds; + } + + @Override + @Transactional + public AlleleVariantAssociation deprecateOrDelete(Long id, Boolean throwApiError, String loadDescription, Boolean deprecate) { + AlleleVariantAssociation association = alleleVariantAssociationDAO.find(id); + + if (association == null) { + String errorMessage = "Could not find AlleleVariantAssociation with id: " + id; + if (throwApiError) { + ObjectResponse response = new ObjectResponse<>(); + response.addErrorMessage("id", errorMessage); + throw new ApiErrorException(response); + } + log.error(errorMessage); + return null; + } + if (deprecate) { + if (!association.getObsolete()) { + association.setObsolete(true); + if (authenticatedPerson.getId() != null) { + association.setUpdatedBy(personDAO.find(authenticatedPerson.getId())); + } else { + association.setUpdatedBy(personService.fetchByUniqueIdOrCreate(loadDescription)); + } + association.setDateUpdated(OffsetDateTime.now()); + return alleleVariantAssociationDAO.persist(association); + } + return association; + } + + Long noteId = null; + if (association.getRelatedNote() != null) { + noteId = association.getRelatedNote().getId(); + } + alleleVariantAssociationDAO.remove(association.getId()); + if (noteId != null) { + noteDAO.remove(noteId); + } + + return null; + } + + public ObjectResponse getAssociation(Long alleleId, String relationName, Long geneId) { + AlleleVariantAssociation association = null; + + Map params = new HashMap<>(); + params.put("alleleAssociationSubject.id", alleleId); + params.put("relation.name", relationName); + params.put("alleleVariantAssociationObject.id", geneId); + + SearchResponse resp = alleleVariantAssociationDAO.findByParams(params); + if (resp != null && resp.getSingleResult() != null) { + association = resp.getSingleResult(); + } + + ObjectResponse response = new ObjectResponse<>(); + response.setEntity(association); + + return response; + } + + public void addAssociationToAllele(AlleleVariantAssociation association) { + Allele allele = association.getAlleleAssociationSubject(); + List currentAssociations = allele.getAlleleVariantAssociations(); + if (currentAssociations == null) { + currentAssociations = new ArrayList<>(); + allele.setAlleleVariantAssociations(currentAssociations); + } + + List currentAssociationIds = new ArrayList<>(); + for (AlleleVariantAssociation aga : currentAssociations) { + currentAssociationIds.add(aga.getId()); + } + + if (!currentAssociationIds.contains(association.getId())) { + currentAssociations.add(association); + } + } + + public void addAssociationToVariant(AlleleVariantAssociation association) { + Variant variant = variantDAO.find(association.getAlleleVariantAssociationObject().getId()); + List currentAssociations = variant.getAlleleVariantAssociations(); + if (currentAssociations == null) { + currentAssociations = new ArrayList<>(); + variant.setAlleleVariantAssociations(currentAssociations); + } + + List currentAssociationIds = new ArrayList<>(); + for (AlleleVariantAssociation ava : currentAssociations) { + currentAssociationIds.add(ava.getId()); + } + + if (!currentAssociationIds.contains(association.getId())) { + currentAssociations.add(association); + } + + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/codingSequenceAssociations/CodingSequenceGenomicLocationAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/codingSequenceAssociations/CodingSequenceGenomicLocationAssociationService.java index e817435c9..0ca58b1fb 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/associations/codingSequenceAssociations/CodingSequenceGenomicLocationAssociationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/codingSequenceAssociations/CodingSequenceGenomicLocationAssociationService.java @@ -19,6 +19,7 @@ import org.alliancegenome.curation_api.response.SearchResponse; import org.alliancegenome.curation_api.services.PersonService; import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; +import org.apache.commons.lang.StringUtils; import jakarta.annotation.PostConstruct; import jakarta.enterprise.context.RequestScoped; @@ -44,6 +45,9 @@ protected void init() { public List getIdsByDataProvider(BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); params.put(EntityFieldConstants.CODING_SEQUENCE_ASSOCIATION_SUBJECT_DATA_PROVIDER, dataProvider.sourceOrganization); + if (StringUtils.equals(dataProvider.sourceOrganization, "RGD")) { + params.put(EntityFieldConstants.CODING_SEQUENCE_ASSOCIATION_SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); + } List associationIds = codingSequenceGenomicLocationAssociationDAO.findIdsByParams(params); associationIds.removeIf(Objects::isNull); @@ -110,8 +114,7 @@ public void addAssociationToSubject(CodingSequenceGenomicLocationAssociation ass currentSubjectAssociations = new ArrayList<>(); } - List currentSubjectAssociationIds = currentSubjectAssociations.stream() - .map(CodingSequenceGenomicLocationAssociation::getId).collect(Collectors.toList()); + List currentSubjectAssociationIds = currentSubjectAssociations.stream().map(CodingSequenceGenomicLocationAssociation::getId).collect(Collectors.toList()); if (!currentSubjectAssociationIds.contains(association.getId())) { currentSubjectAssociations.add(association); diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java index cac42ed22..7a0098d77 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/constructAssociations/ConstructGenomicEntityAssociationService.java @@ -15,7 +15,7 @@ import org.alliancegenome.curation_api.dao.associations.constructAssociations.ConstructGenomicEntityAssociationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ApiErrorException; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.interfaces.crud.BaseUpsertServiceInterface; import org.alliancegenome.curation_api.model.entities.Construct; import org.alliancegenome.curation_api.model.entities.GenomicEntity; @@ -70,13 +70,8 @@ public ObjectResponse validate(ConstructGenom } @Transactional - public ConstructGenomicEntityAssociation upsert(ConstructGenomicEntityAssociationDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { + public ConstructGenomicEntityAssociation upsert(ConstructGenomicEntityAssociationDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { ConstructGenomicEntityAssociation association = constructGenomicEntityAssociationDtoValidator.validateConstructGenomicEntityAssociationDTO(dto, dataProvider); - if (association != null) { - addAssociationToConstruct(association); - addAssociationToGenomicEntity(association); - } - return association; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/exonAssociations/ExonGenomicLocationAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/exonAssociations/ExonGenomicLocationAssociationService.java index 49b3c6c02..d6840d409 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/associations/exonAssociations/ExonGenomicLocationAssociationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/exonAssociations/ExonGenomicLocationAssociationService.java @@ -19,6 +19,7 @@ import org.alliancegenome.curation_api.response.SearchResponse; import org.alliancegenome.curation_api.services.PersonService; import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; +import org.apache.commons.lang.StringUtils; import jakarta.annotation.PostConstruct; import jakarta.enterprise.context.RequestScoped; @@ -44,6 +45,9 @@ protected void init() { public List getIdsByDataProvider(BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); params.put(EntityFieldConstants.EXON_ASSOCIATION_SUBJECT_DATA_PROVIDER, dataProvider.sourceOrganization); + if (StringUtils.equals(dataProvider.sourceOrganization, "RGD")) { + params.put(EntityFieldConstants.EXON_ASSOCIATION_SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); + } List associationIds = exonGenomicLocationAssociationDAO.findIdsByParams(params); associationIds.removeIf(Objects::isNull); diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/transcriptAssociations/TranscriptCodingSequenceAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/transcriptAssociations/TranscriptCodingSequenceAssociationService.java new file mode 100644 index 000000000..ca9bc103e --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/transcriptAssociations/TranscriptCodingSequenceAssociationService.java @@ -0,0 +1,139 @@ +package org.alliancegenome.curation_api.services.associations.transcriptAssociations; + +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +import org.alliancegenome.curation_api.constants.EntityFieldConstants; +import org.alliancegenome.curation_api.dao.PersonDAO; +import org.alliancegenome.curation_api.dao.associations.transcriptAssociations.TranscriptCodingSequenceAssociationDAO; +import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.exceptions.ApiErrorException; +import org.alliancegenome.curation_api.model.entities.CodingSequence; +import org.alliancegenome.curation_api.model.entities.Transcript; +import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptCodingSequenceAssociation; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.response.SearchResponse; +import org.alliancegenome.curation_api.services.PersonService; +import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; +import org.apache.commons.lang.StringUtils; + +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; +import lombok.extern.jbosslog.JBossLog; + +@JBossLog +@RequestScoped +public class TranscriptCodingSequenceAssociationService extends BaseEntityCrudService { + + @Inject TranscriptCodingSequenceAssociationDAO transcriptCodingSequenceAssociationDAO; + @Inject PersonDAO personDAO; + @Inject PersonService personService; + + @Override + @PostConstruct + protected void init() { + setSQLDao(transcriptCodingSequenceAssociationDAO); + } + + + public List getIdsByDataProvider(BackendBulkDataProvider dataProvider) { + Map params = new HashMap<>(); + params.put(EntityFieldConstants.TRANSCRIPT_ASSOCIATION_SUBJECT_DATA_PROVIDER, dataProvider.sourceOrganization); + if (StringUtils.equals(dataProvider.sourceOrganization, "RGD")) { + params.put(EntityFieldConstants.TRANSCRIPT_ASSOCIATION_SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); + } + List associationIds = transcriptCodingSequenceAssociationDAO.findIdsByParams(params); + associationIds.removeIf(Objects::isNull); + + return associationIds; + } + + @Override + @Transactional + public TranscriptCodingSequenceAssociation deprecateOrDelete(Long id, Boolean throwApiError, String loadDescription, Boolean deprecate) { + TranscriptCodingSequenceAssociation association = transcriptCodingSequenceAssociationDAO.find(id); + + if (association == null) { + String errorMessage = "Could not find TranscriptCodingSequenceAssociation with id: " + id; + if (throwApiError) { + ObjectResponse response = new ObjectResponse<>(); + response.addErrorMessage("id", errorMessage); + throw new ApiErrorException(response); + } + log.error(errorMessage); + return null; + } + if (deprecate) { + if (!association.getObsolete()) { + association.setObsolete(true); + if (authenticatedPerson.getId() != null) { + association.setUpdatedBy(personDAO.find(authenticatedPerson.getId())); + } else { + association.setUpdatedBy(personService.fetchByUniqueIdOrCreate(loadDescription)); + } + association.setDateUpdated(OffsetDateTime.now()); + return transcriptCodingSequenceAssociationDAO.persist(association); + } + return association; + } + + transcriptCodingSequenceAssociationDAO.remove(association.getId()); + + return null; + } + + public ObjectResponse getLocationAssociation(Long transcriptId, Long assemblyComponentId) { + TranscriptCodingSequenceAssociation association = null; + + Map params = new HashMap<>(); + params.put(EntityFieldConstants.TRANSCRIPT_ASSOCIATION_SUBJECT + ".id", transcriptId); + params.put("transcriptCodingSequenceAssociationObject.id", assemblyComponentId); + + SearchResponse resp = transcriptCodingSequenceAssociationDAO.findByParams(params); + if (resp != null && resp.getSingleResult() != null) { + association = resp.getSingleResult(); + } + + ObjectResponse response = new ObjectResponse<>(); + response.setEntity(association); + + return response; + } + + public void addAssociationToSubjectAndObject(TranscriptCodingSequenceAssociation association) { + Transcript transcript = association.getTranscriptAssociationSubject(); + + List currentSubjectAssociations = transcript.getTranscriptCodingSequenceAssociations(); + if (currentSubjectAssociations == null) { + currentSubjectAssociations = new ArrayList<>(); + } + + List currentSubjectAssociationIds = currentSubjectAssociations.stream() + .map(TranscriptCodingSequenceAssociation::getId).collect(Collectors.toList()); + + if (!currentSubjectAssociationIds.contains(association.getId())) { + currentSubjectAssociations.add(association); + } + + CodingSequence codingSequence = association.getTranscriptCodingSequenceAssociationObject(); + + List currentObjectAssociations = codingSequence.getTranscriptCodingSequenceAssociations(); + if (currentObjectAssociations == null) { + currentObjectAssociations = new ArrayList<>(); + } + + List currentObjectAssociationIds = currentObjectAssociations.stream() + .map(TranscriptCodingSequenceAssociation::getId).collect(Collectors.toList()); + + if (!currentObjectAssociationIds.contains(association.getId())) { + currentObjectAssociations.add(association); + } + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/transcriptAssociations/TranscriptExonAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/transcriptAssociations/TranscriptExonAssociationService.java new file mode 100644 index 000000000..57602635c --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/transcriptAssociations/TranscriptExonAssociationService.java @@ -0,0 +1,139 @@ +package org.alliancegenome.curation_api.services.associations.transcriptAssociations; + +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +import org.alliancegenome.curation_api.constants.EntityFieldConstants; +import org.alliancegenome.curation_api.dao.PersonDAO; +import org.alliancegenome.curation_api.dao.associations.transcriptAssociations.TranscriptExonAssociationDAO; +import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.exceptions.ApiErrorException; +import org.alliancegenome.curation_api.model.entities.Exon; +import org.alliancegenome.curation_api.model.entities.Transcript; +import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptExonAssociation; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.response.SearchResponse; +import org.alliancegenome.curation_api.services.PersonService; +import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; +import org.apache.commons.lang.StringUtils; + +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; +import lombok.extern.jbosslog.JBossLog; + +@JBossLog +@RequestScoped +public class TranscriptExonAssociationService extends BaseEntityCrudService { + + @Inject TranscriptExonAssociationDAO transcriptExonAssociationDAO; + @Inject PersonDAO personDAO; + @Inject PersonService personService; + + @Override + @PostConstruct + protected void init() { + setSQLDao(transcriptExonAssociationDAO); + } + + + public List getIdsByDataProvider(BackendBulkDataProvider dataProvider) { + Map params = new HashMap<>(); + params.put(EntityFieldConstants.TRANSCRIPT_ASSOCIATION_SUBJECT_DATA_PROVIDER, dataProvider.sourceOrganization); + if (StringUtils.equals(dataProvider.sourceOrganization, "RGD")) { + params.put(EntityFieldConstants.TRANSCRIPT_ASSOCIATION_SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); + } + List associationIds = transcriptExonAssociationDAO.findIdsByParams(params); + associationIds.removeIf(Objects::isNull); + + return associationIds; + } + + @Override + @Transactional + public TranscriptExonAssociation deprecateOrDelete(Long id, Boolean throwApiError, String loadDescription, Boolean deprecate) { + TranscriptExonAssociation association = transcriptExonAssociationDAO.find(id); + + if (association == null) { + String errorMessage = "Could not find TranscriptExonAssociation with id: " + id; + if (throwApiError) { + ObjectResponse response = new ObjectResponse<>(); + response.addErrorMessage("id", errorMessage); + throw new ApiErrorException(response); + } + log.error(errorMessage); + return null; + } + if (deprecate) { + if (!association.getObsolete()) { + association.setObsolete(true); + if (authenticatedPerson.getId() != null) { + association.setUpdatedBy(personDAO.find(authenticatedPerson.getId())); + } else { + association.setUpdatedBy(personService.fetchByUniqueIdOrCreate(loadDescription)); + } + association.setDateUpdated(OffsetDateTime.now()); + return transcriptExonAssociationDAO.persist(association); + } + return association; + } + + transcriptExonAssociationDAO.remove(association.getId()); + + return null; + } + + public ObjectResponse getLocationAssociation(Long transcriptId, Long assemblyComponentId) { + TranscriptExonAssociation association = null; + + Map params = new HashMap<>(); + params.put(EntityFieldConstants.TRANSCRIPT_ASSOCIATION_SUBJECT + ".id", transcriptId); + params.put("transcriptExonAssociationObject.id", assemblyComponentId); + + SearchResponse resp = transcriptExonAssociationDAO.findByParams(params); + if (resp != null && resp.getSingleResult() != null) { + association = resp.getSingleResult(); + } + + ObjectResponse response = new ObjectResponse<>(); + response.setEntity(association); + + return response; + } + + public void addAssociationToSubjectAndObject(TranscriptExonAssociation association) { + Transcript transcript = association.getTranscriptAssociationSubject(); + + List currentSubjectAssociations = transcript.getTranscriptExonAssociations(); + if (currentSubjectAssociations == null) { + currentSubjectAssociations = new ArrayList<>(); + } + + List currentSubjectAssociationIds = currentSubjectAssociations.stream() + .map(TranscriptExonAssociation::getId).collect(Collectors.toList()); + + if (!currentSubjectAssociationIds.contains(association.getId())) { + currentSubjectAssociations.add(association); + } + + Exon exon = association.getTranscriptExonAssociationObject(); + + List currentObjectAssociations = exon.getTranscriptExonAssociations(); + if (currentObjectAssociations == null) { + currentObjectAssociations = new ArrayList<>(); + } + + List currentObjectAssociationIds = currentObjectAssociations.stream() + .map(TranscriptExonAssociation::getId).collect(Collectors.toList()); + + if (!currentObjectAssociationIds.contains(association.getId())) { + currentObjectAssociations.add(association); + } + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/transcriptAssociations/TranscriptGeneAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/transcriptAssociations/TranscriptGeneAssociationService.java new file mode 100644 index 000000000..256d9a003 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/transcriptAssociations/TranscriptGeneAssociationService.java @@ -0,0 +1,139 @@ +package org.alliancegenome.curation_api.services.associations.transcriptAssociations; + +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +import org.alliancegenome.curation_api.constants.EntityFieldConstants; +import org.alliancegenome.curation_api.dao.PersonDAO; +import org.alliancegenome.curation_api.dao.associations.transcriptAssociations.TranscriptGeneAssociationDAO; +import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.exceptions.ApiErrorException; +import org.alliancegenome.curation_api.model.entities.Gene; +import org.alliancegenome.curation_api.model.entities.Transcript; +import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptGeneAssociation; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.response.SearchResponse; +import org.alliancegenome.curation_api.services.PersonService; +import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; +import org.apache.commons.lang.StringUtils; + +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; +import lombok.extern.jbosslog.JBossLog; + +@JBossLog +@RequestScoped +public class TranscriptGeneAssociationService extends BaseEntityCrudService { + + @Inject TranscriptGeneAssociationDAO transcriptGeneAssociationDAO; + @Inject PersonDAO personDAO; + @Inject PersonService personService; + + @Override + @PostConstruct + protected void init() { + setSQLDao(transcriptGeneAssociationDAO); + } + + + public List getIdsByDataProvider(BackendBulkDataProvider dataProvider) { + Map params = new HashMap<>(); + params.put(EntityFieldConstants.TRANSCRIPT_ASSOCIATION_SUBJECT_DATA_PROVIDER, dataProvider.sourceOrganization); + if (StringUtils.equals(dataProvider.sourceOrganization, "RGD")) { + params.put(EntityFieldConstants.TRANSCRIPT_ASSOCIATION_SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); + } + List associationIds = transcriptGeneAssociationDAO.findIdsByParams(params); + associationIds.removeIf(Objects::isNull); + + return associationIds; + } + + @Override + @Transactional + public TranscriptGeneAssociation deprecateOrDelete(Long id, Boolean throwApiError, String loadDescription, Boolean deprecate) { + TranscriptGeneAssociation association = transcriptGeneAssociationDAO.find(id); + + if (association == null) { + String errorMessage = "Could not find TranscriptGeneAssociation with id: " + id; + if (throwApiError) { + ObjectResponse response = new ObjectResponse<>(); + response.addErrorMessage("id", errorMessage); + throw new ApiErrorException(response); + } + log.error(errorMessage); + return null; + } + if (deprecate) { + if (!association.getObsolete()) { + association.setObsolete(true); + if (authenticatedPerson.getId() != null) { + association.setUpdatedBy(personDAO.find(authenticatedPerson.getId())); + } else { + association.setUpdatedBy(personService.fetchByUniqueIdOrCreate(loadDescription)); + } + association.setDateUpdated(OffsetDateTime.now()); + return transcriptGeneAssociationDAO.persist(association); + } + return association; + } + + transcriptGeneAssociationDAO.remove(association.getId()); + + return null; + } + + public ObjectResponse getLocationAssociation(Long transcriptId, Long assemblyComponentId) { + TranscriptGeneAssociation association = null; + + Map params = new HashMap<>(); + params.put(EntityFieldConstants.TRANSCRIPT_ASSOCIATION_SUBJECT + ".id", transcriptId); + params.put("transcriptGeneAssociationObject.id", assemblyComponentId); + + SearchResponse resp = transcriptGeneAssociationDAO.findByParams(params); + if (resp != null && resp.getSingleResult() != null) { + association = resp.getSingleResult(); + } + + ObjectResponse response = new ObjectResponse<>(); + response.setEntity(association); + + return response; + } + + public void addAssociationToSubjectAndObject(TranscriptGeneAssociation association) { + Transcript transcript = association.getTranscriptAssociationSubject(); + + List currentSubjectAssociations = transcript.getTranscriptGeneAssociations(); + if (currentSubjectAssociations == null) { + currentSubjectAssociations = new ArrayList<>(); + } + + List currentSubjectAssociationIds = currentSubjectAssociations.stream() + .map(TranscriptGeneAssociation::getId).collect(Collectors.toList()); + + if (!currentSubjectAssociationIds.contains(association.getId())) { + currentSubjectAssociations.add(association); + } + + Gene gene = association.getTranscriptGeneAssociationObject(); + + List currentObjectAssociations = gene.getTranscriptGeneAssociations(); + if (currentObjectAssociations == null) { + currentObjectAssociations = new ArrayList<>(); + } + + List currentObjectAssociationIds = currentObjectAssociations.stream() + .map(TranscriptGeneAssociation::getId).collect(Collectors.toList()); + + if (!currentObjectAssociationIds.contains(association.getId())) { + currentObjectAssociations.add(association); + } + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/transcriptAssociations/TranscriptGenomicLocationAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/transcriptAssociations/TranscriptGenomicLocationAssociationService.java index 9160786f6..babdc301f 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/associations/transcriptAssociations/TranscriptGenomicLocationAssociationService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/transcriptAssociations/TranscriptGenomicLocationAssociationService.java @@ -19,6 +19,7 @@ import org.alliancegenome.curation_api.response.SearchResponse; import org.alliancegenome.curation_api.services.PersonService; import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; +import org.apache.commons.lang.StringUtils; import jakarta.annotation.PostConstruct; import jakarta.enterprise.context.RequestScoped; @@ -44,6 +45,9 @@ protected void init() { public List getIdsByDataProvider(BackendBulkDataProvider dataProvider) { Map params = new HashMap<>(); params.put(EntityFieldConstants.TRANSCRIPT_ASSOCIATION_SUBJECT_DATA_PROVIDER, dataProvider.sourceOrganization); + if (StringUtils.equals(dataProvider.sourceOrganization, "RGD")) { + params.put(EntityFieldConstants.TRANSCRIPT_ASSOCIATION_SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); + } List associationIds = transcriptGenomicLocationAssociationDAO.findIdsByParams(params); associationIds.removeIf(Objects::isNull); @@ -88,7 +92,7 @@ public ObjectResponse getLocationAssociati TranscriptGenomicLocationAssociation association = null; Map params = new HashMap<>(); - params.put("transcriptAssociationSubject.id", transcriptId); + params.put(EntityFieldConstants.TRANSCRIPT_ASSOCIATION_SUBJECT + ".id", transcriptId); params.put("transcriptGenomicLocationAssociationObject.id", assemblyComponentId); SearchResponse resp = transcriptGenomicLocationAssociationDAO.findByParams(params); diff --git a/src/main/java/org/alliancegenome/curation_api/services/associations/variantAssociations/CuratedVariantGenomicLocationAssociationService.java b/src/main/java/org/alliancegenome/curation_api/services/associations/variantAssociations/CuratedVariantGenomicLocationAssociationService.java new file mode 100644 index 000000000..78f47a501 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/associations/variantAssociations/CuratedVariantGenomicLocationAssociationService.java @@ -0,0 +1,126 @@ +package org.alliancegenome.curation_api.services.associations.variantAssociations; + +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +import org.alliancegenome.curation_api.constants.EntityFieldConstants; +import org.alliancegenome.curation_api.dao.PersonDAO; +import org.alliancegenome.curation_api.dao.associations.variantAssociations.CuratedVariantGenomicLocationAssociationDAO; +import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.exceptions.ApiErrorException; +import org.alliancegenome.curation_api.model.entities.Variant; +import org.alliancegenome.curation_api.model.entities.associations.variantAssociations.CuratedVariantGenomicLocationAssociation; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.response.SearchResponse; +import org.alliancegenome.curation_api.services.PersonService; +import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; +import org.alliancegenome.curation_api.services.validation.dto.fms.VariantFmsDTOValidator; +import org.apache.commons.lang.StringUtils; + +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; +import lombok.extern.jbosslog.JBossLog; + +@JBossLog +@RequestScoped +public class CuratedVariantGenomicLocationAssociationService extends BaseEntityCrudService { + + @Inject CuratedVariantGenomicLocationAssociationDAO curatedVariantGenomicLocationAssociationDAO; + @Inject VariantFmsDTOValidator variantFmsDtoValidator; + @Inject PersonDAO personDAO; + @Inject PersonService personService; + + @Override + @PostConstruct + protected void init() { + setSQLDao(curatedVariantGenomicLocationAssociationDAO); + } + + + public List getIdsByDataProvider(BackendBulkDataProvider dataProvider) { + Map params = new HashMap<>(); + params.put(EntityFieldConstants.VARIANT_ASSOCIATION_SUBJECT_DATA_PROVIDER, dataProvider.sourceOrganization); + if (StringUtils.equals(dataProvider.sourceOrganization, "RGD")) { + params.put(EntityFieldConstants.VARIANT_ASSOCIATION_SUBJECT_TAXON, dataProvider.canonicalTaxonCurie); + } + List associationIds = curatedVariantGenomicLocationAssociationDAO.findIdsByParams(params); + associationIds.removeIf(Objects::isNull); + + return associationIds; + } + + @Override + @Transactional + public CuratedVariantGenomicLocationAssociation deprecateOrDelete(Long id, Boolean throwApiError, String loadDescription, Boolean deprecate) { + CuratedVariantGenomicLocationAssociation association = curatedVariantGenomicLocationAssociationDAO.find(id); + + if (association == null) { + String errorMessage = "Could not find CuratedVariantGenomicLocationAssociation with id: " + id; + if (throwApiError) { + ObjectResponse response = new ObjectResponse<>(); + response.addErrorMessage("id", errorMessage); + throw new ApiErrorException(response); + } + log.error(errorMessage); + return null; + } + if (deprecate) { + if (!association.getObsolete()) { + association.setObsolete(true); + if (authenticatedPerson.getId() != null) { + association.setUpdatedBy(personDAO.find(authenticatedPerson.getId())); + } else { + association.setUpdatedBy(personService.fetchByUniqueIdOrCreate(loadDescription)); + } + association.setDateUpdated(OffsetDateTime.now()); + return curatedVariantGenomicLocationAssociationDAO.persist(association); + } + return association; + } + + curatedVariantGenomicLocationAssociationDAO.remove(association.getId()); + + return null; + } + + public ObjectResponse getLocationAssociation(Long exonId, Long assemblyComponentId) { + CuratedVariantGenomicLocationAssociation association = null; + + Map params = new HashMap<>(); + params.put(EntityFieldConstants.VARIANT_ASSOCIATION_SUBJECT + ".id", exonId); + params.put(EntityFieldConstants.VARIANT_GENOMIC_LOCATION_ASSOCIATION_OBJECT + ".id", assemblyComponentId); + + SearchResponse resp = curatedVariantGenomicLocationAssociationDAO.findByParams(params); + if (resp != null && resp.getSingleResult() != null) { + association = resp.getSingleResult(); + } + + ObjectResponse response = new ObjectResponse<>(); + response.setEntity(association); + + return response; + } + + public void addAssociationToSubject(CuratedVariantGenomicLocationAssociation association) { + Variant variant = association.getVariantAssociationSubject(); + + List currentSubjectAssociations = variant.getCuratedVariantGenomicLocations(); + if (currentSubjectAssociations == null) { + currentSubjectAssociations = new ArrayList<>(); + } + + List currentSubjectAssociationIds = currentSubjectAssociations.stream() + .map(CuratedVariantGenomicLocationAssociation::getId).collect(Collectors.toList()); + + if (!currentSubjectAssociationIds.contains(association.getId())) { + currentSubjectAssociations.add(association); + } + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/base/BaseDTOCrudService.java b/src/main/java/org/alliancegenome/curation_api/services/base/BaseDTOCrudService.java index 56b19cc25..933c7ff4d 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/base/BaseDTOCrudService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/base/BaseDTOCrudService.java @@ -2,7 +2,7 @@ import org.alliancegenome.curation_api.dao.base.BaseEntityDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.base.AuditedObject; import org.alliancegenome.curation_api.model.ingest.dto.base.BaseDTO; @@ -10,6 +10,6 @@ public abstract class BaseDTOCrudService getByCurie(String curie) { } public ObjectResponse getByIdentifier(String identifier) { - E object = findByAlternativeFields(List.of("curie", "modEntityId", "modInternalId", "uniqueId"), identifier); + E object = findByAlternativeFields(List.of("curie", "modEntityId", "modInternalId"), identifier); ObjectResponse ret = new ObjectResponse(object); return ret; } diff --git a/src/main/java/org/alliancegenome/curation_api/services/base/BaseOntologyTermService.java b/src/main/java/org/alliancegenome/curation_api/services/base/BaseOntologyTermService.java index 7b56e26b3..a612843b6 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/base/BaseOntologyTermService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/base/BaseOntologyTermService.java @@ -300,4 +300,15 @@ private void handleCrossReferences(OntologyTerm dbTerm, OntologyTerm incomingTer } } + public T findSubsetTerm(T childTerm, String subsetName) { + for (OntologyTerm term : childTerm.getIsaAncestors()) { + for (String subset : term.getSubsets()) { + if (subset.contains(subsetName)) { + return (T) term; + } + } + } + return null; + } + } diff --git a/src/main/java/org/alliancegenome/curation_api/services/helpers/UniqueIdentifierHelper.java b/src/main/java/org/alliancegenome/curation_api/services/helpers/UniqueIdentifierHelper.java new file mode 100644 index 000000000..55d2b4d71 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/helpers/UniqueIdentifierHelper.java @@ -0,0 +1,75 @@ +package org.alliancegenome.curation_api.services.helpers; + +import org.alliancegenome.curation_api.model.entities.Annotation; +import org.alliancegenome.curation_api.model.entities.base.AuditedObject; +import org.alliancegenome.curation_api.model.entities.base.SubmittedObject; +import org.alliancegenome.curation_api.model.ingest.dto.AnnotationDTO; +import org.alliancegenome.curation_api.model.ingest.dto.DiseaseAnnotationDTO; +import org.alliancegenome.curation_api.model.ingest.dto.base.SubmittedObjectDTO; +import org.apache.commons.lang3.StringUtils; + +public class UniqueIdentifierHelper { + + private UniqueIdentifierHelper() { + } + + public static String getIdentifyingField(E annotationDTO) { + if (StringUtils.isNotBlank(annotationDTO.getModEntityId())) { + return "modEntityId"; + } else if (StringUtils.isNotBlank(annotationDTO.getModInternalId())) { + return "modInternalId"; + } else { + return "uniqueId"; + } + } + + public static void setObsoleteAndInternal(DiseaseAnnotationDTO dto, AuditedObject annotation) { + // default obsolete value: false + annotation.setObsolete(dto.getObsolete() != null && dto.getObsolete()); + // default internal value: false + annotation.setInternal(dto.getInternal() != null && dto.getInternal()); + } + + public static String setAnnotationID(E annotationDTO, F annotation, String uniqueId) { + if (StringUtils.isNotBlank(annotationDTO.getModEntityId())) { + annotation.setModEntityId(annotationDTO.getModEntityId()); + return annotationDTO.getModEntityId(); + } else if (StringUtils.isNotBlank(annotationDTO.getModInternalId())) { + annotation.setModInternalId(annotationDTO.getModInternalId()); + return annotationDTO.getModInternalId(); + } else { + return uniqueId; + } + } + + + public static String getIdentifyingField(E submittedObjectDto) { + if (StringUtils.isNotBlank(submittedObjectDto.getModEntityId())) { + return "modEntityId"; + } else if (StringUtils.isNotBlank(submittedObjectDto.getModInternalId())) { + return "modInternalId"; + } else { + return "uniqueId"; + } + } + + public static void setObsoleteAndInternal(SubmittedObjectDTO dto, SubmittedObject submittedObject) { + // default obsolete value: false + submittedObject.setObsolete(dto.getObsolete() != null && dto.getObsolete()); + // default internal value: false + submittedObject.setInternal(dto.getInternal() != null && dto.getInternal()); + } + + public static String setAnnotationID(E submittedObjectDTO, F submittedObject, String uniqueId) { + if (StringUtils.isNotBlank(submittedObjectDTO.getModEntityId())) { + submittedObject.setModEntityId(submittedObjectDTO.getModEntityId()); + return submittedObjectDTO.getModEntityId(); + } else if (StringUtils.isNotBlank(submittedObjectDTO.getModInternalId())) { + submittedObject.setModInternalId(submittedObjectDTO.getModInternalId()); + return submittedObjectDTO.getModInternalId(); + } else { + return uniqueId; + } + } + +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/AnnotationUniqueIdHelper.java b/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/AnnotationUniqueIdHelper.java index a16a88d12..55482f8c5 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/AnnotationUniqueIdHelper.java +++ b/src/main/java/org/alliancegenome/curation_api/services/helpers/annotations/AnnotationUniqueIdHelper.java @@ -132,7 +132,17 @@ public static String getDiseaseAnnotationUniqueId(DiseaseAnnotation annotation) uniqueId.add(gda.getSgdStrainBackground().getIdentifier()); } } - uniqueId.addSubmittedObjectList(annotation.getDiseaseGeneticModifiers()); + List geneticModifiers = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(annotation.getDiseaseGeneticModifierGenes())) { + geneticModifiers.addAll(annotation.getDiseaseGeneticModifierGenes()); + } + if (CollectionUtils.isNotEmpty(annotation.getDiseaseGeneticModifierAlleles())) { + geneticModifiers.addAll(annotation.getDiseaseGeneticModifierAlleles()); + } + if (CollectionUtils.isNotEmpty(annotation.getDiseaseGeneticModifierAgms())) { + geneticModifiers.addAll(annotation.getDiseaseGeneticModifierAgms()); + } + uniqueId.addSubmittedObjectList(geneticModifiers); return uniqueId.getUniqueId(); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/helpers/gff3/Gff3AttributesHelper.java b/src/main/java/org/alliancegenome/curation_api/services/helpers/gff3/Gff3AttributesHelper.java index 50239d962..7d5872df1 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/helpers/gff3/Gff3AttributesHelper.java +++ b/src/main/java/org/alliancegenome/curation_api/services/helpers/gff3/Gff3AttributesHelper.java @@ -1,13 +1,17 @@ package org.alliancegenome.curation_api.services.helpers.gff3; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import org.alliancegenome.curation_api.constants.Gff3Constants; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.model.ingest.dto.fms.Gff3DTO; +import org.alliancegenome.curation_api.util.ProcessDisplayHelper; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.ImmutablePair; public class Gff3AttributesHelper { @@ -22,31 +26,103 @@ public static Map getAttributes(Gff3DTO dto, BackendBulkDataProv } } - if (StringUtils.equals(dataProvider.sourceOrganization, "WB")) { - for (String key : List.of("ID", "Parent")) { - if (attributes.containsKey(key)) { - String id = attributes.get(key); + // Ensure identifiers have MOD prefix + for (String key : List.of("ID", "Parent")) { + if (attributes.containsKey(key)) { + String idsString = attributes.get(key); + if (StringUtils.equals(dataProvider.sourceOrganization, "WB")) { + // Remove prefixes like Gene: and Transcript: from WB identifiers + idsString = idsString.replaceAll("Gene:", ""); + idsString = idsString.replaceAll("Transcript:", ""); + idsString = idsString.replaceAll("CDS:", ""); + idsString = idsString.replaceAll("Pseudogene:", ""); + } + String[] idsList = idsString.split(","); + List processedIdList = new ArrayList<>(); + for (String id : idsList) { String[] idParts = id.split(":"); - if (idParts.length > 1) { - id = idParts[1]; + if (idParts.length == 1) { + id = dataProvider.name() + ':' + idParts[0]; } - attributes.put(key, id); + processedIdList.add(id); } + attributes.put(key, String.join(",", processedIdList)); } } - for (String key : List.of("ID", "Parent")) { - if (attributes.containsKey(key)) { - String id = attributes.get(key); - String[] idParts = id.split(":"); - if (idParts.length == 1) { - id = dataProvider.name() + ':' + idParts[0]; + return attributes; + } + + public static List>> getExonGffData(List gffData, BackendBulkDataProvider dataProvider) { + List>> retGffData = new ArrayList<>(); + ProcessDisplayHelper ph = new ProcessDisplayHelper(); + ph.startProcess("GFF Exon pre-processing for " + dataProvider.name(), gffData.size()); + for (Gff3DTO originalGffEntry : gffData) { + if (StringUtils.equals(originalGffEntry.getType(), "exon") || StringUtils.equals(originalGffEntry.getType(), "noncoding_exon")) { + processGffEntry(originalGffEntry, retGffData, dataProvider); + } + ph.progressProcess(); + } + ph.finishProcess(); + return retGffData; + } + + public static List>> getCDSGffData(List gffData, BackendBulkDataProvider dataProvider) { + List>> retGffData = new ArrayList<>(); + ProcessDisplayHelper ph = new ProcessDisplayHelper(); + ph.startProcess("GFF CDS pre-processing for " + dataProvider.name(), gffData.size()); + for (Gff3DTO originalGffEntry : gffData) { + if (StringUtils.equals(originalGffEntry.getType(), "CDS")) { + processGffEntry(originalGffEntry, retGffData, dataProvider); + } + ph.progressProcess(); + } + ph.finishProcess(); + return retGffData; + } + + + public static List>> getTranscriptGffData(List gffData, BackendBulkDataProvider dataProvider) { + List>> retGffData = new ArrayList<>(); + ProcessDisplayHelper ph = new ProcessDisplayHelper(); + ph.startProcess("GFF Transcript pre-processing for " + dataProvider.name(), gffData.size()); + for (Gff3DTO originalGffEntry : gffData) { + if (StringUtils.equals(originalGffEntry.getType(), "lnc_RNA")) { + originalGffEntry.setType("lncRNA"); + } + if (Gff3Constants.TRANSCRIPT_TYPES.contains(originalGffEntry.getType())) { + processGffEntry(originalGffEntry, retGffData, dataProvider); + } + ph.progressProcess(); + } + ph.finishProcess(); + return retGffData; + } + + private static void processGffEntry(Gff3DTO originalGffEntry, List>> retGffData, BackendBulkDataProvider dataProvider) { + Map attributes = getAttributes(originalGffEntry, dataProvider); + if (attributes.containsKey("Parent")) { + if (attributes.get("Parent").indexOf(",") > -1) { + for (String parent : attributes.get("Parent").split(",")) { + if (!parent.endsWith("_transposable_element")) { + HashMap attributesCopy = new HashMap<>(); + attributesCopy.putAll(attributes); + String[] parentIdParts = parent.split(":"); + if (parentIdParts.length == 1) { + parent = dataProvider.name() + ':' + parentIdParts[0]; + } + attributesCopy.put("Parent", parent); + retGffData.add(new ImmutablePair<>(originalGffEntry, attributesCopy)); + } + } + } else { + if (!attributes.get("Parent").endsWith("_transposable_element")) { + retGffData.add(new ImmutablePair<>(originalGffEntry, attributes)); } - attributes.put(key, id); } + } else { + retGffData.add(new ImmutablePair<>(originalGffEntry, attributes)); } - - return attributes; } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/helpers/notes/NoteIdentityHelper.java b/src/main/java/org/alliancegenome/curation_api/services/helpers/notes/NoteIdentityHelper.java index aa272f31e..1067f4bb0 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/helpers/notes/NoteIdentityHelper.java +++ b/src/main/java/org/alliancegenome/curation_api/services/helpers/notes/NoteIdentityHelper.java @@ -1,5 +1,6 @@ package org.alliancegenome.curation_api.services.helpers.notes; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -7,6 +8,8 @@ import org.alliancegenome.curation_api.model.entities.Note; import org.alliancegenome.curation_api.model.entities.Reference; import org.alliancegenome.curation_api.model.ingest.dto.NoteDTO; +import org.alliancegenome.curation_api.model.ingest.dto.fms.PublicationRefFmsDTO; +import org.alliancegenome.curation_api.model.ingest.dto.fms.VariantNoteFmsDTO; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; @@ -54,4 +57,20 @@ public static String noteDtoIdentity(NoteDTO note) { return identity; } + + public static String variantNoteFmsDtoIdentity(VariantNoteFmsDTO note) { + String identity = StringUtils.isBlank(note.getNote()) ? "" : note.getNote(); + List referenceCuries = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(note.getReferences())) { + for (PublicationRefFmsDTO publicationDto : note.getReferences()) { + if (StringUtils.isNotBlank(publicationDto.getPublicationId())) { + referenceCuries.add(publicationDto.getPublicationId()); + } + } + Collections.sort(referenceCuries); + identity = identity + "|" + StringUtils.join(referenceCuries, ":"); + } + + return identity; + } } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/helpers/variants/HgvsIdentifierHelper.java b/src/main/java/org/alliancegenome/curation_api/services/helpers/variants/HgvsIdentifierHelper.java new file mode 100644 index 000000000..331712250 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/helpers/variants/HgvsIdentifierHelper.java @@ -0,0 +1,63 @@ +package org.alliancegenome.curation_api.services.helpers.variants; + +import org.alliancegenome.curation_api.model.ingest.dto.fms.VariantFmsDTO; +import org.apache.commons.lang3.StringUtils; + +public abstract class HgvsIdentifierHelper { + + public static String getHgvsIdentifier(VariantFmsDTO dto) { + String start = ""; + if (dto.getStart() != null) { + start = Integer.toString(dto.getStart()); + } + + String end = ""; + if (dto.getEnd() != null) { + end = Integer.toString(dto.getEnd()); + } + + String varSeq = StringUtils.isBlank(dto.getGenomicVariantSequence()) ? "" : dto.getGenomicVariantSequence(); + String refSeq = StringUtils.isBlank(dto.getGenomicReferenceSequence()) ? "" : dto.getGenomicReferenceSequence(); + + String chrAccession = ""; + if (StringUtils.isNotBlank(dto.getSequenceOfReferenceAccessionNumber())) { + String[] accessionParts = dto.getSequenceOfReferenceAccessionNumber().split(":"); + if (accessionParts.length == 2) { + chrAccession = accessionParts[1]; + } else { + chrAccession = dto.getSequenceOfReferenceAccessionNumber(); + } + } + + String hgvs = chrAccession + ":g." + start; + if (StringUtils.isNotBlank(dto.getType())) { + switch (dto.getType()) { + case "SO:1000002": // point mutation + hgvs = hgvs + refSeq + ">" + varSeq; + break; + case "SO:1000008": // substitution + hgvs = hgvs + refSeq + ">" + varSeq; + break; + case "SO:0000667": // insertion + hgvs = hgvs + "_" + end + "ins" + varSeq; + break; + case "SO:0000159": // deletion + hgvs = hgvs + "_" + end + "del"; + break; + case "SO:0002007": // MNV + hgvs = hgvs + "_" + end + "delins" + varSeq; + break; + case "SO:1000032": // delin + hgvs = hgvs + "_" + end + "delins" + varSeq; + break; + default: + hgvs = null; + } + } else { + hgvs = null; + } + + return hgvs; + } + +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkFMSLoadService.java b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkFMSLoadService.java index 9cae02f33..20c9faf14 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkFMSLoadService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkFMSLoadService.java @@ -1,47 +1,22 @@ package org.alliancegenome.curation_api.services.loads; import org.alliancegenome.curation_api.dao.loads.BulkFMSLoadDAO; -import org.alliancegenome.curation_api.enums.JobStatus; -import org.alliancegenome.curation_api.jobs.events.PendingBulkLoadJobEvent; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkFMSLoad; -import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; import jakarta.annotation.PostConstruct; import jakarta.enterprise.context.RequestScoped; -import jakarta.enterprise.event.Event; import jakarta.inject.Inject; -import jakarta.transaction.Transactional; @RequestScoped public class BulkFMSLoadService extends BaseEntityCrudService { @Inject BulkFMSLoadDAO bulkFMSLoadDAO; - @Inject Event pendingJobEvents; - @Override @PostConstruct protected void init() { setSQLDao(bulkFMSLoadDAO); } - public ObjectResponse restartLoad(Long id) { - ObjectResponse resp = updateLoad(id); - if (resp != null) { - pendingJobEvents.fire(new PendingBulkLoadJobEvent(id)); - return resp; - } - return null; - } - - @Transactional - protected ObjectResponse updateLoad(Long id) { - BulkFMSLoad load = bulkFMSLoadDAO.find(id); - if (load != null && load.getBulkloadStatus().isNotRunning()) { - load.setBulkloadStatus(JobStatus.FORCED_PENDING); - return new ObjectResponse(load); - } - return null; - } } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileHistoryService.java b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileHistoryService.java index d342c0044..68237141d 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileHistoryService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileHistoryService.java @@ -1,15 +1,24 @@ package org.alliancegenome.curation_api.services.loads; +import org.alliancegenome.curation_api.dao.loads.BulkLoadDAO; import org.alliancegenome.curation_api.dao.loads.BulkLoadFileExceptionDAO; import org.alliancegenome.curation_api.dao.loads.BulkLoadFileHistoryDAO; +import org.alliancegenome.curation_api.enums.JobStatus; +import org.alliancegenome.curation_api.jobs.events.PendingBulkLoadJobEvent; +import org.alliancegenome.curation_api.jobs.events.PendingLoadJobEvent; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoad; +import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileException; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFileHistory; +import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; +import io.quarkus.logging.Log; import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; import jakarta.annotation.PostConstruct; import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.event.Event; import jakarta.inject.Inject; import jakarta.transaction.Transactional; import jakarta.ws.rs.core.MediaType; @@ -18,9 +27,12 @@ @RequestScoped public class BulkLoadFileHistoryService extends BaseEntityCrudService { + @Inject Event pendingJobEvents; + @Inject Event pendingLoadJobEvents; @Inject BulkLoadFileHistoryDAO bulkLoadFileHistoryDAO; @Inject BulkLoadFileExceptionDAO bulkLoadFileExceptionDAO; - + @Inject BulkLoadDAO bulkLoadDAO; + @Override @PostConstruct protected void init() { @@ -71,9 +83,53 @@ public Response download(Long id) { // response.header("Content-Disposition", "attachment; filename=\"" + id + "_file_exceptions.json\""); Response.ResponseBuilder response = Response.ok(jsonArray.toString()); - response.header("Content-Disposition", "attachment; filename=\"" + bulkLoadFileHistory.getBulkLoadFile().getBulkLoad().getName().replace(" ", "_") + "_exceptions.json\""); + response.header("Content-Disposition", "attachment; filename=\"" + bulkLoadFileHistory.getBulkLoad().getName().replace(" ", "_") + "_exceptions.json\""); response.type(MediaType.APPLICATION_OCTET_STREAM); return response.build(); } + + + + public ObjectResponse restartBulkLoad(Long id) { + ObjectResponse resp = updateBulkLoad(id); // Transaction has to close before calling the fire + Log.debug("Restart Bulk Load: " + id); + if (resp != null) { + Log.debug("Firing Event: " + id); + pendingJobEvents.fireAsync(new PendingBulkLoadJobEvent(id)); + return resp; + } + return null; + } + + @Transactional + public ObjectResponse updateBulkLoad(Long id) { + BulkLoad load = bulkLoadDAO.find(id); + if (load != null && load.getBulkloadStatus().isNotRunning()) { + load.setBulkloadStatus(JobStatus.FORCED_PENDING); + return new ObjectResponse(load); + } + return null; + } + + public ObjectResponse restartBulkLoadHistory(Long id) { + ObjectResponse resp = updateBulkLoadHistory(id); + Log.debug("Restart Bulk Load History: " + id); + if (resp != null) { + Log.debug("Firing Event: " + id); + pendingLoadJobEvents.fireAsync(new PendingLoadJobEvent(id)); + return resp; + } + return null; + } + + @Transactional + public ObjectResponse updateBulkLoadHistory(Long id) { + BulkLoadFileHistory history = bulkLoadFileHistoryDAO.find(id); + if (history != null && history.getBulkloadStatus().isNotRunning()) { + history.setBulkloadStatus(JobStatus.FORCED_PENDING); + return new ObjectResponse(history.getBulkLoadFile()); + } + return null; + } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileService.java b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileService.java index 503d85c3e..54a776d65 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkLoadFileService.java @@ -1,24 +1,21 @@ package org.alliancegenome.curation_api.services.loads; import org.alliancegenome.curation_api.dao.loads.BulkLoadFileDAO; -import org.alliancegenome.curation_api.enums.JobStatus; -import org.alliancegenome.curation_api.jobs.events.PendingBulkLoadFileJobEvent; +import org.alliancegenome.curation_api.jobs.events.PendingLoadJobEvent; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkLoadFile; -import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; import jakarta.annotation.PostConstruct; import jakarta.enterprise.context.RequestScoped; import jakarta.enterprise.event.Event; import jakarta.inject.Inject; -import jakarta.transaction.Transactional; @RequestScoped public class BulkLoadFileService extends BaseEntityCrudService { @Inject BulkLoadFileDAO bulkLoadFileDAO; - @Inject Event pendingFileJobEvents; + @Inject Event pendingFileJobEvents; @Override @PostConstruct @@ -26,23 +23,4 @@ protected void init() { setSQLDao(bulkLoadFileDAO); } - public ObjectResponse restartLoad(Long id) { - ObjectResponse resp = updateLoad(id); - if (resp != null) { - pendingFileJobEvents.fire(new PendingBulkLoadFileJobEvent(id)); - return resp; - } - return null; - } - - @Transactional - protected ObjectResponse updateLoad(Long id) { - BulkLoadFile load = bulkLoadFileDAO.find(id); - if (load != null && load.getBulkloadStatus().isNotRunning()) { - load.setBulkloadStatus(JobStatus.FORCED_PENDING); - return new ObjectResponse(load); - } - return null; - } - } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkManualLoadService.java b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkManualLoadService.java index ea7a58fde..af47be51c 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkManualLoadService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkManualLoadService.java @@ -1,17 +1,14 @@ package org.alliancegenome.curation_api.services.loads; import org.alliancegenome.curation_api.dao.loads.BulkManualLoadDAO; -import org.alliancegenome.curation_api.enums.JobStatus; import org.alliancegenome.curation_api.jobs.events.PendingBulkLoadJobEvent; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkManualLoad; -import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; import jakarta.annotation.PostConstruct; import jakarta.enterprise.context.RequestScoped; import jakarta.enterprise.event.Event; import jakarta.inject.Inject; -import jakarta.transaction.Transactional; @RequestScoped public class BulkManualLoadService extends BaseEntityCrudService { @@ -26,23 +23,4 @@ protected void init() { setSQLDao(bulkManualLoadDAO); } - public ObjectResponse restartLoad(Long id) { - ObjectResponse resp = updateLoad(id); - if (resp != null) { - pendingJobEvents.fire(new PendingBulkLoadJobEvent(id)); - return resp; - } - return null; - } - - @Transactional - protected ObjectResponse updateLoad(Long id) { - BulkManualLoad load = bulkManualLoadDAO.find(id); - if (load != null && load.getBulkloadStatus().isNotRunning()) { - load.setBulkloadStatus(JobStatus.FORCED_PENDING); - return new ObjectResponse(load); - } - return null; - } - } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkURLLoadService.java b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkURLLoadService.java index d86c89e38..7822346ff 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/loads/BulkURLLoadService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/loads/BulkURLLoadService.java @@ -1,18 +1,14 @@ package org.alliancegenome.curation_api.services.loads; import org.alliancegenome.curation_api.dao.loads.BulkURLLoadDAO; -import org.alliancegenome.curation_api.enums.JobStatus; import org.alliancegenome.curation_api.jobs.events.PendingBulkLoadJobEvent; import org.alliancegenome.curation_api.model.entities.bulkloads.BulkURLLoad; -import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.services.base.BaseEntityCrudService; -import io.quarkus.logging.Log; import jakarta.annotation.PostConstruct; import jakarta.enterprise.context.RequestScoped; import jakarta.enterprise.event.Event; import jakarta.inject.Inject; -import jakarta.transaction.Transactional; @RequestScoped public class BulkURLLoadService extends BaseEntityCrudService { @@ -27,25 +23,4 @@ protected void init() { setSQLDao(bulkURLLoadDAO); } - public ObjectResponse restartLoad(Long id) { - Log.info("restartLoad: " + id); - ObjectResponse resp = updateLoad(id); - if (resp != null) { - Log.info("Firing Load Pending Event: " + id); - pendingJobEvents.fire(new PendingBulkLoadJobEvent(id)); - return resp; - } - return null; - } - - @Transactional - protected ObjectResponse updateLoad(Long id) { - Log.info("updateLoad: " + id); - BulkURLLoad load = bulkURLLoadDAO.find(id); - if (load != null && load.getBulkloadStatus().isNotRunning()) { - load.setBulkloadStatus(JobStatus.FORCED_PENDING); - return new ObjectResponse(load); - } - return null; - } } \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/orthology/GeneToGeneOrthologyGeneratedService.java b/src/main/java/org/alliancegenome/curation_api/services/orthology/GeneToGeneOrthologyGeneratedService.java index 205fb9828..0905e034c 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/orthology/GeneToGeneOrthologyGeneratedService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/orthology/GeneToGeneOrthologyGeneratedService.java @@ -7,7 +7,7 @@ import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.dao.orthology.GeneToGeneOrthologyGeneratedDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.interfaces.crud.BaseUpsertServiceInterface; import org.alliancegenome.curation_api.model.entities.orthology.GeneToGeneOrthologyGenerated; import org.alliancegenome.curation_api.model.ingest.dto.fms.OrthologyFmsDTO; @@ -31,7 +31,7 @@ protected void init() { setSQLDao(geneToGeneOrthologyGeneratedDAO); } - public GeneToGeneOrthologyGenerated upsert(OrthologyFmsDTO orthoPair, BackendBulkDataProvider backendBulkDataProvider) throws ObjectUpdateException { + public GeneToGeneOrthologyGenerated upsert(OrthologyFmsDTO orthoPair, BackendBulkDataProvider backendBulkDataProvider) throws ValidationException { return orthologyFmsDtoValidator.validateOrthologyFmsDTO(orthoPair); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/processing/IndexProcessDisplayService.java b/src/main/java/org/alliancegenome/curation_api/services/processing/IndexProcessDisplayService.java index 0b848a73a..f6dcafdb1 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/processing/IndexProcessDisplayService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/processing/IndexProcessDisplayService.java @@ -18,16 +18,16 @@ public class IndexProcessDisplayService implements ProcessDisplayHandler { @Override public void startProcess(String message, long startTime, long totalSize) { - processingEvent.fire(new StartIndexProcessingEvent(message, startTime, totalSize)); + processingEvent.fireAsync(new StartIndexProcessingEvent(message, startTime, totalSize)); } @Override public void progressProcess(String message, String data, long startTime, long nowTime, long lastTime, long currentCount, long lastCount, long totalSize) { - processingEvent.fire(new ProgressIndexProcessingEvent(message, data, startTime, nowTime, lastTime, currentCount, lastCount, totalSize)); + processingEvent.fireAsync(new ProgressIndexProcessingEvent(message, data, startTime, nowTime, lastTime, currentCount, lastCount, totalSize)); } @Override public void finishProcess(String message, String data, long current, long totalSize, long duration) { - processingEvent.fire(new EndIndexProcessingEvent(message, data, current, totalSize, duration)); + processingEvent.fireAsync(new EndIndexProcessingEvent(message, data, current, totalSize, duration)); } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/processing/LoadProcessDisplayService.java b/src/main/java/org/alliancegenome/curation_api/services/processing/LoadProcessDisplayService.java index 07f543bf3..1ab7c0bda 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/processing/LoadProcessDisplayService.java +++ b/src/main/java/org/alliancegenome/curation_api/services/processing/LoadProcessDisplayService.java @@ -18,16 +18,16 @@ public class LoadProcessDisplayService implements ProcessDisplayHandler { @Override public void startProcess(String message, long startTime, long totalSize) { - processingEvent.fire(new StartLoadProcessingEvent(message, startTime, totalSize)); + processingEvent.fireAsync(new StartLoadProcessingEvent(message, startTime, totalSize)); } @Override public void progressProcess(String message, String data, long startTime, long nowTime, long lastTime, long currentCount, long lastCount, long totalSize) { - processingEvent.fire(new ProgressLoadProcessingEvent(message, data, startTime, nowTime, lastTime, currentCount, lastCount, totalSize)); + processingEvent.fireAsync(new ProgressLoadProcessingEvent(message, data, startTime, nowTime, lastTime, currentCount, lastCount, totalSize)); } @Override public void finishProcess(String message, String data, long current, long totalSize, long duration) { - processingEvent.fire(new EndLoadProcessingEvent(message, data, current, totalSize, duration)); + processingEvent.fireAsync(new EndLoadProcessingEvent(message, data, current, totalSize, duration)); } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/DataProviderValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/DataProviderValidator.java index 597ec31c1..8132d9541 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/DataProviderValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/DataProviderValidator.java @@ -40,7 +40,7 @@ public ObjectResponse validateDataProvider(DataProvider uiEntity, dbEntity = new DataProvider(); } - dbEntity = (DataProvider) validateAuditedObjectFields(uiEntity, dbEntity, newEntity); + dbEntity = validateAuditedObjectFields(uiEntity, dbEntity, newEntity); Organization sourceOrganization = validateSourceOrganization(uiEntity, dbEntity); dbEntity.setSourceOrganization(sourceOrganization); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/DiseaseAnnotationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/DiseaseAnnotationValidator.java index ee929311d..ff2edd521 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/DiseaseAnnotationValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/DiseaseAnnotationValidator.java @@ -7,11 +7,13 @@ import org.alliancegenome.curation_api.constants.OntologyConstants; import org.alliancegenome.curation_api.constants.ValidationConstants; import org.alliancegenome.curation_api.constants.VocabularyConstants; -import org.alliancegenome.curation_api.dao.BiologicalEntityDAO; +import org.alliancegenome.curation_api.dao.AffectedGenomicModelDAO; +import org.alliancegenome.curation_api.dao.AlleleDAO; import org.alliancegenome.curation_api.dao.DiseaseAnnotationDAO; import org.alliancegenome.curation_api.dao.GeneDAO; import org.alliancegenome.curation_api.dao.ontology.EcoTermDAO; -import org.alliancegenome.curation_api.model.entities.BiologicalEntity; +import org.alliancegenome.curation_api.model.entities.AffectedGenomicModel; +import org.alliancegenome.curation_api.model.entities.Allele; import org.alliancegenome.curation_api.model.entities.DataProvider; import org.alliancegenome.curation_api.model.entities.DiseaseAnnotation; import org.alliancegenome.curation_api.model.entities.Gene; @@ -35,7 +37,8 @@ public class DiseaseAnnotationValidator extends AnnotationValidator { @Inject EcoTermDAO ecoTermDAO; @Inject DoTermService doTermService; @Inject GeneDAO geneDAO; - @Inject BiologicalEntityDAO biologicalEntityDAO; + @Inject AlleleDAO alleleDAO; + @Inject AffectedGenomicModelDAO agmDAO; @Inject VocabularyTermService vocabularyTermService; @Inject DiseaseAnnotationDAO diseaseAnnotationDAO; @Inject DataProviderService dataProviderService; @@ -150,7 +153,7 @@ public DataProvider validateSecondaryDataProvider(DiseaseAnnotation uiEntity, Di if (uiEntity.getSecondaryDataProvider() == null) { if (dbEntity.getId() == null) { - uiEntity.setSecondaryDataProvider(dataProviderService.createAllianceDataProvider()); + uiEntity.setSecondaryDataProvider(dataProviderService.getAllianceDataProvider()); if (uiEntity.getSecondaryDataProvider() == null) { return null; } @@ -177,33 +180,103 @@ public DataProvider validateSecondaryDataProvider(DiseaseAnnotation uiEntity, Di return validatedDataProvider; } - public List validateDiseaseGeneticModifiers(DiseaseAnnotation uiEntity, DiseaseAnnotation dbEntity) { - if (CollectionUtils.isEmpty(uiEntity.getDiseaseGeneticModifiers())) { + public List validateDiseaseGeneticModifierGenes(DiseaseAnnotation uiEntity, DiseaseAnnotation dbEntity) { + if (CollectionUtils.isEmpty(uiEntity.getDiseaseGeneticModifierGenes())) { return null; } if (uiEntity.getDiseaseGeneticModifierRelation() == null) { - addMessageResponse("diseaseGeneticModifiers", ValidationConstants.DEPENDENCY_MESSAGE_PREFIX + "diseaseGeneticModifierRelation"); + addMessageResponse("diseaseGeneticModifierGenes", ValidationConstants.DEPENDENCY_MESSAGE_PREFIX + "diseaseGeneticModifierRelation"); return null; } - List validModifiers = new ArrayList<>(); + List validModifiers = new ArrayList<>(); List previousIds = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(dbEntity.getDiseaseGeneticModifiers())) { - previousIds = dbEntity.getDiseaseGeneticModifiers().stream().map(BiologicalEntity::getId).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(dbEntity.getDiseaseGeneticModifierGenes())) { + previousIds = dbEntity.getDiseaseGeneticModifierGenes().stream().map(Gene::getId).collect(Collectors.toList()); } - for (BiologicalEntity modifier : uiEntity.getDiseaseGeneticModifiers()) { - BiologicalEntity diseaseGeneticModifier = null; + for (Gene modifier : uiEntity.getDiseaseGeneticModifierGenes()) { + Gene diseaseGeneticModifier = null; if (modifier.getId() != null) { - diseaseGeneticModifier = biologicalEntityDAO.find(modifier.getId()); + diseaseGeneticModifier = geneDAO.find(modifier.getId()); } if (diseaseGeneticModifier == null) { - addMessageResponse("diseaseGeneticModifiers", ValidationConstants.INVALID_MESSAGE); + addMessageResponse("diseaseGeneticModifierGenes", ValidationConstants.INVALID_MESSAGE); return null; } if (diseaseGeneticModifier.getObsolete() && !previousIds.contains(diseaseGeneticModifier.getId())) { - addMessageResponse("diseaseGeneticModifiers", ValidationConstants.OBSOLETE_MESSAGE); + addMessageResponse("diseaseGeneticModifierGenes", ValidationConstants.OBSOLETE_MESSAGE); + return null; + } + validModifiers.add(diseaseGeneticModifier); + } + + return validModifiers; + } + + public List validateDiseaseGeneticModifierAgms(DiseaseAnnotation uiEntity, DiseaseAnnotation dbEntity) { + if (CollectionUtils.isEmpty(uiEntity.getDiseaseGeneticModifierGenes())) { + return null; + } + + if (uiEntity.getDiseaseGeneticModifierRelation() == null) { + addMessageResponse("diseaseGeneticModifierAgms", ValidationConstants.DEPENDENCY_MESSAGE_PREFIX + "diseaseGeneticModifierRelation"); + return null; + } + + List validModifiers = new ArrayList<>(); + List previousIds = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(dbEntity.getDiseaseGeneticModifierAlleles())) { + previousIds = dbEntity.getDiseaseGeneticModifierAlleles().stream().map(Allele::getId).collect(Collectors.toList()); + } + for (AffectedGenomicModel modifier : uiEntity.getDiseaseGeneticModifierAgms()) { + AffectedGenomicModel diseaseGeneticModifier = null; + if (modifier.getId() != null) { + diseaseGeneticModifier = agmDAO.find(modifier.getId()); + } + if (diseaseGeneticModifier == null) { + addMessageResponse("diseaseGeneticModifierAgms", ValidationConstants.INVALID_MESSAGE); + return null; + } + + if (diseaseGeneticModifier.getObsolete() && !previousIds.contains(diseaseGeneticModifier.getId())) { + addMessageResponse("diseaseGeneticModifierAgms", ValidationConstants.OBSOLETE_MESSAGE); + return null; + } + validModifiers.add(diseaseGeneticModifier); + } + + return validModifiers; + } + + public List validateDiseaseGeneticModifierAlleles(DiseaseAnnotation uiEntity, DiseaseAnnotation dbEntity) { + if (CollectionUtils.isEmpty(uiEntity.getDiseaseGeneticModifierGenes())) { + return null; + } + + if (uiEntity.getDiseaseGeneticModifierRelation() == null) { + addMessageResponse("diseaseGeneticModifierAlleles", ValidationConstants.DEPENDENCY_MESSAGE_PREFIX + "diseaseGeneticModifierRelation"); + return null; + } + + List validModifiers = new ArrayList<>(); + List previousIds = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(dbEntity.getDiseaseGeneticModifierAlleles())) { + previousIds = dbEntity.getDiseaseGeneticModifierAlleles().stream().map(Allele::getId).collect(Collectors.toList()); + } + for (Allele modifier : uiEntity.getDiseaseGeneticModifierAlleles()) { + Allele diseaseGeneticModifier = null; + if (modifier.getId() != null) { + diseaseGeneticModifier = alleleDAO.find(modifier.getId()); + } + if (diseaseGeneticModifier == null) { + addMessageResponse("diseaseGeneticModifierAlleles", ValidationConstants.INVALID_MESSAGE); + return null; + } + + if (diseaseGeneticModifier.getObsolete() && !previousIds.contains(diseaseGeneticModifier.getId())) { + addMessageResponse("diseaseGeneticModifierAlleles", ValidationConstants.OBSOLETE_MESSAGE); return null; } validModifiers.add(diseaseGeneticModifier); @@ -218,8 +291,9 @@ public VocabularyTerm validateDiseaseGeneticModifierRelation(DiseaseAnnotation u return null; } - if (CollectionUtils.isEmpty(uiEntity.getDiseaseGeneticModifiers())) { - addMessageResponse(field, ValidationConstants.DEPENDENCY_MESSAGE_PREFIX + "diseaseGeneticModifiers"); + if (CollectionUtils.isEmpty(uiEntity.getDiseaseGeneticModifierGenes()) && CollectionUtils.isEmpty(uiEntity.getDiseaseGeneticModifierAlleles()) + && CollectionUtils.isEmpty(uiEntity.getDiseaseGeneticModifierAgms())) { + addMessageResponse(field, ValidationConstants.DEPENDENCY_MESSAGE_PREFIX + "diseaseGeneticModifierGenes / diseaseGeneticModifierAlleles / diseaseGeneticModifierAgms"); return null; } @@ -322,9 +396,13 @@ public DiseaseAnnotation validateCommonDiseaseAnnotationFields(DiseaseAnnotation DataProvider secondaryDataProvider = validateSecondaryDataProvider(uiEntity, dbEntity); dbEntity.setSecondaryDataProvider(secondaryDataProvider); - List diseaseGeneticModifiers = validateDiseaseGeneticModifiers(uiEntity, dbEntity); + List diseaseGeneticModifierGenes = validateDiseaseGeneticModifierGenes(uiEntity, dbEntity); + List diseaseGeneticModifierAlleles = validateDiseaseGeneticModifierAlleles(uiEntity, dbEntity); + List diseaseGeneticModifierAgms = validateDiseaseGeneticModifierAgms(uiEntity, dbEntity); VocabularyTerm dgmRelation = validateDiseaseGeneticModifierRelation(uiEntity, dbEntity); - dbEntity.setDiseaseGeneticModifiers(diseaseGeneticModifiers); + dbEntity.setDiseaseGeneticModifierGenes(diseaseGeneticModifierGenes); + dbEntity.setDiseaseGeneticModifierAlleles(diseaseGeneticModifierAlleles); + dbEntity.setDiseaseGeneticModifierAgms(diseaseGeneticModifierAgms); dbEntity.setDiseaseGeneticModifierRelation(dgmRelation); List diseaseQualifiers = validateDiseaseQualifiers(uiEntity, dbEntity); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/GeneValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/GeneValidator.java index e10a219a7..dee9d0270 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/GeneValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/GeneValidator.java @@ -76,7 +76,7 @@ public Gene validateGeneCreate(Gene uiEntity) { private Gene validateGene(Gene uiEntity, Gene dbEntity) { - dbEntity = (Gene) validateGenomicEntityFields(uiEntity, dbEntity); + dbEntity = validateGenomicEntityFields(uiEntity, dbEntity); SOTerm geneType = validateGeneType(uiEntity, dbEntity); dbEntity.setGeneType(geneType); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/associations/alleleAssociations/AlleleVariantAssociationValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/associations/alleleAssociations/AlleleVariantAssociationValidator.java new file mode 100644 index 000000000..541fe5bb8 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/associations/alleleAssociations/AlleleVariantAssociationValidator.java @@ -0,0 +1,146 @@ +package org.alliancegenome.curation_api.services.validation.associations.alleleAssociations; + +import org.alliancegenome.curation_api.constants.ValidationConstants; +import org.alliancegenome.curation_api.constants.VocabularyConstants; +import org.alliancegenome.curation_api.dao.VariantDAO; +import org.alliancegenome.curation_api.dao.associations.alleleAssociations.AlleleVariantAssociationDAO; +import org.alliancegenome.curation_api.exceptions.ApiErrorException; +import org.alliancegenome.curation_api.model.entities.Allele; +import org.alliancegenome.curation_api.model.entities.Variant; +import org.alliancegenome.curation_api.model.entities.VocabularyTerm; +import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleVariantAssociation; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.services.VocabularyTermService; +import org.apache.commons.lang3.ObjectUtils; + +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; + +@RequestScoped +public class AlleleVariantAssociationValidator extends AlleleGenomicEntityAssociationValidator { + + @Inject VariantDAO variantDAO; + @Inject AlleleVariantAssociationDAO alleleVariantAssociationDAO; + @Inject VocabularyTermService vocabularyTermService; + + private String errorMessage; + + public ObjectResponse validateAlleleVariantAssociation(AlleleVariantAssociation uiEntity) { + AlleleVariantAssociation variantAssociation = validateAlleleVariantAssociation(uiEntity, false, false); + response.setEntity(variantAssociation); + return response; + } + + public AlleleVariantAssociation validateAlleleVariantAssociation(AlleleVariantAssociation uiEntity, Boolean throwError, Boolean validateAllele) { + response = new ObjectResponse<>(uiEntity); + errorMessage = "Could not create/update Allele Variant Association: [" + uiEntity.getId() + "]"; + + Long id = uiEntity.getId(); + AlleleVariantAssociation dbEntity = null; + if (id != null) { + dbEntity = alleleVariantAssociationDAO.find(id); + if (dbEntity == null) { + addMessageResponse("Could not find Allele Variant Association with ID: [" + id + "]"); + throw new ApiErrorException(response); + } + } else { + dbEntity = new AlleleVariantAssociation(); + } + + dbEntity = (AlleleVariantAssociation) validateAlleleGenomicEntityAssociationFields(uiEntity, dbEntity); + + if (validateAllele) { + Allele subject = validateSubject(uiEntity, dbEntity); + dbEntity.setAlleleAssociationSubject(subject); + } + + Variant object = validateObject(uiEntity, dbEntity); + dbEntity.setAlleleVariantAssociationObject(object); + + VocabularyTerm relation = validateRelation(uiEntity, dbEntity); + dbEntity.setRelation(relation); + + if (response.hasErrors()) { + if (throwError) { + response.setErrorMessage(errorMessage); + throw new ApiErrorException(response); + } else { + return null; + } + } + + return dbEntity; + } + + private Allele validateSubject(AlleleVariantAssociation uiEntity, AlleleVariantAssociation dbEntity) { + String field = "alleleAssociationSubject"; + if (ObjectUtils.isEmpty(uiEntity.getAlleleAssociationSubject())) { + addMessageResponse(field, ValidationConstants.REQUIRED_MESSAGE); + return null; + } + + Allele subjectEntity = null; + if (uiEntity.getAlleleAssociationSubject().getId() != null) { + subjectEntity = alleleDAO.find(uiEntity.getAlleleAssociationSubject().getId()); + } + if (subjectEntity == null) { + addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); + return null; + } + + if (subjectEntity.getObsolete() && (dbEntity.getAlleleAssociationSubject() == null || !subjectEntity.getId().equals(dbEntity.getAlleleAssociationSubject().getId()))) { + addMessageResponse(field, ValidationConstants.OBSOLETE_MESSAGE); + return null; + } + + return subjectEntity; + + } + + private Variant validateObject(AlleleVariantAssociation uiEntity, AlleleVariantAssociation dbEntity) { + String field = "alleleVariantAssociationObject"; + if (ObjectUtils.isEmpty(uiEntity.getAlleleVariantAssociationObject())) { + addMessageResponse(field, ValidationConstants.REQUIRED_MESSAGE); + return null; + } + + Variant objectEntity = null; + if (uiEntity.getAlleleVariantAssociationObject().getId() != null) { + objectEntity = variantDAO.find(uiEntity.getAlleleVariantAssociationObject().getId()); + } + if (objectEntity == null) { + addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); + return null; + } + + if (objectEntity.getObsolete() && (dbEntity.getAlleleVariantAssociationObject() == null || !objectEntity.getId().equals(dbEntity.getAlleleVariantAssociationObject().getId()))) { + addMessageResponse(field, ValidationConstants.OBSOLETE_MESSAGE); + return null; + } + + return objectEntity; + + } + + private VocabularyTerm validateRelation(AlleleVariantAssociation uiEntity, AlleleVariantAssociation dbEntity) { + String field = "relation"; + if (uiEntity.getRelation() == null) { + addMessageResponse(field, ValidationConstants.REQUIRED_MESSAGE); + return null; + } + + VocabularyTerm relation = vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.ALLELE_VARIANT_RELATION_VOCABULARY_TERM_SET, uiEntity.getRelation().getName()).getEntity(); + + if (relation == null) { + addMessageResponse(field, ValidationConstants.INVALID_MESSAGE); + return null; + } + + if (relation.getObsolete() && (dbEntity.getRelation() == null || !relation.getName().equals(dbEntity.getRelation().getName()))) { + addMessageResponse(field, ValidationConstants.OBSOLETE_MESSAGE); + return null; + } + + return relation; + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AGMDiseaseAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AGMDiseaseAnnotationDTOValidator.java index 875022490..d8812d921 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AGMDiseaseAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AGMDiseaseAnnotationDTOValidator.java @@ -7,7 +7,7 @@ import org.alliancegenome.curation_api.constants.VocabularyConstants; import org.alliancegenome.curation_api.dao.AGMDiseaseAnnotationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; import org.alliancegenome.curation_api.model.entities.AGMDiseaseAnnotation; import org.alliancegenome.curation_api.model.entities.AffectedGenomicModel; @@ -22,6 +22,7 @@ import org.alliancegenome.curation_api.services.AlleleService; import org.alliancegenome.curation_api.services.GeneService; import org.alliancegenome.curation_api.services.VocabularyTermService; +import org.alliancegenome.curation_api.services.helpers.UniqueIdentifierHelper; import org.alliancegenome.curation_api.services.helpers.annotations.AnnotationRetrievalHelper; import org.alliancegenome.curation_api.services.helpers.annotations.AnnotationUniqueIdHelper; import org.apache.commons.collections.CollectionUtils; @@ -33,14 +34,18 @@ @RequestScoped public class AGMDiseaseAnnotationDTOValidator extends DiseaseAnnotationDTOValidator { - @Inject AGMDiseaseAnnotationDAO agmDiseaseAnnotationDAO; - @Inject VocabularyTermService vocabularyTermService; - @Inject AffectedGenomicModelService agmService; - @Inject GeneService geneService; - @Inject AlleleService alleleService; - - public AGMDiseaseAnnotation validateAGMDiseaseAnnotationDTO(AGMDiseaseAnnotationDTO dto, BackendBulkDataProvider dataProvider) throws ObjectUpdateException, ObjectValidationException { - + @Inject + AGMDiseaseAnnotationDAO agmDiseaseAnnotationDAO; + @Inject + VocabularyTermService vocabularyTermService; + @Inject + AffectedGenomicModelService agmService; + @Inject + GeneService geneService; + @Inject + AlleleService alleleService; + + public AGMDiseaseAnnotation validateAGMDiseaseAnnotationDTO(AGMDiseaseAnnotationDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { AGMDiseaseAnnotation annotation = new AGMDiseaseAnnotation(); AffectedGenomicModel agm; @@ -58,27 +63,15 @@ public AGMDiseaseAnnotation validateAGMDiseaseAnnotationDTO(AGMDiseaseAnnotation if (agm == null) { adaResponse.addErrorMessage("agm_identifier", ValidationConstants.INVALID_MESSAGE + " (" + dto.getAgmIdentifier() + ")"); } else { - String annotationId; - String identifyingField; String uniqueId = AnnotationUniqueIdHelper.getDiseaseAnnotationUniqueId(dto, dto.getAgmIdentifier(), refCurie); - - if (StringUtils.isNotBlank(dto.getModEntityId())) { - annotationId = dto.getModEntityId(); - annotation.setModEntityId(annotationId); - identifyingField = "modEntityId"; - } else if (StringUtils.isNotBlank(dto.getModInternalId())) { - annotationId = dto.getModInternalId(); - annotation.setModInternalId(annotationId); - identifyingField = "modInternalId"; - } else { - annotationId = uniqueId; - identifyingField = "uniqueId"; - } + String annotationId = UniqueIdentifierHelper.setAnnotationID(dto, annotation, uniqueId); + String identifyingField = UniqueIdentifierHelper.getIdentifyingField(dto); SearchResponse annotationList = agmDiseaseAnnotationDAO.findByField(identifyingField, annotationId); annotation = AnnotationRetrievalHelper.getCurrentAnnotation(annotation, annotationList); annotation.setUniqueId(uniqueId); annotation.setDiseaseAnnotationSubject(agm); + UniqueIdentifierHelper.setObsoleteAndInternal(dto, annotation); if (dataProvider != null && (dataProvider.name().equals("RGD") || dataProvider.name().equals("HUMAN")) diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AffectedGenomicModelDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AffectedGenomicModelDTOValidator.java index 7be172abf..d7e90003a 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AffectedGenomicModelDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AffectedGenomicModelDTOValidator.java @@ -5,6 +5,7 @@ import org.alliancegenome.curation_api.dao.AffectedGenomicModelDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.AffectedGenomicModel; import org.alliancegenome.curation_api.model.entities.VocabularyTerm; import org.alliancegenome.curation_api.model.ingest.dto.AffectedGenomicModelDTO; @@ -25,7 +26,7 @@ public class AffectedGenomicModelDTOValidator extends BaseDTOValidator { private ObjectResponse agmResponse = new ObjectResponse(); - public AffectedGenomicModel validateAffectedGenomicModelDTO(AffectedGenomicModelDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { + public AffectedGenomicModel validateAffectedGenomicModelDTO(AffectedGenomicModelDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { AffectedGenomicModel agm = null; if (StringUtils.isNotBlank(dto.getModEntityId())) { diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDTOValidator.java index b4c5a1d55..2660db0cd 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDTOValidator.java @@ -11,6 +11,7 @@ import org.alliancegenome.curation_api.dao.ReferenceDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.Allele; import org.alliancegenome.curation_api.model.entities.Note; import org.alliancegenome.curation_api.model.entities.Reference; @@ -79,7 +80,7 @@ public class AlleleDTOValidator extends BaseDTOValidator { private ObjectResponse alleleResponse; @Transactional - public Allele validateAlleleDTO(AlleleDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { + public Allele validateAlleleDTO(AlleleDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { alleleResponse = new ObjectResponse<>(); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDiseaseAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDiseaseAnnotationDTOValidator.java index 69c1ad33f..ce5040175 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDiseaseAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AlleleDiseaseAnnotationDTOValidator.java @@ -8,6 +8,7 @@ import org.alliancegenome.curation_api.dao.AlleleDiseaseAnnotationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.Allele; import org.alliancegenome.curation_api.model.entities.AlleleDiseaseAnnotation; import org.alliancegenome.curation_api.model.entities.Gene; @@ -19,6 +20,7 @@ import org.alliancegenome.curation_api.services.AlleleService; import org.alliancegenome.curation_api.services.GeneService; import org.alliancegenome.curation_api.services.VocabularyTermService; +import org.alliancegenome.curation_api.services.helpers.UniqueIdentifierHelper; import org.alliancegenome.curation_api.services.helpers.annotations.AnnotationRetrievalHelper; import org.alliancegenome.curation_api.services.helpers.annotations.AnnotationUniqueIdHelper; import org.apache.commons.collections.CollectionUtils; @@ -35,7 +37,7 @@ public class AlleleDiseaseAnnotationDTOValidator extends DiseaseAnnotationDTOVal @Inject GeneService geneService; @Inject VocabularyTermService vocabularyTermService; - public AlleleDiseaseAnnotation validateAlleleDiseaseAnnotationDTO(AlleleDiseaseAnnotationDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { + public AlleleDiseaseAnnotation validateAlleleDiseaseAnnotationDTO(AlleleDiseaseAnnotationDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { AlleleDiseaseAnnotation annotation = new AlleleDiseaseAnnotation(); Allele allele; @@ -53,27 +55,15 @@ public AlleleDiseaseAnnotation validateAlleleDiseaseAnnotationDTO(AlleleDiseaseA if (allele == null) { adaResponse.addErrorMessage("allele_identifier", ValidationConstants.INVALID_MESSAGE + " (" + dto.getAlleleIdentifier() + ")"); } else { - String annotationId; - String identifyingField; String uniqueId = AnnotationUniqueIdHelper.getDiseaseAnnotationUniqueId(dto, dto.getAlleleIdentifier(), refCurie); - - if (StringUtils.isNotBlank(dto.getModEntityId())) { - annotationId = dto.getModEntityId(); - annotation.setModEntityId(annotationId); - identifyingField = "modEntityId"; - } else if (StringUtils.isNotBlank(dto.getModInternalId())) { - annotationId = dto.getModInternalId(); - annotation.setModInternalId(annotationId); - identifyingField = "modInternalId"; - } else { - annotationId = uniqueId; - identifyingField = "uniqueId"; - } + String annotationId = UniqueIdentifierHelper.setAnnotationID(dto, annotation, uniqueId); + String identifyingField = UniqueIdentifierHelper.getIdentifyingField(dto); SearchResponse annotationList = alleleDiseaseAnnotationDAO.findByField(identifyingField, annotationId); annotation = AnnotationRetrievalHelper.getCurrentAnnotation(annotation, annotationList); annotation.setUniqueId(uniqueId); annotation.setDiseaseAnnotationSubject(allele); + UniqueIdentifierHelper.setObsoleteAndInternal(dto, annotation); if (dataProvider != null && (dataProvider.name().equals("RGD") || dataProvider.name().equals("HUMAN")) diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AnnotationDTOValidator.java index 6f7026b73..5044fed15 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/AnnotationDTOValidator.java @@ -10,11 +10,7 @@ import org.alliancegenome.curation_api.dao.ConditionRelationDAO; import org.alliancegenome.curation_api.dao.DataProviderDAO; import org.alliancegenome.curation_api.dao.NoteDAO; -import org.alliancegenome.curation_api.model.entities.Annotation; -import org.alliancegenome.curation_api.model.entities.ConditionRelation; -import org.alliancegenome.curation_api.model.entities.DataProvider; -import org.alliancegenome.curation_api.model.entities.Note; -import org.alliancegenome.curation_api.model.entities.Reference; +import org.alliancegenome.curation_api.model.entities.*; import org.alliancegenome.curation_api.model.ingest.dto.AnnotationDTO; import org.alliancegenome.curation_api.model.ingest.dto.ConditionRelationDTO; import org.alliancegenome.curation_api.response.ObjectResponse; @@ -141,4 +137,6 @@ public ObjectResponse validat aResponse.setEntity(annotation); return aResponse; } + + } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ConstructDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ConstructDTOValidator.java index 667802e52..520135291 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ConstructDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ConstructDTOValidator.java @@ -9,6 +9,7 @@ import org.alliancegenome.curation_api.dao.ConstructDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.Construct; import org.alliancegenome.curation_api.model.entities.Reference; import org.alliancegenome.curation_api.model.entities.slotAnnotations.constructSlotAnnotations.ConstructComponentSlotAnnotation; @@ -20,6 +21,7 @@ import org.alliancegenome.curation_api.model.ingest.dto.slotAnnotions.constructSlotAnnotations.ConstructComponentSlotAnnotationDTO; import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.response.SearchResponse; +import org.alliancegenome.curation_api.services.helpers.UniqueIdentifierHelper; import org.alliancegenome.curation_api.services.helpers.constructs.ConstructUniqueIdHelper; import org.alliancegenome.curation_api.services.helpers.slotAnnotations.SlotAnnotationIdentityHelper; import org.alliancegenome.curation_api.services.validation.dto.slotAnnotations.constructSlotAnnotations.ConstructComponentSlotAnnotationDTOValidator; @@ -27,7 +29,6 @@ import org.alliancegenome.curation_api.services.validation.dto.slotAnnotations.constructSlotAnnotations.ConstructSymbolSlotAnnotationDTOValidator; import org.alliancegenome.curation_api.services.validation.dto.slotAnnotations.constructSlotAnnotations.ConstructSynonymSlotAnnotationDTOValidator; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; import jakarta.enterprise.context.RequestScoped; import jakarta.inject.Inject; @@ -46,27 +47,15 @@ public class ConstructDTOValidator extends ReagentDTOValidator { private ObjectResponse constructResponse; @Transactional - public Construct validateConstructDTO(ConstructDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { + public Construct validateConstructDTO(ConstructDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { - constructResponse = new ObjectResponse(); + constructResponse = new ObjectResponse<>(); Construct construct = new Construct(); - String constructId; - String identifyingField; String uniqueId = ConstructUniqueIdHelper.getConstructUniqueId(dto); - - if (StringUtils.isNotBlank(dto.getModEntityId())) { - constructId = dto.getModEntityId(); - construct.setModEntityId(constructId); - identifyingField = "modEntityId"; - } else if (StringUtils.isNotBlank(dto.getModInternalId())) { - constructId = dto.getModInternalId(); - construct.setModInternalId(constructId); - identifyingField = "modInternalId"; - } else { - constructId = uniqueId; - identifyingField = "uniqueId"; - } + String constructId = UniqueIdentifierHelper.setAnnotationID(dto, construct, uniqueId); + String identifyingField = UniqueIdentifierHelper.getIdentifyingField(dto); + UniqueIdentifierHelper.setObsoleteAndInternal(dto, construct); SearchResponse constructList = constructDAO.findByField(identifyingField, constructId); if (constructList != null && constructList.getResults().size() > 0) { diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/DiseaseAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/DiseaseAnnotationDTOValidator.java index 522038733..59f6552fb 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/DiseaseAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/DiseaseAnnotationDTOValidator.java @@ -1,17 +1,12 @@ package org.alliancegenome.curation_api.services.validation.dto; -import java.util.ArrayList; -import java.util.List; - +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; import org.alliancegenome.curation_api.constants.OntologyConstants; import org.alliancegenome.curation_api.constants.ValidationConstants; import org.alliancegenome.curation_api.constants.VocabularyConstants; import org.alliancegenome.curation_api.dao.DataProviderDAO; -import org.alliancegenome.curation_api.model.entities.BiologicalEntity; -import org.alliancegenome.curation_api.model.entities.DataProvider; -import org.alliancegenome.curation_api.model.entities.DiseaseAnnotation; -import org.alliancegenome.curation_api.model.entities.Gene; -import org.alliancegenome.curation_api.model.entities.VocabularyTerm; +import org.alliancegenome.curation_api.model.entities.*; import org.alliancegenome.curation_api.model.entities.ontology.DOTerm; import org.alliancegenome.curation_api.model.entities.ontology.ECOTerm; import org.alliancegenome.curation_api.model.ingest.dto.DiseaseAnnotationDTO; @@ -25,20 +20,28 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import jakarta.enterprise.context.RequestScoped; -import jakarta.inject.Inject; +import java.util.ArrayList; +import java.util.List; @RequestScoped public class DiseaseAnnotationDTOValidator extends AnnotationDTOValidator { - @Inject DoTermService doTermService; - @Inject EcoTermService ecoTermService; - @Inject ReferenceService referenceService; - @Inject VocabularyTermService vocabularyTermService; - @Inject GeneService geneService; - @Inject BiologicalEntityService biologicalEntityService; - @Inject DataProviderDTOValidator dataProviderDtoValidator; - @Inject DataProviderDAO dataProviderDAO; + @Inject + DoTermService doTermService; + @Inject + EcoTermService ecoTermService; + @Inject + ReferenceService referenceService; + @Inject + VocabularyTermService vocabularyTermService; + @Inject + GeneService geneService; + @Inject + BiologicalEntityService biologicalEntityService; + @Inject + DataProviderDTOValidator dataProviderDtoValidator; + @Inject + DataProviderDAO dataProviderDAO; public ObjectResponse validateDiseaseAnnotationDTO(E annotation, D dto) { ObjectResponse daResponse = validateAnnotationDTO(annotation, dto, VocabularyConstants.DISEASE_ANNOTATION_NOTE_TYPES_VOCABULARY_TERM_SET); @@ -132,20 +135,34 @@ public ObjectRespo if (diseaseGeneticModifierRelation == null) { daResponse.addErrorMessage("disease_genetic_modifier_relation_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getDiseaseGeneticModifierRelationName() + ")"); } - List diseaseGeneticModifiers = new ArrayList<>(); + List diseaseGeneticModifierGenes = new ArrayList<>(); + List diseaseGeneticModifierAlleles = new ArrayList<>(); + List diseaseGeneticModifierAgms = new ArrayList<>(); for (String modifierIdentifier : dto.getDiseaseGeneticModifierIdentifiers()) { BiologicalEntity diseaseGeneticModifier = biologicalEntityService.findByIdentifierString(modifierIdentifier); if (diseaseGeneticModifier == null) { daResponse.addErrorMessage("disease_genetic_modifier_identifiers", ValidationConstants.INVALID_MESSAGE + " (" + modifierIdentifier + ")"); } else { - diseaseGeneticModifiers.add(diseaseGeneticModifier); + if (diseaseGeneticModifier instanceof Gene) { + diseaseGeneticModifierGenes.add((Gene) diseaseGeneticModifier); + } else if (diseaseGeneticModifier instanceof Allele) { + diseaseGeneticModifierAlleles.add((Allele) diseaseGeneticModifier); + } else if (diseaseGeneticModifier instanceof AffectedGenomicModel) { + diseaseGeneticModifierAgms.add((AffectedGenomicModel) diseaseGeneticModifier); + } else { + daResponse.addErrorMessage("disease_genetic_modifier_identifiers", ValidationConstants.INVALID_MESSAGE + " (" + modifierIdentifier + ")"); + } } } - annotation.setDiseaseGeneticModifiers(diseaseGeneticModifiers); + annotation.setDiseaseGeneticModifierGenes(diseaseGeneticModifierGenes); + annotation.setDiseaseGeneticModifierAlleles(diseaseGeneticModifierAlleles); + annotation.setDiseaseGeneticModifierAgms(diseaseGeneticModifierAgms); annotation.setDiseaseGeneticModifierRelation(diseaseGeneticModifierRelation); } } else { - annotation.setDiseaseGeneticModifiers(null); + annotation.setDiseaseGeneticModifierGenes(null); + annotation.setDiseaseGeneticModifierAlleles(null); + annotation.setDiseaseGeneticModifierAgms(null); annotation.setDiseaseGeneticModifierRelation(null); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/GeneDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/GeneDTOValidator.java index fb7fedd13..697c82b0a 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/GeneDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/GeneDTOValidator.java @@ -9,6 +9,7 @@ import org.alliancegenome.curation_api.dao.GeneDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.Gene; import org.alliancegenome.curation_api.model.entities.ontology.SOTerm; import org.alliancegenome.curation_api.model.entities.slotAnnotations.geneSlotAnnotations.GeneFullNameSlotAnnotation; @@ -51,7 +52,7 @@ public class GeneDTOValidator extends BaseDTOValidator { private ObjectResponse geneResponse; @Transactional - public Gene validateGeneDTO(GeneDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { + public Gene validateGeneDTO(GeneDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { geneResponse = new ObjectResponse(); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/GeneDiseaseAnnotationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/GeneDiseaseAnnotationDTOValidator.java index 0b54f7f96..3cc48b120 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/GeneDiseaseAnnotationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/GeneDiseaseAnnotationDTOValidator.java @@ -7,16 +7,13 @@ import org.alliancegenome.curation_api.dao.NoteDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; -import org.alliancegenome.curation_api.model.entities.AffectedGenomicModel; -import org.alliancegenome.curation_api.model.entities.Gene; -import org.alliancegenome.curation_api.model.entities.GeneDiseaseAnnotation; -import org.alliancegenome.curation_api.model.entities.Reference; -import org.alliancegenome.curation_api.model.entities.VocabularyTerm; +import org.alliancegenome.curation_api.model.entities.*; import org.alliancegenome.curation_api.model.ingest.dto.GeneDiseaseAnnotationDTO; import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.response.SearchResponse; import org.alliancegenome.curation_api.services.AffectedGenomicModelService; import org.alliancegenome.curation_api.services.VocabularyTermService; +import org.alliancegenome.curation_api.services.helpers.UniqueIdentifierHelper; import org.alliancegenome.curation_api.services.helpers.annotations.AnnotationRetrievalHelper; import org.alliancegenome.curation_api.services.helpers.annotations.AnnotationUniqueIdHelper; import org.apache.commons.lang3.StringUtils; @@ -36,7 +33,7 @@ public class GeneDiseaseAnnotationDTOValidator extends DiseaseAnnotationDTOValid public GeneDiseaseAnnotation validateGeneDiseaseAnnotationDTO(GeneDiseaseAnnotationDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { GeneDiseaseAnnotation annotation = new GeneDiseaseAnnotation(); Gene gene; - ObjectResponse gdaResponse = new ObjectResponse(); + ObjectResponse gdaResponse = new ObjectResponse<>(); ObjectResponse refResponse = validateReference(annotation, dto); gdaResponse.addErrorMessages(refResponse.getErrorMessages()); @@ -51,27 +48,16 @@ public GeneDiseaseAnnotation validateGeneDiseaseAnnotationDTO(GeneDiseaseAnnotat if (gene == null) { gdaResponse.addErrorMessage("gene_identifier", ValidationConstants.INVALID_MESSAGE + " (" + dto.getGeneIdentifier() + ")"); } else { - String annotationId; - String identifyingField; String uniqueId = AnnotationUniqueIdHelper.getDiseaseAnnotationUniqueId(dto, dto.getGeneIdentifier(), refCurie); - - if (StringUtils.isNotBlank(dto.getModEntityId())) { - annotationId = dto.getModEntityId(); - annotation.setModEntityId(annotationId); - identifyingField = "modEntityId"; - } else if (StringUtils.isNotBlank(dto.getModInternalId())) { - annotationId = dto.getModInternalId(); - annotation.setModInternalId(annotationId); - identifyingField = "modInternalId"; - } else { - annotationId = uniqueId; - identifyingField = "uniqueId"; - } + String annotationId = UniqueIdentifierHelper.setAnnotationID(dto, annotation, uniqueId); + String identifyingField = UniqueIdentifierHelper.getIdentifyingField(dto); SearchResponse annotationList = geneDiseaseAnnotationDAO.findByField(identifyingField, annotationId); annotation = AnnotationRetrievalHelper.getCurrentAnnotation(annotation, annotationList); annotation.setUniqueId(uniqueId); annotation.setDiseaseAnnotationSubject(gene); + UniqueIdentifierHelper.setObsoleteAndInternal(dto, annotation); + if (dataProvider != null && (dataProvider.name().equals("RGD") || dataProvider.name().equals("HUMAN")) && !gene.getTaxon().getCurie().equals(dataProvider.canonicalTaxonCurie) || !dataProvider.sourceOrganization.equals(gene.getDataProvider().getSourceOrganization().getAbbreviation())) { @@ -111,4 +97,5 @@ public GeneDiseaseAnnotation validateGeneDiseaseAnnotationDTO(GeneDiseaseAnnotat return annotation; } + } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/Gff3DtoValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/Gff3DtoValidator.java index a89ff1654..430cec249 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/Gff3DtoValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/Gff3DtoValidator.java @@ -1,28 +1,38 @@ package org.alliancegenome.curation_api.services.validation.dto; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.alliancegenome.curation_api.constants.EntityFieldConstants; import org.alliancegenome.curation_api.constants.Gff3Constants; import org.alliancegenome.curation_api.constants.ValidationConstants; +import org.alliancegenome.curation_api.constants.VocabularyConstants; import org.alliancegenome.curation_api.dao.CodingSequenceDAO; import org.alliancegenome.curation_api.dao.ExonDAO; import org.alliancegenome.curation_api.dao.TranscriptDAO; import org.alliancegenome.curation_api.dao.associations.codingSequenceAssociations.CodingSequenceGenomicLocationAssociationDAO; import org.alliancegenome.curation_api.dao.associations.exonAssociations.ExonGenomicLocationAssociationDAO; +import org.alliancegenome.curation_api.dao.associations.transcriptAssociations.TranscriptCodingSequenceAssociationDAO; +import org.alliancegenome.curation_api.dao.associations.transcriptAssociations.TranscriptExonAssociationDAO; +import org.alliancegenome.curation_api.dao.associations.transcriptAssociations.TranscriptGeneAssociationDAO; import org.alliancegenome.curation_api.dao.associations.transcriptAssociations.TranscriptGenomicLocationAssociationDAO; import org.alliancegenome.curation_api.dao.ontology.SoTermDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.AssemblyComponent; import org.alliancegenome.curation_api.model.entities.CodingSequence; import org.alliancegenome.curation_api.model.entities.Exon; +import org.alliancegenome.curation_api.model.entities.Gene; import org.alliancegenome.curation_api.model.entities.GenomicEntity; import org.alliancegenome.curation_api.model.entities.LocationAssociation; import org.alliancegenome.curation_api.model.entities.Transcript; import org.alliancegenome.curation_api.model.entities.associations.codingSequenceAssociations.CodingSequenceGenomicLocationAssociation; import org.alliancegenome.curation_api.model.entities.associations.exonAssociations.ExonGenomicLocationAssociation; +import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptCodingSequenceAssociation; +import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptExonAssociation; +import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptGeneAssociation; import org.alliancegenome.curation_api.model.entities.associations.transcriptAssociations.TranscriptGenomicLocationAssociation; import org.alliancegenome.curation_api.model.entities.ontology.SOTerm; import org.alliancegenome.curation_api.model.ingest.dto.fms.Gff3DTO; @@ -30,9 +40,9 @@ import org.alliancegenome.curation_api.response.SearchResponse; import org.alliancegenome.curation_api.services.AssemblyComponentService; import org.alliancegenome.curation_api.services.DataProviderService; +import org.alliancegenome.curation_api.services.GeneService; import org.alliancegenome.curation_api.services.Gff3Service; import org.alliancegenome.curation_api.services.VocabularyTermService; -import org.alliancegenome.curation_api.services.helpers.gff3.Gff3AttributesHelper; import org.alliancegenome.curation_api.services.helpers.gff3.Gff3UniqueIdHelper; import org.alliancegenome.curation_api.services.ontology.NcbiTaxonTermService; import org.apache.commons.lang3.StringUtils; @@ -47,8 +57,12 @@ public class Gff3DtoValidator { @Inject ExonDAO exonDAO; @Inject TranscriptDAO transcriptDAO; @Inject CodingSequenceDAO codingSequenceDAO; + @Inject GeneService geneService; @Inject ExonGenomicLocationAssociationDAO exonLocationDAO; @Inject TranscriptGenomicLocationAssociationDAO transcriptLocationDAO; + @Inject TranscriptGeneAssociationDAO transcriptGeneDAO; + @Inject TranscriptExonAssociationDAO transcriptExonDAO; + @Inject TranscriptCodingSequenceAssociationDAO transcriptCdsDAO; @Inject CodingSequenceGenomicLocationAssociationDAO cdsLocationDAO; @Inject AssemblyComponentService assemblyComponentService; @Inject DataProviderService dataProviderService; @@ -58,11 +72,14 @@ public class Gff3DtoValidator { @Inject VocabularyTermService vocabularyTermService; @Transactional - public Exon validateExonEntry(Gff3DTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { + public void validateExonEntry(Gff3DTO dto, Map attributes, List idsAdded, BackendBulkDataProvider dataProvider) throws ValidationException { Exon exon = null; + + if (!StringUtils.equals(dto.getType(), "exon") && !StringUtils.equals(dto.getType(), "noncoding_exon")) { + throw new ObjectValidationException(dto, "Invalid Type: " + dto.getType() + " for Exon Entity"); + } - Map attributes = Gff3AttributesHelper.getAttributes(dto, dataProvider); String uniqueId = Gff3UniqueIdHelper.getExonOrCodingSequenceUniqueId(dto, attributes, dataProvider); SearchResponse searchResponse = exonDAO.findByField("uniqueId", uniqueId); if (searchResponse != null && searchResponse.getSingleResult() != null) { @@ -76,21 +93,27 @@ public Exon validateExonEntry(Gff3DTO dto, BackendBulkDataProvider dataProvider) exon.setName(attributes.get("Name")); } - ObjectResponse exonResponse = validateGffEntity(exon, dto, attributes, dataProvider); + ObjectResponse exonResponse = validateGenomicEntity(exon, dto, attributes, dataProvider); if (exonResponse.hasErrors()) { throw new ObjectValidationException(dto, exonResponse.errorMessagesString()); } - return exonDAO.persist(exonResponse.getEntity()); + exon = exonDAO.persist(exonResponse.getEntity()); + if (exon != null) { + idsAdded.add(exon.getId()); + } } @Transactional - public CodingSequence validateCdsEntry(Gff3DTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { + public void validateCdsEntry(Gff3DTO dto, Map attributes, List idsAdded, BackendBulkDataProvider dataProvider) throws ValidationException { CodingSequence cds = null; - Map attributes = Gff3AttributesHelper.getAttributes(dto, dataProvider); + if (!StringUtils.equals(dto.getType(), "CDS")) { + throw new ObjectValidationException(dto, "Invalid Type: " + dto.getType() + " for CDS Entity"); + } + String uniqueId = Gff3UniqueIdHelper.getExonOrCodingSequenceUniqueId(dto, attributes, dataProvider); SearchResponse searchResponse = codingSequenceDAO.findByField("uniqueId", uniqueId); if (searchResponse != null && searchResponse.getSingleResult() != null) { @@ -104,21 +127,26 @@ public CodingSequence validateCdsEntry(Gff3DTO dto, BackendBulkDataProvider data cds.setName(attributes.get("Name")); } - ObjectResponse cdsResponse = validateGffEntity(cds, dto, attributes, dataProvider); + ObjectResponse cdsResponse = validateGenomicEntity(cds, dto, attributes, dataProvider); if (cdsResponse.hasErrors()) { throw new ObjectValidationException(dto, cdsResponse.errorMessagesString()); } - return codingSequenceDAO.persist(cdsResponse.getEntity()); + cds = codingSequenceDAO.persist(cdsResponse.getEntity()); + if (cds != null) { + idsAdded.add(cds.getId()); + } } @Transactional - public Transcript validateTranscriptEntry(Gff3DTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { + public void validateTranscriptEntry(Gff3DTO dto, Map attributes, List idsAdded, BackendBulkDataProvider dataProvider) throws ValidationException { + + if (!Gff3Constants.TRANSCRIPT_TYPES.contains(dto.getType())) { + throw new ObjectValidationException(dto, "Invalid Type: " + dto.getType() + " for Transcript Entity"); + } Transcript transcript = null; - - Map attributes = Gff3AttributesHelper.getAttributes(dto, dataProvider); if (attributes.containsKey("ID")) { SearchResponse searchResponse = transcriptDAO.findByField("modInternalId", attributes.get("ID")); if (searchResponse != null && searchResponse.getSingleResult() != null) { @@ -138,7 +166,7 @@ public Transcript validateTranscriptEntry(Gff3DTO dto, BackendBulkDataProvider d transcript.setName(attributes.get("Name")); } - ObjectResponse transcriptResponse = validateGffEntity(transcript, dto, attributes, dataProvider); + ObjectResponse transcriptResponse = validateGenomicEntity(transcript, dto, attributes, dataProvider); if (!attributes.containsKey("ID")) { transcriptResponse.addErrorMessage("attributes - ID", ValidationConstants.REQUIRED_MESSAGE); } @@ -147,13 +175,16 @@ public Transcript validateTranscriptEntry(Gff3DTO dto, BackendBulkDataProvider d throw new ObjectValidationException(dto, transcriptResponse.errorMessagesString()); } - return transcriptDAO.persist(transcriptResponse.getEntity()); + transcript = transcriptDAO.persist(transcriptResponse.getEntity()); + if (transcript != null) { + idsAdded.add(transcript.getId()); + } } - private ObjectResponse validateGffEntity(E entity, Gff3DTO dto, Map attributes, BackendBulkDataProvider dataProvider) { + private ObjectResponse validateGenomicEntity(E entity, Gff3DTO dto, Map attributes, BackendBulkDataProvider dataProvider) { ObjectResponse geResponse = new ObjectResponse(); - entity.setDataProvider(dataProviderService.createOrganizationDataProvider(dataProvider.sourceOrganization)); + entity.setDataProvider(dataProviderService.getDefaultDataProvider(dataProvider.sourceOrganization)); entity.setTaxon(ncbiTaxonTermService.getByCurie(dataProvider.canonicalTaxonCurie).getEntity()); geResponse.setEntity(entity); @@ -166,10 +197,10 @@ public CodingSequenceGenomicLocationAssociation validateCdsLocation(Gff3DTO gffE AssemblyComponent assemblyComponent = null; CodingSequenceGenomicLocationAssociation locationAssociation = new CodingSequenceGenomicLocationAssociation(); if (StringUtils.isNotBlank(gffEntry.getSeqId())) { - assemblyComponent = assemblyComponentService.fetchOrCreate(gffEntry.getSeqId(), assemblyId, dataProvider.canonicalTaxonCurie, dataProvider.sourceOrganization); + assemblyComponent = assemblyComponentService.fetchOrCreate(gffEntry.getSeqId(), assemblyId, dataProvider.canonicalTaxonCurie, dataProvider); Map params = new HashMap<>(); params.put(EntityFieldConstants.CODING_SEQUENCE_ASSOCIATION_SUBJECT + ".id", cds.getId()); - params.put(EntityFieldConstants.CODING_SEQUENCE_GENOMIC_LOCATION_ASSOCIATION_OBJECT, assemblyComponent.getName()); + params.put(EntityFieldConstants.CODING_SEQUENCE_GENOMIC_LOCATION_ASSOCIATION_OBJECT + ".name", assemblyComponent.getName()); params.put(EntityFieldConstants.CODING_SEQUENCE_GENOMIC_LOCATION_ASSOCIATION_OBJECT_ASSEMBLY, assemblyId); SearchResponse locationSearchResponse = cdsLocationDAO.findByParams(params); if (locationSearchResponse != null && locationSearchResponse.getSingleResult() != null) { @@ -194,10 +225,10 @@ public ExonGenomicLocationAssociation validateExonLocation(Gff3DTO gffEntry, Exo AssemblyComponent assemblyComponent = null; ExonGenomicLocationAssociation locationAssociation = new ExonGenomicLocationAssociation(); if (StringUtils.isNotBlank(gffEntry.getSeqId())) { - assemblyComponent = assemblyComponentService.fetchOrCreate(gffEntry.getSeqId(), assemblyId, dataProvider.canonicalTaxonCurie, dataProvider.sourceOrganization); + assemblyComponent = assemblyComponentService.fetchOrCreate(gffEntry.getSeqId(), assemblyId, dataProvider.canonicalTaxonCurie, dataProvider); Map params = new HashMap<>(); params.put(EntityFieldConstants.EXON_ASSOCIATION_SUBJECT + ".id", exon.getId()); - params.put(EntityFieldConstants.EXON_GENOMIC_LOCATION_ASSOCIATION_OBJECT, assemblyComponent.getName()); + params.put(EntityFieldConstants.EXON_GENOMIC_LOCATION_ASSOCIATION_OBJECT + ".name", assemblyComponent.getName()); params.put(EntityFieldConstants.EXON_GENOMIC_LOCATION_ASSOCIATION_OBJECT_ASSEMBLY, assemblyId); SearchResponse locationSearchResponse = exonLocationDAO.findByParams(params); if (locationSearchResponse != null && locationSearchResponse.getSingleResult() != null) { @@ -221,7 +252,7 @@ public TranscriptGenomicLocationAssociation validateTranscriptLocation(Gff3DTO g AssemblyComponent assemblyComponent = null; TranscriptGenomicLocationAssociation locationAssociation = new TranscriptGenomicLocationAssociation(); if (StringUtils.isNotBlank(gffEntry.getSeqId())) { - assemblyComponent = assemblyComponentService.fetchOrCreate(gffEntry.getSeqId(), assemblyId, dataProvider.canonicalTaxonCurie, dataProvider.sourceOrganization); + assemblyComponent = assemblyComponentService.fetchOrCreate(gffEntry.getSeqId(), assemblyId, dataProvider.canonicalTaxonCurie, dataProvider); Map params = new HashMap<>(); params.put(EntityFieldConstants.TRANSCRIPT_ASSOCIATION_SUBJECT + ".id", transcript.getId()); params.put(EntityFieldConstants.TRANSCRIPT_GENOMIC_LOCATION_ASSOCIATION_OBJECT_ASSEMBLY, assemblyId); @@ -243,10 +274,114 @@ public TranscriptGenomicLocationAssociation validateTranscriptLocation(Gff3DTO g return transcriptLocationDAO.persist(locationResponse.getEntity()); } + @Transactional + public TranscriptGeneAssociation validateTranscriptGeneAssociation(Gff3DTO gffEntry, Transcript transcript, Map attributes, Map geneIdCurieMap) throws ObjectValidationException { + TranscriptGeneAssociation association = new TranscriptGeneAssociation(); + boolean newAssociation = true; + ObjectResponse associationResponse = new ObjectResponse(); + if (!attributes.containsKey("Parent")) { + associationResponse.addErrorMessage("Attributes - Parent", ValidationConstants.REQUIRED_MESSAGE); + } else { + String geneCurie = geneIdCurieMap.containsKey(attributes.get("Parent")) ? geneIdCurieMap.get(attributes.get("Parent")) : attributes.get("Parent"); + Gene parentGene = geneService.findByIdentifierString(geneCurie); + if (parentGene == null) { + associationResponse.addErrorMessage("Attributes - Parent", ValidationConstants.INVALID_MESSAGE + " (" + attributes.get("Parent") + ")"); + } else { + Map params = new HashMap<>(); + params.put(EntityFieldConstants.TRANSCRIPT_ASSOCIATION_SUBJECT + ".id", transcript.getId()); + params.put("transcriptGeneAssociationObject.id", parentGene.getId()); + SearchResponse searchResponse = transcriptGeneDAO.findByParams(params); + if (searchResponse != null && searchResponse.getSingleResult() != null) { + association = searchResponse.getSingleResult(); + newAssociation = false; + } + association.setTranscriptGeneAssociationObject(parentGene); + } + } + association.setTranscriptAssociationSubject(transcript); + association.setRelation(vocabularyTermService.getTermInVocabulary(VocabularyConstants.TRANSCRIPT_RELATION_VOCABULARY, VocabularyConstants.TRANSCRIPT_CHILD_TERM).getEntity()); + + if (associationResponse.hasErrors()) { + throw new ObjectValidationException(gffEntry, associationResponse.errorMessagesString()); + } + + if (newAssociation) { + return transcriptGeneDAO.persist(association); + } else { + return association; + } + } + + @Transactional + public TranscriptCodingSequenceAssociation validateTranscriptCodingSequenceAssociation(Gff3DTO gffEntry, CodingSequence cds, Map attributes) throws ObjectValidationException { + TranscriptCodingSequenceAssociation association = new TranscriptCodingSequenceAssociation(); + + ObjectResponse associationResponse = new ObjectResponse(); + if (!attributes.containsKey("Parent")) { + associationResponse.addErrorMessage("Attributes - Parent", ValidationConstants.REQUIRED_MESSAGE); + } else { + SearchResponse parentTranscriptSearch = transcriptDAO.findByField("modInternalId", attributes.get("Parent")); + if (parentTranscriptSearch == null || parentTranscriptSearch.getSingleResult() == null) { + associationResponse.addErrorMessage("Attributes - Parent", ValidationConstants.INVALID_MESSAGE + " (" + attributes.get("Parent") + ")"); + } else { + Transcript parentTranscript = parentTranscriptSearch.getSingleResult(); + Map params = new HashMap<>(); + params.put(EntityFieldConstants.TRANSCRIPT_ASSOCIATION_SUBJECT + ".id", parentTranscript.getId()); + params.put("transcriptCodingSequenceAssociationObject.id", cds.getId()); + SearchResponse searchResponse = transcriptCdsDAO.findByParams(params); + if (searchResponse != null && searchResponse.getSingleResult() != null) { + association = searchResponse.getSingleResult(); + } + association.setTranscriptAssociationSubject(parentTranscript); + } + } + association.setTranscriptCodingSequenceAssociationObject(cds); + association.setRelation(vocabularyTermService.getTermInVocabulary(VocabularyConstants.TRANSCRIPT_RELATION_VOCABULARY, VocabularyConstants.TRANSCRIPT_PARENT_TERM).getEntity()); + + if (associationResponse.hasErrors()) { + throw new ObjectValidationException(gffEntry, associationResponse.errorMessagesString()); + } + + return transcriptCdsDAO.persist(association); + } + + @Transactional + public TranscriptExonAssociation validateTranscriptExonAssociation(Gff3DTO gffEntry, Exon exon, Map attributes) throws ObjectValidationException { + TranscriptExonAssociation association = new TranscriptExonAssociation(); + + ObjectResponse associationResponse = new ObjectResponse(); + if (!attributes.containsKey("Parent")) { + associationResponse.addErrorMessage("Attributes - Parent", ValidationConstants.REQUIRED_MESSAGE); + } else { + SearchResponse parentTranscriptSearch = transcriptDAO.findByField("modInternalId", attributes.get("Parent")); + if (parentTranscriptSearch == null || parentTranscriptSearch.getSingleResult() == null) { + associationResponse.addErrorMessage("Attributes - Parent", ValidationConstants.INVALID_MESSAGE + " (" + attributes.get("Parent") + ")"); + } else { + Transcript parentTranscript = parentTranscriptSearch.getSingleResult(); + Map params = new HashMap<>(); + params.put(EntityFieldConstants.TRANSCRIPT_ASSOCIATION_SUBJECT + ".id", parentTranscript.getId()); + params.put("transcriptExonAssociationObject.id", exon.getId()); + SearchResponse searchResponse = transcriptExonDAO.findByParams(params); + if (searchResponse != null && searchResponse.getSingleResult() != null) { + association = searchResponse.getSingleResult(); + } + association.setTranscriptAssociationSubject(parentTranscript); + } + } + association.setTranscriptExonAssociationObject(exon); + association.setRelation(vocabularyTermService.getTermInVocabulary(VocabularyConstants.TRANSCRIPT_RELATION_VOCABULARY, VocabularyConstants.TRANSCRIPT_PARENT_TERM).getEntity()); + + if (associationResponse.hasErrors()) { + throw new ObjectValidationException(gffEntry, associationResponse.errorMessagesString()); + } + + return transcriptExonDAO.persist(association); + } + private ObjectResponse validateLocationAssociation(E association, Gff3DTO dto, AssemblyComponent assemblyComponent) { ObjectResponse associationResponse = new ObjectResponse(); - association.setRelation(vocabularyTermService.getTermInVocabulary("location_association_relation", "located_on").getEntity()); + association.setRelation(vocabularyTermService.getTermInVocabulary(VocabularyConstants.LOCATION_ASSOCIATION_RELATION_VOCABULARY, "located_on").getEntity()); if (assemblyComponent == null) { associationResponse.addErrorMessage("SeqId", ValidationConstants.REQUIRED_MESSAGE); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ResourceDescriptorDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ResourceDescriptorDTOValidator.java index 1ff2de6d3..3ffdbb6f4 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ResourceDescriptorDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/ResourceDescriptorDTOValidator.java @@ -8,6 +8,7 @@ import org.alliancegenome.curation_api.dao.ResourceDescriptorDAO; import org.alliancegenome.curation_api.dao.ResourceDescriptorPageDAO; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.ResourceDescriptor; import org.alliancegenome.curation_api.model.entities.ResourceDescriptorPage; import org.alliancegenome.curation_api.model.ingest.dto.ResourceDescriptorDTO; @@ -29,7 +30,7 @@ public class ResourceDescriptorDTOValidator extends BaseDTOValidator { @Inject ResourceDescriptorPageDAO resourceDescriptorPageDAO; @Inject ResourceDescriptorPageDTOValidator resourceDescriptorPageDtoValidator; - public ResourceDescriptor validateResourceDescriptorDTO(ResourceDescriptorDTO dto) throws ObjectValidationException { + public ResourceDescriptor validateResourceDescriptorDTO(ResourceDescriptorDTO dto) throws ValidationException { ObjectResponse rdResponse = new ObjectResponse(); ResourceDescriptor rd = null; diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/VariantDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/VariantDTOValidator.java index 73df6c086..134bbc2ea 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/VariantDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/VariantDTOValidator.java @@ -9,6 +9,7 @@ import org.alliancegenome.curation_api.dao.VariantDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.Note; import org.alliancegenome.curation_api.model.entities.Variant; import org.alliancegenome.curation_api.model.entities.VocabularyTerm; @@ -39,7 +40,7 @@ public class VariantDTOValidator extends BaseDTOValidator { private ObjectResponse variantResponse; @Transactional - public Variant validateVariantDTO(VariantDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { + public Variant validateVariantDTO(VariantDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { variantResponse = new ObjectResponse(); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java index eb3f098cc..bfd87c332 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleGeneAssociationDTOValidator.java @@ -8,6 +8,7 @@ import org.alliancegenome.curation_api.dao.associations.alleleAssociations.AlleleGeneAssociationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.Allele; import org.alliancegenome.curation_api.model.entities.Gene; import org.alliancegenome.curation_api.model.entities.VocabularyTerm; @@ -32,7 +33,7 @@ public class AlleleGeneAssociationDTOValidator extends AlleleGenomicEntityAssoci @Inject GeneService geneService; @Inject VocabularyTermService vocabularyTermService; - public AlleleGeneAssociation validateAlleleGeneAssociationDTO(AlleleGeneAssociationDTO dto, BackendBulkDataProvider beDataProvider) throws ObjectValidationException { + public AlleleGeneAssociation validateAlleleGeneAssociationDTO(AlleleGeneAssociationDTO dto, BackendBulkDataProvider beDataProvider) throws ValidationException { ObjectResponse agaResponse = new ObjectResponse(); List subjectIds = null; diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleVariantAssociationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleVariantAssociationDTOValidator.java new file mode 100644 index 000000000..48728f2fe --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/alleleAssociations/AlleleVariantAssociationDTOValidator.java @@ -0,0 +1,123 @@ +package org.alliancegenome.curation_api.services.validation.dto.associations.alleleAssociations; + +import java.util.HashMap; +import java.util.List; + +import org.alliancegenome.curation_api.constants.ValidationConstants; +import org.alliancegenome.curation_api.constants.VocabularyConstants; +import org.alliancegenome.curation_api.dao.associations.alleleAssociations.AlleleVariantAssociationDAO; +import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; +import org.alliancegenome.curation_api.model.entities.Allele; +import org.alliancegenome.curation_api.model.entities.Variant; +import org.alliancegenome.curation_api.model.entities.VocabularyTerm; +import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleVariantAssociation; +import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleGenomicEntityAssociation; +import org.alliancegenome.curation_api.model.ingest.dto.associations.alleleAssociations.AlleleVariantAssociationDTO; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.response.SearchResponse; +import org.alliancegenome.curation_api.services.AlleleService; +import org.alliancegenome.curation_api.services.VariantService; +import org.alliancegenome.curation_api.services.VocabularyTermService; +import org.apache.commons.lang3.StringUtils; + +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; + +@RequestScoped +public class AlleleVariantAssociationDTOValidator extends AlleleGenomicEntityAssociationDTOValidator { + + @Inject AlleleVariantAssociationDAO alleleVariantAssociationDAO; + @Inject AlleleService alleleService; + @Inject VariantService variantService; + @Inject VocabularyTermService vocabularyTermService; + + public AlleleVariantAssociation validateAlleleVariantAssociationDTO(AlleleVariantAssociationDTO dto, BackendBulkDataProvider beDataProvider) throws ValidationException { + ObjectResponse agaResponse = new ObjectResponse(); + + List subjectIds = null; + if (StringUtils.isBlank(dto.getAlleleIdentifier())) { + agaResponse.addErrorMessage("allele_identifier", ValidationConstants.REQUIRED_MESSAGE); + } else { + subjectIds = alleleService.findIdsByIdentifierString(dto.getAlleleIdentifier()); + if (subjectIds == null || subjectIds.size() != 1) { + agaResponse.addErrorMessage("allele_identifier", ValidationConstants.INVALID_MESSAGE + " (" + dto.getAlleleIdentifier() + ")"); + } + } + + List objectIds = null; + if (StringUtils.isBlank(dto.getVariantIdentifier())) { + agaResponse.addErrorMessage("variant_identifier", ValidationConstants.REQUIRED_MESSAGE); + } else { + objectIds = variantService.findIdsByIdentifierString(dto.getVariantIdentifier()); + if (objectIds == null || objectIds.size() != 1) { + agaResponse.addErrorMessage("variant_identifier", ValidationConstants.INVALID_MESSAGE + " (" + dto.getVariantIdentifier() + ")"); + } + } + + AlleleVariantAssociation association = null; + if (subjectIds != null && subjectIds.size() == 1 && objectIds != null || objectIds.size() == 1 && StringUtils.isNotBlank(dto.getRelationName())) { + HashMap params = new HashMap<>(); + + params.put("alleleAssociationSubject.id", subjectIds.get(0)); + params.put("relation.name", dto.getRelationName()); + params.put("alleleVariantAssociationObject.id", objectIds.get(0)); + + SearchResponse searchResponse = alleleVariantAssociationDAO.findByParams(params); + if (searchResponse != null && searchResponse.getResults().size() == 1) { + association = searchResponse.getSingleResult(); + } + } + + if (association == null) { + association = new AlleleVariantAssociation(); + } + + VocabularyTerm relation = null; + if (StringUtils.isNotEmpty(dto.getRelationName())) { + relation = vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.ALLELE_VARIANT_RELATION_VOCABULARY_TERM_SET, dto.getRelationName()).getEntity(); + if (relation == null) { + agaResponse.addErrorMessage("relation_name", ValidationConstants.INVALID_MESSAGE + " (" + dto.getRelationName() + ")"); + } + } else { + agaResponse.addErrorMessage("relation_name", ValidationConstants.REQUIRED_MESSAGE); + } + association.setRelation(relation); + + if (association.getAlleleAssociationSubject() == null && !StringUtils.isBlank(dto.getAlleleIdentifier())) { + + Allele subject = alleleService.findByIdentifierString(dto.getAlleleIdentifier()); + if (subject == null) { + agaResponse.addErrorMessage("allele_identifier", ValidationConstants.INVALID_MESSAGE + " (" + dto.getAlleleIdentifier() + ")"); + } else if (beDataProvider != null && !subject.getDataProvider().getSourceOrganization().getAbbreviation().equals(beDataProvider.sourceOrganization)) { + agaResponse.addErrorMessage("allele_identifier", ValidationConstants.INVALID_MESSAGE + " for " + beDataProvider.name() + " load (" + dto.getAlleleIdentifier() + ")"); + } else { + association.setAlleleAssociationSubject(subject); + } + } + + if (association.getAlleleVariantAssociationObject() == null && !StringUtils.isBlank(dto.getVariantIdentifier())) { + + Variant object = variantService.findByIdentifierString(dto.getVariantIdentifier()); + if (object == null) { + agaResponse.addErrorMessage("variant_identifier", ValidationConstants.INVALID_MESSAGE + " (" + dto.getVariantIdentifier() + ")"); + } else if (beDataProvider != null && !object.getDataProvider().getSourceOrganization().getAbbreviation().equals(beDataProvider.sourceOrganization)) { + agaResponse.addErrorMessage("variant_identifier", ValidationConstants.INVALID_MESSAGE + " for " + beDataProvider.name() + " load (" + dto.getVariantIdentifier() + ")"); + } else { + association.setAlleleVariantAssociationObject(object); + } + } + + ObjectResponse ageaResponse = validateAlleleGenomicEntityAssociationDTO(association, dto); + agaResponse.addErrorMessages(ageaResponse.getErrorMessages()); + association = (AlleleVariantAssociation) ageaResponse.getEntity(); + + if (agaResponse.hasErrors()) { + throw new ObjectValidationException(dto, agaResponse.errorMessagesString()); + } + + association = alleleVariantAssociationDAO.persist(association); + return association; + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTOValidator.java index 3899fccac..62f269466 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/associations/constructAssociations/ConstructGenomicEntityAssociationDTOValidator.java @@ -9,6 +9,7 @@ import org.alliancegenome.curation_api.dao.associations.constructAssociations.ConstructGenomicEntityAssociationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.Construct; import org.alliancegenome.curation_api.model.entities.GenomicEntity; import org.alliancegenome.curation_api.model.entities.Note; @@ -40,17 +41,16 @@ public class ConstructGenomicEntityAssociationDTOValidator extends EvidenceAssoc private ObjectResponse assocResponse; - public ConstructGenomicEntityAssociation validateConstructGenomicEntityAssociationDTO(ConstructGenomicEntityAssociationDTO dto, BackendBulkDataProvider beDataProvider) throws ObjectValidationException { + public ConstructGenomicEntityAssociation validateConstructGenomicEntityAssociationDTO(ConstructGenomicEntityAssociationDTO dto, BackendBulkDataProvider beDataProvider) throws ValidationException { - assocResponse = new ObjectResponse(); + assocResponse = new ObjectResponse<>(); Construct construct = null; if (StringUtils.isNotBlank(dto.getConstructIdentifier())) { - ObjectResponse constructResponse = constructService.getByIdentifier(dto.getConstructIdentifier()); - if (constructResponse == null || constructResponse.getEntity() == null) { + construct = constructService.getShallowEntity(constructService.getIdByModID(dto.getConstructIdentifier())); + if (construct == null) { assocResponse.addErrorMessage("construct_identifier", ValidationConstants.INVALID_MESSAGE); } else { - construct = constructResponse.getEntity(); if (beDataProvider != null && !construct.getDataProvider().getSourceOrganization().getAbbreviation().equals(beDataProvider.sourceOrganization)) { assocResponse.addErrorMessage("construct_identifier", ValidationConstants.INVALID_MESSAGE + " for " + beDataProvider.name() + " load"); } @@ -63,7 +63,7 @@ public ConstructGenomicEntityAssociation validateConstructGenomicEntityAssociati if (StringUtils.isBlank(dto.getGenomicEntityIdentifier())) { assocResponse.addErrorMessage("genomic_entity_identifier", ValidationConstants.REQUIRED_MESSAGE); } else { - genomicEntity = genomicEntityService.findByIdentifierString(dto.getGenomicEntityIdentifier()); + genomicEntity = genomicEntityService.getShallowEntity(genomicEntityService.getIdByModID(dto.getGenomicEntityIdentifier())); if (genomicEntity == null) { assocResponse.addErrorMessage("genomic_entity_identifier", ValidationConstants.INVALID_MESSAGE + " (" + dto.getGenomicEntityIdentifier() + ")"); } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/AGMPhenotypeAnnotationFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/AGMPhenotypeAnnotationFmsDTOValidator.java index 1b8763cc2..e421bb32b 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/AGMPhenotypeAnnotationFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/AGMPhenotypeAnnotationFmsDTOValidator.java @@ -8,6 +8,7 @@ import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.AGMPhenotypeAnnotation; import org.alliancegenome.curation_api.model.entities.AffectedGenomicModel; import org.alliancegenome.curation_api.model.entities.Allele; @@ -72,7 +73,7 @@ public AGMPhenotypeAnnotation validatePrimaryAnnotation(AffectedGenomicModel sub } - public List validateInferredOrAssertedEntities(AffectedGenomicModel primaryAnnotationSubject, PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { + public List validateInferredOrAssertedEntities(AffectedGenomicModel primaryAnnotationSubject, PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { ObjectResponse apaResponse = new ObjectResponse(); ObjectResponse refResponse = validateReference(dto); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/AllelePhenotypeAnnotationFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/AllelePhenotypeAnnotationFmsDTOValidator.java index 7a22d2fe8..19475c38a 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/AllelePhenotypeAnnotationFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/AllelePhenotypeAnnotationFmsDTOValidator.java @@ -8,6 +8,7 @@ import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.Allele; import org.alliancegenome.curation_api.model.entities.AllelePhenotypeAnnotation; import org.alliancegenome.curation_api.model.entities.Gene; @@ -69,7 +70,7 @@ public AllelePhenotypeAnnotation validatePrimaryAnnotation(Allele subject, Pheno } - public List validateInferredOrAssertedEntities(Allele primaryAnnotationSubject, PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { + public List validateInferredOrAssertedEntities(Allele primaryAnnotationSubject, PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { ObjectResponse apaResponse = new ObjectResponse(); ObjectResponse refResponse = validateReference(dto); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/CrossReferenceFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/CrossReferenceFmsDTOValidator.java new file mode 100644 index 000000000..a5606a08f --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/CrossReferenceFmsDTOValidator.java @@ -0,0 +1,70 @@ +package org.alliancegenome.curation_api.services.validation.dto.fms; + +import java.util.ArrayList; +import java.util.List; + +import org.alliancegenome.curation_api.constants.ValidationConstants; +import org.alliancegenome.curation_api.model.entities.CrossReference; +import org.alliancegenome.curation_api.model.entities.ResourceDescriptor; +import org.alliancegenome.curation_api.model.entities.ResourceDescriptorPage; +import org.alliancegenome.curation_api.model.ingest.dto.fms.CrossReferenceFmsDTO; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.services.ResourceDescriptorPageService; +import org.alliancegenome.curation_api.services.ResourceDescriptorService; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; + +@RequestScoped +public class CrossReferenceFmsDTOValidator { + + @Inject ResourceDescriptorService resourceDescriptorService; + @Inject ResourceDescriptorPageService resourceDescriptorPageService; + + public ObjectResponse> validateCrossReferenceFmsDTO(CrossReferenceFmsDTO dto) { + + ObjectResponse> crResponse = new ObjectResponse<>(); + List xrefList = new ArrayList<>(); + List pageNames = List.of("default"); + + if (CollectionUtils.isNotEmpty(dto.getPages())) { + pageNames = dto.getPages(); + } + + for (String pageName : pageNames) { + CrossReference xref = new CrossReference(); + + if (StringUtils.isBlank(dto.getId())) { + crResponse.addErrorMessage("id", ValidationConstants.REQUIRED_MESSAGE); + } else { + String[] idParts = dto.getId().split(":"); + ResourceDescriptor resourceDescriptor = null; + if (idParts.length == 2) { + ObjectResponse rdResponse = resourceDescriptorService.getByPrefixOrSynonym(idParts[0]); + if (rdResponse != null) { + resourceDescriptor = rdResponse.getEntity(); + } + } + if (resourceDescriptor == null) { + crResponse.addErrorMessage("id", ValidationConstants.INVALID_MESSAGE + " (" + dto.getId() + ")"); + } else { + xref.setReferencedCurie(dto.getId()); + xref.setDisplayName(dto.getId()); + ResourceDescriptorPage page = resourceDescriptorPageService.getPageForResourceDescriptor(idParts[0], pageName); + if (page == null) { + crResponse.addErrorMessage("pages", ValidationConstants.INVALID_MESSAGE + " (" + page + ")"); + } + xref.setResourceDescriptorPage(page); + xrefList.add(xref); + } + } + } + + crResponse.setEntity(xrefList); + + return crResponse; + } + +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/ExternalDataBaseEntityFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/ExternalDataBaseEntityFmsDTOValidator.java new file mode 100644 index 000000000..c7c2d34cf --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/ExternalDataBaseEntityFmsDTOValidator.java @@ -0,0 +1,148 @@ +package org.alliancegenome.curation_api.services.validation.dto.fms; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import org.alliancegenome.curation_api.constants.ValidationConstants; +import org.alliancegenome.curation_api.dao.CrossReferenceDAO; +import org.alliancegenome.curation_api.dao.ExternalDataBaseEntityDAO; +import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; +import org.alliancegenome.curation_api.model.entities.CrossReference; +import org.alliancegenome.curation_api.model.entities.ExternalDataBaseEntity; +import org.alliancegenome.curation_api.model.entities.ResourceDescriptorPage; +import org.alliancegenome.curation_api.model.ingest.dto.fms.CrossReferenceFmsDTO; +import org.alliancegenome.curation_api.model.ingest.dto.fms.HTPIdFmsDTO; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.services.CrossReferenceService; +import org.alliancegenome.curation_api.services.ExternalDataBaseEntityService; +import org.alliancegenome.curation_api.services.ResourceDescriptorPageService; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; + +@RequestScoped +public class ExternalDataBaseEntityFmsDTOValidator { + + @Inject ExternalDataBaseEntityDAO externalDataBaseEntityDAO; + @Inject ExternalDataBaseEntityService externalDataBaseEntityService; + @Inject CrossReferenceDAO crossReferenceDAO; + @Inject CrossReferenceService crossReferenceService; + @Inject ResourceDescriptorPageService resourceDescriptorPageService; + + @Transactional + public ExternalDataBaseEntity validateExternalDataBaseEntityFmsDTO(HTPIdFmsDTO dto) throws ValidationException { + + ObjectResponse externalDBEntityResponse = new ObjectResponse<>(); + ExternalDataBaseEntity externalDBEntity = null; + + if (StringUtils.isEmpty(dto.getPrimaryId())) { + externalDBEntityResponse.addErrorMessage("primaryId", ValidationConstants.REQUIRED_MESSAGE); + } else { + externalDBEntity = externalDataBaseEntityService.findByCurie(dto.getPrimaryId()); + } + + if (externalDBEntity == null) { + externalDBEntity = new ExternalDataBaseEntity(); + externalDBEntity.setCurie(dto.getPrimaryId()); + } + + if (CollectionUtils.isNotEmpty(dto.getAlternateIds())) { + if (externalDBEntity.getSecondaryIdentifiers() == null) { + externalDBEntity.setSecondaryIdentifiers(new ArrayList<>()); + } + Set existingSecondaryIds = new HashSet<>(externalDBEntity.getSecondaryIdentifiers()); + Set incomingAlternateIds = new HashSet<>(dto.getAlternateIds()); + + existingSecondaryIds.retainAll(incomingAlternateIds); + existingSecondaryIds.addAll(incomingAlternateIds); + externalDBEntity.setSecondaryIdentifiers(new ArrayList<>(existingSecondaryIds)); + } + + List currentXrefIds; + if (externalDBEntity.getCrossReferences() == null) { + currentXrefIds = new ArrayList<>(); + } else { + currentXrefIds = externalDBEntity.getCrossReferences().stream().map(CrossReference::getId).collect(Collectors.toList()); + } + + List mergedXrefIds = null; + List mergedCrossReferences = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(dto.getCrossReferences())) { + mergedCrossReferences = crossReferenceService.getMergedFmsXrefList(dto.getCrossReferences(), externalDBEntity.getCrossReferences()); + mergedXrefIds = mergedCrossReferences.stream().map(CrossReference::getId).collect(Collectors.toList()); + externalDBEntity.setCrossReferences(mergedCrossReferences); + } else { + mergedXrefIds = new ArrayList<>(); + externalDBEntity.setCrossReferences(null); + } + + Map mergedXrefUniqueIdsMap = new HashMap<>(); + for (CrossReference mergedXref : mergedCrossReferences) { + mergedXrefUniqueIdsMap.put(crossReferenceService.getCrossReferenceUniqueId(mergedXref), mergedXref); + } + + if (externalDBEntity.getPreferredCrossReference() != null) { + if (dto.getPreferredCrossReference() != null) { + CrossReference incomingPreferredXref = createNewCrossReference(dto.getPreferredCrossReference()); + String incomingXrefUniqueId = crossReferenceService.getCrossReferenceUniqueId(incomingPreferredXref); + String currentXrefUniqueId = crossReferenceService.getCrossReferenceUniqueId(externalDBEntity.getPreferredCrossReference()); + + if (!incomingXrefUniqueId.equals(currentXrefUniqueId)) { + externalDBEntity.setPreferredCrossReference(null); + if (mergedXrefUniqueIdsMap.containsKey(incomingXrefUniqueId)) { + externalDBEntity.setPreferredCrossReference(mergedXrefUniqueIdsMap.get(incomingXrefUniqueId)); + } else { + externalDBEntity.setPreferredCrossReference(crossReferenceDAO.persist(incomingPreferredXref)); + } + } + } else { + externalDBEntity.setPreferredCrossReference(null); + } + } else { + if (dto.getPreferredCrossReference() != null) { + CrossReference incomingPreferredXref = createNewCrossReference(dto.getPreferredCrossReference()); + String incomingXrefUniqueId = crossReferenceService.getCrossReferenceUniqueId(incomingPreferredXref); + if (mergedXrefUniqueIdsMap.containsKey(incomingXrefUniqueId)) { + externalDBEntity.setPreferredCrossReference(mergedXrefUniqueIdsMap.get(incomingXrefUniqueId)); + } else { + externalDBEntity.setPreferredCrossReference(crossReferenceDAO.persist(incomingPreferredXref)); + } + } + } + + externalDataBaseEntityDAO.persist(externalDBEntity); + + for (Long currentId : currentXrefIds) { + if (!mergedXrefIds.contains(currentId)) { + crossReferenceDAO.remove(currentId); + } + } + + if (externalDBEntityResponse.hasErrors()) { + throw new ObjectValidationException(dto, externalDBEntityResponse.errorMessagesString()); + } + + return externalDBEntity; + } + + private CrossReference createNewCrossReference(CrossReferenceFmsDTO dto) { + CrossReference xref = new CrossReference(); + xref.setReferencedCurie(dto.getCurie()); + xref.setDisplayName(dto.getCurie()); + String prefix = dto.getCurie().indexOf(":") == -1 ? dto.getCurie() : dto.getCurie().substring(0, dto.getCurie().indexOf(":")); + ResourceDescriptorPage rdp = resourceDescriptorPageService.getPageForResourceDescriptor(prefix, dto.getPages().get(0)); + if (rdp != null) { + xref.setResourceDescriptorPage(rdp); + } + return xref; + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneExpressionAnnotationFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneExpressionAnnotationFmsDTOValidator.java index 8bda1f807..203bd6d5b 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneExpressionAnnotationFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneExpressionAnnotationFmsDTOValidator.java @@ -6,48 +6,51 @@ import org.alliancegenome.curation_api.constants.VocabularyConstants; import org.alliancegenome.curation_api.dao.GeneExpressionAnnotationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; -import org.alliancegenome.curation_api.exceptions.ObjectUpdateException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; -import org.alliancegenome.curation_api.model.entities.Gene; -import org.alliancegenome.curation_api.model.entities.Reference; -import org.alliancegenome.curation_api.model.entities.ontology.MMOTerm; +import org.alliancegenome.curation_api.model.entities.*; +import org.alliancegenome.curation_api.model.entities.ontology.*; import org.alliancegenome.curation_api.model.ingest.dto.fms.GeneExpressionFmsDTO; +import org.alliancegenome.curation_api.model.ingest.dto.fms.UberonSlimTermDTO; import org.alliancegenome.curation_api.response.ObjectResponse; import org.alliancegenome.curation_api.response.SearchResponse; -import org.alliancegenome.curation_api.services.*; +import org.alliancegenome.curation_api.services.DataProviderService; +import org.alliancegenome.curation_api.services.GeneService; +import org.alliancegenome.curation_api.services.ReferenceService; +import org.alliancegenome.curation_api.services.VocabularyTermService; import org.alliancegenome.curation_api.services.helpers.annotations.GeneExpressionAnnotationUniqueIdHelper; -import org.alliancegenome.curation_api.services.ontology.MmoTermService; +import org.alliancegenome.curation_api.services.ontology.*; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.ObjectUtils; -import org.alliancegenome.curation_api.model.entities.GeneExpressionAnnotation; import java.time.OffsetDateTime; import java.time.format.DateTimeParseException; +import java.util.ArrayList; +import java.util.List; @RequestScoped public class GeneExpressionAnnotationFmsDTOValidator { @Inject GeneService geneService; - @Inject MmoTermService mmoTermService; - @Inject ReferenceService referenceService; - @Inject GeneExpressionAnnotationUniqueIdHelper geneExpressionAnnotationUniqueIdHelper; - @Inject GeneExpressionAnnotationDAO geneExpressionAnnotationDAO; - @Inject DataProviderService dataProviderService; - @Inject VocabularyTermService vocabularyTermService; + @Inject AnatomicalTermService anatomicalTermService; + @Inject GoTermService goTermService; + @Inject UberonTermService uberonTermService; + @Inject StageTermService stageTermService; + @Inject OntologyTermService ontologyTermService; - public GeneExpressionAnnotation validateAnnotation(GeneExpressionFmsDTO geneExpressionFmsDTO, BackendBulkDataProvider dataProvider) throws ObjectUpdateException { - ObjectResponse response = new ObjectResponse(); + public GeneExpressionAnnotation validateAnnotation(GeneExpressionFmsDTO geneExpressionFmsDTO, BackendBulkDataProvider dataProvider) throws ValidationException { + ObjectResponse response = new ObjectResponse<>(); GeneExpressionAnnotation geneExpressionAnnotation; ObjectResponse singleReferenceResponse = validateEvidence(geneExpressionFmsDTO); if (singleReferenceResponse.hasErrors()) { - response.addErrorMessages("singleReference", singleReferenceResponse.getErrorMessages()); + response.addErrorMessage("singleReference", singleReferenceResponse.errorMessagesString()); throw new ObjectValidationException(geneExpressionFmsDTO, response.errorMessagesString()); } else { String referenceCurie = singleReferenceResponse.getEntity().getCurie(); @@ -59,6 +62,9 @@ public GeneExpressionAnnotation validateAnnotation(GeneExpressionFmsDTO geneExpr geneExpressionAnnotation = new GeneExpressionAnnotation(); geneExpressionAnnotation.setUniqueId(uniqueId); } + if (geneExpressionAnnotation.getExpressionPattern() == null) { + geneExpressionAnnotation.setExpressionPattern(new ExpressionPattern()); + } geneExpressionAnnotation.setSingleReference(singleReferenceResponse.getEntity()); } @@ -96,29 +102,25 @@ public GeneExpressionAnnotation validateAnnotation(GeneExpressionFmsDTO geneExpr } } - if (ObjectUtils.isEmpty(geneExpressionFmsDTO.getWhereExpressed())) { - response.addErrorMessage("whereExpressed - ", ValidationConstants.REQUIRED_MESSAGE + " (" + geneExpressionFmsDTO.getWhereExpressed() + ")"); + ObjectResponse anatomicalSiteObjectResponse = validateAnatomicalSite(geneExpressionFmsDTO); + if (anatomicalSiteObjectResponse.hasErrors()) { + response.addErrorMessage("expressionPattern", anatomicalSiteObjectResponse.errorMessagesString()); } else { - String whereExpressedStatement = geneExpressionFmsDTO.getWhereExpressed().getWhereExpressedStatement(); - if (ObjectUtils.isEmpty(whereExpressedStatement)) { - response.addErrorMessage("whereExpressed - whereExpressedStatement", ValidationConstants.REQUIRED_MESSAGE + " (" + geneExpressionFmsDTO.getWhereExpressed().getWhereExpressedStatement() + ")"); - } else { - geneExpressionAnnotation.setWhereExpressedStatement(whereExpressedStatement); - } + geneExpressionAnnotation.setWhereExpressedStatement(geneExpressionFmsDTO.getWhereExpressed().getWhereExpressedStatement()); + AnatomicalSite anatomicalSite = updateAnatomicalSite(anatomicalSiteObjectResponse, geneExpressionAnnotation); + geneExpressionAnnotation.getExpressionPattern().setWhereExpressed(anatomicalSite); } - if (ObjectUtils.isEmpty(geneExpressionFmsDTO.getWhenExpressed())) { - response.addErrorMessage("whenExpressed - ", ValidationConstants.REQUIRED_MESSAGE + " (" + geneExpressionFmsDTO.getWhenExpressed() + ")"); + ObjectResponse temporalContextObjectResponse = validateTemporalContext(geneExpressionFmsDTO); + if (temporalContextObjectResponse.hasErrors()) { + response.addErrorMessage("expressionPattern", temporalContextObjectResponse.errorMessagesString()); } else { - String stageName = geneExpressionFmsDTO.getWhenExpressed().getStageName(); - if (ObjectUtils.isEmpty(stageName)) { - response.addErrorMessage("whenExpressed - whenExpressedStageName", ValidationConstants.REQUIRED_MESSAGE + " (" + geneExpressionFmsDTO.getWhenExpressed().getStageName() + ")"); - } else { - geneExpressionAnnotation.setWhenExpressedStageName(stageName); - } + geneExpressionAnnotation.setWhenExpressedStageName(geneExpressionFmsDTO.getWhenExpressed().getStageName()); + TemporalContext temporalContext = updateTemporalContext(temporalContextObjectResponse, geneExpressionAnnotation); + geneExpressionAnnotation.getExpressionPattern().setWhenExpressed(temporalContext); } - geneExpressionAnnotation.setDataProvider(dataProviderService.createOrganizationDataProvider(dataProvider.sourceOrganization)); + geneExpressionAnnotation.setDataProvider(dataProviderService.getDefaultDataProvider(dataProvider.sourceOrganization)); geneExpressionAnnotation.setRelation(vocabularyTermService.getTermInVocabulary(VocabularyConstants.GENE_EXPRESSION_VOCABULARY, VocabularyConstants.GENE_EXPRESSION_RELATION_TERM).getEntity()); geneExpressionAnnotation.setObsolete(false); geneExpressionAnnotation.setInternal(false); @@ -129,8 +131,170 @@ public GeneExpressionAnnotation validateAnnotation(GeneExpressionFmsDTO geneExpr return geneExpressionAnnotation; } + private ObjectResponse validateTemporalContext(GeneExpressionFmsDTO geneExpressionFmsDTO) { + ObjectResponse response = new ObjectResponse<>(); + TemporalContext temporalContext = new TemporalContext(); + if (ObjectUtils.isEmpty(geneExpressionFmsDTO.getWhenExpressed())) { + response.addErrorMessage("whenExpressed - ", ValidationConstants.REQUIRED_MESSAGE + " (" + geneExpressionFmsDTO.getWhenExpressed() + ")"); + return response; + } else { + String stageName = geneExpressionFmsDTO.getWhenExpressed().getStageName(); + if (ObjectUtils.isEmpty(stageName)) { + response.addErrorMessage("whenExpressed - whenExpressedStageName", ValidationConstants.REQUIRED_MESSAGE + " (" + stageName + ")"); + } + String stageTermId = geneExpressionFmsDTO.getWhenExpressed().getStageTermId(); + if (!ObjectUtils.isEmpty(stageTermId)) { + StageTerm stageTerm = stageTermService.findByCurie(stageTermId); + if (stageTerm == null) { + response.addErrorMessage("whenExpressed - stageTermId", ValidationConstants.INVALID_MESSAGE + " (" + stageTermId + ")"); + } else { + temporalContext.setDevelopmentalStageStart(stageTerm); + } + } + if (!ObjectUtils.isEmpty(geneExpressionFmsDTO.getWhenExpressed().getStageUberonSlimTerm())) { + if (!ObjectUtils.isEmpty(geneExpressionFmsDTO.getWhenExpressed().getStageUberonSlimTerm().getUberonTerm())) { + String stageUberonSlimTermId = geneExpressionFmsDTO.getWhenExpressed().getStageUberonSlimTerm().getUberonTerm(); + if (!ObjectUtils.isEmpty(stageUberonSlimTermId)) { + VocabularyTerm stageUberonSlimTerm = vocabularyTermService.getTermInVocabulary(VocabularyConstants.STAGE_UBERON_SLIM_TERMS, stageUberonSlimTermId).getEntity(); + if (stageUberonSlimTerm == null) { + response.addErrorMessage("whenExpressed - stageUberonSlimTermId", ValidationConstants.INVALID_MESSAGE + " (" + stageUberonSlimTermId + ")"); + } else { + temporalContext.setStageUberonSlimTerms(List.of(stageUberonSlimTerm)); + } + } + } + } + response.setEntity(temporalContext); + } + return response; + } + + private ObjectResponse validateAnatomicalSite(GeneExpressionFmsDTO geneExpressionFmsDTO) { + ObjectResponse response = new ObjectResponse<>(); + AnatomicalSite anatomicalSite = new AnatomicalSite(); + if (ObjectUtils.isEmpty(geneExpressionFmsDTO.getWhereExpressed())) { + response.addErrorMessage("whereExpressed - ", ValidationConstants.REQUIRED_MESSAGE + " (" + geneExpressionFmsDTO.getWhereExpressed() + ")"); + } else { + if (ObjectUtils.isEmpty(geneExpressionFmsDTO.getWhereExpressed().getWhereExpressedStatement())) { + response.addErrorMessage("whereExpressed - whereExpressedStatement", ValidationConstants.REQUIRED_MESSAGE + " (" + geneExpressionFmsDTO.getWhereExpressed().getWhereExpressedStatement() + ")"); + return response; + } + + boolean lackAnatomicalStructureTermId = ObjectUtils.isEmpty(geneExpressionFmsDTO.getWhereExpressed().getAnatomicalStructureTermId()); + boolean lackStructureUberonSlimTermIds = ObjectUtils.isEmpty(geneExpressionFmsDTO.getWhereExpressed().getAnatomicalStructureUberonSlimTermIds()); + boolean lackCellularComponentId = ObjectUtils.isEmpty(geneExpressionFmsDTO.getWhereExpressed().getCellularComponentTermId()); - private ObjectResponse validateEvidence(GeneExpressionFmsDTO geneExpressionFmsDTO) throws ObjectUpdateException { + if ((lackAnatomicalStructureTermId || lackStructureUberonSlimTermIds) && lackCellularComponentId) { + response.addErrorMessage("whereExpressed - MUST HAVe (anatomicalStructureTermId and anatomicalStructureUberonSlimTermIds) or cellularComponentTermId", ValidationConstants.REQUIRED_MESSAGE + " (" + geneExpressionFmsDTO.getWhereExpressed() + ")"); + } + + if (!lackAnatomicalStructureTermId) { + AnatomicalTerm anatomicalStructureTerm = anatomicalTermService.findByCurie(geneExpressionFmsDTO.getWhereExpressed().getAnatomicalStructureTermId()); + if (anatomicalStructureTerm == null) { + response.addErrorMessage("whereExpressed - anatomicalStructureTermId", ValidationConstants.INVALID_MESSAGE + " (" + geneExpressionFmsDTO.getWhereExpressed().getAnatomicalStructureTermId() + ")"); + } else { + anatomicalSite.setAnatomicalStructure(anatomicalStructureTerm); + } + } + + if (!ObjectUtils.isEmpty(geneExpressionFmsDTO.getWhereExpressed().getAnatomicalSubStructureTermId())) { + AnatomicalTerm anatomicalSubStructureTerm = anatomicalTermService.findByCurie(geneExpressionFmsDTO.getWhereExpressed().getAnatomicalSubStructureTermId()); + if (anatomicalSubStructureTerm == null) { + response.addErrorMessage("whereExpressed - anatomicalSubStructureTermId", ValidationConstants.INVALID_MESSAGE + " (" + geneExpressionFmsDTO.getWhereExpressed().getAnatomicalSubStructureTermId() + ")"); + } else { + anatomicalSite.setAnatomicalSubstructure(anatomicalSubStructureTerm); + } + } + + if (!lackCellularComponentId) { + GOTerm cellularComponent = goTermService.findByCurie(geneExpressionFmsDTO.getWhereExpressed().getCellularComponentTermId()); + if (cellularComponent == null) { + response.addErrorMessage("whereExpressed - cellularComponentTermId", ValidationConstants.INVALID_MESSAGE + " (" + geneExpressionFmsDTO.getWhereExpressed().getCellularComponentTermId() + ")"); + } else { + GOTerm cellularComponentRibbon = goTermService.findSubsetTerm(cellularComponent, "goslim_agr"); + if (cellularComponentRibbon == null) { + anatomicalSite.setCellularComponentOther(true); + } else { + anatomicalSite.setCellularComponentOther(false); + anatomicalSite.setCellularComponentRibbonTerm(cellularComponentRibbon); + } + anatomicalSite.setCellularComponentTerm(cellularComponent); + } + } + + if (!ObjectUtils.isEmpty(geneExpressionFmsDTO.getWhereExpressed().getAnatomicalStructureQualifierTermId())) { + String anatomicalstructurequalifiertermId = geneExpressionFmsDTO.getWhereExpressed().getAnatomicalStructureQualifierTermId(); + if (vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.ANATOMICAL_STRUCTURE_QUALIFIER, anatomicalstructurequalifiertermId) != null) { + OntologyTerm anatomicalStructureQualifierTerm = ontologyTermService.findByCurieOrSecondaryId(anatomicalstructurequalifiertermId); + if (anatomicalStructureQualifierTerm == null) { + response.addErrorMessage("whereExpressed - anatomicalStructureQualifierTermId", ValidationConstants.INVALID_MESSAGE + " (" + anatomicalstructurequalifiertermId + ")"); + } else { + anatomicalSite.setAnatomicalStructureQualifiers(List.of(anatomicalStructureQualifierTerm)); + } + } + } + + if (!ObjectUtils.isEmpty(geneExpressionFmsDTO.getWhereExpressed().getAnatomicalSubStructureQualifierTermId())) { + String anatomicalsubstructurequalifierId = geneExpressionFmsDTO.getWhereExpressed().getAnatomicalSubStructureQualifierTermId(); + if (vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.ANATOMICAL_SUBSTRUCTURE_QUALIFIER, anatomicalsubstructurequalifierId) != null) { + OntologyTerm anatomicalSubStructureQualifierTerm = ontologyTermService.findByCurieOrSecondaryId(anatomicalsubstructurequalifierId); + if (anatomicalSubStructureQualifierTerm == null) { + response.addErrorMessage("whereExpressed - anatomicalSubStructureQualifierTermId", ValidationConstants.INVALID_MESSAGE + " (" + anatomicalsubstructurequalifierId + ")"); + } else { + anatomicalSite.setAnatomicalSubstructureQualifiers(List.of(anatomicalSubStructureQualifierTerm)); + } + } + } + + if (!ObjectUtils.isEmpty(geneExpressionFmsDTO.getWhereExpressed().getCellularComponentQualifierTermId())) { + String cellularComponentQualifierTermId = geneExpressionFmsDTO.getWhereExpressed().getCellularComponentQualifierTermId(); + if (vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.CELLULAR_COMPONENT_QUALIFIER, cellularComponentQualifierTermId) != null) { + OntologyTerm cellularComponentQualifierTerm = ontologyTermService.findByCurieOrSecondaryId(cellularComponentQualifierTermId); + if (cellularComponentQualifierTerm == null) { + response.addErrorMessage("whereExpressed - cellularComponentQualifierTermId", ValidationConstants.INVALID_MESSAGE + " (" + cellularComponentQualifierTermId + ")"); + } else { + anatomicalSite.setCellularComponentQualifiers(List.of(cellularComponentQualifierTerm)); + } + } + } + + if (!ObjectUtils.isEmpty(geneExpressionFmsDTO.getWhereExpressed().getAnatomicalStructureUberonSlimTermIds())) { + List anatomicalStructureUberonSlimTermIds = geneExpressionFmsDTO.getWhereExpressed().getAnatomicalStructureUberonSlimTermIds(); + List uberonTerms = new ArrayList<>(); + for (UberonSlimTermDTO uberonSlimTermDTO: anatomicalStructureUberonSlimTermIds) { + if (!uberonSlimTermDTO.getUberonTerm().equals("Other")) { + UBERONTerm uberonTerm = uberonTermService.getByCurie(uberonSlimTermDTO.getUberonTerm()).getEntity(); + if (uberonTerm == null) { + response.addErrorMessage("whereExpressed - anatomicalStructureUberonSlimTermId", ValidationConstants.INVALID_MESSAGE + " (" + uberonSlimTermDTO.getUberonTerm() + ")"); + } else { + uberonTerms.add(uberonTerm); + } + } + } + anatomicalSite.setAnatomicalStructureUberonTerms(uberonTerms); + } + + if (!ObjectUtils.isEmpty(geneExpressionFmsDTO.getWhereExpressed().getAnatomicalSubStructureUberonSlimTermIds())) { + List anatomicalSubStructureUberonSlimTermIds = geneExpressionFmsDTO.getWhereExpressed().getAnatomicalSubStructureUberonSlimTermIds(); + List uberonTerms = new ArrayList<>(); + for (UberonSlimTermDTO uberonSlimTermDTO : anatomicalSubStructureUberonSlimTermIds) { + if (!uberonSlimTermDTO.getUberonTerm().equals("Other")) { + UBERONTerm uberonTerm = uberonTermService.getByCurie(uberonSlimTermDTO.getUberonTerm()).getEntity(); + if (uberonTerm == null) { + response.addErrorMessage("whereExpressed - anatomicalStructureUberonSlimTermId", ValidationConstants.INVALID_MESSAGE + " (" + uberonSlimTermDTO.getUberonTerm() + ")"); + } else { + uberonTerms.add(uberonTerm); + } + } + } + anatomicalSite.setAnatomicalSubstructureUberonTerms(uberonTerms); + } + response.setEntity(anatomicalSite); + } + return response; + } + + private ObjectResponse validateEvidence(GeneExpressionFmsDTO geneExpressionFmsDTO) { ObjectResponse response = new ObjectResponse<>(); if (ObjectUtils.isEmpty(geneExpressionFmsDTO.getEvidence())) { @@ -149,4 +313,34 @@ private ObjectResponse validateEvidence(GeneExpressionFmsDTO geneExpr } return response; } + + private TemporalContext updateTemporalContext(ObjectResponse temporalContextObjectResponse, GeneExpressionAnnotation geneExpressionAnnotation) { + TemporalContext temporalContext = temporalContextObjectResponse.getEntity(); + TemporalContext temporalContextDB = geneExpressionAnnotation.getExpressionPattern().getWhenExpressed(); + if (temporalContextDB == null) { + temporalContextDB = new TemporalContext(); + } + temporalContextDB.setDevelopmentalStageStart(temporalContext.getDevelopmentalStageStart()); + temporalContextDB.setStageUberonSlimTerms(temporalContext.getStageUberonSlimTerms()); + return temporalContextDB; + } + + private AnatomicalSite updateAnatomicalSite(ObjectResponse anatomicalSiteObjectResponse, GeneExpressionAnnotation geneExpressionAnnotation) { + AnatomicalSite anatomicalSite = anatomicalSiteObjectResponse.getEntity(); + AnatomicalSite anatomicalSiteDB = geneExpressionAnnotation.getExpressionPattern().getWhereExpressed(); + if (anatomicalSiteDB == null) { + anatomicalSiteDB = new AnatomicalSite(); + } + anatomicalSiteDB.setCellularComponentTerm(anatomicalSite.getCellularComponentTerm()); + anatomicalSiteDB.setCellularComponentRibbonTerm(anatomicalSite.getCellularComponentRibbonTerm()); + anatomicalSiteDB.setCellularComponentOther(anatomicalSite.getCellularComponentOther()); + anatomicalSiteDB.setAnatomicalStructure(anatomicalSite.getAnatomicalStructure()); + anatomicalSiteDB.setAnatomicalSubstructure(anatomicalSite.getAnatomicalSubstructure()); + anatomicalSiteDB.setAnatomicalStructureQualifiers(anatomicalSite.getAnatomicalStructureQualifiers()); + anatomicalSiteDB.setAnatomicalSubstructureQualifiers(anatomicalSite.getAnatomicalSubstructureQualifiers()); + anatomicalSiteDB.setCellularComponentQualifiers(anatomicalSite.getCellularComponentQualifiers()); + anatomicalSiteDB.setAnatomicalStructureUberonTerms(anatomicalSite.getAnatomicalStructureUberonTerms()); + anatomicalSiteDB.setAnatomicalSubstructureUberonTerms(anatomicalSite.getAnatomicalSubstructureUberonTerms()); + return anatomicalSiteDB; + } } diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneGeneticInteractionFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneGeneticInteractionFmsDTOValidator.java index 066ec65dc..e2bab6dc8 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneGeneticInteractionFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneGeneticInteractionFmsDTOValidator.java @@ -6,6 +6,7 @@ import org.alliancegenome.curation_api.constants.VocabularyConstants; import org.alliancegenome.curation_api.enums.PsiMiTabPrefixEnum; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.Allele; import org.alliancegenome.curation_api.model.entities.Gene; import org.alliancegenome.curation_api.model.entities.GeneGeneticInteraction; @@ -33,7 +34,7 @@ public class GeneGeneticInteractionFmsDTOValidator extends GeneInteractionFmsDTO private ObjectResponse ggiResponse; - public GeneGeneticInteraction validateGeneGeneticInteractionFmsDTO(PsiMiTabDTO dto) throws ObjectValidationException { + public GeneGeneticInteraction validateGeneGeneticInteractionFmsDTO(PsiMiTabDTO dto) throws ValidationException { GeneGeneticInteraction interaction = null; ggiResponse = new ObjectResponse(); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneMolecularInteractionFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneMolecularInteractionFmsDTOValidator.java index c60763e62..eea77d460 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneMolecularInteractionFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GeneMolecularInteractionFmsDTOValidator.java @@ -6,6 +6,7 @@ import org.alliancegenome.curation_api.constants.VocabularyConstants; import org.alliancegenome.curation_api.enums.PsiMiTabPrefixEnum; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.Gene; import org.alliancegenome.curation_api.model.entities.GeneMolecularInteraction; import org.alliancegenome.curation_api.model.entities.Reference; @@ -29,7 +30,7 @@ public class GeneMolecularInteractionFmsDTOValidator extends GeneInteractionFmsD private ObjectResponse gmiResponse; - public GeneMolecularInteraction validateGeneMolecularInteractionFmsDTO(PsiMiTabDTO dto) throws ObjectValidationException { + public GeneMolecularInteraction validateGeneMolecularInteractionFmsDTO(PsiMiTabDTO dto) throws ValidationException { GeneMolecularInteraction interaction = null; gmiResponse = new ObjectResponse(); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GenePhenotypeAnnotationFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GenePhenotypeAnnotationFmsDTOValidator.java index cc782f83a..fa1c02c87 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GenePhenotypeAnnotationFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/GenePhenotypeAnnotationFmsDTOValidator.java @@ -3,6 +3,7 @@ import org.alliancegenome.curation_api.dao.GenePhenotypeAnnotationDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.Gene; import org.alliancegenome.curation_api.model.entities.GenePhenotypeAnnotation; import org.alliancegenome.curation_api.model.entities.Reference; @@ -23,7 +24,7 @@ public class GenePhenotypeAnnotationFmsDTOValidator extends PhenotypeAnnotationF @Inject GenomicEntityService genomicEntityService; @Inject PhenotypeAnnotationService phenotypeAnnotationService; - public GenePhenotypeAnnotation validatePrimaryAnnotation(Gene subject, PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ObjectValidationException { + public GenePhenotypeAnnotation validatePrimaryAnnotation(Gene subject, PhenotypeFmsDTO dto, BackendBulkDataProvider dataProvider) throws ValidationException { ObjectResponse apaResponse = new ObjectResponse(); GenePhenotypeAnnotation annotation = new GenePhenotypeAnnotation(); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/HTPExpressionDatasetAnnotationFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/HTPExpressionDatasetAnnotationFmsDTOValidator.java new file mode 100644 index 000000000..60733d14c --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/HTPExpressionDatasetAnnotationFmsDTOValidator.java @@ -0,0 +1,175 @@ +package org.alliancegenome.curation_api.services.validation.dto.fms; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.alliancegenome.curation_api.constants.ValidationConstants; +import org.alliancegenome.curation_api.constants.VocabularyConstants; +import org.alliancegenome.curation_api.dao.HTPExpressionDatasetAnnotationDAO; +import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; +import org.alliancegenome.curation_api.model.entities.ExternalDataBaseEntity; +import org.alliancegenome.curation_api.model.entities.HTPExpressionDatasetAnnotation; +import org.alliancegenome.curation_api.model.entities.Note; +import org.alliancegenome.curation_api.model.entities.Reference; +import org.alliancegenome.curation_api.model.input.Pagination; +import org.alliancegenome.curation_api.model.entities.VocabularyTerm; +import org.alliancegenome.curation_api.model.ingest.dto.fms.HTPExpressionDatasetAnnotationFmsDTO; +import org.alliancegenome.curation_api.model.ingest.dto.fms.PublicationFmsDTO; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.response.SearchResponse; +import org.alliancegenome.curation_api.services.DataProviderService; +import org.alliancegenome.curation_api.services.ExternalDataBaseEntityService; +import org.alliancegenome.curation_api.services.ReferenceService; +import org.alliancegenome.curation_api.services.VocabularyTermService; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; + +@RequestScoped +public class HTPExpressionDatasetAnnotationFmsDTOValidator { + + @Inject HTPExpressionDatasetAnnotationDAO htpExpressionDatasetAnnotationDAO; + @Inject ExternalDataBaseEntityService externalDataBaseService; + @Inject ReferenceService referenceService; + @Inject VocabularyTermService vocabularyTermService; + @Inject ExternalDataBaseEntityFmsDTOValidator externalDataBaseEntityFmsDtoValidator; + @Inject DataProviderService dataProviderService; + + @Transactional + public HTPExpressionDatasetAnnotation validateHTPExpressionDatasetAnnotationFmsDTO(HTPExpressionDatasetAnnotationFmsDTO dto, BackendBulkDataProvider backendBulkDataProvider) throws ValidationException { + ObjectResponse htpAnnotationResponse = new ObjectResponse<>(); + + HTPExpressionDatasetAnnotation htpannotation; + + if (dto.getDatasetId() != null) { + String curie = dto.getDatasetId().getPrimaryId(); + ExternalDataBaseEntity externalDbEntity = externalDataBaseEntityFmsDtoValidator.validateExternalDataBaseEntityFmsDTO(dto.getDatasetId()); + if (externalDbEntity != null) { + Long htpId = externalDbEntity.getId(); + Map params = new HashMap<>(); + params.put("htpExpressionDataset.id", htpId); + SearchResponse searchResponse = htpExpressionDatasetAnnotationDAO.findByParams(params); + if (searchResponse == null || searchResponse.getSingleResult() == null) { + htpannotation = new HTPExpressionDatasetAnnotation(); + htpannotation.setHtpExpressionDataset(externalDbEntity); + } else { + htpannotation = searchResponse.getSingleResult(); + } + } else { + htpAnnotationResponse.addErrorMessage("datasetId", ValidationConstants.INVALID_MESSAGE + " (" + curie + ")"); + htpannotation = new HTPExpressionDatasetAnnotation(); + } + } else { + htpAnnotationResponse.addErrorMessage("datasetId", ValidationConstants.REQUIRED_MESSAGE); + htpannotation = new HTPExpressionDatasetAnnotation(); + } + + if (CollectionUtils.isNotEmpty(dto.getPublications())) { + List references = new ArrayList<>(); + for (PublicationFmsDTO publication : dto.getPublications()) { + if (StringUtils.isEmpty(publication.getPublicationId())) { + htpAnnotationResponse.addErrorMessage("Publication - publicationId", ValidationConstants.REQUIRED_MESSAGE + " (" + publication.getPublicationId() + ")"); + } else { + Reference reference = referenceService.retrieveFromDbOrLiteratureService(publication.getPublicationId()); + if (reference == null) { + htpAnnotationResponse.addErrorMessage("Publication - publicationId", ValidationConstants.INVALID_MESSAGE + " (" + publication.getPublicationId() + ")"); + } else { + references.add(reference); + } + } + } + htpannotation.setReferences(references); + } else { + htpannotation.setReferences(null); + } + + if (dto.getNumChannels() != null) { + if (dto.getNumChannels() == 1 || dto.getNumChannels() == 2) { + htpannotation.setNumberOfChannels(dto.getNumChannels()); + } else { + htpAnnotationResponse.addErrorMessage("numChannels", ValidationConstants.INVALID_MESSAGE); + } + } else { + htpannotation.setNumberOfChannels(null); + } + + if (CollectionUtils.isNotEmpty(dto.getSubSeries())) { + List subSeries = new ArrayList<>(); + for (String subSeriesString : dto.getSubSeries()) { + if (StringUtils.isNotEmpty(subSeriesString)) { + ExternalDataBaseEntity externalDbEntity = externalDataBaseService.findByCurie(subSeriesString); + if (externalDbEntity != null) { + subSeries.add(externalDbEntity); + } else { + htpAnnotationResponse.addErrorMessage("subSeries", ValidationConstants.INVALID_MESSAGE + " (" + subSeries + ")"); + } + } + } + htpannotation.setSubSeries(subSeries); + } else { + htpannotation.setSubSeries(null); + } + + if (CollectionUtils.isNotEmpty(dto.getCategoryTags())) { + Map categoryTags = new HashMap<>(); + for (String categoryTag : dto.getCategoryTags()) { + if (StringUtils.isNotEmpty(categoryTag)) { + Map params = new HashMap<>(); + params.put("name", categoryTag); + params.put("query_operator", "or"); + params.put("synonyms", categoryTag); + SearchResponse searchResponse = vocabularyTermService.findByParams(new Pagination(), params); + boolean added = false; + if (searchResponse.getTotalResults() > 0) { + for (VocabularyTerm tag : searchResponse.getResults()) { + if (tag.getVocabulary().getName().equals("Data Set Category Tags") && (tag.getName().equals(categoryTag) || tag.getSynonyms().contains(categoryTag))) { + if (categoryTags.containsKey(categoryTag)) { + htpAnnotationResponse.addErrorMessage("categoryTags", ValidationConstants.INVALID_MESSAGE + " Multiple Tags found in the Vocabulary " + " (" + categoryTag + ")"); + } else { + categoryTags.put(categoryTag, tag); + added = true; + } + } + } + } + if (!added) { + htpAnnotationResponse.addErrorMessage("categoryTags", ValidationConstants.INVALID_MESSAGE + " (" + categoryTag + ")"); + } + } + } + htpannotation.setCategoryTags(new ArrayList<>(categoryTags.values())); + } else { + htpAnnotationResponse.addErrorMessage("categoryTags", ValidationConstants.REQUIRED_MESSAGE); + } + + if (StringUtils.isEmpty(dto.getTitle())) { + htpAnnotationResponse.addErrorMessage("title", ValidationConstants.REQUIRED_MESSAGE); + } else { + htpannotation.setName(dto.getTitle()); + } + + if (StringUtils.isNotEmpty(dto.getSummary())) { + Note relatedNote = new Note(); + relatedNote.setFreeText(dto.getSummary()); + relatedNote.setNoteType(vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.HTP_DATASET_NOTE_TYPE_VOCABULARY_TERM_SET, "htp_expression_dataset_summary").getEntity()); + htpannotation.setRelatedNote(relatedNote); + } else { + htpannotation.setRelatedNote(null); + } + + htpannotation.setDataProvider(dataProviderService.getDefaultDataProvider(backendBulkDataProvider.sourceOrganization)); + + if (htpAnnotationResponse.hasErrors()) { + throw new ObjectValidationException(dto, htpAnnotationResponse.errorMessagesString()); + } + + return htpExpressionDatasetAnnotationDAO.persist(htpannotation); + } +} \ No newline at end of file diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/OrthologyFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/OrthologyFmsDTOValidator.java index 7c2c19fc3..7e5ed7a78 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/OrthologyFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/OrthologyFmsDTOValidator.java @@ -9,7 +9,9 @@ import org.alliancegenome.curation_api.constants.VocabularyConstants; import org.alliancegenome.curation_api.dao.orthology.GeneToGeneOrthologyGeneratedDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.exceptions.KnownIssueValidationException; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.Gene; import org.alliancegenome.curation_api.model.entities.VocabularyTerm; import org.alliancegenome.curation_api.model.entities.ontology.NCBITaxonTerm; @@ -36,7 +38,7 @@ public class OrthologyFmsDTOValidator { @Inject VocabularyTermService vocabularyTermService; @Transactional - public GeneToGeneOrthologyGenerated validateOrthologyFmsDTO(OrthologyFmsDTO dto) throws ObjectValidationException { + public GeneToGeneOrthologyGenerated validateOrthologyFmsDTO(OrthologyFmsDTO dto) throws ValidationException { ObjectResponse orthologyResponse = new ObjectResponse(); @@ -60,7 +62,8 @@ public GeneToGeneOrthologyGenerated validateOrthologyFmsDTO(OrthologyFmsDTO dto) if (StringUtils.isNotBlank(dto.getGene1())) { subjectGene = geneService.findByIdentifierString(subjectGeneIdentifier); if (subjectGene == null) { - orthologyResponse.addErrorMessage("gene1", ValidationConstants.INVALID_MESSAGE + " (" + subjectGeneIdentifier + ")"); + //orthologyResponse.addErrorMessage("gene1", ValidationConstants.INVALID_MESSAGE + " (" + subjectGeneIdentifier + ")"); + throw new KnownIssueValidationException(ValidationConstants.UNRECOGNIZED_MESSAGE + " (" + subjectGeneIdentifier + ")"); } else { if (dto.getGene1Species() == null) { orthologyResponse.addErrorMessage("gene1Species", ValidationConstants.REQUIRED_MESSAGE); @@ -80,7 +83,8 @@ public GeneToGeneOrthologyGenerated validateOrthologyFmsDTO(OrthologyFmsDTO dto) if (StringUtils.isNotBlank(dto.getGene2())) { objectGene = geneService.findByIdentifierString(objectGeneIdentifier); if (objectGene == null) { - orthologyResponse.addErrorMessage("gene2", ValidationConstants.INVALID_MESSAGE + " (" + objectGeneIdentifier + ")"); + //orthologyResponse.addErrorMessage("gene2", ValidationConstants.INVALID_MESSAGE + " (" + objectGeneIdentifier + ")"); + throw new KnownIssueValidationException(ValidationConstants.UNRECOGNIZED_MESSAGE + " (" + objectGeneIdentifier + ")"); } else { if (dto.getGene2Species() == null) { orthologyResponse.addErrorMessage("gene2Species", ValidationConstants.REQUIRED_MESSAGE); diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/ParalogyFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/ParalogyFmsDTOValidator.java index 6a6d611f2..c0c6060f3 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/ParalogyFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/ParalogyFmsDTOValidator.java @@ -10,6 +10,7 @@ import org.alliancegenome.curation_api.dao.GeneToGeneParalogyDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.Gene; import org.alliancegenome.curation_api.model.entities.GeneToGeneParalogy; import org.alliancegenome.curation_api.model.entities.VocabularyTerm; @@ -36,7 +37,7 @@ public class ParalogyFmsDTOValidator { @Inject VocabularyTermService vocabularyTermService; @Transactional - public GeneToGeneParalogy validateParalogyFmsDTO(ParalogyFmsDTO dto) throws ObjectValidationException { + public GeneToGeneParalogy validateParalogyFmsDTO(ParalogyFmsDTO dto) throws ValidationException { ObjectResponse paralogyResponse = new ObjectResponse(); @@ -162,19 +163,13 @@ public GeneToGeneParalogy validateParalogyFmsDTO(ParalogyFmsDTO dto) throws Obje } paralogyData.setConfidence(confidence); - if (dto.getSimilarity() == null) { - paralogyResponse.addErrorMessage("Similarity", ValidationConstants.REQUIRED_MESSAGE); - } else { + if (dto.getSimilarity() != null) { paralogyData.setSimilarity(dto.getSimilarity()); } - if (dto.getIdentity() == null) { - paralogyResponse.addErrorMessage("Identity", ValidationConstants.REQUIRED_MESSAGE); - } else { + if (dto.getIdentity() != null) { paralogyData.setIdentity(dto.getIdentity()); } - if (dto.getLength() == null) { - paralogyResponse.addErrorMessage("Length", ValidationConstants.REQUIRED_MESSAGE); - } else { + if (dto.getLength() != null) { paralogyData.setLength(dto.getLength()); } if (dto.getRank() == null) { diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/PhenotypeAnnotationFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/PhenotypeAnnotationFmsDTOValidator.java index 8ccc75bb0..ee59dceb0 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/PhenotypeAnnotationFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/PhenotypeAnnotationFmsDTOValidator.java @@ -88,7 +88,7 @@ public ObjectResponse validatePhenotypeAnnota annotation.setConditionRelations(null); } - annotation.setDataProvider(dataProviderService.createOrganizationDataProvider(beDataProvider.sourceOrganization)); + annotation.setDataProvider(dataProviderService.getDefaultDataProvider(beDataProvider.sourceOrganization)); annotation.setRelation(vocabularyTermService.getTermInVocabulary(VocabularyConstants.PHENOTYPE_RELATION_VOCABULARY, "has_phenotype").getEntity()); CrossReference evidenceXref = null; diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/SequenceTargetingReagentFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/SequenceTargetingReagentFmsDTOValidator.java index 55cdec3ba..f97d98efc 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/SequenceTargetingReagentFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/SequenceTargetingReagentFmsDTOValidator.java @@ -4,6 +4,7 @@ import org.alliancegenome.curation_api.dao.SequenceTargetingReagentDAO; import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; import org.alliancegenome.curation_api.model.entities.SequenceTargetingReagent; import org.alliancegenome.curation_api.model.entities.ontology.NCBITaxonTerm; import org.alliancegenome.curation_api.model.ingest.dto.fms.SequenceTargetingReagentFmsDTO; @@ -35,7 +36,7 @@ public class SequenceTargetingReagentFmsDTOValidator { @Inject VocabularyTermService vocabularyTermService; - public SequenceTargetingReagent validateSQTRFmsDTO(SequenceTargetingReagentFmsDTO dto, BackendBulkDataProvider beDataProvider) throws ObjectValidationException { + public SequenceTargetingReagent validateSQTRFmsDTO(SequenceTargetingReagentFmsDTO dto, BackendBulkDataProvider beDataProvider) throws ValidationException { ObjectResponse sqtrResponse = new ObjectResponse<>(); SequenceTargetingReagent sqtr; @@ -86,7 +87,7 @@ public SequenceTargetingReagent validateSQTRFmsDTO(SequenceTargetingReagentFmsDT } if (beDataProvider != null) { - sqtr.setDataProvider(dataProviderService.createOrganizationDataProvider(beDataProvider.sourceOrganization)); + sqtr.setDataProvider(dataProviderService.getDefaultDataProvider(beDataProvider.sourceOrganization)); } if (sqtrResponse.hasErrors()) { diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/VariantFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/VariantFmsDTOValidator.java new file mode 100644 index 000000000..5cbd0a331 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/VariantFmsDTOValidator.java @@ -0,0 +1,333 @@ +package org.alliancegenome.curation_api.services.validation.dto.fms; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import org.alliancegenome.curation_api.constants.ValidationConstants; +import org.alliancegenome.curation_api.constants.VocabularyConstants; +import org.alliancegenome.curation_api.dao.AssemblyComponentDAO; +import org.alliancegenome.curation_api.dao.NoteDAO; +import org.alliancegenome.curation_api.dao.VariantDAO; +import org.alliancegenome.curation_api.dao.associations.alleleAssociations.AlleleVariantAssociationDAO; +import org.alliancegenome.curation_api.dao.associations.variantAssociations.CuratedVariantGenomicLocationAssociationDAO; +import org.alliancegenome.curation_api.enums.BackendBulkDataProvider; +import org.alliancegenome.curation_api.enums.ChromosomeAccessionEnum; +import org.alliancegenome.curation_api.exceptions.ObjectValidationException; +import org.alliancegenome.curation_api.exceptions.ValidationException; +import org.alliancegenome.curation_api.model.entities.Allele; +import org.alliancegenome.curation_api.model.entities.AssemblyComponent; +import org.alliancegenome.curation_api.model.entities.CrossReference; +import org.alliancegenome.curation_api.model.entities.Note; +import org.alliancegenome.curation_api.model.entities.Variant; +import org.alliancegenome.curation_api.model.entities.associations.alleleAssociations.AlleleVariantAssociation; +import org.alliancegenome.curation_api.model.entities.associations.variantAssociations.CuratedVariantGenomicLocationAssociation; +import org.alliancegenome.curation_api.model.entities.ontology.SOTerm; +import org.alliancegenome.curation_api.model.ingest.dto.fms.CrossReferenceFmsDTO; +import org.alliancegenome.curation_api.model.ingest.dto.fms.VariantFmsDTO; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.response.SearchResponse; +import org.alliancegenome.curation_api.services.AlleleService; +import org.alliancegenome.curation_api.services.CrossReferenceService; +import org.alliancegenome.curation_api.services.DataProviderService; +import org.alliancegenome.curation_api.services.VocabularyTermService; +import org.alliancegenome.curation_api.services.VocabularyTermSetService; +import org.alliancegenome.curation_api.services.associations.alleleAssociations.AlleleVariantAssociationService; +import org.alliancegenome.curation_api.services.associations.variantAssociations.CuratedVariantGenomicLocationAssociationService; +import org.alliancegenome.curation_api.services.helpers.notes.NoteIdentityHelper; +import org.alliancegenome.curation_api.services.helpers.variants.HgvsIdentifierHelper; +import org.alliancegenome.curation_api.services.ontology.NcbiTaxonTermService; +import org.alliancegenome.curation_api.services.ontology.SoTermService; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; +import jakarta.transaction.Transactional; + +@RequestScoped +public class VariantFmsDTOValidator { + + @Inject VariantDAO variantDAO; + @Inject NoteDAO noteDAO; + @Inject AlleleService alleleService; + @Inject AssemblyComponentDAO assemblyComponentDAO; + @Inject CuratedVariantGenomicLocationAssociationDAO curatedVariantGenomicLocationAssociationDAO; + @Inject CuratedVariantGenomicLocationAssociationService curatedVariantGenomicLocationAssociationService; + @Inject AlleleVariantAssociationDAO alleleVariantAssociationDAO; + @Inject AlleleVariantAssociationService alleleVariantAssociationService; + @Inject SoTermService soTermService; + @Inject DataProviderService dataProviderService; + @Inject NcbiTaxonTermService ncbiTaxonTermService; + @Inject VocabularyTermService vocabularyTermService; + @Inject VocabularyTermSetService vocabularyTermSetService; + @Inject CrossReferenceFmsDTOValidator crossReferenceFmsDtoValidator; + @Inject CrossReferenceService crossReferenceService; + @Inject VariantNoteFmsDTOValidator variantNoteFmsDtoValidator; + + @Transactional + public Long validateVariant(VariantFmsDTO dto, List idsAdded, BackendBulkDataProvider dataProvider) throws ValidationException { + + ObjectResponse variantResponse = new ObjectResponse(); + Variant variant = new Variant(); + + if (dto.getStart() == null) { + variantResponse.addErrorMessage("start", ValidationConstants.REQUIRED_MESSAGE); + } + + if (dto.getEnd() == null) { + variantResponse.addErrorMessage("end", ValidationConstants.REQUIRED_MESSAGE); + } + + if (StringUtils.isBlank(dto.getSequenceOfReferenceAccessionNumber())) { + variantResponse.addErrorMessage("sequenceOfReferenceAccessionNumber", ValidationConstants.REQUIRED_MESSAGE); + } + + SOTerm variantType = null; + if (StringUtils.isBlank(dto.getType())) { + variantResponse.addErrorMessage("type", ValidationConstants.REQUIRED_MESSAGE); + } else if (Objects.equals(dto.getType(), "SO:1000002") || Objects.equals(dto.getType(), "SO:1000008") + || Objects.equals(dto.getType(), "SO:0000667") || Objects.equals(dto.getType(), "SO:0000159") + || Objects.equals(dto.getType(), "SO:0002007") || Objects.equals(dto.getType(), "SO:1000032")) { + variantType = soTermService.findByCurieOrSecondaryId(dto.getType()); + if (variantType == null) { + variantResponse.addErrorMessage("type", ValidationConstants.INVALID_MESSAGE + " (" + dto.getType() + ")"); + } else { + if (StringUtils.isBlank(dto.getGenomicReferenceSequence()) && !Objects.equals(dto.getType(), "SO:0000159") + && !Objects.equals(dto.getType(), "SO:1000032")) { + variantResponse.addErrorMessage("genomicReferenceSequence", ValidationConstants.REQUIRED_MESSAGE + " for variant type " + dto.getType()); + } + if (StringUtils.isBlank(dto.getGenomicVariantSequence()) && !Objects.equals(dto.getType(), "SO:0000667") + && !Objects.equals(dto.getType(), "SO:1000032")) { + variantResponse.addErrorMessage("genomicVariantSequence", ValidationConstants.REQUIRED_MESSAGE + " for variant type " + dto.getType()); + } + } + } else { + variantResponse.addErrorMessage("type", ValidationConstants.INVALID_MESSAGE + " for FMS submissions (" + dto.getType() + ")"); + } + + String hgvs = HgvsIdentifierHelper.getHgvsIdentifier(dto); + String modInternalId = DigestUtils.md5Hex(hgvs); + + if (StringUtils.isNotBlank(hgvs) && !variantResponse.hasErrors()) { + SearchResponse searchResponse = variantDAO.findByField("modInternalId", modInternalId); + if (searchResponse != null && searchResponse.getSingleResult() != null) { + variant = searchResponse.getSingleResult(); + } + } + + variant.setModInternalId(modInternalId); + variant.setVariantType(variantType); + variant.setDataProvider(dataProviderService.getDefaultDataProvider(dataProvider.name())); + variant.setTaxon(ncbiTaxonTermService.getByCurie(dataProvider.canonicalTaxonCurie).getEntity()); + + SOTerm consequence = null; + if (StringUtils.isNotBlank(dto.getConsequence())) { + consequence = soTermService.findByCurieOrSecondaryId(dto.getConsequence()); + if (consequence == null) { + variantResponse.addErrorMessage("consequence", ValidationConstants.INVALID_MESSAGE + " (" + dto.getConsequence() + ")"); + } + } + variant.setSourceGeneralConsequence(consequence); + + List validatedXrefs = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(dto.getCrossReferences())) { + for (CrossReferenceFmsDTO xrefDto : dto.getCrossReferences()) { + ObjectResponse> xrefResponse = crossReferenceFmsDtoValidator.validateCrossReferenceFmsDTO(xrefDto); + if (xrefResponse.hasErrors()) { + variantResponse.addErrorMessage("cross_references", xrefResponse.errorMessagesString()); + break; + } else { + validatedXrefs.addAll(xrefResponse.getEntity()); + } + } + } + List xrefs = crossReferenceService.getUpdatedXrefList(validatedXrefs, variant.getCrossReferences()); + if (variant.getCrossReferences() != null) { + variant.getCrossReferences().clear(); + } + if (xrefs != null) { + if (variant.getCrossReferences() == null) { + variant.setCrossReferences(new ArrayList<>()); + } + variant.getCrossReferences().addAll(xrefs); + } + + if (variant.getRelatedNotes() != null) { + variant.getRelatedNotes().clear(); + } + + List validatedNotes = new ArrayList(); + List noteIdentities = new ArrayList(); + Boolean allNotesValid = true; + if (CollectionUtils.isNotEmpty(dto.getNotes())) { + for (int ix = 0; ix < dto.getNotes().size(); ix++) { + ObjectResponse noteResponse = variantNoteFmsDtoValidator.validateVariantNoteFmsDTO(dto.getNotes().get(ix)); + if (noteResponse.hasErrors()) { + allNotesValid = false; + variantResponse.addErrorMessages("notes", ix, noteResponse.getErrorMessages()); + } else { + String noteIdentity = NoteIdentityHelper.variantNoteFmsDtoIdentity(dto.getNotes().get(ix)); + if (!noteIdentities.contains(noteIdentity)) { + noteIdentities.add(noteIdentity); + validatedNotes.add(noteDAO.persist(noteResponse.getEntity())); + } + } + } + } + if (!allNotesValid) { + variantResponse.convertMapToErrorMessages("notes"); + } + if (CollectionUtils.isNotEmpty(validatedNotes) && allNotesValid) { + if (variant.getRelatedNotes() == null) { + variant.setRelatedNotes(new ArrayList<>()); + } + variant.getRelatedNotes().addAll(validatedNotes); + } + + if (variantResponse.hasErrors()) { + variantResponse.convertErrorMessagesToMap(); + throw new ObjectValidationException(dto, variantResponse.errorMessagesString()); + } + + variant = variantDAO.persist(variant); + if (variant != null) { + idsAdded.add(variant.getId()); + } + + return variant.getId(); + } + + @Transactional + public void validateCuratedVariantGenomicLocationAssociation(VariantFmsDTO dto, List idsAdded, Long variantId) throws ValidationException { + + CuratedVariantGenomicLocationAssociation association = new CuratedVariantGenomicLocationAssociation(); + ObjectResponse cvglaResponse = new ObjectResponse(); + AssemblyComponent chromosome = null; + + if (dto.getStart() == null) { + cvglaResponse.addErrorMessage("start", ValidationConstants.REQUIRED_MESSAGE); + } + + if (dto.getEnd() == null) { + cvglaResponse.addErrorMessage("end", ValidationConstants.REQUIRED_MESSAGE); + } + + if (StringUtils.isBlank(dto.getSequenceOfReferenceAccessionNumber())) { + cvglaResponse.addErrorMessage("sequenceOfReferenceAccessionNumber", ValidationConstants.REQUIRED_MESSAGE); + } else { + ChromosomeAccessionEnum cae = ChromosomeAccessionEnum.getChromosomeAccessionEnum(dto.getSequenceOfReferenceAccessionNumber()); + if (cae != null) { + Map params = new HashMap<>(); + params.put("name", cae.chromosomeName); + params.put("genomeAssembly.modEntityId", cae.assemblyIdentifier); + SearchResponse acResponse = assemblyComponentDAO.findByParams(params); + if (acResponse != null) { + chromosome = acResponse.getSingleResult(); + } + } + if (chromosome == null) { + cvglaResponse.addErrorMessage("sequenceOfReferenceAccessionNumber", ValidationConstants.INVALID_MESSAGE + " (" + + dto.getSequenceOfReferenceAccessionNumber() + ")"); + } + } + + String hgvs = HgvsIdentifierHelper.getHgvsIdentifier(dto); + + Variant variant = null; + if (variantId != null) { + variant = variantDAO.find(variantId); + } + if (variant != null && StringUtils.isNotBlank(hgvs) && !cvglaResponse.hasErrors() && CollectionUtils.isNotEmpty(variant.getCuratedVariantGenomicLocations())) { + for (CuratedVariantGenomicLocationAssociation existingLocationAssociation : variant.getCuratedVariantGenomicLocations()) { + if (Objects.equals(hgvs, existingLocationAssociation.getHgvs())) { + association = curatedVariantGenomicLocationAssociationDAO.find(existingLocationAssociation.getId()); + break; + } + } + } + + association.setHgvs(hgvs); + association.setVariantAssociationSubject(variant); + association.setVariantGenomicLocationAssociationObject(chromosome); + association.setStart(dto.getStart()); + association.setEnd(dto.getEnd()); + association.setRelation(vocabularyTermService.getTermInVocabulary(VocabularyConstants.LOCATION_ASSOCIATION_RELATION_VOCABULARY, "located_on").getEntity()); + if (StringUtils.isNotBlank(dto.getGenomicReferenceSequence())) { + association.setReferenceSequence(dto.getGenomicReferenceSequence()); + } + if (StringUtils.isNotBlank(dto.getGenomicVariantSequence())) { + association.setVariantSequence(dto.getGenomicVariantSequence()); + } + + if (variantId == null) { + cvglaResponse.addErrorMessage("variant", ValidationConstants.INVALID_MESSAGE); + } + + if (cvglaResponse.hasErrors()) { + throw new ObjectValidationException(dto, cvglaResponse.errorMessagesString()); + } + + association = curatedVariantGenomicLocationAssociationDAO.persist(association); + if (association != null) { + idsAdded.add(association.getId()); + curatedVariantGenomicLocationAssociationService.addAssociationToSubject(association); + } + + } + + @Transactional + public void validateAlleleVariantAssociation(VariantFmsDTO dto, List idsAdded, Long variantId) throws ValidationException { + + AlleleVariantAssociation association = new AlleleVariantAssociation(); + ObjectResponse avaResponse = new ObjectResponse(); + + Variant variant = null; + if (variantId == null) { + avaResponse.addErrorMessage("variant", ValidationConstants.INVALID_MESSAGE); + } else { + variant = variantDAO.find(variantId); + } + if (StringUtils.isBlank(dto.getAlleleId())) { + avaResponse.addErrorMessage("alleleId", ValidationConstants.REQUIRED_MESSAGE); + } else { + if (association.getId() == null) { + Allele allele = alleleService.findByIdentifierString(dto.getAlleleId()); + if (allele == null) { + avaResponse.addErrorMessage("alleleId", ValidationConstants.INVALID_MESSAGE + " (" + dto.getAlleleId() + ")"); + } else { + if (CollectionUtils.isNotEmpty(allele.getAlleleVariantAssociations())) { + for (AlleleVariantAssociation existingAssociation : allele.getAlleleVariantAssociations()) { + if (Objects.equals(dto.getAlleleId(), existingAssociation.getAlleleAssociationSubject().getModEntityId())) { + association = alleleVariantAssociationDAO.find(existingAssociation.getId()); + break; + } + } + } + association.setAlleleAssociationSubject(allele); + } + } + } + + association.setAlleleVariantAssociationObject(variant); + association.setRelation(vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.ALLELE_VARIANT_RELATION_VOCABULARY_TERM_SET, "has_variant").getEntity()); + + if (variant == null) { + avaResponse.addErrorMessage("variant", ValidationConstants.INVALID_MESSAGE); + } + + if (avaResponse.hasErrors()) { + throw new ObjectValidationException(dto, avaResponse.errorMessagesString()); + } + + association = alleleVariantAssociationDAO.persist(association); + if (association != null) { + idsAdded.add(association.getId()); + alleleVariantAssociationService.addAssociationToAllele(association); + alleleVariantAssociationService.addAssociationToVariant(association); + } + } +} diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/VariantNoteFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/VariantNoteFmsDTOValidator.java new file mode 100644 index 000000000..3cf356ba5 --- /dev/null +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/VariantNoteFmsDTOValidator.java @@ -0,0 +1,74 @@ +package org.alliancegenome.curation_api.services.validation.dto.fms; + +import java.util.ArrayList; +import java.util.List; + +import org.alliancegenome.curation_api.constants.ValidationConstants; +import org.alliancegenome.curation_api.constants.VocabularyConstants; +import org.alliancegenome.curation_api.dao.ReferenceDAO; +import org.alliancegenome.curation_api.model.entities.Note; +import org.alliancegenome.curation_api.model.entities.Reference; +import org.alliancegenome.curation_api.model.entities.VocabularyTerm; +import org.alliancegenome.curation_api.model.ingest.dto.fms.PublicationRefFmsDTO; +import org.alliancegenome.curation_api.model.ingest.dto.fms.VariantNoteFmsDTO; +import org.alliancegenome.curation_api.response.ObjectResponse; +import org.alliancegenome.curation_api.services.PersonService; +import org.alliancegenome.curation_api.services.ReferenceService; +import org.alliancegenome.curation_api.services.VocabularyTermService; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; + +@RequestScoped +public class VariantNoteFmsDTOValidator { + + @Inject ReferenceDAO referenceDAO; + @Inject ReferenceService referenceService; + @Inject PersonService personService; + @Inject VocabularyTermService vocabularyTermService; + + public ObjectResponse validateVariantNoteFmsDTO(VariantNoteFmsDTO dto) { + Note note = new Note(); + ObjectResponse noteResponse = new ObjectResponse<>(); + + if (StringUtils.isBlank(dto.getNote())) { + noteResponse.addErrorMessage("note", ValidationConstants.REQUIRED_MESSAGE); + } + note.setFreeText(dto.getNote()); + + VocabularyTerm noteType = vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.VARIANT_NOTE_TYPES_VOCABULARY_TERM_SET, "comment").getEntity(); + if (noteType == null) { + noteResponse.addErrorMessage("note_type", ValidationConstants.INVALID_MESSAGE + " (comment)"); + } + note.setNoteType(noteType); + + if (CollectionUtils.isNotEmpty(dto.getReferences())) { + List noteReferences = new ArrayList<>(); + for (PublicationRefFmsDTO publicationDto : dto.getReferences()) { + if (StringUtils.isBlank(publicationDto.getPublicationId())) { + noteResponse.addErrorMessage("references - publicationId", ValidationConstants.REQUIRED_MESSAGE); + } else { + Reference reference = null; + reference = referenceService.retrieveFromDbOrLiteratureService(publicationDto.getPublicationId()); + if (reference == null) { + noteResponse.addErrorMessage("evidence_curies", ValidationConstants.INVALID_MESSAGE + " (" + publicationDto.getPublicationId() + ")"); + break; + } + noteReferences.add(reference); + } + } + note.setReferences(noteReferences); + } else { + note.setReferences(null); + } + + note.setInternal(false); + + noteResponse.setEntity(note); + + return noteResponse; + } + +} diff --git a/src/main/java/org/alliancegenome/curation_api/view/View.java b/src/main/java/org/alliancegenome/curation_api/view/View.java index 24dc2fbc4..4cfb53a03 100644 --- a/src/main/java/org/alliancegenome/curation_api/view/View.java +++ b/src/main/java/org/alliancegenome/curation_api/view/View.java @@ -105,6 +105,9 @@ public static class VariantUpdate extends GeneView { public static class VariantCreate extends GeneView { } + + public static class VariantDetailView extends VariantView { + } public static class GeneInteractionView extends FieldsOnly { } diff --git a/src/main/java/org/alliancegenome/curation_api/websocket/IndexProcessingWebsocket.java b/src/main/java/org/alliancegenome/curation_api/websocket/IndexProcessingWebsocket.java index 8fbf88d94..2e140c837 100644 --- a/src/main/java/org/alliancegenome/curation_api/websocket/IndexProcessingWebsocket.java +++ b/src/main/java/org/alliancegenome/curation_api/websocket/IndexProcessingWebsocket.java @@ -1,15 +1,15 @@ package org.alliancegenome.curation_api.websocket; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; import org.alliancegenome.curation_api.model.event.index.IndexProcessingEvent; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.event.Observes; +import jakarta.enterprise.event.ObservesAsync; import jakarta.inject.Inject; import jakarta.websocket.OnClose; import jakarta.websocket.OnError; @@ -26,7 +26,7 @@ public class IndexProcessingWebsocket { @Inject ObjectMapper mapper; - Map sessions = new ConcurrentHashMap<>(); + Map sessions = new HashMap<>(); @Getter private IndexProcessingEvent event; @@ -66,7 +66,7 @@ public void message(String message, Session session) { // session.getOpenSessions().forEach(s -> s.getAsyncRemote().sendText(message)); } - public void observeProcessingEvent(@Observes IndexProcessingEvent event) { + public void observeProcessingEvent(@ObservesAsync IndexProcessingEvent event) { this.event = event; //Log.info(sessions); for (Entry sessionEntry : sessions.entrySet()) { diff --git a/src/main/java/org/alliancegenome/curation_api/websocket/LoadProcessingWebsocket.java b/src/main/java/org/alliancegenome/curation_api/websocket/LoadProcessingWebsocket.java index 28f0ef6d7..5a9b7f6b1 100644 --- a/src/main/java/org/alliancegenome/curation_api/websocket/LoadProcessingWebsocket.java +++ b/src/main/java/org/alliancegenome/curation_api/websocket/LoadProcessingWebsocket.java @@ -1,15 +1,15 @@ package org.alliancegenome.curation_api.websocket; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; import org.alliancegenome.curation_api.model.event.load.LoadProcessingEvent; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.event.Observes; +import jakarta.enterprise.event.ObservesAsync; import jakarta.inject.Inject; import jakarta.websocket.OnClose; import jakarta.websocket.OnError; @@ -25,7 +25,7 @@ public class LoadProcessingWebsocket { @Inject ObjectMapper mapper; - Map sessions = new ConcurrentHashMap<>(); + Map sessions = new HashMap<>(); @OnOpen public void onOpen(Session session) { @@ -59,7 +59,7 @@ public void message(String message, Session session) { // session.getOpenSessions().forEach(s -> s.getAsyncRemote().sendText(message)); } - public void observeProcessingEvent(@Observes LoadProcessingEvent event) { + public void observeProcessingEvent(@ObservesAsync LoadProcessingEvent event) { //Log.info(sessions); //Log.info(event); for (Entry sessionEntry : sessions.entrySet()) { diff --git a/src/main/resources/application.properties.defaults b/src/main/resources/application.properties.defaults index f8686f556..f1cf5b070 100644 --- a/src/main/resources/application.properties.defaults +++ b/src/main/resources/application.properties.defaults @@ -34,7 +34,7 @@ quarkus.flyway.clean-disabled=true quarkus.elasticsearch.protocol = http -quarkus.hibernate-search-orm.elasticsearch.version=opensearch:1.2.4 +quarkus.hibernate-search-orm.elasticsearch.version=opensearch:2.16.0 quarkus.hibernate-search-orm.elasticsearch.protocol=http quarkus.hibernate-search-orm.elasticsearch.read-timeout=600S quarkus.hibernate-search-orm.schema-management.strategy=create-or-update diff --git a/src/main/resources/db/migration/v0.36.0.7__expression_pattern.sql b/src/main/resources/db/migration/v0.36.0.7__expression_pattern.sql new file mode 100644 index 000000000..ab500c931 --- /dev/null +++ b/src/main/resources/db/migration/v0.36.0.7__expression_pattern.sql @@ -0,0 +1,240 @@ + +CREATE SEQUENCE public.expressionpattern_seq START WITH 1 INCREMENT BY 50 NO MINVALUE NO MAXVALUE CACHE 1; +CREATE SEQUENCE public.temporalcontext_seq START WITH 1 INCREMENT BY 50 NO MINVALUE NO MAXVALUE CACHE 1; +CREATE SEQUENCE public.anatomicalsite_seq START WITH 1 INCREMENT BY 50 NO MINVALUE NO MAXVALUE CACHE 1; + +CREATE TABLE expressionpattern ( + id BIGINT CONSTRAINT expressionpattern_pkey PRIMARY KEY, + whenexpressed_id BIGINT, + whereexpressed_id BIGINT, + datecreated timestamp without time zone, + dbdatecreated timestamp without time zone, + dateupdated timestamp without time zone, + dbdateupdated timestamp without time zone, + internal boolean DEFAULT false, + obsolete boolean DEFAULT false, + createdby_id bigint, + updatedby_id bigint +); + +CREATE TABLE temporalcontext ( + id BIGINT CONSTRAINT temporalcontext_pkey PRIMARY KEY, + developmentalstagestart_id BIGINT, + developmentalstagestop_id BIGINT, + age VARCHAR(1000), + datecreated timestamp without time zone, + dbdatecreated timestamp without time zone, + dateupdated timestamp without time zone, + dbdateupdated timestamp without time zone, + internal boolean DEFAULT false, + obsolete boolean DEFAULT false, + createdby_id bigint, + updatedby_id bigint +); + +CREATE TABLE anatomicalsite ( + id BIGINT CONSTRAINT anatomicalsite_pkey PRIMARY KEY, + anatomicalstructure_id BIGINT, + anatomicalsubstructure_id BIGINT, + cellularcomponentterm_id BIGINT, + datecreated timestamp without time zone, + dbdatecreated timestamp without time zone, + dateupdated timestamp without time zone, + dbdateupdated timestamp without time zone, + internal boolean DEFAULT false, + obsolete boolean DEFAULT false, + createdby_id bigint, + updatedby_id bigint +); + +CREATE TABLE anatomicalsite_anatomicalstructurequalifiers ( + anatomicalsite_id BIGINT, + anatomicalstructurequalifiers_id BIGINT +); + +CREATE TABLE anatomicalsite_anatomicalsubstructurequalifiers ( + anatomicalsite_id BIGINT, + anatomicalsubstructurequalifiers_id BIGINT +); + +CREATE TABLE anatomicalsite_cellularcomponentqualifiers ( + anatomicalsite_id BIGINT, + cellularcomponentqualifiers_id BIGINT +); + +CREATE TABLE anatomicalsite_anatomicalstructureuberonterms ( + anatomicalsite_id BIGINT, + anatomicalstructureuberonterms_id BIGINT +); + +CREATE TABLE anatomicalsite_anatomicalsubstructureuberonterms ( + anatomicalsite_id BIGINT, + anatomicalsubstructureuberonterms_id BIGINT +); + +CREATE TABLE temporalcontext_stageuberonslimterms ( + temporalcontext_id BIGINT, + stageuberonslimterms_id BIGINT +); + +CREATE TABLE temporalcontext_temporalqualifiers ( + temporalcontext_id BIGINT, + temporalqualifiers_id BIGINT +); + +ALTER TABLE expressionannotation + ADD COLUMN expressionpattern_id BIGINT; + +ALTER TABLE expressionannotation + ADD CONSTRAINT expressionannotationexpressionpattern_fk + FOREIGN KEY (expressionpattern_id) REFERENCES expressionpattern(id); + +ALTER TABLE expressionpattern + ADD CONSTRAINT expressionpattern_whenexpressed_fk + FOREIGN KEY (whenexpressed_id) REFERENCES temporalcontext(id); + +ALTER TABLE expressionpattern + ADD CONSTRAINT expressionpattern_whereexpressed_fk + FOREIGN KEY (whereexpressed_id) REFERENCES anatomicalsite(id); + +ALTER TABLE anatomicalsite_anatomicalstructurequalifiers + ADD CONSTRAINT anatomicalstructurequalifiers_anatomicalsite_fk + FOREIGN KEY (anatomicalsite_id) REFERENCES anatomicalsite(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + +ALTER TABLE anatomicalsite_anatomicalstructurequalifiers + ADD CONSTRAINT anatomicalstructurequalifiers_structurequalifier_fk + FOREIGN KEY (anatomicalstructurequalifiers_id) REFERENCES vocabularyterm(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + +ALTER TABLE anatomicalsite_anatomicalsubstructurequalifiers + ADD CONSTRAINT anatomicalsubstructurequalifiers_anatomicalsite_fk + FOREIGN KEY (anatomicalsite_id) REFERENCES anatomicalsite(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + +ALTER TABLE anatomicalsite_anatomicalsubstructurequalifiers + ADD CONSTRAINT anatomicalsubstructurequalifiers_qualifier_fk + FOREIGN KEY (anatomicalsubstructurequalifiers_id) REFERENCES vocabularyterm(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + +ALTER TABLE anatomicalsite_cellularcomponentqualifiers + ADD CONSTRAINT cellularcomponentqualifiers_anatomicalsite_fk + FOREIGN KEY (anatomicalsite_id) REFERENCES anatomicalsite(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + +ALTER TABLE anatomicalsite_cellularcomponentqualifiers + ADD CONSTRAINT cellularcomponentqualifiers_cellularcomponentqualifier_fk + FOREIGN KEY (cellularcomponentqualifiers_id) REFERENCES vocabularyterm(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + +ALTER TABLE anatomicalsite_anatomicalstructureuberonterms + ADD CONSTRAINT anatomicalstructureuberonterms_anatomicalsite_fk + FOREIGN KEY (anatomicalsite_id) REFERENCES anatomicalsite(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + +ALTER TABLE anatomicalsite_anatomicalstructureuberonterms + ADD CONSTRAINT anatomicalstructureuberonterms_uberonterm_fk + FOREIGN KEY (anatomicalstructureuberonterms_id) REFERENCES ontologyterm(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + +ALTER TABLE anatomicalsite_anatomicalsubstructureuberonterms + ADD CONSTRAINT anatomicalsubstructureuberonterms_anatomicalsite_fk + FOREIGN KEY (anatomicalsite_id) REFERENCES anatomicalsite(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + +ALTER TABLE anatomicalsite_anatomicalsubstructureuberonterms + ADD CONSTRAINT anatomicalsubstructureuberonterms_uberonterm_fk + FOREIGN KEY (anatomicalsubstructureuberonterms_id) REFERENCES ontologyterm(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + +ALTER TABLE temporalcontext_stageuberonslimterms + ADD CONSTRAINT stageuberonterms_temporalcontext_fk + FOREIGN KEY (temporalcontext_id) REFERENCES temporalcontext(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + +ALTER TABLE temporalcontext_stageuberonslimterms + ADD CONSTRAINT stageuberonslimterms_uberonterm_fk + FOREIGN KEY (stageuberonslimterms_id) REFERENCES vocabularyterm(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + +ALTER TABLE temporalcontext_temporalqualifiers + ADD CONSTRAINT temporalqualifiers_temporalcontext_fk + FOREIGN KEY (temporalcontext_id) REFERENCES temporalcontext(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + +ALTER TABLE temporalcontext_temporalqualifiers + ADD CONSTRAINT temporalqualifiers_temporqualifiers_fk + FOREIGN KEY (temporalqualifiers_id) REFERENCES vocabularyterm(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + + +CREATE INDEX expressionannotation_expressionpattern_index ON expressionannotation USING btree (expressionpattern_id); + +CREATE INDEX expressionpattern_whenexpressed_index ON expressionpattern USING btree (whenexpressed_id); +CREATE INDEX expressionpattern_whereexpressed_index ON expressionpattern USING btree (whereexpressed_id); + +CREATE INDEX temporalcontext_developmentalstagestart_index ON temporalcontext USING btree (developmentalstagestart_id); +CREATE INDEX temporalcontext_developmentalstagestop_index ON temporalcontext USING btree (developmentalstagestop_id); +CREATE INDEX temporalcontext_age_index ON temporalcontext USING btree (age); +CREATE INDEX temporalqualifiers_temporalcontext_index ON temporalcontext_temporalqualifiers USING btree (temporalcontext_id); +CREATE INDEX temporalqualifiers_temporalqualifiers_index ON temporalcontext_temporalqualifiers USING btree (temporalqualifiers_id); +CREATE INDEX stageuberonslimterms_temporalcontext_index ON temporalcontext_stageuberonslimterms USING btree (temporalcontext_id); +CREATE INDEX stageuberonslimterms_uberonterms_index ON temporalcontext_stageuberonslimterms USING btree (stageuberonslimterms_id); + +CREATE INDEX anatomicalsite_anatomicalstructure_index ON anatomicalsite USING btree (anatomicalstructure_id); +CREATE INDEX anatomicalsite_anatomicalsubstructure_index ON anatomicalsite USING btree (anatomicalsubstructure_id); +CREATE INDEX anatomicalsite_cellularcomponentterm_index ON anatomicalsite USING btree (cellularcomponentterm_id); +CREATE INDEX anatomicalstructurequalifiers_anatomicalsite_index ON anatomicalsite_anatomicalstructurequalifiers USING btree (anatomicalsite_id); +CREATE INDEX anatomicalstructurequalifiers_structurequalifiers_index ON anatomicalsite_anatomicalstructurequalifiers USING btree (anatomicalstructurequalifiers_id); +CREATE INDEX anatomicalsubstructurequalifiers_anatomicalsite_index ON anatomicalsite_anatomicalsubstructurequalifiers USING btree (anatomicalsite_id); +CREATE INDEX anatomicalsubstructurequalifiers_qualifiers_index ON anatomicalsite_anatomicalsubstructurequalifiers USING btree (anatomicalsubstructurequalifiers_id); +CREATE INDEX cellularcomponentqualifiers_anatomicalsite_index ON anatomicalsite_cellularcomponentqualifiers USING btree (anatomicalsite_id); +CREATE INDEX cellularcomponentqualifiers_qualifiers_index ON anatomicalsite_cellularcomponentqualifiers USING btree (cellularcomponentqualifiers_id); +CREATE INDEX anatomicalstructureuberonterms_anatomicalsite_index ON anatomicalsite_anatomicalstructureuberonterms USING btree (anatomicalsite_id); +CREATE INDEX anatomicalstructureuberonterms_uberonterms_index ON anatomicalsite_anatomicalstructureuberonterms USING btree (anatomicalstructureuberonterms_id); +CREATE INDEX anatomicalsubstructureuberonterms_anatomicalsite_index ON anatomicalsite_anatomicalsubstructureuberonterms USING btree (anatomicalsite_id); +CREATE INDEX anatomicalsubstructureuberonterms_uberonterms_index ON anatomicalsite_anatomicalsubstructureuberonterms USING btree (anatomicalsubstructureuberonterms_id); + + +INSERT INTO vocabulary (id, name, vocabularylabel) VALUES (nextval('vocabulary_seq'), 'Stage Uberon Slim Terms', 'stage_uberon_slim_terms'); +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'post embryonic', id FROM vocabulary WHERE vocabularylabel = 'stage_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'pre-adult', id FROM vocabulary WHERE vocabularylabel = 'stage_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0000113', id FROM vocabulary WHERE vocabularylabel = 'stage_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0000068', id FROM vocabulary WHERE vocabularylabel = 'stage_uberon_slim_terms'; + +INSERT INTO vocabulary (id, name, vocabularylabel) VALUES (nextval('vocabulary_seq'), 'Anatomical Structure Uberon Slim Terms', 'anatomical_structure_uberon_slim_terms'); +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0001009', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0005409', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0000949', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0001008', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0002330', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0002193', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0002416', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0002423', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0002204', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0001016', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0000990', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0001004', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0001032', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0005726', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0007037', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0002105', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0002104', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0000924', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0000925', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0000926', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0003104', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0001013', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0000026', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0016887', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:6005023', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'UBERON:0002539', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'Other', id FROM vocabulary WHERE vocabularylabel = 'anatomical_structure_uberon_slim_terms'; + +INSERT INTO vocabulary (id, name, vocabularylabel) VALUES (nextval('vocabulary_seq'), 'Cellular Component Qualifiers', 'cellular_component_qualifiers'); +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000046', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000047', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000048', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000050', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000053', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000054', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000055', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000058', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000059', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000063', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000065', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000066', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000067', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000070', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000167', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000168', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000169', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000170', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000171', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000653', id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; diff --git a/src/main/resources/db/migration/v0.37.0.10__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.10__remove_dataprovider_dups.sql new file mode 100644 index 000000000..b4c4b4803 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.10__remove_dataprovider_dups.sql @@ -0,0 +1,36 @@ +-- Update all BiologicalEntity.dataProvider to point to a MGI dataprovider that is first in the DB + +UPDATE biologicalentity be +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1, crossreference cr1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id = cr1.id + AND o1.abbreviation = 'MGI' + AND cr1.referencedCurie = 'MGI' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o, crossreference cr +WHERE + be.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id = cr.id AND + o.abbreviation = cr.referencedCurie AND + o.abbreviation = 'MGI'; + +UPDATE biologicalentity be +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id is null + AND o1.abbreviation = 'MGI' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o +WHERE + be.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id is null AND + o.abbreviation = 'MGI'; + diff --git a/src/main/resources/db/migration/v0.37.0.11__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.11__remove_dataprovider_dups.sql new file mode 100644 index 000000000..0da883e0d --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.11__remove_dataprovider_dups.sql @@ -0,0 +1,36 @@ +-- Update all BiologicalEntity.dataProvider to point to a WB dataprovider that is first in the DB + +UPDATE biologicalentity be +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1, crossreference cr1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id = cr1.id + AND o1.abbreviation = 'WB' + AND cr1.referencedCurie = 'WB' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o, crossreference cr +WHERE + be.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id = cr.id AND + o.abbreviation = cr.referencedCurie AND + o.abbreviation = 'WB'; + +UPDATE biologicalentity be +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id is null + AND o1.abbreviation = 'WB' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o +WHERE + be.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id is null AND + o.abbreviation = 'WB'; + diff --git a/src/main/resources/db/migration/v0.37.0.12__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.12__remove_dataprovider_dups.sql new file mode 100644 index 000000000..abcf6bf09 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.12__remove_dataprovider_dups.sql @@ -0,0 +1,36 @@ +-- Update all BiologicalEntity.dataProvider to point to a SGD dataprovider that is first in the DB + +UPDATE biologicalentity be +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1, crossreference cr1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id = cr1.id + AND o1.abbreviation = 'SGD' + AND cr1.referencedCurie = 'SGD' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o, crossreference cr +WHERE + be.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id = cr.id AND + o.abbreviation = cr.referencedCurie AND + o.abbreviation = 'SGD'; + +UPDATE biologicalentity be +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id is null + AND o1.abbreviation = 'SGD' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o +WHERE + be.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id is null AND + o.abbreviation = 'SGD'; + diff --git a/src/main/resources/db/migration/v0.37.0.13__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.13__remove_dataprovider_dups.sql new file mode 100644 index 000000000..d83fc3aad --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.13__remove_dataprovider_dups.sql @@ -0,0 +1,36 @@ +-- Update all BiologicalEntity.dataProvider to point to a RGD dataprovider that is first in the DB + +UPDATE biologicalentity be +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1, crossreference cr1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id = cr1.id + AND o1.abbreviation = 'RGD' + AND cr1.referencedCurie = 'RGD' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o, crossreference cr +WHERE + be.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id = cr.id AND + o.abbreviation = cr.referencedCurie AND + o.abbreviation = 'RGD'; + +UPDATE biologicalentity be +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id is null + AND o1.abbreviation = 'RGD' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o +WHERE + be.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id is null AND + o.abbreviation = 'RGD'; + diff --git a/src/main/resources/db/migration/v0.37.0.14__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.14__remove_dataprovider_dups.sql new file mode 100644 index 000000000..1b31e9112 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.14__remove_dataprovider_dups.sql @@ -0,0 +1,36 @@ +-- Update all BiologicalEntity.dataProvider to point to a ZFIN dataprovider that is first in the DB + +UPDATE biologicalentity be +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1, crossreference cr1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id = cr1.id + AND o1.abbreviation = 'ZFIN' + AND cr1.referencedCurie = 'ZFIN' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o, crossreference cr +WHERE + be.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id = cr.id AND + o.abbreviation = cr.referencedCurie AND + o.abbreviation = 'ZFIN'; + +UPDATE biologicalentity be +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id is null + AND o1.abbreviation = 'ZFIN' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o +WHERE + be.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id is null AND + o.abbreviation = 'ZFIN'; + diff --git a/src/main/resources/db/migration/v0.37.0.15__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.15__remove_dataprovider_dups.sql new file mode 100644 index 000000000..b101a2fdc --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.15__remove_dataprovider_dups.sql @@ -0,0 +1,36 @@ +-- Update all BiologicalEntity.dataProvider to point to a Alliance dataprovider that is first in the DB + +UPDATE biologicalentity be +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1, crossreference cr1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id = cr1.id + AND o1.abbreviation = 'Alliance' + AND cr1.referencedCurie = 'Alliance' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o, crossreference cr +WHERE + be.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id = cr.id AND + o.abbreviation = cr.referencedCurie AND + o.abbreviation = 'Alliance'; + +UPDATE biologicalentity be +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id is null + AND o1.abbreviation = 'Alliance' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o +WHERE + be.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id is null AND + o.abbreviation = 'Alliance'; + diff --git a/src/main/resources/db/migration/v0.37.0.16__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.16__remove_dataprovider_dups.sql new file mode 100644 index 000000000..84eb5e068 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.16__remove_dataprovider_dups.sql @@ -0,0 +1,36 @@ +-- Update all annotation.dataProvider to point to a ZFIN dataprovider that is first in the DB + +UPDATE annotation an +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1, crossreference cr1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id = cr1.id + AND o1.abbreviation = 'ZFIN' + AND cr1.referencedCurie = 'ZFIN' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o, crossreference cr +WHERE + an.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id = cr.id AND + o.abbreviation = cr.referencedCurie AND + o.abbreviation = 'ZFIN'; + +UPDATE annotation an +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id is null + AND o1.abbreviation = 'ZFIN' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o +WHERE + an.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id is null AND + o.abbreviation = 'ZFIN'; + diff --git a/src/main/resources/db/migration/v0.37.0.17__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.17__remove_dataprovider_dups.sql new file mode 100644 index 000000000..59b5622ac --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.17__remove_dataprovider_dups.sql @@ -0,0 +1,36 @@ + + +UPDATE annotation an +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1, crossreference cr1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id = cr1.id + AND o1.abbreviation = 'Alliance' + AND cr1.referencedCurie = 'Alliance' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o, crossreference cr +WHERE + an.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id = cr.id AND + o.abbreviation = cr.referencedCurie AND + o.abbreviation = 'Alliance'; + +UPDATE annotation an +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id is null + AND o1.abbreviation = 'Alliance' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o +WHERE + an.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id is null AND + o.abbreviation = 'Alliance'; + diff --git a/src/main/resources/db/migration/v0.37.0.18__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.18__remove_dataprovider_dups.sql new file mode 100644 index 000000000..35a07035f --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.18__remove_dataprovider_dups.sql @@ -0,0 +1,35 @@ +UPDATE annotation an +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1, crossreference cr1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id = cr1.id + AND o1.abbreviation = 'XB' + AND cr1.referencedCurie = 'XB' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o, crossreference cr +WHERE + an.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id = cr.id AND + o.abbreviation = cr.referencedCurie AND + o.abbreviation = 'XB'; + +UPDATE annotation an +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id is null + AND o1.abbreviation = 'XB' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o +WHERE + an.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id is null AND + o.abbreviation = 'XB'; + + diff --git a/src/main/resources/db/migration/v0.37.0.19__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.19__remove_dataprovider_dups.sql new file mode 100644 index 000000000..1b0a923a7 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.19__remove_dataprovider_dups.sql @@ -0,0 +1,35 @@ +UPDATE annotation an +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1, crossreference cr1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id = cr1.id + AND o1.abbreviation = 'MGI' + AND cr1.referencedCurie = 'MGI' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o, crossreference cr +WHERE + an.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id = cr.id AND + o.abbreviation = cr.referencedCurie AND + o.abbreviation = 'MGI'; + +UPDATE annotation an +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id is null + AND o1.abbreviation = 'MGI' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o +WHERE + an.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id is null AND + o.abbreviation = 'MGI'; + + diff --git a/src/main/resources/db/migration/v0.37.0.1__transcript_association_tables.sql b/src/main/resources/db/migration/v0.37.0.1__transcript_association_tables.sql new file mode 100644 index 000000000..c8207dedf --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.1__transcript_association_tables.sql @@ -0,0 +1,117 @@ +CREATE TABLE transcriptcodingsequenceassociation ( + id bigint CONSTRAINT transcriptcodingsequenceassociation_pkey PRIMARY KEY, + relation_id bigint, + transcriptassociationsubject_id bigint, + transcriptcodingsequenceassociationobject_id bigint +); + +ALTER TABLE transcriptcodingsequenceassociation ADD CONSTRAINT transcriptcodingsequenceassociation_id_fk + FOREIGN KEY (id) REFERENCES evidenceassociation(id); +ALTER TABLE transcriptcodingsequenceassociation ADD CONSTRAINT transcriptcodingsequenceassociation_relation_id_fk + FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); +ALTER TABLE transcriptcodingsequenceassociation ADD CONSTRAINT transcriptcodingsequenceassociation_tasubject_id_fk + FOREIGN KEY (transcriptassociationsubject_id) REFERENCES transcript(id); +ALTER TABLE transcriptcodingsequenceassociation ADD CONSTRAINT transcriptcodingsequenceassociation_tcdsaobject_id_fk + FOREIGN KEY (transcriptcodingsequenceassociationobject_id) REFERENCES codingsequence(id); + +CREATE INDEX transcriptcdsassociation_relation_index ON transcriptcodingsequenceassociation + USING btree (relation_id); +CREATE INDEX transcriptcdsassociation_subject_index ON transcriptcodingsequenceassociation + USING btree (transcriptassociationsubject_id); +CREATE INDEX transcriptcdsassociation_object_index ON transcriptcodingsequenceassociation + USING btree (transcriptcodingsequenceassociationobject_id); + +CREATE TABLE transcriptexonassociation ( + id bigint CONSTRAINT transcriptexonassociation_pkey PRIMARY KEY, + relation_id bigint, + transcriptassociationsubject_id bigint, + transcriptexonassociationobject_id bigint +); + +ALTER TABLE transcriptexonassociation ADD CONSTRAINT transcriptexonassociation_id_fk + FOREIGN KEY (id) REFERENCES evidenceassociation(id); +ALTER TABLE transcriptexonassociation ADD CONSTRAINT transcriptexonassociation_relation_id_fk + FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); +ALTER TABLE transcriptexonassociation ADD CONSTRAINT transcriptexonassociation_tasubject_id_fk + FOREIGN KEY (transcriptassociationsubject_id) REFERENCES transcript(id); +ALTER TABLE transcriptexonassociation ADD CONSTRAINT transcriptexonassociation_teaobject_id_fk + FOREIGN KEY (transcriptexonassociationobject_id) REFERENCES exon(id); + +CREATE INDEX transcriptexonassociation_relation_index ON transcriptexonassociation + USING btree (relation_id); +CREATE INDEX transcriptcodingsequenceassociation_subject_index ON transcriptexonassociation + USING btree (transcriptassociationsubject_id); +CREATE INDEX transcriptexonassociation_object_index ON transcriptexonassociation + USING btree (transcriptexonassociationobject_id); + +CREATE TABLE transcriptgeneassociation ( + id bigint CONSTRAINT transcriptgeneassociation_pkey PRIMARY KEY, + relation_id bigint, + transcriptassociationsubject_id bigint, + transcriptgeneassociationobject_id bigint +); + +ALTER TABLE transcriptgeneassociation ADD CONSTRAINT transcriptgeneassociation_id_fk + FOREIGN KEY (id) REFERENCES evidenceassociation(id); +ALTER TABLE transcriptgeneassociation ADD CONSTRAINT transcriptgeneassociation_relation_id_fk + FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); +ALTER TABLE transcriptgeneassociation ADD CONSTRAINT transcriptgeneassociation_tasubject_id_fk + FOREIGN KEY (transcriptassociationsubject_id) REFERENCES transcript(id); +ALTER TABLE transcriptgeneassociation ADD CONSTRAINT transcriptgeneassociation_tgaobject_id_fk + FOREIGN KEY (transcriptgeneassociationobject_id) REFERENCES gene(id); + +CREATE INDEX transcriptgeneassociation_relation_index ON transcriptgeneassociation + USING btree (relation_id); +CREATE INDEX transcriptgeneassociation_subject_index ON transcriptgeneassociation + USING btree (transcriptassociationsubject_id); +CREATE INDEX transcriptgeneassociation_object_index ON transcriptgeneassociation + USING btree (transcriptgeneassociationobject_id); + +INSERT INTO vocabulary (id, name, vocabularylabel) VALUES (nextval('vocabulary_seq'), 'Transcript Relation', 'transcript_relation'); + +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'is_parent_of', id FROM vocabulary WHERE vocabularylabel = 'transcript_relation'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'is_child_of', id FROM vocabulary WHERE vocabularylabel = 'transcript_relation'; + +INSERT INTO vocabularytermset (id, name, vocabularylabel, vocabularytermsetvocabulary_id) + SELECT nextval('vocabularytermset_seq'), 'Transcript CodingSequence Association Relation', 'transcript_coding_sequence_relation', id FROM vocabulary + WHERE vocabularylabel = 'transcript_relation'; +INSERT INTO vocabularytermset (id, name, vocabularylabel, vocabularytermsetvocabulary_id) + SELECT nextval('vocabularytermset_seq'), 'Transcript Exon Association Relation', 'transcript_exon_relation', id FROM vocabulary + WHERE vocabularylabel = 'transcript_relation'; +INSERT INTO vocabularytermset (id, name, vocabularylabel, vocabularytermsetvocabulary_id) + SELECT nextval('vocabularytermset_seq'), 'Transcript Gene Association Relation', 'transcript_gene_relation', id FROM vocabulary + WHERE vocabularylabel = 'transcript_relation'; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) + WITH t1 AS ( + SELECT id FROM vocabularytermset WHERE vocabularylabel = 'transcript_coding_sequence_relation' + ), + t2 AS ( + SELECT id FROM vocabularyterm WHERE name = 'is_parent_of' AND vocabulary_id = ( + SELECT id FROM vocabulary WHERE vocabularylabel = 'transcript_relation' + ) + ) + SELECT t1.id, t2.id FROM t1, t2; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) + WITH t1 AS ( + SELECT id FROM vocabularytermset WHERE vocabularylabel = 'transcript_exon_relation' + ), + t2 AS ( + SELECT id FROM vocabularyterm WHERE name = 'is_parent_of' AND vocabulary_id = ( + SELECT id FROM vocabulary WHERE vocabularylabel = 'transcript_relation' + ) + ) + SELECT t1.id, t2.id FROM t1, t2; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) + WITH t1 AS ( + SELECT id FROM vocabularytermset WHERE vocabularylabel = 'transcript_gene_relation' + ), + t2 AS ( + SELECT id FROM vocabularyterm WHERE name = 'is_child_of' AND vocabulary_id = ( + SELECT id FROM vocabulary WHERE vocabularylabel = 'transcript_relation' + ) + ) + SELECT t1.id, t2.id FROM t1, t2; + \ No newline at end of file diff --git a/src/main/resources/db/migration/v0.37.0.20__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.20__remove_dataprovider_dups.sql new file mode 100644 index 000000000..126dfe0f7 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.20__remove_dataprovider_dups.sql @@ -0,0 +1,35 @@ +UPDATE annotation an +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1, crossreference cr1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id = cr1.id + AND o1.abbreviation = 'RGD' + AND cr1.referencedCurie = 'RGD' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o, crossreference cr +WHERE + an.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id = cr.id AND + o.abbreviation = cr.referencedCurie AND + o.abbreviation = 'RGD'; + +UPDATE annotation an +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id is null + AND o1.abbreviation = 'RGD' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o +WHERE + an.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id is null AND + o.abbreviation = 'RGD'; + + diff --git a/src/main/resources/db/migration/v0.37.0.21__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.21__remove_dataprovider_dups.sql new file mode 100644 index 000000000..6a17ab82a --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.21__remove_dataprovider_dups.sql @@ -0,0 +1,35 @@ +UPDATE annotation an +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1, crossreference cr1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id = cr1.id + AND o1.abbreviation = 'SGD' + AND cr1.referencedCurie = 'SGD' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o, crossreference cr +WHERE + an.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id = cr.id AND + o.abbreviation = cr.referencedCurie AND + o.abbreviation = 'SGD'; + +UPDATE annotation an +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id is null + AND o1.abbreviation = 'SGD' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o +WHERE + an.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id is null AND + o.abbreviation = 'SGD'; + + diff --git a/src/main/resources/db/migration/v0.37.0.22__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.22__remove_dataprovider_dups.sql new file mode 100644 index 000000000..3cad8c41d --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.22__remove_dataprovider_dups.sql @@ -0,0 +1,35 @@ +UPDATE annotation an +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1, crossreference cr1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id = cr1.id + AND o1.abbreviation = 'FB' + AND cr1.referencedCurie = 'FB' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o, crossreference cr +WHERE + an.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id = cr.id AND + o.abbreviation = cr.referencedCurie AND + o.abbreviation = 'FB'; + +UPDATE annotation an +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id is null + AND o1.abbreviation = 'FB' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o +WHERE + an.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id is null AND + o.abbreviation = 'FB'; + + diff --git a/src/main/resources/db/migration/v0.37.0.23__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.23__remove_dataprovider_dups.sql new file mode 100644 index 000000000..f65984e9f --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.23__remove_dataprovider_dups.sql @@ -0,0 +1,36 @@ + +UPDATE annotation an +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1, crossreference cr1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id = cr1.id + AND o1.abbreviation = 'WB' + AND cr1.referencedCurie = 'WB' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o, crossreference cr +WHERE + an.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id = cr.id AND + o.abbreviation = cr.referencedCurie AND + o.abbreviation = 'WB'; + +UPDATE annotation an +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id is null + AND o1.abbreviation = 'WB' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o +WHERE + an.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id is null AND + o.abbreviation = 'WB'; + + diff --git a/src/main/resources/db/migration/v0.37.0.24__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.24__remove_dataprovider_dups.sql new file mode 100644 index 000000000..715462dfb --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.24__remove_dataprovider_dups.sql @@ -0,0 +1,37 @@ +CREATE TABLE dataprovider_ids_to_keep ( + id bigint PRIMARY KEY +); +CREATE TABLE crossreference_ids_to_delete ( + id bigint +); +CREATE TABLE dataprovider_ids_to_delete ( + id bigint +); + +INSERT INTO dataprovider_ids_to_keep (id) +SELECT dp1.id + FROM dataprovider dp1, organization o1, crossreference cr1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id = cr1.id + AND o1.abbreviation = 'Alliance' + AND cr1.referencedCurie = 'Alliance' + ORDER BY dp1.id ASC LIMIT 1; + +-- select all the dataproviders that we are going to keep +INSERT INTO dataprovider_ids_to_keep (id) SELECT dataprovider_id FROM annotation where dataprovider_id is not null ON CONFLICT (id) DO NOTHING; -- 191431 +INSERT INTO dataprovider_ids_to_keep (id) SELECT dataprovider_id FROM biologicalentity where dataprovider_id is not null ON CONFLICT (id) DO NOTHING; -- 6241140 +INSERT INTO dataprovider_ids_to_keep (id) SELECT dataprovider_id FROM chromosome where dataprovider_id is not null ON CONFLICT (id) DO NOTHING; -- 0 +INSERT INTO dataprovider_ids_to_keep (id) SELECT secondarydataprovider_id FROM diseaseannotation where secondarydataprovider_id is not null ON CONFLICT (id) DO NOTHING; -- 14380 +INSERT INTO dataprovider_ids_to_keep (id) SELECT dataprovider_id FROM reagent where dataprovider_id is not null ON CONFLICT (id) DO NOTHING; -- 226431 +INSERT INTO dataprovider_ids_to_keep (id) SELECT dataprovider_id FROM species where dataprovider_id is not null ON CONFLICT (id) DO NOTHING; -- 10 +-- Total 6673392 + +INSERT INTO crossreference_ids_to_delete (id) select crossreference_id from dataprovider dp left join dataprovider_ids_to_keep dk on dp.id = dk.id where dp.crossreference_id is not null and dk.id is null; -- 42582734 +CREATE INDEX crossreference_ids_to_delete_index ON crossreference_ids_to_delete USING btree (id); + +INSERT INTO dataprovider_ids_to_delete (id) select dp.id from dataprovider dp left join dataprovider_ids_to_keep dk on dp.id = dk.id where dk.id is null; +CREATE INDEX dataprovider_ids_to_delete_index ON dataprovider_ids_to_delete USING btree (id); + +ALTER TABLE ONLY phenotypeannotation DROP CONSTRAINT crossreference_id_fk; +ALTER TABLE ONLY dataprovider DROP CONSTRAINT dataprovider_crossreference_id_fk; +ALTER TABLE ONLY externaldatabaseentity DROP CONSTRAINT externaldatabaseentity_preferredcrossreference_id; diff --git a/src/main/resources/db/migration/v0.37.0.25__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.25__remove_dataprovider_dups.sql new file mode 100644 index 000000000..ebfd4ed96 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.25__remove_dataprovider_dups.sql @@ -0,0 +1,22 @@ +-- This is faster then doing the query in one go as it seems this is done in memory whereas a larger query operates on disk which is much slower + +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 0) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 1000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 1250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 1500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 1750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 2000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 2250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 2500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 2750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 3000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 3250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 3500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 3750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 4000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 4250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 4500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 4750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.26__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.26__remove_dataprovider_dups.sql new file mode 100644 index 000000000..4fde4f3c5 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.26__remove_dataprovider_dups.sql @@ -0,0 +1,20 @@ +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 5000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 5250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 5500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 5750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 6000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 6250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 6500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 6750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 7000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 7250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 7500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 7750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 8000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 8250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 8500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 8750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 9000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 9250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 9500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 9750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.27__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.27__remove_dataprovider_dups.sql new file mode 100644 index 000000000..2be88dac0 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.27__remove_dataprovider_dups.sql @@ -0,0 +1,20 @@ +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 10000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 10250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 10500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 10750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 11000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 11250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 11500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 11750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 12000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 12250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 12500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 12750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 13000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 13250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 13500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 13750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 14000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 14250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 14500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 14750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.28__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.28__remove_dataprovider_dups.sql new file mode 100644 index 000000000..6186a22c7 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.28__remove_dataprovider_dups.sql @@ -0,0 +1,20 @@ +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 15000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 15250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 15500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 15750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 16000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 16250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 16500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 16750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 17000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 17250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 17500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 17750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 18000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 18250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 18500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 18750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 19000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 19250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 19500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 19750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.29__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.29__remove_dataprovider_dups.sql new file mode 100644 index 000000000..c257dafb8 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.29__remove_dataprovider_dups.sql @@ -0,0 +1,20 @@ +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 20000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 20250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 20500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 20750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 21000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 21250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 21500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 21750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 22000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 22250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 22500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 22750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 23000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 23250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 23500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 23750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 24000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 24250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 24500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 24750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.2__Fixing_HTPDataset.sql b/src/main/resources/db/migration/v0.37.0.2__Fixing_HTPDataset.sql new file mode 100644 index 000000000..172b2167c --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.2__Fixing_HTPDataset.sql @@ -0,0 +1,7 @@ +ALTER TABLE htpexpressiondatasetannotation DROP CONSTRAINT htpexpressiondatasetannotation_dataprovider_id_fk; + +ALTER TABLE htpexpressiondatasetannotation DROP COLUMN curie; +ALTER TABLE htpexpressiondatasetannotation DROP COLUMN modentityid; +ALTER TABLE htpexpressiondatasetannotation DROP COLUMN modinternalid; +ALTER TABLE htpexpressiondatasetannotation DROP COLUMN dataprovider_id; + diff --git a/src/main/resources/db/migration/v0.37.0.30__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.30__remove_dataprovider_dups.sql new file mode 100644 index 000000000..bfb3e0e10 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.30__remove_dataprovider_dups.sql @@ -0,0 +1,20 @@ +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 25000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 25250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 25500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 25750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 26000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 26250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 26500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 26750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 27000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 27250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 27500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 27750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 28000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 28250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 28500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 28750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 29000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 29250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 29500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 29750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.31__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.31__remove_dataprovider_dups.sql new file mode 100644 index 000000000..6f301efc3 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.31__remove_dataprovider_dups.sql @@ -0,0 +1,20 @@ +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 30000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 30250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 30500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 30750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 31000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 31250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 31500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 31750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 32000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 32250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 32500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 32750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 33000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 33250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 33500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 33750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 34000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 34250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 34500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 34750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.32__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.32__remove_dataprovider_dups.sql new file mode 100644 index 000000000..6d2e71d86 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.32__remove_dataprovider_dups.sql @@ -0,0 +1,20 @@ +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 35000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 35250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 35500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 35750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 36000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 36250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 36500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 36750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 37000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 37250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 37500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 37750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 38000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 38250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 38500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 38750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 39000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 39250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 39500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 39750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.33__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.33__remove_dataprovider_dups.sql new file mode 100644 index 000000000..71f2c8077 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.33__remove_dataprovider_dups.sql @@ -0,0 +1,20 @@ +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 40000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 40250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 40500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 40750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 41000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 41250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 41500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 41750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 42000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 42250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 42500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 42750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 43000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 43250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 43500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 43750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 44000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 44250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 44500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 44750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.34__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.34__remove_dataprovider_dups.sql new file mode 100644 index 000000000..fed63fae5 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.34__remove_dataprovider_dups.sql @@ -0,0 +1,20 @@ +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 45000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 45250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 45500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 45750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 46000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 46250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 46500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 46750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 47000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 47250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 47500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 47750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 48000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 48250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 48500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 48750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 49000000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 49250000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 49500000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM dataprovider_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 49750000) DELETE FROM dataprovider WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.35__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.35__remove_dataprovider_dups.sql new file mode 100644 index 000000000..d4ecb635e --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.35__remove_dataprovider_dups.sql @@ -0,0 +1,3 @@ + +-- Just in case anything was missed this query should run much faster after all the rows have been deleted +DELETE FROM dataprovider dp USING dataprovider_ids_to_delete cd WHERE dp.id = cd.id; diff --git a/src/main/resources/db/migration/v0.37.0.36__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.36__remove_dataprovider_dups.sql new file mode 100644 index 000000000..571cf2476 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.36__remove_dataprovider_dups.sql @@ -0,0 +1,22 @@ +-- This is faster then doing the query in one go as it seems this is done in memory whereas a larger query operates on disk which is much slower + +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 0) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 1000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 1250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 1500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 1750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 2000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 2250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 2500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 2750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 3000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 3250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 3500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 3750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 4000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 4250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 4500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 4750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.37__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.37__remove_dataprovider_dups.sql new file mode 100644 index 000000000..a67689b29 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.37__remove_dataprovider_dups.sql @@ -0,0 +1,20 @@ +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 5000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 5250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 5500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 5750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 6000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 6250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 6500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 6750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 7000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 7250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 7500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 7750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 8000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 8250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 8500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 8750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 9000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 9250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 9500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 9750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.38__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.38__remove_dataprovider_dups.sql new file mode 100644 index 000000000..54d68ac7e --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.38__remove_dataprovider_dups.sql @@ -0,0 +1,20 @@ +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 10000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 10250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 10500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 10750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 11000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 11250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 11500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 11750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 12000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 12250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 12500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 12750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 13000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 13250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 13500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 13750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 14000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 14250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 14500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 14750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.39__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.39__remove_dataprovider_dups.sql new file mode 100644 index 000000000..70a25d95b --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.39__remove_dataprovider_dups.sql @@ -0,0 +1,20 @@ +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 15000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 15250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 15500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 15750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 16000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 16250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 16500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 16750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 17000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 17250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 17500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 17750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 18000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 18250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 18500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 18750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 19000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 19250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 19500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 19750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.3__cleanup_erroneous_do_terms.sql b/src/main/resources/db/migration/v0.37.0.3__cleanup_erroneous_do_terms.sql new file mode 100644 index 000000000..7beec0550 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.3__cleanup_erroneous_do_terms.sql @@ -0,0 +1,125 @@ +-- Create temporary tables + +CREATE TABLE ontology_ids_to_delete ( + id bigint PRIMARY KEY +); + +CREATE TABLE other_ids_to_delete ( + id bigint PRIMARY KEY +); + +INSERT INTO ontology_ids_to_delete (id) SELECT id FROM ontologyterm + WHERE curie = 'DOID:0080025' OR curie = 'DOID:0080004' OR curie = 'DOID:0080003' + OR curie = 'DOID:0080035' OR curie = 'DOID:0080002'; + +-- Clean up disease annotations + +INSERT INTO other_ids_to_delete (id) SELECT id FROM diseaseannotation WHERE diseaseannotationobject_id IN ( + SELECT id FROM ontology_ids_to_delete +); + +DELETE FROM agmdiseaseannotation_gene WHERE agmdiseaseannotation_id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM agmdiseaseannotation WHERE id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM allelediseaseannotation_gene WHERE allelediseaseannotation_id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM allelediseaseannotation WHERE id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM genediseaseannotation WHERE id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM genediseaseannotation WHERE id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM genediseaseannotation WHERE id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM diseaseannotation_biologicalentity WHERE diseaseannotation_id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM diseaseannotation_gene WHERE diseaseannotation_id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM diseaseannotation_ontologyterm WHERE diseaseannotation_id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM diseaseannotation_vocabularyterm WHERE diseaseannotation_id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM diseaseannotation WHERE id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM annotation_conditionrelation WHERE annotation_id IN (SELECT id FROM other_ids_to_delete); + +CREATE TABLE note_ids_to_delete ( + id bigint PRIMARY KEY +); + +INSERT INTO note_ids_to_delete (id) SELECT relatednotes_id FROM annotation_note WHERE annotation_id IN ( + SELECT id FROM other_ids_to_delete +); + +DELETE FROM annotation_note WHERE annotation_id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM note WHERE id IN (SELECT id FROM note_ids_to_delete); + +DROP TABLE note_ids_to_delete; + +DELETE FROM annotation WHERE id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM singlereferenceassociation WHERE id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM association WHERE id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM other_ids_to_delete; + +-- Clean up xrefs + +INSERT INTO other_ids_to_delete (id) SELECT crossreferences_id FROM ontologyterm_crossreference WHERE ontologyterm_id IN ( + SELECT id FROM ontology_ids_to_delete +); + +DELETE FROM ontologyterm_crossreference WHERE crossreferences_id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM crossreference WHERE id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM other_ids_to_delete; + +-- Clean up definition URLs + +DELETE FROM ontologyterm_definitionurls WHERE ontologyterm_id IN (SELECT id FROM ontology_ids_to_delete); + +-- Clean up ancestor/descendants + +DELETE FROM ontologyterm_isa_ancestor_descendant WHERE isaancestors_id IN (SELECT id FROM ontology_ids_to_delete); + +DELETE FROM ontologyterm_isa_ancestor_descendant WHERE isadescendants_id IN (SELECT id FROM ontology_ids_to_delete); + +-- Clean up parents/children + +DELETE FROM ontologyterm_isa_parent_children WHERE isachildren_id IN (SELECT id FROM ontology_ids_to_delete); + +DELETE FROM ontologyterm_isa_parent_children WHERE isaparents_id IN (SELECT id FROM ontology_ids_to_delete); + +-- Clean up secondary identifiers + +DELETE FROM ontologyterm_secondaryidentifiers where ontologyterm_id IN (SELECT id FROM ontology_ids_to_delete); + +-- Clean up subsets + +DELETE FROM ontologyterm_subsets where ontologyterm_id IN (SELECT id FROM ontology_ids_to_delete); + +-- Clean up synonyms + +INSERT INTO other_ids_to_delete (id) SELECT synonyms_id FROM ontologyterm_synonym WHERE ontologyterm_id IN ( + SELECT id FROM ontology_ids_to_delete +); + +DELETE FROM ontologyterm_synonym WHERE synonyms_id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM synonym WHERE id IN (SELECT id FROM other_ids_to_delete); + +DELETE FROM other_ids_to_delete; + +-- Clean up ontology terms + +DELETE FROM ontologyterm WHERE id IN (SELECT id FROM ontology_ids_to_delete); + +-- Remove temporary tables + +DROP TABLE ontology_ids_to_delete; + +DROP TABLE other_ids_to_delete; \ No newline at end of file diff --git a/src/main/resources/db/migration/v0.37.0.40__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.40__remove_dataprovider_dups.sql new file mode 100644 index 000000000..68859f711 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.40__remove_dataprovider_dups.sql @@ -0,0 +1,20 @@ +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 20000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 20250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 20500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 20750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 21000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 21250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 21500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 21750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 22000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 22250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 22500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 22750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 23000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 23250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 23500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 23750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 24000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 24250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 24500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 24750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.41__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.41__remove_dataprovider_dups.sql new file mode 100644 index 000000000..1500ed3d1 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.41__remove_dataprovider_dups.sql @@ -0,0 +1,20 @@ +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 25000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 25250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 25500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 25750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 26000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 26250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 26500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 26750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 27000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 27250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 27500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 27750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 28000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 28250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 28500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 28750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 29000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 29250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 29500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 29750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.42__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.42__remove_dataprovider_dups.sql new file mode 100644 index 000000000..ff118bb2c --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.42__remove_dataprovider_dups.sql @@ -0,0 +1,20 @@ +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 30000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 30250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 30500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 30750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 31000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 31250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 31500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 31750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 32000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 32250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 32500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 32750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 33000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 33250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 33500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 33750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 34000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 34250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 34500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 34750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.43__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.43__remove_dataprovider_dups.sql new file mode 100644 index 000000000..c6d2fc4db --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.43__remove_dataprovider_dups.sql @@ -0,0 +1,20 @@ +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 35000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 35250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 35500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 35750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 36000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 36250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 36500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 36750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 37000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 37250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 37500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 37750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 38000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 38250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 38500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 38750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 39000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 39250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 39500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 39750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.44__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.44__remove_dataprovider_dups.sql new file mode 100644 index 000000000..29c934d3e --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.44__remove_dataprovider_dups.sql @@ -0,0 +1,20 @@ +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 40000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 40250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 40500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 40750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 41000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 41250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 41500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 41750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 42000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 42250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 42500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 42750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 43000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 43250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 43500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 43750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 44000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 44250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 44500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 44750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.45__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.45__remove_dataprovider_dups.sql new file mode 100644 index 000000000..37dae1a75 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.45__remove_dataprovider_dups.sql @@ -0,0 +1,20 @@ +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 45000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 45250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 45500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 45750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 46000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 46250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 46500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 46750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 47000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 47250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 47500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 47750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 48000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 48250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 48500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 48750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 49000000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 49250000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 49500000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); +WITH ids AS (SELECT id FROM crossreference_ids_to_delete ORDER BY id LIMIT 250000 OFFSET 49750000) DELETE FROM crossreference WHERE id IN (SELECT id FROM ids); diff --git a/src/main/resources/db/migration/v0.37.0.46__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.46__remove_dataprovider_dups.sql new file mode 100644 index 000000000..a6148f5f1 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.46__remove_dataprovider_dups.sql @@ -0,0 +1,160 @@ +DELETE FROM crossreference cr USING crossreference_ids_to_delete cd WHERE cr.id = cd.id; + +DROP TABLE dataprovider_ids_to_keep; +DROP TABLE crossreference_ids_to_delete; +DROP TABLE dataprovider_ids_to_delete; + +ALTER TABLE ONLY phenotypeannotation ADD CONSTRAINT crossreference_id_fk FOREIGN KEY (crossreference_id) REFERENCES crossreference(id); +ALTER TABLE ONLY dataprovider ADD CONSTRAINT dataprovider_crossreference_id_fk FOREIGN KEY (crossreference_id) REFERENCES crossreference(id); +ALTER TABLE ONLY externaldatabaseentity ADD CONSTRAINT externaldatabaseentity_preferredcrossreference_id FOREIGN KEY (preferredcrossreference_id) REFERENCES crossreference(id); + +-- Migration to switch bulk load file and history around + +ALTER TABLE bulkloadfilehistory ADD COLUMN bulkload_id bigint; +ALTER TABLE bulkloadfilehistory ADD COLUMN errormessage text; +ALTER TABLE bulkloadfilehistory ADD COLUMN bulkloadstatus character varying(255); +ALTER TABLE bulkloadfilehistory ADD CONSTRAINT bulkloadfilehistory_bulkload_fk FOREIGN KEY (bulkload_id) REFERENCES bulkload(id); + +CREATE INDEX bulkloadfilehistory_bulkloadstatus_index ON bulkloadfilehistory USING btree (bulkloadstatus); +CREATE INDEX bulkloadfilehistory_bulkload_index ON bulkloadfilehistory USING btree (bulkload_id); +CREATE INDEX bulkloadfile_md5sum_index ON bulkloadfile USING btree (md5sum); + +UPDATE bulkloadfilehistory bh +SET bulkload_id = bf.bulkload_id +FROM bulkloadfile bf +WHERE + bf.id = bh.bulkloadfile_id; + +UPDATE bulkloadfilehistory bh +SET errormessage = bf.errormessage +FROM bulkloadfile bf +WHERE + bf.id = bh.bulkloadfile_id; + +UPDATE bulkloadfilehistory bh +SET bulkloadstatus = bf.bulkloadstatus +FROM bulkloadfile bf +WHERE + bf.id = bh.bulkloadfile_id; + +DELETE from bulkloadfilehistory where bulkloadfile_id is null; + +ALTER TABLE bulkloadfile DROP COLUMN bulkload_id; +ALTER TABLE bulkloadfile DROP COLUMN errorMessage; +ALTER TABLE bulkloadfile DROP COLUMN bulkloadStatus; + +DELETE from bulkloadfileexception where bulkloadfilehistory_id in (select id from bulkloadfilehistory where bulkload_id in (select id from bulkload where name like '%GFF%')); +DELETE from bulkloadfilehistory where bulkload_id in (select id from bulkload where name like '%GFF%'); + +DELETE from bulkfmsload where id in (select id from bulkload where name like '%GFF%'); +DELETE from bulkscheduledload where id in (select id from bulkload where name like '%GFF%'); +DELETE from bulkload where name like '%GFF%'; +DELETE from bulkloadgroup where name = 'GFF Loads'; + +INSERT INTO bulkloadgroup (id, name) VALUES (nextval('bulkloadgroup_seq'), 'File Management System (FMS) GFF Loads'); + +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT', 'FB GFF Transcript Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT', 'Human GFF Transcript Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT', 'MGI GFF Transcript Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT', 'RGD GFF Transcript Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT', 'SGD GFF Transcript Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT', 'WB GFF Transcript Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT', 'XBXL GFF Transcript Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT', 'XBXT GFF Transcript Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT', 'ZFIN GFF Transcript Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; + +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_CDS', 'FB GFF CDS Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_CDS', 'Human GFF CDS Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_CDS', 'MGI GFF CDS Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_CDS', 'RGD GFF CDS Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_CDS', 'SGD GFF CDS Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_CDS', 'WB GFF CDS Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_CDS', 'XBXL GFF CDS Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_CDS', 'XBXT GFF CDS Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_CDS', 'ZFIN GFF CDS Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; + +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_EXON', 'FB GFF Exon Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_EXON', 'Human GFF Exon Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_EXON', 'MGI GFF Exon Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_EXON', 'RGD GFF Exon Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_EXON', 'SGD GFF Exon Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_EXON', 'WB GFF Exon Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_EXON', 'XBXL GFF Exon Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_EXON', 'XBXT GFF Exon Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_EXON', 'ZFIN GFF Exon Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; + +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_EXON_LOCATION', 'FB GFF Exon Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_EXON_LOCATION', 'Human GFF Exon Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_EXON_LOCATION', 'MGI GFF Exon Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_EXON_LOCATION', 'RGD GFF Exon Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_EXON_LOCATION', 'SGD GFF Exon Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_EXON_LOCATION', 'WB GFF Exon Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_EXON_LOCATION', 'XBXL GFF Exon Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_EXON_LOCATION', 'XBXT GFF Exon Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_EXON_LOCATION', 'ZFIN GFF Exon Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; + +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_CDS_LOCATION', 'FB GFF CDS Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_CDS_LOCATION', 'Human GFF CDS Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_CDS_LOCATION', 'MGI GFF CDS Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_CDS_LOCATION', 'RGD GFF CDS Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_CDS_LOCATION', 'SGD GFF CDS Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_CDS_LOCATION', 'WB GFF CDS Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_CDS_LOCATION', 'XBXL GFF CDS Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_CDS_LOCATION', 'XBXT GFF CDS Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_CDS_LOCATION', 'ZFIN GFF CDS Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; + +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_LOCATION', 'FB GFF Transcript Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_LOCATION', 'Human GFF Transcript Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_LOCATION', 'MGI GFF Transcript Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_LOCATION', 'RGD GFF Transcript Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_LOCATION', 'SGD GFF Transcript Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_LOCATION', 'WB GFF Transcript Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_LOCATION', 'XBXL GFF Transcript Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_LOCATION', 'XBXT GFF Transcript Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_LOCATION', 'ZFIN GFF Transcript Location Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; + +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_GENE', 'FB GFF Transcript Gene Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_GENE', 'Human GFF Transcript Gene Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_GENE', 'MGI GFF Transcript Gene Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_GENE', 'RGD GFF Transcript Gene Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_GENE', 'SGD GFF Transcript Gene Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_GENE', 'WB GFF Transcript Gene Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_GENE', 'XBXL GFF Transcript Gene Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_GENE', 'XBXT GFF Transcript Gene Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_GENE', 'ZFIN GFF Transcript Gene Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; + +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_EXON', 'FB GFF Transcript Exon Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_EXON', 'Human GFF Transcript Exon Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_EXON', 'MGI GFF Transcript Exon Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_EXON', 'RGD GFF Transcript Exon Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_EXON', 'SGD GFF Transcript Exon Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_EXON', 'WB GFF Transcript Exon Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_EXON', 'XBXL GFF Transcript Exon Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_EXON', 'XBXT GFF Transcript Exon Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_EXON', 'ZFIN GFF Transcript Exon Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; + +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_CDS', 'FB GFF Transcript CDS Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_CDS', 'Human GFF Transcript CDS Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_CDS', 'MGI GFF Transcript CDS Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_CDS', 'RGD GFF Transcript CDS Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_CDS', 'SGD GFF Transcript CDS Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_CDS', 'WB GFF Transcript CDS Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_CDS', 'XBXL GFF Transcript CDS Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_CDS', 'XBXT GFF Transcript CDS Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) SELECT nextval('bulkload_seq'), 'GFF_TRANSCRIPT_CDS', 'ZFIN GFF Transcript CDS Association Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) GFF Loads'; + +INSERT INTO bulkscheduledload (id, cronschedule, scheduleactive) SELECT id, '0 0 22 ? * SUN-THU', false FROM bulkload WHERE backendbulkloadtype in( + 'GFF_TRANSCRIPT', 'GFF_CDS', 'GFF_EXON', + 'GFF_EXON_LOCATION', 'GFF_CDS_LOCATION', 'GFF_TRANSCRIPT_LOCATION', + 'GFF_TRANSCRIPT_GENE', 'GFF_TRANSCRIPT_EXON', 'GFF_TRANSCRIPT_CDS' +); + +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) SELECT id, 'GFF', 'FB' FROM bulkload WHERE name like 'FB GFF%'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) SELECT id, 'GFF', 'HUMAN' FROM bulkload WHERE name like 'Human GFF%'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) SELECT id, 'GFF', 'MGI' FROM bulkload WHERE name like 'MGI GFF%'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) SELECT id, 'GFF', 'RGD' FROM bulkload WHERE name like 'RGD GFF%'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) SELECT id, 'GFF', 'SGD' FROM bulkload WHERE name like 'SGD GFF%'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) SELECT id, 'GFF', 'WB' FROM bulkload WHERE name like 'WB GFF%'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) SELECT id, 'GFF', 'XBXL' FROM bulkload WHERE name like 'XBXL GFF%'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) SELECT id, 'GFF', 'XBXT' FROM bulkload WHERE name like 'XBXT GFF%'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) SELECT id, 'GFF', 'ZFIN' FROM bulkload WHERE name like 'ZFIN GFF%'; diff --git a/src/main/resources/db/migration/v0.37.0.47__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.47__remove_dataprovider_dups.sql new file mode 100644 index 000000000..310711a7f --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.47__remove_dataprovider_dups.sql @@ -0,0 +1,16 @@ +ALTER TABLE bulkloadfilehistory DROP COLUMN totaldeleterecords; +ALTER TABLE bulkloadfilehistory DROP COLUMN deletefailedrecords; +ALTER TABLE bulkloadfilehistory DROP COLUMN deletedrecords; +ALTER TABLE bulkloadfilehistory DROP COLUMN errorrate; +ALTER TABLE bulkloadfilehistory DROP COLUMN completedrecords; +ALTER TABLE bulkloadfilehistory DROP COLUMN totalrecords; +ALTER TABLE bulkloadfilehistory DROP COLUMN failedrecords; + +ALTER TABLE bulkloadfilehistory ADD COLUMN counts jsonb; + +delete from bulkfmsload where id in (select id from bulkload where backendbulkloadtype like '%_LOCATION' or backendbulkloadtype like 'GFF_%_GENE' or backendbulkloadtype like 'GFF_%_CDS' or backendbulkloadtype like 'GFF_%_EXON'); +delete from bulkscheduledload where id in (select id from bulkload where backendbulkloadtype like '%_LOCATION' or backendbulkloadtype like 'GFF_%_GENE' or backendbulkloadtype like 'GFF_%_CDS' or backendbulkloadtype like 'GFF_%_EXON'); +delete from bulkloadfileexception where bulkloadfilehistory_id in (select id from bulkloadfilehistory where bulkload_id in (select id from bulkload where backendbulkloadtype like '%_LOCATION' or backendbulkloadtype like 'GFF_%_GENE' or backendbulkloadtype like 'GFF_%_CDS' or backendbulkloadtype like 'GFF_%_EXON')); +delete from bulkloadfilehistory where bulkload_id in (select id from bulkload where backendbulkloadtype like '%_LOCATION' or backendbulkloadtype like 'GFF_%_GENE' or backendbulkloadtype like 'GFF_%_CDS' or backendbulkloadtype like 'GFF_%_EXON'); +delete from bulkload where backendbulkloadtype like '%_LOCATION' or backendbulkloadtype like 'GFF_%_GENE' or backendbulkloadtype like 'GFF_%_CDS' or backendbulkloadtype like 'GFF_%_EXON'; + diff --git a/src/main/resources/db/migration/v0.37.0.48__adding_dataprovide_to_htp.sql b/src/main/resources/db/migration/v0.37.0.48__adding_dataprovide_to_htp.sql new file mode 100644 index 000000000..6fae0b441 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.48__adding_dataprovide_to_htp.sql @@ -0,0 +1,8 @@ +ALTER TABLE htpexpressiondatasetannotation ADD COLUMN dataprovider_id BIGINT; +ALTER TABLE htpexpressiondatasetannotation ADD CONSTRAINT htpexpressiondatasetannotation_dataprovider_id_fk FOREIGN KEY (dataprovider_id) REFERENCES dataprovider(id); +CREATE INDEX htpdatasetannotation_dataprovider_index ON htpexpressiondatasetannotation USING btree (dataprovider_id); + +CREATE INDEX htpdatasetannotation_htpExpressionDataset_index ON htpexpressiondatasetannotation USING btree (htpExpressionDataset_id); +CREATE INDEX htpdatasetannotation_relatednote_index ON htpexpressiondatasetannotation USING btree (relatednote_id); +CREATE INDEX htpdatasetannotation_createdby_index ON htpexpressiondatasetannotation USING btree (createdby_id); +CREATE INDEX htpdatasetannotation_updatedby_index ON htpexpressiondatasetannotation USING btree (updatedby_id); \ No newline at end of file diff --git a/src/main/resources/db/migration/v0.37.0.49__flatten_assocations.sql b/src/main/resources/db/migration/v0.37.0.49__flatten_assocations.sql new file mode 100644 index 000000000..a3b0ab07b --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.49__flatten_assocations.sql @@ -0,0 +1,651 @@ +CREATE TABLE association_gene ( + agmdiseaseannotation_id bigint, + assertedgenes_id bigint, + allelediseaseannotation_id bigint, + diseaseannotation_id bigint, + with_id bigint, + allelephenotypeannotation_id bigint, + agmphenotypeannotation_id bigint +); + +CREATE TABLE association_biologicalentity ( + diseaseannotation_id bigint NOT NULL, + diseasegeneticmodifiers_id bigint NOT NULL +); + +CREATE TABLE association_conditionrelation ( + annotation_id bigint NOT NULL, + conditionrelations_id bigint NOT NULL +); + +CREATE TABLE association_crossreference ( + geneinteraction_id bigint NOT NULL, + crossreferences_id bigint NOT NULL +); + +CREATE TABLE association_informationcontententity ( + evidenceassociation_id bigint NOT NULL, + evidence_id bigint NOT NULL +); + +CREATE TABLE association_note ( + annotation_id bigint, + relatednotes_id bigint, + constructgenomicentityassociation_id bigint +); + +CREATE TABLE association_ontologyterm ( + diseaseannotation_id bigint, + evidencecodes_id bigint, + phenotypeannotation_id bigint, + phenotypeterms_id bigint +); + +CREATE TABLE association_vocabularyterm ( + diseaseannotation_id bigint NOT NULL, + diseasequalifiers_id bigint NOT NULL +); + +ALTER TABLE association + ADD COLUMN curie character varying(255), + ADD COLUMN modentityid character varying(255), + ADD COLUMN modinternalid character varying(255), + ADD COLUMN uniqueid character varying(3500), + ADD COLUMN phenotypeannotationobject character varying(255), + ADD COLUMN whenexpressedstagename character varying(2000), + ADD COLUMN whereexpressedstatement character varying(2000), + ADD COLUMN "end" integer, + ADD COLUMN start integer, + ADD COLUMN strand character varying(1), + ADD COLUMN negated boolean DEFAULT false NOT NULL, + ADD COLUMN interactionid character varying(255), + ADD COLUMN phase integer, + ADD COLUMN constructassociationsubject_id bigint, + ADD COLUMN constructgenomicentityassociationobject_id bigint, + ADD COLUMN relation_id bigint, + ADD COLUMN singlereference_id bigint, + ADD COLUMN dataprovider_id bigint, + ADD COLUMN crossreference_id bigint, + ADD COLUMN assertedallele_id bigint, + ADD COLUMN inferredallele_id bigint, + ADD COLUMN inferredgene_id bigint, + ADD COLUMN phenotypeannotationsubject_id bigint, + ADD COLUMN sgdstrainbackground_id bigint, + ADD COLUMN expressionpattern_id bigint, + ADD COLUMN expressionannotationsubject_id bigint, + ADD COLUMN expressionassayused_id bigint, + ADD COLUMN sequencetargetingreagentassociationsubject_id bigint, + ADD COLUMN sequencetargetingreagentgeneassociationobject_id bigint, + ADD COLUMN evidencecode_id bigint, + ADD COLUMN relatednote_id bigint, + ADD COLUMN geneassociationsubject_id bigint, + ADD COLUMN genegeneassociationobject_id bigint, + ADD COLUMN transcriptassociationsubject_id bigint, + ADD COLUMN transcriptgeneassociationobject_id bigint, + ADD COLUMN exonassociationsubject_id bigint, + ADD COLUMN exongenomiclocationassociationobject_id bigint, + ADD COLUMN annotationtype_id bigint, + ADD COLUMN diseaseannotationobject_id bigint, + ADD COLUMN diseasegeneticmodifierrelation_id bigint, + ADD COLUMN geneticsex_id bigint, + ADD COLUMN secondarydataprovider_id bigint, + ADD COLUMN diseaseannotationsubject_id bigint, + ADD COLUMN interactionsource_id bigint, + ADD COLUMN interactiontype_id bigint, + ADD COLUMN interactorarole_id bigint, + ADD COLUMN interactoratype_id bigint, + ADD COLUMN interactorbrole_id bigint, + ADD COLUMN interactorbtype_id bigint, + ADD COLUMN interactorageneticperturbation_id bigint, + ADD COLUMN interactorbgeneticperturbation_id bigint, + ADD COLUMN alleleassociationsubject_id bigint, + ADD COLUMN allelegeneassociationobject_id bigint, + ADD COLUMN transcriptexonassociationobject_id bigint, + ADD COLUMN transcriptgenomiclocationassociationobject_id bigint, + ADD COLUMN codingsequenceassociationsubject_id bigint, + ADD COLUMN codingsequencegenomiclocationassociationobject_id bigint, + ADD COLUMN aggregationdatabase_id bigint, + ADD COLUMN detectionmethod_id bigint, + ADD COLUMN transcriptcodingsequenceassociationobject_id bigint, + ADD COLUMN associationtype character varying(96); + +UPDATE association a SET + associationtype = 'AGMDiseaseAnnotation', + inferredallele_id = b.inferredallele_id, + inferredgene_id = b.inferredgene_id, + assertedallele_id = b.assertedallele_id, + diseaseannotationsubject_id = b.diseaseannotationsubject_id +FROM AGMDiseaseAnnotation b where a.id = b.id; + +INSERT INTO association_gene (agmdiseaseannotation_id, assertedgenes_id) + SELECT agmdiseaseannotation_id, assertedgenes_id FROM agmdiseaseannotation_gene; + +DROP TABLE AGMDiseaseAnnotation_Gene; +DROP TABLE AGMDiseaseAnnotation; + +UPDATE association a SET + associationtype = 'AlleleDiseaseAnnotation', + inferredgene_id = b.inferredgene_id, + diseaseannotationsubject_id = b.diseaseannotationsubject_id +FROM AlleleDiseaseAnnotation b where a.id = b.id; + +INSERT INTO association_gene (allelediseaseannotation_id, assertedgenes_id) + SELECT allelediseaseannotation_id, assertedgenes_id FROM allelediseaseannotation_gene; + +DROP TABLE allelediseaseannotation_gene; +DROP TABLE AlleleDiseaseAnnotation; + +UPDATE association a SET + associationtype = 'GeneDiseaseAnnotation', + sgdstrainbackground_id = b.sgdstrainbackground_id, + diseaseannotationsubject_id = b.diseaseannotationsubject_id +FROM GeneDiseaseAnnotation b WHERE a.id = b.id; + +DROP TABLE GeneDiseaseAnnotation; + +UPDATE association a SET + negated = b.negated, + relation_id = b.relation_id, + diseasegeneticmodifierrelation_id = b.diseasegeneticmodifierrelation_id, + annotationtype_id = b.annotationtype_id, + geneticsex_id = b.geneticsex_id, + secondarydataprovider_id = b.secondarydataprovider_id, + diseaseannotationobject_id = b.diseaseannotationobject_id +FROM DiseaseAnnotation b WHERE a.id = b.id; + +INSERT INTO association_ontologyterm (diseaseannotation_id, evidencecodes_id) + SELECT diseaseannotation_id, evidencecodes_id FROM diseaseannotation_ontologyterm; + +DROP TABLE diseaseannotation_ontologyterm; + +INSERT INTO association_vocabularyterm (diseaseannotation_id, diseasequalifiers_id) + SELECT diseaseannotation_id, diseasequalifiers_id FROM diseaseannotation_vocabularyterm; + +DROP TABLE diseaseannotation_vocabularyterm; + +INSERT INTO association_biologicalentity (diseaseannotation_id, diseasegeneticmodifiers_id) + SELECT diseaseannotation_id, diseasegeneticmodifiers_id FROM diseaseannotation_biologicalentity; + +DROP TABLE diseaseannotation_biologicalentity; + +INSERT INTO association_gene (diseaseannotation_id, with_id) + SELECT diseaseannotation_id, with_id FROM diseaseannotation_gene; + +DROP TABLE diseaseannotation_gene; +DROP TABLE DiseaseAnnotation; + +UPDATE association a SET + associationtype = 'GeneExpressionAnnotation', + expressionannotationsubject_id = b.expressionannotationsubject_id, + expressionassayused_id = b.expressionassayused_id +FROM GeneExpressionAnnotation b WHERE a.id = b.id; + +DROP TABLE GeneExpressionAnnotation; + +UPDATE association a SET + relation_id = b.relation_id, + whenexpressedstagename = b.whenexpressedstagename, + whereexpressedstatement = b.whereexpressedstatement, + expressionpattern_id = b.expressionpattern_id +FROM ExpressionAnnotation b WHERE a.id = b.id; + +DROP TABLE ExpressionAnnotation; + +UPDATE association a SET + associationtype = 'GenePhenotypeAnnotation', + phenotypeannotationsubject_id = b.phenotypeannotationsubject_id, + sgdstrainbackground_id = b.sgdstrainbackground_id +FROM GenePhenotypeAnnotation b WHERE a.id = b.id; + +DROP TABLE GenePhenotypeAnnotation; + +UPDATE association a SET + associationtype = 'AllelePhenotypeAnnotation', + phenotypeannotationsubject_id = b.phenotypeannotationsubject_id, + inferredgene_id = b.inferredgene_id +FROM AllelePhenotypeAnnotation b WHERE a.id = b.id; + +INSERT INTO association_gene (allelephenotypeannotation_id, assertedgenes_id) + SELECT allelephenotypeannotation_id, assertedgenes_id FROM allelephenotypeannotation_gene; + +DROP TABLE allelephenotypeannotation_gene; +DROP TABLE AllelePhenotypeAnnotation; + +UPDATE association a SET + associationtype = 'AGMPhenotypeAnnotation', + phenotypeannotationsubject_id = b.phenotypeannotationsubject_id, + inferredgene_id = b.inferredgene_id, + inferredallele_id = b.inferredallele_id, + assertedallele_id = b.assertedallele_id +FROM AGMPhenotypeAnnotation b WHERE a.id = b.id; + +INSERT INTO association_gene (agmphenotypeannotation_id, assertedgenes_id) + SELECT agmphenotypeannotation_id, assertedgenes_id FROM agmphenotypeannotation_gene; + +DROP TABLE agmphenotypeannotation_gene; +DROP TABLE AGMPhenotypeAnnotation; + +UPDATE association a SET + phenotypeannotationobject = b.phenotypeannotationobject, + crossreference_id = b.crossreference_id, + relation_id = b.relation_id +FROM phenotypeannotation b WHERE a.id = b.id; + +INSERT INTO association_ontologyterm (phenotypeannotation_id, phenotypeterms_id) + SELECT phenotypeannotation_id, phenotypeterms_id FROM phenotypeannotation_ontologyterm; + +DROP TABLE phenotypeannotation_ontologyterm; +DROP TABLE phenotypeannotation; + +UPDATE association a SET + curie = b.curie, + modentityid = b.modentityid, + modinternalid = b.modinternalid, + uniqueid = b.uniqueid, + dataprovider_id = b.dataprovider_id +FROM Annotation b WHERE a.id = b.id; + +INSERT INTO association_conditionrelation (annotation_id, conditionrelations_id) + SELECT annotation_id, conditionrelations_id FROM annotation_conditionrelation; + +DROP TABLE annotation_conditionrelation; + +INSERT INTO association_note (annotation_id, relatednotes_id) + SELECT annotation_id, relatednotes_id FROM annotation_note; + +DROP TABLE annotation_note; + +DROP TABLE annotation; + +UPDATE association a SET + singlereference_id = b.singlereference_id +FROM singlereferenceassociation b WHERE a.id = b.id; + +DROP TABLE singlereferenceassociation; + +UPDATE association a SET + associationtype = 'GeneGeneticInteraction', + interactorageneticperturbation_id = b.interactorageneticperturbation_id, + interactorbgeneticperturbation_id = b.interactorbgeneticperturbation_id +FROM GeneGeneticInteraction b WHERE a.id = b.id; + +-- association_phenotypesortraits +ALTER TABLE genegeneticinteraction_phenotypesortraits + DROP CONSTRAINT genegeneticinteraction_phenotypesortraits_genegeneticinteractio; + +DROP TABLE GeneGeneticInteraction; + +UPDATE association a SET + associationtype = 'GeneMolecularInteraction', + aggregationdatabase_id = b.aggregationdatabase_id, + detectionmethod_id = b.detectionmethod_id +FROM GeneMolecularInteraction b WHERE a.id = b.id; + +DROP TABLE GeneMolecularInteraction; + +UPDATE association a SET + interactionid = b.interactionid, + uniqueid = b.uniqueid, + interactionsource_id = b.interactionsource_id, + interactiontype_id = b.interactiontype_id, + interactorarole_id = b.interactorarole_id, + interactorbrole_id = b.interactorbrole_id, + interactoratype_id = b.interactoratype_id, + interactorbtype_id = b.interactorbtype_id +FROM GeneInteraction b WHERE a.id = b.id; + +INSERT INTO association_crossreference (geneinteraction_id, crossreferences_id) + SELECT geneinteraction_id, crossreferences_id FROM geneinteraction_crossreference; + +DROP TABLE geneinteraction_crossreference; +DROP TABLE GeneInteraction; + + +UPDATE association a SET + geneassociationsubject_id = b.geneassociationsubject_id, + genegeneassociationobject_id = b.genegeneassociationobject_id, + relation_id = b.relation_id +FROM GeneGeneAssociation b WHERE a.id = b.id; + +DROP TABLE GeneGeneAssociation; + +UPDATE association a SET + associationtype = 'AlleleGeneAssociation', + alleleassociationsubject_id = b.alleleassociationsubject_id, + allelegeneassociationobject_id = b.allelegeneassociationobject_id +FROM AlleleGeneAssociation b WHERE a.id = b.id; + +DROP TABLE AlleleGeneAssociation; + +UPDATE association a SET + relatednote_id = b.relatednote_id, + relation_id = b.relation_id, + evidencecode_id = b.evidencecode_id +FROM AlleleGenomicEntityAssociation b WHERE a.id = b.id; + +DROP TABLE AlleleGenomicEntityAssociation; + +UPDATE association a SET + associationtype = 'ConstructGenomicEntityAssociation', + constructassociationsubject_id = b.constructassociationsubject_id, + relation_id = b.relation_id, + constructgenomicentityassociationobject_id = b.constructgenomicentityassociationobject_id +FROM ConstructGenomicEntityAssociation b WHERE a.id = b.id; + + +INSERT INTO association_note (constructgenomicentityassociation_id, relatednotes_id) + SELECT constructgenomicentityassociation_id, relatednotes_id FROM constructgenomicentityassociation_note; + +DROP TABLE constructgenomicentityassociation_note; +DROP TABLE ConstructGenomicEntityAssociation; + +UPDATE association a SET + associationtype = 'SequenceTargetingReagentGeneAssociation', + relation_id = b.relation_id, + sequencetargetingreagentassociationsubject_id = b.sequencetargetingreagentassociationsubject_id, + sequencetargetingreagentgeneassociationobject_id = b.sequencetargetingreagentgeneassociationobject_id +FROM SequenceTargetingReagentGeneAssociation b WHERE a.id = b.id; + +DROP TABLE SequenceTargetingReagentGeneAssociation; + +INSERT INTO association_informationcontententity (evidenceassociation_id, evidence_id) + SELECT evidenceassociation_id, evidence_id FROM evidenceassociation_informationcontententity; + +DROP TABLE evidenceassociation_informationcontententity; + + +DROP TABLE TranscriptGeneAssociation; +DROP TABLE TranscriptExonAssociation; +DROP TABLE TranscriptCodingSequenceAssociation; +DROP TABLE CodingSequenceGenomicLocationAssociation; +DROP TABLE ExonGenomicLocationAssociation; +DROP TABLE TranscriptGenomicLocationAssociation; +-- Will need to rerun the GFF loads to populate these tables + +DROP TABLE evidenceassociation; + +DELETE FROM association WHERE associationtype is NULL; + +ALTER TABLE association ALTER COLUMN associationtype SET NOT null; + + +CREATE INDEX association_curie_index ON association USING btree (curie); +CREATE INDEX association_modentityid_index ON association USING btree (modentityid); +CREATE INDEX association_modinternalid_index ON association USING btree (modinternalid); +CREATE INDEX association_uniqueid_index ON association USING btree (uniqueid); +CREATE INDEX association_whenexpressedstagename_index ON association USING btree (whenexpressedstagename); +CREATE INDEX association_whereexpressedstatement_index ON association USING btree (whereexpressedstatement); +CREATE INDEX association_interactionid_index ON association USING btree (interactionid); +CREATE INDEX association_construct_subject_index ON association USING btree (constructassociationsubject_id); +CREATE INDEX association_construct_object_index ON association USING btree (constructgenomicentityassociationobject_id); +CREATE INDEX association_relation_index ON association USING btree (relation_id); +CREATE INDEX association_singlereference_index ON association USING btree (singlereference_id); +CREATE INDEX association_dataprovider_index ON association USING btree (dataprovider_id); +CREATE INDEX association_crossreference_index ON association USING btree (crossreference_id); +CREATE INDEX association_assertedallele_index ON association USING btree (assertedallele_id); +CREATE INDEX association_inferredallele_index ON association USING btree (inferredallele_id); +CREATE INDEX association_inferredgene_index ON association USING btree (inferredgene_id); + +CREATE INDEX association_phenotypeannotationsubject_index ON association USING btree (phenotypeannotationsubject_id); + +CREATE INDEX association_sgdstrainbackground_index ON association USING btree (sgdstrainbackground_id); +CREATE INDEX association_expressionpattern_index ON association USING btree (expressionpattern_id); +CREATE INDEX association_expression_annotation_subject_index ON association USING btree (expressionannotationsubject_id); +CREATE INDEX association_expression_assay_used_index ON association USING btree (expressionassayused_id); +CREATE INDEX association_sqtr_subject_index ON association USING btree (sequencetargetingreagentassociationsubject_id); +CREATE INDEX association_sqtr_object_index ON association USING btree (sequencetargetingreagentgeneassociationobject_id); +CREATE INDEX association_evidencecode_index ON association USING btree (evidencecode_id); +CREATE INDEX association_relatednote_index ON association USING btree (relatednote_id); +CREATE INDEX association_geneassociationsubject_index ON association USING btree (geneassociationsubject_id); +CREATE INDEX association_genegeneassociationobject_index ON association USING btree (genegeneassociationobject_id); +CREATE INDEX association_transcript_subject_index ON association USING btree (transcriptassociationsubject_id); +CREATE INDEX association_transcript_gene_object_index ON association USING btree (transcriptgeneassociationobject_id); +CREATE INDEX association_exon_subject_index ON association USING btree (exonassociationsubject_id); +CREATE INDEX association_exon_object_index ON association USING btree (exongenomiclocationassociationobject_id); +CREATE INDEX association_annotationtype_index ON association USING btree (annotationtype_id); +CREATE INDEX association_diseaseannotationobject_index ON association USING btree (diseaseannotationobject_id); +CREATE INDEX association_diseasegeneticmodifierrelation_index ON association USING btree (diseasegeneticmodifierrelation_id); +CREATE INDEX association_geneticsex_index ON association USING btree (geneticsex_id); +CREATE INDEX association_secondarydataprovider_index ON association USING btree (secondarydataprovider_id); +CREATE INDEX association_diseaseannotationsubject_index ON association USING btree (diseaseannotationsubject_id); +CREATE INDEX association_interactionsource_index ON association USING btree (interactionsource_id); +CREATE INDEX association_interactiontype_index ON association USING btree (interactiontype_id); +CREATE INDEX association_interactorarole_index ON association USING btree (interactorarole_id); +CREATE INDEX association_interactoratype_index ON association USING btree (interactoratype_id); +CREATE INDEX association_interactorbrole_index ON association USING btree (interactorbrole_id); +CREATE INDEX association_interactorbtype_index ON association USING btree (interactorbtype_id); +CREATE INDEX association_interactorageneticperturbarion_index ON association USING btree (interactorageneticperturbation_id); +CREATE INDEX association_interactorbgeneticperturbarion_index ON association USING btree (interactorbgeneticperturbation_id); +CREATE INDEX association_alleleassociationsubject_index ON association USING btree (alleleassociationsubject_id); +CREATE INDEX association_allelegeneassociationobject_index ON association USING btree (allelegeneassociationobject_id); +CREATE INDEX association_transcript_exon_object_index ON association USING btree (transcriptexonassociationobject_id); +CREATE INDEX association_transcript_object_index ON association USING btree (transcriptgenomiclocationassociationobject_id); +CREATE INDEX association_cds_subject_index ON association USING btree (codingsequenceassociationsubject_id); +CREATE INDEX association_cds_object_index ON association USING btree (codingsequencegenomiclocationassociationobject_id); +CREATE INDEX association_aggregationdatabase_index ON association USING btree (aggregationdatabase_id); +CREATE INDEX association_detectionmethod_index ON association USING btree (detectionmethod_id); +CREATE INDEX association_transcript_cds_object_index ON association USING btree (transcriptcodingsequenceassociationobject_id); + +CREATE INDEX association_associationtype_index ON association USING btree (associationtype); + +-- association_gene +CREATE INDEX association_assertedgenes_index ON association_gene USING btree (assertedgenes_id); +CREATE INDEX association_agmdiseaseannotation_index ON association_gene USING btree (agmdiseaseannotation_id); +CREATE INDEX association_allelediseaseannotation_index ON association_gene USING btree (allelediseaseannotation_id); +CREATE INDEX association_diseaseannotation_gene_index ON association_gene USING btree (diseaseannotation_id); +CREATE INDEX association_diseaseannotation_with_index ON association_gene USING btree (with_id); +CREATE INDEX association_allelephenotypeannotation_index ON association_gene USING btree (allelephenotypeannotation_id); +CREATE INDEX association_agmphenotypeannotation_index ON association_gene USING btree (agmphenotypeannotation_id); + +-- association_biologicalentity +CREATE INDEX association_diseaseannotation_BiologicalEntity_index ON association_biologicalentity USING btree (diseaseannotation_id); +CREATE INDEX association_diseaseannotation_dgms_index ON association_biologicalentity USING btree (diseasegeneticmodifiers_id); + +-- association_conditionrelation +CREATE INDEX association_annotation_conditionrelation_index ON association_conditionrelation USING btree (annotation_id); +CREATE INDEX association_annotation_conditionrelations_index ON association_conditionrelation USING btree (conditionrelations_id); + +-- association_crossreference +CREATE INDEX association_geneinteraction_crossreference_index ON association_crossreference USING btree (geneinteraction_id, crossreferences_id); +CREATE INDEX association_geneinteraction_crossreferences_index ON association_crossreference USING btree (crossreferences_id); +CREATE INDEX association_geneinteraction_geneinteraction_index ON association_crossreference USING btree (geneinteraction_id); + +-- association_informationcontententity +CREATE INDEX association_evidenceassociation_index ON association_informationcontententity USING btree (evidenceassociation_id); +CREATE INDEX association_evidenceassociation_evidence_index ON association_informationcontententity USING btree (evidence_id); + +-- association_note +CREATE INDEX association_annotation_annotation_index ON association_note USING btree (annotation_id); +CREATE INDEX association_relatednotes_index ON association_note USING btree (relatednotes_id); +CREATE INDEX association_cgeassociation_cgeassociation_index ON association_note USING btree (constructgenomicentityassociation_id); + +-- association_ontologyterm +CREATE INDEX association_diseaseannotation_diseaseannotation_index ON association_ontologyterm USING btree (diseaseannotation_id); +CREATE INDEX association_diseaseannotation_evidencecodes_index ON association_ontologyterm USING btree (evidencecodes_id); +CREATE INDEX association_phenotypeannotation_phenotypeannotation_index ON association_ontologyterm USING btree (phenotypeannotation_id); +CREATE INDEX association_phenotypeannotation_phenotypeterms_index ON association_ontologyterm USING btree (phenotypeterms_id); + +-- association_vocabularyterm +CREATE INDEX association_diseaseannotation_vt_diseaseannotation_index ON association_vocabularyterm USING btree (diseaseannotation_id); +CREATE INDEX association_diseaseannotation_diseasequalifiers_index ON association_vocabularyterm USING btree (diseasequalifiers_id); + +-- genegeneticinteraction_phenotypesortraits +CREATE INDEX association_genegeneticinteraction_phenotypesortraits_index ON genegeneticinteraction_phenotypesortraits USING btree (genegeneticinteraction_id); + +-- FK's + +-- association_gene +ALTER TABLE ONLY association_gene ADD CONSTRAINT fkhav6kkcn2o8ndwa5hv6gmwdaq FOREIGN KEY (assertedgenes_id) REFERENCES gene(id); +ALTER TABLE ONLY association_gene ADD CONSTRAINT fkfoqrp7f7uar43ue42a873aqjk FOREIGN KEY (agmdiseaseannotation_id) REFERENCES association(id); +ALTER TABLE ONLY association_gene ADD CONSTRAINT fkc8yg269l93lpu4fna99912d1y FOREIGN KEY (allelediseaseannotation_id) REFERENCES association(id); +ALTER TABLE ONLY association_gene ADD CONSTRAINT fkgib9oxtydiwdm5ibh8e14s8om FOREIGN KEY (diseaseannotation_id) REFERENCES association(id); +ALTER TABLE ONLY association_gene ADD CONSTRAINT fkeepgwlxwk2cgvs00fdbhuvc6n FOREIGN KEY (with_id) REFERENCES gene(id); +ALTER TABLE ONLY association_gene ADD CONSTRAINT fk7cqwg0wtuxw2ltm0f4de62bx1 FOREIGN KEY (allelephenotypeannotation_id) REFERENCES association(id); +ALTER TABLE ONLY association_gene ADD CONSTRAINT fkjwoi4su8vkylcfor313n7md25 FOREIGN KEY (agmphenotypeannotation_id) REFERENCES association(id); + +-- association_biologicalentity +ALTER TABLE ONLY association_biologicalentity ADD CONSTRAINT fkkikn34sq62h6ajyagxno5bwhc FOREIGN KEY (diseaseannotation_id) REFERENCES association(id); +ALTER TABLE ONLY association_biologicalentity ADD CONSTRAINT fkp5pi80ie788coafu1490s8fla FOREIGN KEY (diseasegeneticmodifiers_id) REFERENCES biologicalentity(id); + +-- association_conditionrelation +ALTER TABLE ONLY association_conditionrelation ADD CONSTRAINT fkc4spolvq2xj2253q6yg5rdqc9 FOREIGN KEY (annotation_id) REFERENCES association(id); +ALTER TABLE ONLY association_conditionrelation ADD CONSTRAINT fkiuqvgg26wj61xm3peaabj5a4f FOREIGN KEY (conditionrelations_id) REFERENCES conditionrelation(id); + +-- association_crossreference +ALTER TABLE ONLY association_crossreference ADD CONSTRAINT fkt7xih7j80e5stq2rr88bbfr9 FOREIGN KEY (geneinteraction_id) REFERENCES association(id); +ALTER TABLE ONLY association_crossreference ADD CONSTRAINT fk6h7jv57hlmwj53to752mxo5ru FOREIGN KEY (crossreferences_id) REFERENCES crossreference(id); + +-- association_informationcontententity +ALTER TABLE ONLY association_informationcontententity ADD CONSTRAINT fkd52dcl4h9urwl8w0s20wkxvob FOREIGN KEY (evidenceassociation_id) REFERENCES association(id); +ALTER TABLE ONLY association_informationcontententity ADD CONSTRAINT fkbgupm60jot5gk9i9q4carypcb FOREIGN KEY (evidence_id) REFERENCES informationcontententity(id); + +-- association_note +ALTER TABLE ONLY association_note ADD CONSTRAINT fkgemsq21ksrmcdm5btgyna3bqw FOREIGN KEY (annotation_id) REFERENCES association(id); +ALTER TABLE ONLY association_note ADD CONSTRAINT fk6mcmoe71135qpoueb2cjtrrxd FOREIGN KEY (relatednotes_id) REFERENCES note(id); +ALTER TABLE ONLY association_note ADD CONSTRAINT fkm7ao01tj7hlgmqgx9xrp677sv FOREIGN KEY (constructgenomicentityassociation_id) REFERENCES association(id); + +-- association_ontologyterm +ALTER TABLE ONLY association_ontologyterm ADD CONSTRAINT fki4p7fsji03okqpmakl22225jp FOREIGN KEY (diseaseannotation_id) REFERENCES association(id); +ALTER TABLE ONLY association_ontologyterm ADD CONSTRAINT fk2vi7xbepfem6fur85he3565el FOREIGN KEY (evidencecodes_id) REFERENCES ontologyterm(id); + +-- Phototype Annotation Orphan Cleanup +DELETE FROM association_ontologyterm WHERE phenotypeannotation_id IN ( + SELECT ao.phenotypeannotation_id from association_ontologyterm ao + LEFT JOIN association a ON ao.phenotypeannotation_id = a.id + WHERE ao.phenotypeannotation_id IS NOT NULL AND a.id IS NULL +); + +ALTER TABLE ONLY association_ontologyterm ADD CONSTRAINT fkom7p46wwwv16bkye0gjc2omxp FOREIGN KEY (phenotypeannotation_id) REFERENCES association(id); +ALTER TABLE ONLY association_ontologyterm ADD CONSTRAINT fk9hbubr81amn71dtvm86qw9pl7 FOREIGN KEY (phenotypeterms_id) REFERENCES ontologyterm(id); + +-- association_vocabularyterm +ALTER TABLE ONLY association_vocabularyterm ADD CONSTRAINT fkcfijtoyigdh9b4ss8efnf3jro FOREIGN KEY (diseaseannotation_id) REFERENCES association(id); +ALTER TABLE ONLY association_vocabularyterm ADD CONSTRAINT fkbf73p7v3d72e2fsni076talw4 FOREIGN KEY (diseasequalifiers_id) REFERENCES vocabularyterm(id); + + + +ALTER TABLE ONLY association ADD CONSTRAINT fkgobipxrs66w3ur1w1tk4sl8ac FOREIGN KEY (constructassociationsubject_id) REFERENCES construct(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkscnsbwmhpug2to0yu6gw895oh FOREIGN KEY (constructgenomicentityassociationobject_id) REFERENCES genomicentity(id); +ALTER TABLE ONLY association ADD CONSTRAINT fk1sb2qk5clgbkk2976x13v5bum FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); +ALTER TABLE ONLY association ADD CONSTRAINT fk6p763216qfdincsh6i5aei5kg FOREIGN KEY (singlereference_id) REFERENCES reference(id); +ALTER TABLE ONLY association ADD CONSTRAINT fk3omr7j2o1nneqgyroynbyulqq FOREIGN KEY (dataprovider_id) REFERENCES dataprovider(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkmm82blif2e7bpb31jn9485ehc FOREIGN KEY (crossreference_id) REFERENCES crossreference(id); +ALTER TABLE ONLY association ADD CONSTRAINT fk6t34ef007ov1vpfk7ulksfy8y FOREIGN KEY (assertedallele_id) REFERENCES allele(id); +ALTER TABLE ONLY association ADD CONSTRAINT fk2t4nhpv4jnk38yn9bd646wrpj FOREIGN KEY (inferredallele_id) REFERENCES allele(id); +ALTER TABLE ONLY association ADD CONSTRAINT fk9ko4u7l6641hlhpn9eeyf8toh FOREIGN KEY (inferredgene_id) REFERENCES gene(id); + +-- ALTER TABLE ONLY association ADD CONSTRAINT fktgpn8b91m1qb178srwe9n8s7 FOREIGN KEY (phenotypeannotationsubject_id) REFERENCES gene(id) ON DELETE CASCADE; +-- ALTER TABLE ONLY association ADD CONSTRAINT fk3bh18tfrhnab3usyc1naldwde FOREIGN KEY (phenotypeannotationsubject_id) REFERENCES affectedgenomicmodel(id) ON DELETE CASCADE; +-- ALTER TABLE ONLY Association ADD CONSTRAINT fk5dmwn688s6ls0mjo3nhgtli2h FOREIGN KEY (phenotypeAnnotationSubject_id) REFERENCES allele(id) ON DELETE CASCADE; +-- These constraints can't be added as the field points to 3 different objects + +ALTER TABLE ONLY association ADD CONSTRAINT fknrw40h3f8fkk01kclygxd86h9 FOREIGN KEY (sgdstrainbackground_id) REFERENCES affectedgenomicmodel(id); +ALTER TABLE ONLY association ADD CONSTRAINT fknx6o6bclwogm0v4rli1cdrfdv FOREIGN KEY (expressionpattern_id) REFERENCES expressionpattern(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkbh4gekhrbpbt4k9yvons42dux FOREIGN KEY (expressionannotationsubject_id) REFERENCES gene(id); +ALTER TABLE ONLY association ADD CONSTRAINT fk7e020acyvcolnnhpb4118tp3w FOREIGN KEY (expressionassayused_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkf2q4ns5ogkba5dtowqk3cajo5 FOREIGN KEY (sequencetargetingreagentassociationsubject_id) REFERENCES sequencetargetingreagent(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkjsjeyjo4eljj3xm4ogi5ucyyw FOREIGN KEY (sequencetargetingreagentgeneassociationobject_id) REFERENCES gene(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkidh408kt3t3fim9rbvgw32hw1 FOREIGN KEY (evidencecode_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkcas3usi3dh8j7s57xqrv29hlm FOREIGN KEY (relatednote_id) REFERENCES note(id); +ALTER TABLE ONLY association ADD CONSTRAINT fk8h34l4ktb6ui786lp9y2mfewo FOREIGN KEY (geneassociationsubject_id) REFERENCES gene(id); +ALTER TABLE ONLY association ADD CONSTRAINT fk7f05186xuynsh72ikqeuhe1pv FOREIGN KEY (genegeneassociationobject_id) REFERENCES gene(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkt8fk74cx4ibjl7c4g2kvmhldf FOREIGN KEY (transcriptassociationsubject_id) REFERENCES transcript(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkmiewpuidiblk7jcc5usb1jo63 FOREIGN KEY (transcriptgeneassociationobject_id) REFERENCES gene(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkirjv7oatlssgiqoytcqiyhuqi FOREIGN KEY (exonassociationsubject_id) REFERENCES exon(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkrwjlq6jcmn90cin2o0801oqxj FOREIGN KEY (exongenomiclocationassociationobject_id) REFERENCES assemblycomponent(id); +ALTER TABLE ONLY association ADD CONSTRAINT fknpx0xn81d3edht9pss6n7r2yo FOREIGN KEY (annotationtype_id) REFERENCES vocabularyterm(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkr70o6q95nap6g7ry2jjxa90ya FOREIGN KEY (diseaseannotationobject_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY association ADD CONSTRAINT fknk44lwm2xauhs3r22h09us4ji FOREIGN KEY (diseasegeneticmodifierrelation_id) REFERENCES vocabularyterm(id); +ALTER TABLE ONLY association ADD CONSTRAINT fksinpe44rjxl9n6mn7vhanbwlg FOREIGN KEY (geneticsex_id) REFERENCES vocabularyterm(id); +ALTER TABLE ONLY association ADD CONSTRAINT fk554ce408ek9gf44f6db3w4et1 FOREIGN KEY (secondarydataprovider_id) REFERENCES dataprovider(id); + +-- ALTER TABLE ONLY association ADD CONSTRAINT fkouxa4j6wep8rss3jviti0qibg FOREIGN KEY (diseaseannotationsubject_id) REFERENCES allele(id) ON DELETE CASCADE; +-- ALTER TABLE ONLY association ADD CONSTRAINT fk8qyy1fyhm3273j2p57alkp02t FOREIGN KEY (diseaseannotationsubject_id) REFERENCES gene(id) ON DELETE CASCADE; +-- ALTER TABLE ONLY association ADD CONSTRAINT fkksi8xjap9hliwoo4j3io09frg FOREIGN KEY (diseaseannotationsubject_id) REFERENCES affectedgenomicmodel(id) ON DELETE CASCADE; +-- These constraints can't be added as the field points to 3 different objects + +ALTER TABLE ONLY association ADD CONSTRAINT fkaj9ynw0e9bswh3dth646t834o FOREIGN KEY (interactionsource_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkh8gqvx5c40tlw0a37uff6e9ky FOREIGN KEY (interactiontype_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkapag4jcegsd5rus25ladx3eat FOREIGN KEY (interactorarole_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY association ADD CONSTRAINT fks83wq2dpg8csweamyp31roli9 FOREIGN KEY (interactoratype_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkl05py1cdx0304xdev9697uptx FOREIGN KEY (interactorbrole_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkqokld7svnht4m6k4t9jnk81gf FOREIGN KEY (interactorbtype_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkf2m5olg8hj4awsnr9p12kjvry FOREIGN KEY (interactorageneticperturbation_id) REFERENCES allele(id) ON DELETE CASCADE; +ALTER TABLE ONLY association ADD CONSTRAINT fkpocxhp5klhi10d84xy8wm6yh1 FOREIGN KEY (interactorbgeneticperturbation_id) REFERENCES allele(id) ON DELETE CASCADE; +ALTER TABLE ONLY association ADD CONSTRAINT fkiwqrtab6l4bkwcg6ysfprr0tg FOREIGN KEY (alleleassociationsubject_id) REFERENCES allele(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkik71nx67sxxpfmvly6exwsf4m FOREIGN KEY (allelegeneassociationobject_id) REFERENCES gene(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkfdqmfjd4v0smqmu8hossg5jet FOREIGN KEY (transcriptexonassociationobject_id) REFERENCES exon(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkeclnm31mpi8i1iy07n0cm003g FOREIGN KEY (transcriptgenomiclocationassociationobject_id) REFERENCES assemblycomponent(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkfgso1aqthy90ltcc6pdo235p1 FOREIGN KEY (codingsequenceassociationsubject_id) REFERENCES codingsequence(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkeot29m2x4peefkgwrqmu36ub1 FOREIGN KEY (codingsequencegenomiclocationassociationobject_id) REFERENCES assemblycomponent(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkd6l423ab6u2hfoyjaf85nxt4f FOREIGN KEY (aggregationdatabase_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkkbi83cmvdnis7mdsx966rvdxe FOREIGN KEY (detectionmethod_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY association ADD CONSTRAINT fkfk71crh2hl7wuwpmrwvcybnq3 FOREIGN KEY (transcriptcodingsequenceassociationobject_id) REFERENCES codingsequence(id); + +ALTER TABLE ONLY genegeneticinteraction_phenotypesortraits ADD CONSTRAINT fklufk1y85ki3qeo1ixbko56rol FOREIGN KEY (genegeneticinteraction_id) REFERENCES association(id); + + +-- Fix sqtr long names; + +DROP INDEX sequencetargetingreagent_secondaryIdentifiers_sequencetargetingreagent_index; +DROP INDEX sequencetargetingreagent_synonyms_sequencetargetingreagent_index; + +CREATE INDEX sqtr_secondaryidentifiers_sqtr_index ON sequencetargetingreagent_secondaryidentifiers USING btree (sequencetargetingreagent_id); +CREATE INDEX sqtr_synonyms_sqtr_index ON sequencetargetingreagent_synonyms USING btree (sequencetargetingreagent_id); + +-- Missing Indexes + +CREATE INDEX biologicalentity_curie_index ON public.biologicalentity USING btree (curie); +CREATE INDEX biologicalentity_modinternalid_index ON public.biologicalentity USING btree (modinternalid); +CREATE INDEX cellularcomponentqualifiers_cellularcomponentqualifiers_index ON public.anatomicalsite_cellularcomponentqualifiers USING btree (cellularcomponentqualifiers_id); +CREATE INDEX informationcontententity_curie_index ON public.informationcontententity USING btree (curie); +CREATE INDEX ontologyterm_curie_index ON public.ontologyterm USING btree (curie); +CREATE INDEX ontologyterm_isa_ancestor_descendant_isancestors_index ON public.ontologyterm_isa_ancestor_descendant USING btree (isaancestors_id); + +-- Missing Constrains + +ALTER TABLE ONLY public.anatomicalsite ADD CONSTRAINT fk4h252bd81x75fwxgyy6wa61u7 FOREIGN KEY (anatomicalstructure_id) REFERENCES public.ontologyterm(id); +ALTER TABLE ONLY public.anatomicalsite ADD CONSTRAINT fk820ik52dv75y8yeeymw9fib0l FOREIGN KEY (anatomicalsubstructure_id) REFERENCES public.ontologyterm(id); +ALTER TABLE ONLY public.anatomicalsite ADD CONSTRAINT fka5b13b9htt6lmwtckr393w62r FOREIGN KEY (updatedby_id) REFERENCES public.person(id); +ALTER TABLE ONLY public.anatomicalsite ADD CONSTRAINT fkbwi9cqjupg87x1fjiea13swda FOREIGN KEY (createdby_id) REFERENCES public.person(id); +ALTER TABLE ONLY public.anatomicalsite ADD CONSTRAINT fkkbkvdh25o66jw9mkimtvt0fjl FOREIGN KEY (cellularcomponentterm_id) REFERENCES public.ontologyterm(id); + +ALTER TABLE ONLY public.expressionpattern ADD CONSTRAINT fkjnwc0l0tjukc7939l5aa3gylu FOREIGN KEY (updatedby_id) REFERENCES public.person(id); +ALTER TABLE ONLY public.expressionpattern ADD CONSTRAINT fksnvyfgvqvdcf49lnklncwjm0t FOREIGN KEY (createdby_id) REFERENCES public.person(id); + +ALTER TABLE ONLY public.temporalcontext ADD CONSTRAINT fkqxng45bjismw8qcc4x3met821 FOREIGN KEY (developmentalstagestart_id) REFERENCES public.ontologyterm(id); +ALTER TABLE ONLY public.temporalcontext ADD CONSTRAINT fks5wnscfpf8l2fxacvo8bdg6rp FOREIGN KEY (createdby_id) REFERENCES public.person(id); +ALTER TABLE ONLY public.temporalcontext ADD CONSTRAINT fk7saeiw0res25be1sekjkebvxp FOREIGN KEY (updatedby_id) REFERENCES public.person(id); +ALTER TABLE ONLY public.temporalcontext ADD CONSTRAINT fksrvvhoclqm33da4boc3dopmxh FOREIGN KEY (developmentalstagestop_id) REFERENCES public.ontologyterm(id); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/db/migration/v0.37.0.4__fix_stageuberonslim_terms.sql b/src/main/resources/db/migration/v0.37.0.4__fix_stageuberonslim_terms.sql new file mode 100644 index 000000000..1344b0135 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.4__fix_stageuberonslim_terms.sql @@ -0,0 +1,3 @@ +DELETE FROM vocabularyterm WHERE name = 'post embryonic' AND vocabulary_id = (SELECT id FROM vocabulary WHERE vocabularylabel = 'stage_uberon_slim_terms'); +DELETE FROM vocabularyterm WHERE name = 'pre-adult' AND vocabulary_id = (SELECT id FROM vocabulary WHERE vocabularylabel = 'stage_uberon_slim_terms'); +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'post embryonic, pre-adult', id FROM vocabulary WHERE vocabularylabel = 'stage_uberon_slim_terms'; diff --git a/src/main/resources/db/migration/v0.37.0.50__change_expression_model.sql b/src/main/resources/db/migration/v0.37.0.50__change_expression_model.sql new file mode 100644 index 000000000..f2d31a43d --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.50__change_expression_model.sql @@ -0,0 +1,1530 @@ +DROP TABLE anatomicalsite_anatomicalstructurequalifiers; +DROP TABLE anatomicalsite_anatomicalsubstructurequalifiers; +DROP TABLE anatomicalsite_cellularcomponentqualifiers; + +CREATE TABLE anatomicalsite_anatomicalstructurequalifiers ( + anatomicalsite_id BIGINT, + anatomicalstructurequalifiers_id BIGINT +); + +CREATE TABLE anatomicalsite_anatomicalsubstructurequalifiers ( + anatomicalsite_id BIGINT, + anatomicalsubstructurequalifiers_id BIGINT +); + +CREATE TABLE anatomicalsite_cellularcomponentqualifiers ( + anatomicalsite_id BIGINT, + cellularcomponentqualifiers_id BIGINT +); + +ALTER TABLE anatomicalsite_anatomicalstructurequalifiers + ADD CONSTRAINT anatomicalstructurequalifiers_anatomicalsite_fk + FOREIGN KEY (anatomicalsite_id) REFERENCES anatomicalsite(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + +ALTER TABLE anatomicalsite_anatomicalstructurequalifiers + ADD CONSTRAINT anatomicalstructurequalifiers_structurequalifier_fk + FOREIGN KEY (anatomicalstructurequalifiers_id) REFERENCES ontologyterm(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + +ALTER TABLE anatomicalsite_anatomicalsubstructurequalifiers + ADD CONSTRAINT anatomicalsubstructurequalifiers_anatomicalsite_fk + FOREIGN KEY (anatomicalsite_id) REFERENCES anatomicalsite(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + +ALTER TABLE anatomicalsite_anatomicalsubstructurequalifiers + ADD CONSTRAINT anatomicalsubstructurequalifiers_qualifier_fk + FOREIGN KEY (anatomicalsubstructurequalifiers_id) REFERENCES ontologyterm(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + +ALTER TABLE anatomicalsite_cellularcomponentqualifiers + ADD CONSTRAINT cellularcomponentqualifiers_anatomicalsite_fk + FOREIGN KEY (anatomicalsite_id) REFERENCES anatomicalsite(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + +ALTER TABLE anatomicalsite_cellularcomponentqualifiers + ADD CONSTRAINT cellularcomponentqualifiers_cellularcomponentqualifier_fk + FOREIGN KEY (cellularcomponentqualifiers_id) REFERENCES ontologyterm(id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION; + +CREATE INDEX anatomicalstructurequalifiers_anatomicalsite_index ON anatomicalsite_anatomicalstructurequalifiers USING btree (anatomicalsite_id); +CREATE INDEX anatomicalstructurequalifiers_structurequalifiers_index ON anatomicalsite_anatomicalstructurequalifiers USING btree (anatomicalstructurequalifiers_id); +CREATE INDEX anatomicalsubstructurequalifiers_anatomicalsite_index ON anatomicalsite_anatomicalsubstructurequalifiers USING btree (anatomicalsite_id); +CREATE INDEX anatomicalsubstructurequalifiers_qualifiers_index ON anatomicalsite_anatomicalsubstructurequalifiers USING btree (anatomicalsubstructurequalifiers_id); +CREATE INDEX cellularcomponentqualifiers_anatomicalsite_index ON anatomicalsite_cellularcomponentqualifiers USING btree (anatomicalsite_id); +CREATE INDEX cellularcomponentqualifiers_qualifiers_index ON anatomicalsite_cellularcomponentqualifiers USING btree (cellularcomponentqualifiers_id); + +DELETE FROM vocabularyterm WHERE vocabulary_id = (SELECT id FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'); +DELETE FROM vocabulary WHERE vocabularylabel = 'cellular_component_qualifiers'; + +INSERT INTO vocabulary (id, name, vocabularylabel) VALUES (nextval('vocabulary_seq'), 'Spatial Expression Qualifier', 'spatial_expression_qualifiers'); + +INSERT INTO vocabularytermset (id, name, vocabularylabel, vocabularytermsetvocabulary_id) + SELECT nextval('vocabularytermset_seq'), 'Anatomical Structure Qualifier', 'anatomical_structure_qualifier', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; + +INSERT INTO vocabularytermset (id, name, vocabularylabel, vocabularytermsetvocabulary_id) + SELECT nextval('vocabularytermset_seq'), 'Anatomical SubStructure Qualifier', 'anatomical_subtructure_qualifier', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; + +INSERT INTO vocabularytermset (id, name, vocabularylabel, vocabularytermsetvocabulary_id) + SELECT nextval('vocabularytermset_seq'), 'Cellular Component Qualifier', 'cellular_component_qualifier', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; + +-- QUALIFIER TERMS +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000099', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000118', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000069', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000058', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000168', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000071', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000128', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000089', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000674', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000109', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000082', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000102', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000051', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000383', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000135', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000120', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000066', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000680', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000170', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000050', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000045', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000093', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000127', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000065', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000131', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000172', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000101', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000110', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000688', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000169', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000027', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000091', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000096', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000319', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000673', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000052', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000678', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000079', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000374', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000059', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000322', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000054', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000036', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000007', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000039', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000074', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000373', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000678', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000095', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000000', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000117', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000037', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000055', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000029', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000081', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000653', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000132', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000684', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000047', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0001001', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000004', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000130', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000066', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000683', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000034', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000088', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000137', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000062', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000100', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000125', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000028', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000323', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000033', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000083', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000049', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000003', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000111', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000124', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000333', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000171', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000077', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000145', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000142', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000056', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000055', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000079', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000063', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000141', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000119', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000032', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000076', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000057', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000090', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000013', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000075', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000199', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000377', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000042', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000078', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000104', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000050', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000379', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000112', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000039', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000058', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000127', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000077', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000046', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000069', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000035', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000121', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'RO:0002325', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000071', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000072', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000073', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000093', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000060', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000080', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000041', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000136', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000086', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000098', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000143', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000133', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000122', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000147', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000067', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000085', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000134', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000320', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000148', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000371', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000064', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000082', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000672', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000064', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000070', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000031', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000048', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000026', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000084', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000103', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000038', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000094', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000097', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000150', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000139', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000123', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000030', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000063', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000084', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000677', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000126', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000167', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000046', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000679', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000087', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000128', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000053', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000115', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000049', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000088', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000056', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000092', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000006', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000092', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000685', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000682', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000005', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000068', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000671', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000040', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000078', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000045', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000067', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000080', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000129', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000053', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000061', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'FBcv:0000070', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'BSPO:0000075', id FROM vocabulary WHERE vocabularylabel = 'spatial_expression_qualifiers'; + +-- ANATOMICAL STRUCTURE QUALIFIERS + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000078' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000109' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000679' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000379' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000683' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000084' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000040' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000092' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000037' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000074' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000079' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000115' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000055' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000374' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000065' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000067' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000030' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000035' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000111' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000172' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000077' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000034' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000653' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000128' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000170' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000000' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000322' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000673' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000099' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000061' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000100' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000110' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000049' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000050' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000056' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000048' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000171' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000141' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000082' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000058' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000070' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000085' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000058' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000082' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000101' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000080' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000063' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000678' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000684' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000383' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000688' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000007' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000006' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000049' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000068' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000136' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000077' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000055' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000671' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000004' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000097' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000062' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000199' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000128' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000169' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000092' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000073' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000319' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000047' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000122' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000069' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000078' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000129' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000070' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000121' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000090' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000112' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000093' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000167' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000083' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000677' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000150' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000132' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000142' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000052' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000071' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000069' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000053' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000053' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000087' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000032' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000064' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000130' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000080' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000371' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000076' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000674' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000029' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000088' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000036' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000072' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000373' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000071' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000075' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000124' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000005' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000057' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000050' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000137' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000117' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000127' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000041' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000091' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000133' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000094' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000685' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000134' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000680' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000103' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000168' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000125' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000038' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000067' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000064' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000039' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000098' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000123' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000104' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000118' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000060' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000323' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000672' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000066' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000046' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000095' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000096' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000026' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000102' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000143' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000033' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000147' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000131' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000148' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000145' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000333' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000139' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000028' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000377' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000119' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000120' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000027' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000127' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000086' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000056' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000003' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000042' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000013' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000063' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000682' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000079' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000054' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000046' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000093' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000088' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000059' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000135' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000084' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0001001' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000066' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000045' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000045' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000031' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000051' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000039' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000081' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000075' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000126' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000089' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='BSPO:0000678' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_structure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000320' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +-- ANATOMICAL SUBSTRUCTURE QUALIFIERS + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_subtructure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000167' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_subtructure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000058' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_subtructure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000059' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_subtructure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000169' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_subtructure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000071' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_subtructure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000054' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_subtructure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000150' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_subtructure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000046' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_subtructure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000653' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_subtructure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000067' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_subtructure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000055' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'anatomical_subtructure_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000063' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +-- CELLULAR COMPONENT QUALIFIERS + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000066' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000167' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000048' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000058' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000170' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000047' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000065' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000653' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000169' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000046' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000055' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000168' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000050' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000063' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000059' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000054' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000053' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='RO:0002325' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000067' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000070' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) +WITH + termset AS (SELECT id FROM vocabularytermset WHERE vocabularylabel = 'cellular_component_qualifier'), + termid AS (SELECT id FROM vocabularyterm WHERE name='FBcv:0000171' AND vocabulary_id = (SELECT id from vocabulary WHERE vocabularylabel= 'spatial_expression_qualifiers')) +SELECT termset.id, termid.id from termset, termid; diff --git a/src/main/resources/db/migration/v0.37.0.51__mappersuperclass__assocations.sql b/src/main/resources/db/migration/v0.37.0.51__mappersuperclass__assocations.sql new file mode 100644 index 000000000..fb077c04b --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.51__mappersuperclass__assocations.sql @@ -0,0 +1,550 @@ +CREATE TABLE agmdiseaseannotation ( + id bigint PRIMARY KEY, + assertedallele_id bigint, + diseaseannotationsubject_id bigint, + inferredallele_id bigint, + inferredgene_id bigint +); + +CREATE TABLE agmdiseaseannotation_gene ( + agmdiseaseannotation_id bigint NOT NULL, + assertedgenes_id bigint + ); + +CREATE TABLE agmphenotypeannotation ( + id bigint PRIMARY KEY, + assertedallele_id bigint, + inferredallele_id bigint, + inferredgene_id bigint, + phenotypeannotationsubject_id bigint +); + +CREATE TABLE agmphenotypeannotation_gene ( + agmphenotypeannotation_id bigint NOT NULL, + assertedgenes_id bigint NOT NULL +); + +CREATE TABLE allelediseaseannotation ( + id bigint PRIMARY KEY, + diseaseannotationsubject_id bigint, + inferredgene_id bigint +); + +CREATE TABLE allelediseaseannotation_gene ( + allelediseaseannotation_id bigint NOT NULL, + assertedgenes_id bigint +); + +CREATE TABLE allelegeneassociation ( + id bigint PRIMARY KEY, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + createdby_id bigint, + updatedby_id bigint, + evidencecode_id bigint, + relatednote_id bigint, + relation_id bigint, + alleleassociationsubject_id bigint, + allelegeneassociationobject_id bigint +); + +CREATE TABLE allelegeneassociation_informationcontententity ( + association_id bigint NOT NULL, + evidence_id bigint NOT NULL +); + +CREATE SEQUENCE allelegeneassociation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE TABLE allelephenotypeannotation ( + id bigint PRIMARY KEY, + inferredgene_id bigint, + phenotypeannotationsubject_id bigint +); + +CREATE TABLE allelephenotypeannotation_gene ( + allelephenotypeannotation_id bigint NOT NULL, + assertedgenes_id bigint NOT NULL +); + +CREATE TABLE codingsequencegenomiclocationassociation ( + id bigint PRIMARY KEY, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + "end" integer, + start integer, + phase integer, + strand character varying(1), + createdby_id bigint, + updatedby_id bigint, + relation_id bigint, + codingsequenceassociationsubject_id bigint, + codingsequencegenomiclocationassociationobject_id bigint +); + +CREATE TABLE CodingSequenceGenomicLocationAssociation_InformationContentEntity ( + association_id bigint NOT NULL, + evidence_id bigint NOT NULL +); + +CREATE SEQUENCE codingsequencegenomiclocationassociation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE TABLE constructgenomicentityassociation ( + id bigint PRIMARY KEY, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + createdby_id bigint, + updatedby_id bigint, + constructassociationsubject_id bigint, + constructgenomicentityassociationobject_id bigint, + relation_id bigint +); + +CREATE TABLE constructgenomicentityassociation_informationcontententity ( + association_id bigint NOT NULL, + evidence_id bigint NOT NULL +); + +CREATE TABLE constructgenomicentityassociation_note ( + constructgenomicentityassociation_id bigint NOT NULL, + relatednotes_id bigint NOT NULL +); + +CREATE SEQUENCE constructgenomicentityassociation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE TABLE exongenomiclocationassociation ( + id bigint PRIMARY KEY, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + "end" integer, + start integer, + strand character varying(1), + createdby_id bigint, + updatedby_id bigint, + relation_id bigint, + exonassociationsubject_id bigint, + exongenomiclocationassociationobject_id bigint +); + +CREATE TABLE exongenomiclocationassociation_informationcontententity ( + association_id bigint NOT NULL, + evidence_id bigint NOT NULL +); + +CREATE SEQUENCE exongenomiclocationassociation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE TABLE diseaseannotation ( + id bigint PRIMARY KEY, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + curie character varying(255), + modentityid character varying(255), + modinternalid character varying(255), + uniqueid character varying(3500), + negated boolean DEFAULT false NOT NULL, + createdby_id bigint, + updatedby_id bigint, + singlereference_id bigint, + dataprovider_id bigint, + annotationtype_id bigint, + diseaseannotationobject_id bigint, + diseasegeneticmodifierrelation_id bigint, + geneticsex_id bigint, + relation_id bigint, + secondarydataprovider_id bigint +); + +CREATE TABLE genediseaseannotation ( + id bigint PRIMARY KEY, + diseaseannotationsubject_id bigint, + sgdstrainbackground_id bigint +); + +CREATE TABLE diseaseannotation_biologicalentity ( + diseaseannotation_id bigint NOT NULL, + diseasegeneticmodifiers_id bigint NOT NULL +); + +CREATE TABLE diseaseannotation_conditionrelation ( + annotation_id bigint NOT NULL, + conditionrelations_id bigint NOT NULL +); + +CREATE TABLE diseaseannotation_gene ( + diseaseannotation_id bigint NOT NULL, + with_id bigint NOT NULL +); + +CREATE TABLE diseaseannotation_note ( + annotation_id bigint NOT NULL, + relatednotes_id bigint NOT NULL +); + +CREATE TABLE diseaseannotation_ontologyterm ( + diseaseannotation_id bigint NOT NULL, + evidencecodes_id bigint NOT NULL +); + +CREATE SEQUENCE diseaseannotation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE TABLE diseaseannotation_vocabularyterm ( + diseaseannotation_id bigint NOT NULL, + diseasequalifiers_id bigint NOT NULL +); + +CREATE TABLE geneexpressionannotation ( + id bigint PRIMARY KEY, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + curie character varying(255), + modentityid character varying(255), + modinternalid character varying(255), + uniqueid character varying(3500), + whenexpressedstagename character varying(2000), + whereexpressedstatement character varying(2000), + createdby_id bigint, + updatedby_id bigint, + singlereference_id bigint, + dataprovider_id bigint, + expressionpattern_id bigint, + relation_id bigint, + expressionannotationsubject_id bigint, + expressionassayused_id bigint +); + +CREATE TABLE geneexpressionannotation_conditionrelation ( + annotation_id bigint NOT NULL, + conditionrelations_id bigint NOT NULL +); + +CREATE TABLE geneexpressionannotation_note ( + annotation_id bigint NOT NULL, + relatednotes_id bigint NOT NULL +); + +CREATE TABLE genegeneticinteraction ( + id bigint PRIMARY KEY, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + interactionid character varying(255), + uniqueid character varying(2000), + createdby_id bigint, + updatedby_id bigint, + geneassociationsubject_id bigint, + genegeneassociationobject_id bigint, + relation_id bigint, + interactionsource_id bigint, + interactiontype_id bigint, + interactorarole_id bigint, + interactoratype_id bigint, + interactorbrole_id bigint, + interactorbtype_id bigint, + interactorageneticperturbation_id bigint, + interactorbgeneticperturbation_id bigint +); + +CREATE TABLE genegeneticinteraction_crossreference ( + geneinteraction_id bigint NOT NULL, + crossreferences_id bigint NOT NULL +); + +CREATE TABLE genegeneticinteraction_informationcontententity ( + association_id bigint NOT NULL, + evidence_id bigint NOT NULL +); + +DROP TABLE IF EXISTS genegeneticinteraction_phenotypesortraits; + +CREATE TABLE genegeneticinteraction_phenotypesortraits ( + genegeneticinteraction_id bigint NOT NULL, + phenotypesortraits character varying(255) +); + +CREATE SEQUENCE genegeneticinteraction_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE TABLE genemolecularinteraction ( + id bigint PRIMARY KEY, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + interactionid character varying(255), + uniqueid character varying(2000), + createdby_id bigint, + updatedby_id bigint, + geneassociationsubject_id bigint, + genegeneassociationobject_id bigint, + relation_id bigint, + interactionsource_id bigint, + interactiontype_id bigint, + interactorarole_id bigint, + interactoratype_id bigint, + interactorbrole_id bigint, + interactorbtype_id bigint, + aggregationdatabase_id bigint, + detectionmethod_id bigint +); + +CREATE TABLE genemolecularinteraction_crossreference ( + geneinteraction_id bigint NOT NULL, + crossreferences_id bigint NOT NULL +); + +CREATE TABLE genemolecularinteraction_informationcontententity ( + association_id bigint NOT NULL, + evidence_id bigint NOT NULL +); + +CREATE SEQUENCE genemolecularinteraction_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE TABLE phenotypeannotation ( + id bigint PRIMARY KEY, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + curie character varying(255), + modentityid character varying(255), + modinternalid character varying(255), + uniqueid character varying(3500), + phenotypeannotationobject character varying(255), + createdby_id bigint, + updatedby_id bigint, + singlereference_id bigint, + dataprovider_id bigint, + crossreference_id bigint, + relation_id bigint +); + +CREATE TABLE genephenotypeannotation ( + id bigint PRIMARY KEY, + phenotypeannotationsubject_id bigint, + sgdstrainbackground_id bigint +); + +CREATE TABLE phenotypeannotation_conditionrelation ( + annotation_id bigint NOT NULL, + conditionrelations_id bigint NOT NULL +); + +CREATE TABLE phenotypeannotation_note ( + annotation_id bigint NOT NULL, + relatednotes_id bigint NOT NULL +); + +CREATE TABLE phenotypeannotation_ontologyterm ( + phenotypeannotation_id bigint NOT NULL, + phenotypeterms_id bigint NOT NULL +); + +CREATE SEQUENCE phenotypeannotation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE TABLE sequencetargetingreagentgeneassociation ( + id bigint PRIMARY KEY, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + createdby_id bigint, + updatedby_id bigint, + relation_id bigint, + sequencetargetingreagentassociationsubject_id bigint, + sequencetargetingreagentgeneassociationobject_id bigint +); + +CREATE TABLE sequencetargetingreagentgeneassociation_informationcontententit ( + association_id bigint NOT NULL, + evidence_id bigint NOT NULL +); + +CREATE SEQUENCE sequencetargetingreagentgeneassociation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE TABLE transcriptcodingsequenceassociation ( + id bigint PRIMARY KEY, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + createdby_id bigint, + updatedby_id bigint, + relation_id bigint, + transcriptassociationsubject_id bigint, + transcriptcodingsequenceassociationobject_id bigint +); + +CREATE TABLE transcriptcodingsequenceassociation_informationcontententity ( + association_id bigint NOT NULL, + evidence_id bigint NOT NULL +); + +CREATE SEQUENCE transcriptcodingsequenceassociation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE TABLE transcriptexonassociation ( + id bigint PRIMARY KEY, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + createdby_id bigint, + updatedby_id bigint, + relation_id bigint, + transcriptassociationsubject_id bigint, + transcriptexonassociationobject_id bigint +); + +CREATE TABLE transcriptexonassociation_informationcontententity ( + association_id bigint NOT NULL, + evidence_id bigint NOT NULL +); + +CREATE SEQUENCE transcriptexonassociation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE TABLE transcriptgeneassociation ( + id bigint PRIMARY KEY, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + createdby_id bigint, + updatedby_id bigint, + relation_id bigint, + transcriptassociationsubject_id bigint, + transcriptgeneassociationobject_id bigint +); + +CREATE TABLE transcriptgeneassociation_informationcontententity ( + association_id bigint NOT NULL, + evidence_id bigint NOT NULL +); + +CREATE SEQUENCE transcriptgeneassociation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE TABLE transcriptgenomiclocationassociation ( + id bigint PRIMARY KEY, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + "end" integer, + start integer, + phase integer, + strand character varying(1), + createdby_id bigint, + updatedby_id bigint, + relation_id bigint, + transcriptassociationsubject_id bigint, + transcriptgenomiclocationassociationobject_id bigint +); + +CREATE TABLE transcriptgenomiclocationassociation_informationcontententity ( + association_id bigint NOT NULL, + evidence_id bigint NOT NULL +); + +CREATE SEQUENCE transcriptgenomiclocationassociation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; diff --git a/src/main/resources/db/migration/v0.37.0.52__mappersuperclass__assocations.sql b/src/main/resources/db/migration/v0.37.0.52__mappersuperclass__assocations.sql new file mode 100644 index 000000000..fc91a99ef --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.52__mappersuperclass__assocations.sql @@ -0,0 +1,14 @@ + +SELECT setval( 'AlleleGeneAssociation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); +SELECT setval( 'PhenotypeAnnotation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); +SELECT setval( 'CodingSequenceGenomicLocationAssociation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); +SELECT setval( 'ConstructGenomicEntityAssociation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); +SELECT setval( 'ExonGenomicLocationAssociation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); +SELECT setval( 'DiseaseAnnotation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); +SELECT setval( 'GeneGeneticInteraction_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); +SELECT setval( 'GeneMolecularInteraction_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); +SELECT setval( 'SequenceTargetingReagentGeneAssociation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); +SELECT setval( 'TranscriptCodingSequenceAssociation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); +SELECT setval( 'TranscriptExonAssociation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); +SELECT setval( 'TranscriptGeneAssociation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); +SELECT setval( 'TranscriptGenomicLocationAssociation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM Association) ); diff --git a/src/main/resources/db/migration/v0.37.0.53__mappersuperclass__assocations.sql b/src/main/resources/db/migration/v0.37.0.53__mappersuperclass__assocations.sql new file mode 100644 index 000000000..5b1e5ab9c --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.53__mappersuperclass__assocations.sql @@ -0,0 +1,765 @@ +INSERT INTO diseaseannotation + SELECT id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + curie, + modentityid, + modinternalid, + uniqueid, + negated, + createdby_id, + updatedby_id, + singlereference_id, + dataprovider_id, + annotationtype_id, + diseaseannotationobject_id, + diseasegeneticmodifierrelation_id, + geneticsex_id, + relation_id, + secondarydataprovider_id FROM Association WHERE AssociationType = 'AGMDiseaseAnnotation'; + + +INSERT INTO agmdiseaseannotation + SELECT id, + assertedallele_id, + diseaseannotationsubject_id, + inferredallele_id, + inferredgene_id FROM Association WHERE AssociationType = 'AGMDiseaseAnnotation'; + +INSERT INTO diseaseannotation_biologicalentity + SELECT ab.diseaseannotation_id, ab.diseasegeneticmodifiers_id + FROM association_biologicalentity ab, Association a + WHERE ab.diseaseannotation_id = a.id AND a.associationtype = 'AGMDiseaseAnnotation'; + +DELETE FROM association_biologicalentity WHERE diseaseannotation_id IN (SELECT id FROM agmdiseaseannotation); + +INSERT INTO diseaseannotation_conditionrelation + SELECT ac.annotation_id, ac.conditionrelations_id + FROM association_conditionrelation ac, Association a + WHERE ac.annotation_id = a.id AND a.associationtype = 'AGMDiseaseAnnotation'; + +DELETE FROM association_conditionrelation WHERE annotation_id IN (SELECT id FROM agmdiseaseannotation); + +INSERT INTO agmdiseaseannotation_gene (agmdiseaseannotation_id, assertedgenes_id) + SELECT + agmdiseaseannotation_id, + assertedgenes_id + FROM association_gene WHERE agmdiseaseannotation_id is NOT NULL; + +DELETE from association_gene WHERE agmdiseaseannotation_id IN (SELECT id FROM agmdiseaseannotation); + +INSERT INTO diseaseannotation_note + SELECT an.annotation_id, an.relatednotes_id + FROM association_note an, Association a + WHERE an.annotation_id = a.id AND a.associationtype = 'AGMDiseaseAnnotation'; + +DELETE FROM association_note WHERE annotation_id IN (SELECT id FROM agmdiseaseannotation); + +INSERT INTO diseaseannotation_ontologyterm + SELECT ao.diseaseannotation_id, ao.evidencecodes_id + FROM association_ontologyterm ao, Association a + WHERE ao.diseaseannotation_id = a.id AND a.associationtype = 'AGMDiseaseAnnotation'; + +DELETE FROM association_ontologyterm WHERE diseaseannotation_id IN (SELECT id FROM agmdiseaseannotation); + +INSERT INTO diseaseannotation_vocabularyterm + SELECT av.diseaseannotation_id, av.diseasequalifiers_id + FROM association_vocabularyterm av, Association a + WHERE av.diseaseannotation_id = a.id AND a.associationtype = 'AGMDiseaseAnnotation'; + +DELETE FROM association_vocabularyterm WHERE diseaseannotation_id IN (SELECT id FROM agmdiseaseannotation); + +DELETE FROM Association WHERE AssociationType = 'AGMDiseaseAnnotation'; + +INSERT INTO phenotypeannotation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + curie, + modentityid, + modinternalid, + uniqueid, + phenotypeannotationobject, + createdby_id, + updatedby_id, + singlereference_id, + dataprovider_id, + crossreference_id, + relation_id FROM Association WHERE AssociationType = 'AGMPhenotypeAnnotation'; + +INSERT INTO agmphenotypeannotation + SELECT + id, + assertedallele_id, + inferredallele_id, + inferredgene_id, + phenotypeannotationsubject_id FROM Association WHERE AssociationType = 'AGMPhenotypeAnnotation'; + +INSERT INTO phenotypeannotation_conditionrelation + SELECT ac.annotation_id, ac.conditionrelations_id + FROM association_conditionrelation ac, Association a + WHERE ac.annotation_id = a.id AND a.associationtype = 'AGMPhenotypeAnnotation'; + +DELETE FROM association_conditionrelation WHERE annotation_id IN (SELECT id FROM agmphenotypeannotation); + +INSERT INTO agmphenotypeannotation_gene + SELECT + agmphenotypeannotation_id, + assertedgenes_id + FROM association_gene WHERE agmphenotypeannotation_id is NOT NULL; + +DELETE from association_gene WHERE agmphenotypeannotation_id IN (SELECT id FROM agmphenotypeannotation); + +INSERT INTO phenotypeannotation_note + SELECT an.annotation_id, an.relatednotes_id + FROM association_note an, Association a + WHERE an.annotation_id = a.id AND a.associationtype = 'AGMPhenotypeAnnotation'; + +DELETE FROM association_note WHERE annotation_id IN (SELECT id FROM agmphenotypeannotation); + +INSERT INTO phenotypeannotation_ontologyterm + SELECT ao.phenotypeannotation_id, ao.phenotypeterms_id + FROM association_ontologyterm ao, Association a + WHERE ao.phenotypeannotation_id = a.id AND a.associationtype = 'AGMPhenotypeAnnotation'; + +DELETE FROM association_ontologyterm WHERE phenotypeannotation_id IN (SELECT id FROM agmphenotypeannotation); + +DELETE FROM Association WHERE AssociationType = 'AGMPhenotypeAnnotation'; + +INSERT INTO diseaseannotation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + curie, + modentityid, + modinternalid, + uniqueid, + negated, + createdby_id, + updatedby_id, + singlereference_id, + dataprovider_id, + annotationtype_id, + diseaseannotationobject_id, + diseasegeneticmodifierrelation_id, + geneticsex_id, + relation_id, + secondarydataprovider_id FROM Association WHERE AssociationType = 'AlleleDiseaseAnnotation'; + +INSERT INTO allelediseaseannotation + SELECT + id, + diseaseannotationsubject_id, + inferredgene_id FROM Association WHERE AssociationType = 'AlleleDiseaseAnnotation'; + +INSERT INTO diseaseannotation_biologicalentity + SELECT ab.diseaseannotation_id, ab.diseasegeneticmodifiers_id + FROM association_biologicalentity ab, Association a + WHERE ab.diseaseannotation_id = a.id AND a.associationtype = 'AlleleDiseaseAnnotation'; + +DELETE FROM association_biologicalentity WHERE diseaseannotation_id IN (SELECT id FROM allelediseaseannotation); + +INSERT INTO diseaseannotation_conditionrelation + SELECT ac.annotation_id, ac.conditionrelations_id + FROM association_conditionrelation ac, Association a + WHERE ac.annotation_id = a.id AND a.associationtype = 'AlleleDiseaseAnnotation'; + +DELETE FROM association_conditionrelation WHERE annotation_id IN (SELECT id FROM allelediseaseannotation); + +INSERT INTO allelediseaseannotation_gene (allelediseaseannotation_id, assertedgenes_id) + SELECT + allelediseaseannotation_id, + assertedgenes_id + FROM association_gene WHERE allelediseaseannotation_id is NOT NULL; + +DELETE from association_gene WHERE allelediseaseannotation_id IN (SELECT id FROM allelediseaseannotation); + +INSERT INTO diseaseannotation_note + SELECT an.annotation_id, an.relatednotes_id + FROM association_note an, Association a + WHERE an.annotation_id = a.id AND a.associationtype = 'AlleleDiseaseAnnotation'; + +DELETE FROM association_note WHERE annotation_id IN (SELECT id FROM allelediseaseannotation); + +INSERT INTO diseaseannotation_ontologyterm + SELECT ao.diseaseannotation_id, ao.evidencecodes_id + FROM association_ontologyterm ao, Association a + WHERE ao.diseaseannotation_id = a.id AND a.associationtype = 'AlleleDiseaseAnnotation'; + +DELETE FROM association_ontologyterm WHERE diseaseannotation_id IN (SELECT id FROM allelediseaseannotation); + +INSERT INTO diseaseannotation_vocabularyterm + SELECT av.diseaseannotation_id, av.diseasequalifiers_id + FROM association_vocabularyterm av, Association a + WHERE av.diseaseannotation_id = a.id AND a.associationtype = 'AlleleDiseaseAnnotation'; + +DELETE FROM association_vocabularyterm WHERE diseaseannotation_id IN (SELECT id FROM allelediseaseannotation); + +DELETE FROM Association WHERE AssociationType = 'AlleleDiseaseAnnotation'; + +INSERT INTO allelegeneassociation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + createdby_id, + updatedby_id, + evidencecode_id, + relatednote_id, + relation_id, + alleleassociationsubject_id, + allelegeneassociationobject_id FROM Association WHERE AssociationType = 'AlleleGeneAssociation'; + +INSERT INTO allelegeneassociation_informationcontententity + SELECT ai.evidenceassociation_id, ai.evidence_id + FROM association_informationcontententity ai, Association a + WHERE ai.evidenceassociation_id = a.id AND a.associationtype = 'AlleleGeneAssociation'; + +DELETE FROM association_informationcontententity WHERE evidenceassociation_id IN (SELECT id FROM allelegeneassociation); + +DELETE FROM Association WHERE AssociationType = 'AlleleGeneAssociation'; + +INSERT INTO phenotypeannotation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + curie, + modentityid, + modinternalid, + uniqueid, + phenotypeannotationobject, + createdby_id, + updatedby_id, + singlereference_id, + dataprovider_id, + crossreference_id, + relation_id FROM Association WHERE AssociationType = 'AllelePhenotypeAnnotation'; + +INSERT INTO allelephenotypeannotation + SELECT + id, + inferredgene_id, + phenotypeannotationsubject_id FROM Association WHERE AssociationType = 'AllelePhenotypeAnnotation'; + +INSERT INTO phenotypeannotation_conditionrelation + SELECT ac.annotation_id, ac.conditionrelations_id + FROM association_conditionrelation ac, Association a + WHERE ac.annotation_id = a.id AND a.associationtype = 'AllelePhenotypeAnnotation'; + +DELETE FROM association_conditionrelation WHERE annotation_id IN (SELECT id FROM allelephenotypeannotation); + +INSERT INTO allelephenotypeannotation_gene + SELECT + allelephenotypeannotation_id, + assertedgenes_id + FROM association_gene WHERE allelephenotypeannotation_id is NOT NULL; + +DELETE from association_gene WHERE allelephenotypeannotation_id IN (SELECT id FROM allelephenotypeannotation); + +INSERT INTO phenotypeannotation_note + SELECT an.annotation_id, an.relatednotes_id + FROM association_note an, Association a + WHERE an.annotation_id = a.id AND a.associationtype = 'AllelePhenotypeAnnotation'; + +DELETE FROM association_note WHERE annotation_id IN (SELECT id FROM allelephenotypeannotation); + +INSERT INTO phenotypeannotation_ontologyterm + SELECT ao.phenotypeannotation_id, ao.phenotypeterms_id + FROM association_ontologyterm ao, Association a + WHERE ao.phenotypeannotation_id = a.id AND a.associationtype = 'AllelePhenotypeAnnotation'; + +DELETE FROM association_ontologyterm WHERE phenotypeannotation_id IN (SELECT id FROM allelephenotypeannotation); + +DELETE FROM Association WHERE AssociationType = 'AllelePhenotypeAnnotation'; + +INSERT INTO codingsequencegenomiclocationassociation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + "end", + start, + phase, + strand, + createdby_id, + updatedby_id, + relation_id, + codingsequenceassociationsubject_id, + codingsequencegenomiclocationassociationobject_id FROM Association WHERE AssociationType = 'CodingSequenceGenomicLocationAssociation'; + +INSERT INTO CodingSequenceGenomicLocationAssociation_InformationContentEntity + SELECT ai.evidenceassociation_id, ai.evidence_id + FROM association_informationcontententity ai, Association a + WHERE ai.evidenceassociation_id = a.id AND a.associationtype = 'CodingSequenceGenomicLocationAssociation'; + +DELETE FROM association_informationcontententity WHERE evidenceassociation_id IN (SELECT id FROM codingsequencegenomiclocationassociation); + +DELETE FROM Association WHERE AssociationType = 'CodingSequenceGenomicLocationAssociation'; + +INSERT INTO constructgenomicentityassociation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + createdby_id, + updatedby_id, + constructassociationsubject_id, + constructgenomicentityassociationobject_id, + relation_id FROM Association WHERE AssociationType = 'ConstructGenomicEntityAssociation'; + +INSERT INTO constructgenomicentityassociation_informationcontententity + SELECT ai.evidenceassociation_id, ai.evidence_id + FROM association_informationcontententity ai, Association a + WHERE ai.evidenceassociation_id = a.id AND a.associationtype = 'ConstructGenomicEntityAssociation'; + +DELETE FROM association_informationcontententity WHERE evidenceassociation_id IN (SELECT id FROM constructgenomicentityassociation); + +INSERT INTO constructgenomicentityassociation_note + SELECT an.constructgenomicentityassociation_id, an.relatednotes_id + FROM association_note an, Association a + WHERE an.constructgenomicentityassociation_id = a.id AND a.associationtype = 'ConstructGenomicEntityAssociation'; + +DELETE FROM association_note WHERE constructgenomicentityassociation_id IN (SELECT id FROM constructgenomicentityassociation); + +DELETE FROM Association WHERE AssociationType = 'ConstructGenomicEntityAssociation'; + +INSERT INTO exongenomiclocationassociation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + "end", + start, + strand, + createdby_id, + updatedby_id, + relation_id, + exonassociationsubject_id, + exongenomiclocationassociationobject_id FROM Association WHERE AssociationType = 'ExonGenomicLocationAssociation'; + +INSERT INTO exongenomiclocationassociation_informationcontententity + SELECT ai.evidenceassociation_id, ai.evidence_id + FROM association_informationcontententity ai, Association a + WHERE ai.evidenceassociation_id = a.id AND a.associationtype = 'ExonGenomicLocationAssociation'; + +DELETE FROM association_informationcontententity WHERE evidenceassociation_id IN (SELECT id FROM exongenomiclocationassociation); + +DELETE FROM Association WHERE AssociationType = 'ExonGenomicLocationAssociation'; + +INSERT INTO diseaseannotation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + curie, + modentityid, + modinternalid, + uniqueid, + negated, + createdby_id, + updatedby_id, + singlereference_id, + dataprovider_id, + annotationtype_id, + diseaseannotationobject_id, + diseasegeneticmodifierrelation_id, + geneticsex_id, + relation_id, + secondarydataprovider_id FROM Association WHERE AssociationType = 'GeneDiseaseAnnotation'; + +INSERT INTO genediseaseannotation + SELECT + id, + diseaseannotationsubject_id, + sgdstrainbackground_id FROM Association WHERE AssociationType = 'GeneDiseaseAnnotation'; + +INSERT INTO diseaseannotation_biologicalentity + SELECT ab.diseaseannotation_id, ab.diseasegeneticmodifiers_id + FROM association_biologicalentity ab, Association a + WHERE ab.diseaseannotation_id = a.id AND a.associationtype = 'GeneDiseaseAnnotation'; + +DELETE FROM association_biologicalentity WHERE diseaseannotation_id IN (SELECT id FROM genediseaseannotation); + +INSERT INTO diseaseannotation_conditionrelation + SELECT ac.annotation_id, ac.conditionrelations_id + FROM association_conditionrelation ac, Association a + WHERE ac.annotation_id = a.id AND a.associationtype = 'GeneDiseaseAnnotation'; + +DELETE FROM association_conditionrelation WHERE annotation_id IN (SELECT id FROM genediseaseannotation); + +INSERT INTO diseaseannotation_gene (diseaseannotation_id, with_id) + SELECT + diseaseannotation_id, + with_id + FROM association_gene WHERE diseaseannotation_id is NOT NULL; + +DELETE from association_gene WHERE diseaseannotation_id IN (SELECT id FROM genediseaseannotation); + +INSERT INTO diseaseannotation_note + SELECT an.annotation_id, an.relatednotes_id + FROM association_note an, Association a + WHERE an.annotation_id = a.id AND a.associationtype = 'GeneDiseaseAnnotation'; + +DELETE FROM association_note WHERE annotation_id IN (SELECT id FROM genediseaseannotation); + +INSERT INTO diseaseannotation_ontologyterm + SELECT ao.diseaseannotation_id, ao.evidencecodes_id + FROM association_ontologyterm ao, Association a + WHERE ao.diseaseannotation_id = a.id AND a.associationtype = 'GeneDiseaseAnnotation'; + +DELETE FROM association_ontologyterm WHERE diseaseannotation_id IN (SELECT id FROM genediseaseannotation); + +INSERT INTO diseaseannotation_vocabularyterm + SELECT av.diseaseannotation_id, av.diseasequalifiers_id + FROM association_vocabularyterm av, Association a + WHERE av.diseaseannotation_id = a.id AND a.associationtype = 'GeneDiseaseAnnotation'; + +DELETE FROM association_vocabularyterm WHERE diseaseannotation_id IN (SELECT id FROM genediseaseannotation); + +DELETE FROM Association WHERE AssociationType = 'GeneDiseaseAnnotation'; + +INSERT INTO geneexpressionannotation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + curie, + modentityid, + modinternalid, + uniqueid, + whenexpressedstagename, + whereexpressedstatement, + createdby_id, + updatedby_id, + singlereference_id, + dataprovider_id, + expressionpattern_id, + relation_id, + expressionannotationsubject_id, + expressionassayused_id FROM Association WHERE AssociationType = 'GeneExpressionAnnotation'; + +INSERT INTO geneexpressionannotation_conditionrelation + SELECT ac.annotation_id, ac.conditionrelations_id + FROM association_conditionrelation ac, Association a + WHERE ac.annotation_id = a.id AND a.associationtype = 'GeneExpressionAnnotation'; + +DELETE FROM association_conditionrelation WHERE annotation_id IN (SELECT id FROM geneexpressionannotation); + +INSERT INTO geneexpressionannotation_note + SELECT an.annotation_id, an.relatednotes_id + FROM association_note an, Association a + WHERE an.annotation_id = a.id AND a.associationtype = 'GeneExpressionAnnotation'; + +DELETE FROM association_note WHERE annotation_id IN (SELECT id FROM geneexpressionannotation); + +DELETE FROM Association WHERE AssociationType = 'GeneExpressionAnnotation'; + +INSERT INTO genegeneticinteraction + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + interactionid, + uniqueid, + createdby_id, + updatedby_id, + geneassociationsubject_id, + genegeneassociationobject_id, + relation_id, + interactionsource_id, + interactiontype_id, + interactorarole_id, + interactoratype_id, + interactorbrole_id, + interactorbtype_id, + interactorageneticperturbation_id, + interactorbgeneticperturbation_id FROM Association WHERE AssociationType = 'GeneGeneticInteraction'; + +INSERT INTO genegeneticinteraction_crossreference + SELECT ac.geneinteraction_id, ac.crossreferences_id + FROM association_crossreference ac, Association a + WHERE ac.geneinteraction_id = a.id AND a.associationtype = 'GeneGeneticInteraction'; + +DELETE FROM association_crossreference WHERE geneinteraction_id IN (SELECT id FROM genegeneticinteraction); + +INSERT INTO genegeneticinteraction_informationcontententity + SELECT ai.evidenceassociation_id, ai.evidence_id + FROM association_informationcontententity ai, Association a + WHERE ai.evidenceassociation_id = a.id AND a.associationtype = 'GeneGeneticInteraction'; + +DELETE FROM association_informationcontententity WHERE evidenceassociation_id IN (SELECT id FROM genegeneticinteraction); + +DELETE FROM Association WHERE AssociationType = 'GeneGeneticInteraction'; + +INSERT INTO genemolecularinteraction + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + interactionid, + uniqueid, + createdby_id, + updatedby_id, + geneassociationsubject_id, + genegeneassociationobject_id, + relation_id, + interactionsource_id, + interactiontype_id, + interactorarole_id, + interactoratype_id, + interactorbrole_id, + interactorbtype_id, + aggregationdatabase_id, + detectionmethod_id FROM Association WHERE AssociationType = 'GeneMolecularInteraction'; + +INSERT INTO genemolecularinteraction_crossreference + SELECT ac.geneinteraction_id, ac.crossreferences_id + FROM association_crossreference ac, Association a + WHERE ac.geneinteraction_id = a.id AND a.associationtype = 'GeneMolecularInteraction'; + +DELETE FROM association_crossreference WHERE geneinteraction_id IN (SELECT id FROM genemolecularinteraction); + +INSERT INTO genemolecularinteraction_informationcontententity + SELECT ai.evidenceassociation_id, ai.evidence_id + FROM association_informationcontententity ai, Association a + WHERE ai.evidenceassociation_id = a.id AND a.associationtype = 'GeneMolecularInteraction'; + +DELETE FROM association_informationcontententity WHERE evidenceassociation_id IN (SELECT id FROM genemolecularinteraction); + +DELETE FROM Association WHERE AssociationType = 'GeneMolecularInteraction'; + +INSERT INTO phenotypeannotation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + curie, + modentityid, + modinternalid, + uniqueid, + phenotypeannotationobject, + createdby_id, + updatedby_id, + singlereference_id, + dataprovider_id, + crossreference_id, + relation_id FROM Association WHERE AssociationType = 'GenePhenotypeAnnotation'; + +INSERT INTO genephenotypeannotation + SELECT + id, + phenotypeannotationsubject_id, + sgdstrainbackground_id FROM Association WHERE AssociationType = 'GenePhenotypeAnnotation'; + +INSERT INTO phenotypeannotation_conditionrelation + SELECT ac.annotation_id, ac.conditionrelations_id + FROM association_conditionrelation ac, Association a + WHERE ac.annotation_id = a.id AND a.associationtype = 'GenePhenotypeAnnotation'; + +DELETE FROM association_conditionrelation WHERE annotation_id IN (SELECT id FROM genephenotypeannotation); + +INSERT INTO phenotypeannotation_note + SELECT an.annotation_id, an.relatednotes_id + FROM association_note an, Association a + WHERE an.annotation_id = a.id AND a.associationtype = 'GenePhenotypeAnnotation'; + +DELETE FROM association_note WHERE annotation_id IN (SELECT id FROM genephenotypeannotation); + +INSERT INTO phenotypeannotation_ontologyterm + SELECT ao.phenotypeannotation_id, ao.phenotypeterms_id + FROM association_ontologyterm ao, Association a + WHERE ao.phenotypeannotation_id = a.id AND a.associationtype = 'GenePhenotypeAnnotation'; + +DELETE FROM association_ontologyterm WHERE phenotypeannotation_id IN (SELECT id FROM genephenotypeannotation); + +DELETE FROM Association WHERE AssociationType = 'GenePhenotypeAnnotation'; + +INSERT INTO sequencetargetingreagentgeneassociation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + createdby_id, + updatedby_id, + relation_id, + sequencetargetingreagentassociationsubject_id, + sequencetargetingreagentgeneassociationobject_id FROM Association WHERE AssociationType = 'SequenceTargetingReagentGeneAssociation'; + +INSERT INTO sequencetargetingreagentgeneassociation_informationcontententit + SELECT ai.evidenceassociation_id, ai.evidence_id + FROM association_informationcontententity ai, Association a + WHERE ai.evidenceassociation_id = a.id AND a.associationtype = 'SequenceTargetingReagentGeneAssociation'; + +DELETE FROM association_informationcontententity WHERE evidenceassociation_id IN (SELECT id FROM sequencetargetingreagentgeneassociation); + +DELETE FROM Association WHERE AssociationType = 'SequenceTargetingReagentGeneAssociation'; + +INSERT INTO transcriptcodingsequenceassociation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + createdby_id, + updatedby_id, + relation_id, + transcriptassociationsubject_id, + transcriptcodingsequenceassociationobject_id FROM Association WHERE AssociationType = 'TranscriptCodingSequenceAssociation'; + +INSERT INTO transcriptcodingsequenceassociation_informationcontententity + SELECT ai.evidenceassociation_id, ai.evidence_id + FROM association_informationcontententity ai, Association a + WHERE ai.evidenceassociation_id = a.id AND a.associationtype = 'TranscriptCodingSequenceAssociation'; + +DELETE FROM association_informationcontententity WHERE evidenceassociation_id IN (SELECT id FROM transcriptcodingsequenceassociation); + +DELETE FROM Association WHERE AssociationType = 'TranscriptCodingSequenceAssociation'; + +INSERT INTO transcriptexonassociation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + createdby_id, + updatedby_id, + relation_id, + transcriptassociationsubject_id, + transcriptexonassociationobject_id FROM Association WHERE AssociationType = 'TranscriptExonAssociation'; + +INSERT INTO transcriptexonassociation_informationcontententity + SELECT ai.evidenceassociation_id, ai.evidence_id + FROM association_informationcontententity ai, Association a + WHERE ai.evidenceassociation_id = a.id AND a.associationtype = 'TranscriptExonAssociation'; + +DELETE FROM association_informationcontententity WHERE evidenceassociation_id IN (SELECT id FROM transcriptexonassociation); + +DELETE FROM Association WHERE AssociationType = 'TranscriptExonAssociation'; + +INSERT INTO transcriptgeneassociation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + createdby_id, + updatedby_id, + relation_id, + transcriptassociationsubject_id, + transcriptgeneassociationobject_id FROM Association WHERE AssociationType = 'TranscriptGeneAssociation'; + +INSERT INTO transcriptgeneassociation_informationcontententity + SELECT ai.evidenceassociation_id, ai.evidence_id + FROM association_informationcontententity ai, Association a + WHERE ai.evidenceassociation_id = a.id AND a.associationtype = 'TranscriptGeneAssociation'; + +DELETE FROM association_informationcontententity WHERE evidenceassociation_id IN (SELECT id FROM transcriptgeneassociation); + +DELETE FROM Association WHERE AssociationType = 'TranscriptGeneAssociation'; + +INSERT INTO transcriptgenomiclocationassociation + SELECT + id, + datecreated, + dateupdated, + dbdatecreated, + dbdateupdated, + internal, + obsolete, + "end", + start, + phase, + strand, + createdby_id, + updatedby_id, + relation_id, + transcriptassociationsubject_id, + transcriptgenomiclocationassociationobject_id FROM Association WHERE AssociationType = 'TranscriptGenomicLocationAssociation'; + +INSERT INTO transcriptgenomiclocationassociation_informationcontententity + SELECT ai.evidenceassociation_id, ai.evidence_id + FROM association_informationcontententity ai, Association a + WHERE ai.evidenceassociation_id = a.id AND a.associationtype = 'TranscriptGenomicLocationAssociation'; + +DELETE FROM association_informationcontententity WHERE evidenceassociation_id IN (SELECT id FROM transcriptgenomiclocationassociation); + +DELETE FROM Association WHERE AssociationType = 'TranscriptGenomicLocationAssociation'; + +DROP TABLE association_biologicalentity; +DROP TABLE association_conditionrelation; +DROP TABLE association_crossreference; +DROP TABLE association_gene; +DROP TABLE association_informationcontententity; +DROP TABLE association_note; +DROP TABLE association_ontologyterm; +DROP TABLE association_vocabularyterm; + +DROP TABLE association; diff --git a/src/main/resources/db/migration/v0.37.0.54__mappersuperclass__assocations.sql b/src/main/resources/db/migration/v0.37.0.54__mappersuperclass__assocations.sql new file mode 100644 index 000000000..49dc7a470 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.54__mappersuperclass__assocations.sql @@ -0,0 +1,274 @@ +CREATE INDEX diseaseannotation_annotationtype_index ON diseaseannotation USING btree (annotationtype_id); +CREATE INDEX agmdiseaseannotation_assertedallele_index ON agmdiseaseannotation USING btree (assertedallele_id); +CREATE INDEX diseaseannotation_createdby_index ON diseaseannotation USING btree (createdby_id); +CREATE INDEX diseaseannotation_curie_index ON diseaseannotation USING btree (curie); +CREATE INDEX diseaseannotation_dataprovider_index ON diseaseannotation USING btree (dataprovider_id); +CREATE INDEX diseaseannotation_diseaseannotationobject_index ON diseaseannotation USING btree (diseaseannotationobject_id); +CREATE INDEX agmdiseaseannotation_diseaseannotationsubject_index ON agmdiseaseannotation USING btree (diseaseannotationsubject_id); +CREATE INDEX diseaseannotation_diseasegeneticmodifierrelation_index ON diseaseannotation USING btree (diseasegeneticmodifierrelation_id); +CREATE INDEX diseaseannotation_geneticsex_index ON diseaseannotation USING btree (geneticsex_id); +CREATE INDEX agmdiseaseannotation_inferredallele_index ON agmdiseaseannotation USING btree (inferredallele_id); +CREATE INDEX agmdiseaseannotation_inferredgene_index ON agmdiseaseannotation USING btree (inferredgene_id); +CREATE INDEX diseaseannotation_internal_index ON diseaseannotation USING btree (internal); +CREATE INDEX diseaseannotation_modentityid_index ON diseaseannotation USING btree (modentityid); +CREATE INDEX diseaseannotation_modinternalid_index ON diseaseannotation USING btree (modinternalid); +CREATE INDEX diseaseannotation_negated_index ON diseaseannotation USING btree (negated); +CREATE INDEX diseaseannotation_obsolete_index ON diseaseannotation USING btree (obsolete); +CREATE INDEX diseaseannotation_relation_index ON diseaseannotation USING btree (relation_id); +CREATE INDEX diseaseannotation_secondarydataprovider_index ON diseaseannotation USING btree (secondarydataprovider_id); +CREATE INDEX diseaseannotation_singlereference_index ON diseaseannotation USING btree (singlereference_id); +CREATE INDEX diseaseannotation_uniqueid_index ON diseaseannotation USING btree (uniqueid); +CREATE INDEX diseaseannotation_updatedby_index ON diseaseannotation USING btree (updatedby_id); + +CREATE INDEX diseaseannotation_biologicalentity_da_index ON diseaseannotation_biologicalentity USING btree (diseaseannotation_id); +CREATE INDEX diseaseannotation_biologicalentity_dgm_index ON diseaseannotation_biologicalentity USING btree (diseasegeneticmodifiers_id); + +CREATE INDEX idxtehx15lof8bcxrcc1ccpfoov2 ON diseaseannotation_conditionrelation USING btree (annotation_id); +CREATE INDEX idxk8n3raw0up98oyn0dbhq1o2fv ON diseaseannotation_conditionrelation USING btree (conditionrelations_id); + +CREATE INDEX agmdiseaseannotation_gene_assertedgenes_index ON agmdiseaseannotation_gene USING btree (assertedgenes_id); +CREATE INDEX agmdiseaseannotation_gene_agmda_index ON agmdiseaseannotation_gene USING btree (agmdiseaseannotation_id); +CREATE INDEX diseaseannotation_gene_da_index ON diseaseannotation_gene USING btree (diseaseannotation_id); +CREATE INDEX diseaseannotation_gene_with_index ON diseaseannotation_gene USING btree (with_id); + +CREATE INDEX idxes81on0evcu8cyfdei59wupb0 ON diseaseannotation_note USING btree (annotation_id); +CREATE INDEX idxf3o1apeoj9un48jw6qmiihpjc ON diseaseannotation_note USING btree (relatednotes_id); + +CREATE INDEX diseaseannotation_ontologyterm_da_index ON diseaseannotation_ontologyterm USING btree (diseaseannotation_id); +CREATE INDEX diseaseannotation_ontologyterm_evidencecodes_index ON diseaseannotation_ontologyterm USING btree (evidencecodes_id); + +CREATE INDEX diseaseannotation_vocabularyterm_da_index ON diseaseannotation_vocabularyterm USING btree (diseaseannotation_id); +CREATE INDEX diseaseannotation_vocabularyterm_dq_index ON diseaseannotation_vocabularyterm USING btree (diseasequalifiers_id); + +CREATE INDEX agmphenotypeannotation_assertedallele_index ON agmphenotypeannotation USING btree (assertedallele_id); +CREATE INDEX phenotypeannotation_createdby_index ON phenotypeannotation USING btree (createdby_id); +CREATE INDEX phenotypeannotation_crossreference_index ON phenotypeannotation USING btree (crossreference_id); +CREATE INDEX phenotypeannotation_curie_index ON phenotypeannotation USING btree (curie); +CREATE INDEX phenotypeannotation_dataprovider_index ON phenotypeannotation USING btree (dataprovider_id); +CREATE INDEX agmphenotypeannotation_inferredallele_index ON agmphenotypeannotation USING btree (inferredallele_id); +CREATE INDEX agmphenotypeannotation_inferredgene_index ON agmphenotypeannotation USING btree (inferredgene_id); +CREATE INDEX phenotypeannotation_internal_index ON phenotypeannotation USING btree (internal); +CREATE INDEX phenotypeannotation_modentityid_index ON phenotypeannotation USING btree (modentityid); +CREATE INDEX phenotypeannotation_modinternalid_index ON phenotypeannotation USING btree (modinternalid); +CREATE INDEX phenotypeannotation_obsolete_index ON phenotypeannotation USING btree (obsolete); +CREATE INDEX agmphenotypeannotation_phenotypeannotationsubject_index ON agmphenotypeannotation USING btree (phenotypeannotationsubject_id); +CREATE INDEX phenotypeannotation_relation_index ON phenotypeannotation USING btree (relation_id); +CREATE INDEX phenotypeannotation_singlereference_index ON phenotypeannotation USING btree (singlereference_id); +CREATE INDEX phenotypeannotation_uniqueid_index ON phenotypeannotation USING btree (uniqueid); +CREATE INDEX phenotypeannotation_updatedby_index ON phenotypeannotation USING btree (updatedby_id); + +CREATE INDEX idxfsppmvsmvokcuh3liqina4xc2 ON phenotypeannotation_conditionrelation USING btree (annotation_id); +CREATE INDEX idx5d01e5hfm2ur0a8kliqgosyw ON phenotypeannotation_conditionrelation USING btree (conditionrelations_id); + +CREATE INDEX agmphenotypeannotation_gene_assertedgenes_index ON agmphenotypeannotation_gene USING btree (assertedgenes_id); +CREATE INDEX agmphenotypeannotation_gene_agmpa_index ON agmphenotypeannotation_gene USING btree (agmphenotypeannotation_id); + +CREATE INDEX idxs9iwgydguom8kb44l92ves8ay ON phenotypeannotation_note USING btree (annotation_id); +CREATE INDEX idxcr11ebjoa76c90wp9ymoeryav ON phenotypeannotation_note USING btree (relatednotes_id); + +CREATE INDEX phenotypeannotation_ontologyterm_phenotypeterms_index ON phenotypeannotation_ontologyterm USING btree (phenotypeterms_id); +CREATE INDEX phenotypeannotation_ontologyterm_pa_index ON phenotypeannotation_ontologyterm USING btree (phenotypeannotation_id); + +CREATE INDEX allelediseaseannotation_diseaseannotationsubject_index ON allelediseaseannotation USING btree (diseaseannotationsubject_id); +CREATE INDEX allelediseaseannotation_inferredgene_index ON allelediseaseannotation USING btree (inferredgene_id); + +CREATE INDEX allelediseaseannotation_gene_assertedgenes_index ON allelediseaseannotation_gene USING btree (assertedgenes_id); +CREATE INDEX allelediseaseannotation_gene_alleleda_index ON allelediseaseannotation_gene USING btree (allelediseaseannotation_id); + +CREATE INDEX allelegeneassociation_alleleassociationsubject_index ON allelegeneassociation USING btree (alleleassociationsubject_id); +CREATE INDEX allelegeneassociation_allelegeneassociationobject_index ON allelegeneassociation USING btree (allelegeneassociationobject_id); +CREATE INDEX allelegeneassociation_createdby_index ON allelegeneassociation USING btree (createdby_id); +CREATE INDEX allelegeneassociation_evidencecode_index ON allelegeneassociation USING btree (evidencecode_id); +CREATE INDEX allelegeneassociation_internal_index ON allelegeneassociation USING btree (internal); +CREATE INDEX allelegeneassociation_obsolete_index ON allelegeneassociation USING btree (obsolete); +CREATE INDEX allelegeneassociation_relatednote_index ON allelegeneassociation USING btree (relatednote_id); +CREATE INDEX allelegeneassociation_relation_index ON allelegeneassociation USING btree (relation_id); +CREATE INDEX allelegeneassociation_updatedby_index ON allelegeneassociation USING btree (updatedby_id); + +CREATE INDEX idx9u4cqfbtajokovj1quacsvld2 ON allelegeneassociation_informationcontententity USING btree (association_id); +CREATE INDEX idxp3na9i2xw0ea9igcwx1jdpc9g ON allelegeneassociation_informationcontententity USING btree (evidence_id); + +CREATE INDEX allelephenotypeannotation_inferredgene_index ON allelephenotypeannotation USING btree (inferredgene_id); +CREATE INDEX allelephenotypeannotation_phenotypeannotationsubject_index ON allelephenotypeannotation USING btree (phenotypeannotationsubject_id); + +CREATE INDEX allelephenotypeannotation_gene_assertedgenes_index ON allelephenotypeannotation_gene USING btree (assertedgenes_id); +CREATE INDEX allelephenotypeannotation_gene_allelepa_index ON allelephenotypeannotation_gene USING btree (allelephenotypeannotation_id); + +CREATE INDEX idxl9e4a6sp66j64ijkjv0bkih00 ON codingsequencegenomiclocationassociation USING btree (codingsequenceassociationsubject_id); +CREATE INDEX idxra2iufgb07uc25aelolsnf3by ON codingsequencegenomiclocationassociation USING btree (codingsequencegenomiclocationassociationobject_id); +CREATE INDEX idxkmsyqr54idykm7nuoi32k7ruk ON codingsequencegenomiclocationassociation USING btree (createdby_id); +CREATE INDEX idx7g9txdnm3bwk5bxn7wlhskfng ON codingsequencegenomiclocationassociation USING btree (internal); +CREATE INDEX idxsv2u8tq3qdw6nubs1ar8v63hm ON codingsequencegenomiclocationassociation USING btree (obsolete); +CREATE INDEX idxtark2ners5x44tsu59ewaer2d ON codingsequencegenomiclocationassociation USING btree (phase); +CREATE INDEX idxqbpw668oh0k8odryloou00h3k ON codingsequencegenomiclocationassociation USING btree (relation_id); +CREATE INDEX idx6hn6om3p991ntu7alvh1ryuji ON codingsequencegenomiclocationassociation USING btree (strand); +CREATE INDEX idx3wrew2y9txskknyf8ej3gkh4k ON codingsequencegenomiclocationassociation USING btree (updatedby_id); + +CREATE INDEX idx9x4hjxaf5yi68uyhxx0goxp6g ON CodingSequenceGenomicLocationAssociation_InformationContentEntity USING btree (association_id); +CREATE INDEX idxsp0jo6nxvd8pdbtyn4pcbag3f ON CodingSequenceGenomicLocationAssociation_InformationContentEntity USING btree (evidence_id); + +CREATE INDEX idxvsibphiuleew24wjckpfxeae ON constructgenomicentityassociation USING btree (internal); +CREATE INDEX idx8myuo0a6hx59vxfhlbrcn8ujk ON constructgenomicentityassociation USING btree (constructassociationsubject_id); +CREATE INDEX idxevduykusoc08mycbrmn4o7dnq ON constructgenomicentityassociation USING btree (constructgenomicentityassociationobject_id); +CREATE INDEX idxch64a8ot2vv6i0rue8khyjb3m ON constructgenomicentityassociation USING btree (createdby_id); +CREATE INDEX idxi6hc4krcrxpsrrwj728vd2wpx ON constructgenomicentityassociation USING btree (obsolete); +CREATE INDEX idxsoyddowolab2mrp5eaxj57yar ON constructgenomicentityassociation USING btree (relation_id); +CREATE INDEX idxevh4c07xjfxyylj7ck2dtn6jh ON constructgenomicentityassociation USING btree (updatedby_id); + +CREATE INDEX idxg5fxj3nedebt3cw93uxptf7om ON constructgenomicentityassociation_informationcontententity USING btree (association_id); +CREATE INDEX idxb9tloa39yyvirjvacah10hfd5 ON constructgenomicentityassociation_informationcontententity USING btree (evidence_id); + +CREATE INDEX constructgeassociation_note_cgea_index ON constructgenomicentityassociation_note USING btree (constructgenomicentityassociation_id); +CREATE INDEX constructgeassociation_note_relatednotes_index ON constructgenomicentityassociation_note USING btree (relatednotes_id); + +CREATE INDEX idxhgjuh3b5r08q54fwecp64k3a4 ON exongenomiclocationassociation USING btree (createdby_id); +CREATE INDEX idx82dedqro7ri1f8g558icrjxc6 ON exongenomiclocationassociation USING btree (exonassociationsubject_id); +CREATE INDEX idx53jvdw533s5e082xlj0sx7p7x ON exongenomiclocationassociation USING btree (exongenomiclocationassociationobject_id); +CREATE INDEX idx2knwxko11qkxvr98w7l76wlgi ON exongenomiclocationassociation USING btree (internal); +CREATE INDEX idxo923wv3e7dg9e2flm08ghwiig ON exongenomiclocationassociation USING btree (obsolete); +CREATE INDEX idx5ufu3a6guayhxy2cg6crxde2i ON exongenomiclocationassociation USING btree (relation_id); +CREATE INDEX idxdwfj56lqtx86brdvwafjqo8nn ON exongenomiclocationassociation USING btree (strand); +CREATE INDEX idxd12130inhcxcp1dbks190955j ON exongenomiclocationassociation USING btree (updatedby_id); + +CREATE INDEX idxtaunnvner3uu6vfarcb9kv0o1 ON exongenomiclocationassociation_informationcontententity USING btree (association_id); +CREATE INDEX idxbugjixb2a6vb0xuho653me8as ON exongenomiclocationassociation_informationcontententity USING btree (evidence_id); + +CREATE INDEX genediseaseannotation_diseaseannotationsubject_index ON genediseaseannotation USING btree (diseaseannotationsubject_id); +CREATE INDEX genediseaseannotation_sgdstrainbackground_index ON genediseaseannotation USING btree (sgdstrainbackground_id); + +CREATE INDEX geneexpressionannotation_createdby_index ON geneexpressionannotation USING btree (createdby_id); +CREATE INDEX geneexpressionannotation_curie_index ON geneexpressionannotation USING btree (curie); +CREATE INDEX geneexpressionannotation_dataprovider_index ON geneexpressionannotation USING btree (dataprovider_id); +CREATE INDEX geneexpressionannotation_expressionannotationsubject_index ON geneexpressionannotation USING btree (expressionannotationsubject_id); +CREATE INDEX geneexpressionannotation_expressionassayused_index ON geneexpressionannotation USING btree (expressionassayused_id); +CREATE INDEX geneexpressionannotation_expressionpattern_index ON geneexpressionannotation USING btree (expressionpattern_id); +CREATE INDEX geneexpressionannotation_internal_index ON geneexpressionannotation USING btree (internal); +CREATE INDEX geneexpressionannotation_modentityid_index ON geneexpressionannotation USING btree (modentityid); +CREATE INDEX geneexpressionannotation_modinternalid_index ON geneexpressionannotation USING btree (modinternalid); +CREATE INDEX geneexpressionannotation_obsolete_index ON geneexpressionannotation USING btree (obsolete); +CREATE INDEX geneexpressionannotation_relation_index ON geneexpressionannotation USING btree (relation_id); +CREATE INDEX geneexpressionannotation_singlereference_index ON geneexpressionannotation USING btree (singlereference_id); +CREATE INDEX geneexpressionannotation_uniqueid_index ON geneexpressionannotation USING btree (uniqueid); +CREATE INDEX geneexpressionannotation_updatedby_index ON geneexpressionannotation USING btree (updatedby_id); + +CREATE INDEX idx1yl81g2efybjh19332kp0v80l ON geneexpressionannotation_conditionrelation USING btree (annotation_id); +CREATE INDEX idxrcptfqy2xuw35xeer5ilrqtc1 ON geneexpressionannotation_conditionrelation USING btree (conditionrelations_id); + +CREATE INDEX idxa4a6b8jwiqomyvkmrx1wsadh6 ON geneexpressionannotation_note USING btree (annotation_id); +CREATE INDEX idxm4mig223w5vb6bpjubkd5xuac ON geneexpressionannotation_note USING btree (relatednotes_id); + +CREATE INDEX genegeneticinteraction_createdby_index ON genegeneticinteraction USING btree (createdby_id); +CREATE INDEX genegeneticinteraction_geneassociationsubject_index ON genegeneticinteraction USING btree (geneassociationsubject_id); +CREATE INDEX genegeneticinteraction_genegeneassociationobject_index ON genegeneticinteraction USING btree (genegeneassociationobject_id); +CREATE INDEX genegeneticinteraction_interactionid_index ON genegeneticinteraction USING btree (interactionid); +CREATE INDEX genegeneticinteraction_interactionsource_index ON genegeneticinteraction USING btree (interactionsource_id); +CREATE INDEX genegeneticinteraction_interactiontype_index ON genegeneticinteraction USING btree (interactiontype_id); +CREATE INDEX genegeneticinteraction_interactorageneticperturbation_index ON genegeneticinteraction USING btree (interactorageneticperturbation_id); +CREATE INDEX genegeneticinteraction_interactorarole_index ON genegeneticinteraction USING btree (interactorarole_id); +CREATE INDEX genegeneticinteraction_interactoratype_index ON genegeneticinteraction USING btree (interactoratype_id); +CREATE INDEX genegeneticinteraction_interactorbgeneticperturbation_index ON genegeneticinteraction USING btree (interactorbgeneticperturbation_id); +CREATE INDEX genegeneticinteraction_interactorbrole_index ON genegeneticinteraction USING btree (interactorbrole_id); +CREATE INDEX genegeneticinteraction_interactorbtype_index ON genegeneticinteraction USING btree (interactorbtype_id); +CREATE INDEX genegeneticinteraction_internal_index ON genegeneticinteraction USING btree (internal); +CREATE INDEX genegeneticinteraction_obsolete_index ON genegeneticinteraction USING btree (obsolete); +CREATE INDEX genegeneticinteraction_relation_index ON genegeneticinteraction USING btree (relation_id); +CREATE INDEX genegeneticinteraction_uniqueid_index ON genegeneticinteraction USING btree (uniqueid); +CREATE INDEX genegeneticinteraction_updatedby_index ON genegeneticinteraction USING btree (updatedby_id); + +CREATE INDEX idx785n3i90n4wijv5sqk4as6kvx ON genegeneticinteraction_crossreference USING btree (geneinteraction_id); +CREATE INDEX idxolfx2gsnlx0vyvpv85ba3s1my ON genegeneticinteraction_crossreference USING btree (crossreferences_id); + +CREATE INDEX idxiwxeu6vppndg2hl252knhgcm2 ON genegeneticinteraction_informationcontententity USING btree (association_id); +CREATE INDEX idx3l5ew8bcu7dqbqu2gux877rqp ON genegeneticinteraction_informationcontententity USING btree (evidence_id); + +CREATE INDEX genegeneticinteraction_phenotypesortraits_interaction_index ON genegeneticinteraction_phenotypesortraits USING btree (genegeneticinteraction_id); +CREATE INDEX genegeneticinteraction_phenotypesortraits_pt_index ON genegeneticinteraction_phenotypesortraits USING btree (phenotypesortraits); + +CREATE INDEX genemolecularinteraction_aggregationdatabase_index ON genemolecularinteraction USING btree (aggregationdatabase_id); +CREATE INDEX genemolecularinteraction_createdby_index ON genemolecularinteraction USING btree (createdby_id); +CREATE INDEX genemolecularinteraction_detectionmethod_index ON genemolecularinteraction USING btree (detectionmethod_id); +CREATE INDEX genemolecularinteraction_geneassociationsubject_index ON genemolecularinteraction USING btree (geneassociationsubject_id); +CREATE INDEX genemolecularinteraction_genegeneassociationobject_index ON genemolecularinteraction USING btree (genegeneassociationobject_id); +CREATE INDEX genemolecularinteraction_interactionid_index ON genemolecularinteraction USING btree (interactionid); +CREATE INDEX genemolecularinteraction_interactionsource_index ON genemolecularinteraction USING btree (interactionsource_id); +CREATE INDEX genemolecularinteraction_interactiontype_index ON genemolecularinteraction USING btree (interactiontype_id); +CREATE INDEX genemolecularinteraction_interactorarole_index ON genemolecularinteraction USING btree (interactorarole_id); +CREATE INDEX genemolecularinteraction_interactoratype_index ON genemolecularinteraction USING btree (interactoratype_id); +CREATE INDEX genemolecularinteraction_interactorbrole_index ON genemolecularinteraction USING btree (interactorbrole_id); +CREATE INDEX genemolecularinteraction_interactorbtype_index ON genemolecularinteraction USING btree (interactorbtype_id); +CREATE INDEX genemolecularinteraction_internal_index ON genemolecularinteraction USING btree (internal); +CREATE INDEX genemolecularinteraction_obsolete_index ON genemolecularinteraction USING btree (obsolete); +CREATE INDEX genemolecularinteraction_relation_index ON genemolecularinteraction USING btree (relation_id); +CREATE INDEX genemolecularinteraction_uniqueid_index ON genemolecularinteraction USING btree (uniqueid); +CREATE INDEX genemolecularinteraction_updatedby_index ON genemolecularinteraction USING btree (updatedby_id); + +CREATE INDEX idx7lx7isr6eb5w0w5in5vsncutg ON genemolecularinteraction_crossreference USING btree (crossreferences_id); +CREATE INDEX idxod8u9onkd3pi9r4p1h1by4cl0 ON genemolecularinteraction_crossreference USING btree (geneinteraction_id); + +CREATE INDEX idxcuc2oxltucskw9yld02sck6kk ON genemolecularinteraction_informationcontententity USING btree (association_id); +CREATE INDEX idxqdpatuorfp3xeoa2ogmg20x1q ON genemolecularinteraction_informationcontententity USING btree (evidence_id); + +CREATE INDEX genephenotypeannotation_phenotypeannotationsubject_index ON genephenotypeannotation USING btree (phenotypeannotationsubject_id); +CREATE INDEX genephenotypeannotation_sgdstrainbackground_index ON genephenotypeannotation USING btree (sgdstrainbackground_id); + +CREATE INDEX sqtrgeneassociation_createdby_index ON sequencetargetingreagentgeneassociation USING btree (createdby_id); +CREATE INDEX sqtrgeneassociation_internal_index ON sequencetargetingreagentgeneassociation USING btree (internal); +CREATE INDEX sqtrgeneassociation_obsolete_index ON sequencetargetingreagentgeneassociation USING btree (obsolete); +CREATE INDEX sqtrgeneassociation_relation_index ON sequencetargetingreagentgeneassociation USING btree (relation_id); +CREATE INDEX sqtrgeneassociation_sqtrassociationsubject_index ON sequencetargetingreagentgeneassociation USING btree (sequencetargetingreagentassociationsubject_id); +CREATE INDEX sqtrgeneassociation_sqtrgeneassociationobject_index ON sequencetargetingreagentgeneassociation USING btree (sequencetargetingreagentgeneassociationobject_id); +CREATE INDEX sqtrgeneassociation_updatedby_index ON sequencetargetingreagentgeneassociation USING btree (updatedby_id); + +CREATE INDEX idxicqsm49w1cwo7kqlp15vr2643 ON sequencetargetingreagentgeneassociation_informationcontententit USING btree (association_id); +CREATE INDEX idx3rr3mmw2hmnwvlx3u7lsgehh ON sequencetargetingreagentgeneassociation_informationcontententit USING btree (evidence_id); + +CREATE INDEX idxon9k4nqnwlav7ammge7obyshm ON transcriptcodingsequenceassociation USING btree (createdby_id); +CREATE INDEX idxf95tn5xv2nugt594ch7kggtex ON transcriptcodingsequenceassociation USING btree (internal); +CREATE INDEX idxd7d7oeub6eclirxmjpmc7ibot ON transcriptcodingsequenceassociation USING btree (obsolete); +CREATE INDEX idxio6g2jejebbjqugso2ge8cncf ON transcriptcodingsequenceassociation USING btree (relation_id); +CREATE INDEX idxptss0twuhfg2ibqnb8vai4v2v ON transcriptcodingsequenceassociation USING btree (transcriptassociationsubject_id); +CREATE INDEX idx8jsnbfbebppm2memg9yywpea6 ON transcriptcodingsequenceassociation USING btree (transcriptcodingsequenceassociationobject_id); +CREATE INDEX idxe31s0f5w54vnjhxeysi3g1oy0 ON transcriptcodingsequenceassociation USING btree (updatedby_id); + +CREATE INDEX idxl4jg4t2dlkjivgea1lta3l9xm ON transcriptcodingsequenceassociation_informationcontententity USING btree (association_id); +CREATE INDEX idxmbtwtvy0731b13p3dhoni3ywd ON transcriptcodingsequenceassociation_informationcontententity USING btree (evidence_id); + +CREATE INDEX idxfdeljm7108w0j2nbrrme945ur ON transcriptexonassociation USING btree (createdby_id); +CREATE INDEX idxrig5300vc2ppesjckdkpv219m ON transcriptexonassociation USING btree (internal); +CREATE INDEX idxfmwe55e0r89q00xqlvi4v7sm0 ON transcriptexonassociation USING btree (obsolete); +CREATE INDEX idxm76icxt2r2qs52o4wpiexpb39 ON transcriptexonassociation USING btree (relation_id); +CREATE INDEX idxdct5af7efyqufibj1rjrvieam ON transcriptexonassociation USING btree (transcriptassociationsubject_id); +CREATE INDEX idxhpo9wefgxyoasohcctnr0qev3 ON transcriptexonassociation USING btree (transcriptexonassociationobject_id); +CREATE INDEX idx29575n6x9yueygvw1mj9exc2g ON transcriptexonassociation USING btree (updatedby_id); + +CREATE INDEX idxf124air9olggpyrs5i3rgkbkj ON transcriptexonassociation_informationcontententity USING btree (association_id); +CREATE INDEX idxgg4iqmx96raypy761sn4h99ns ON transcriptexonassociation_informationcontententity USING btree (evidence_id); + +CREATE INDEX transcriptgeneassociation_createdby_index ON transcriptgeneassociation USING btree (createdby_id); +CREATE INDEX transcriptgeneassociation_internal_index ON transcriptgeneassociation USING btree (internal); +CREATE INDEX transcriptgeneassociation_obsolete_index ON transcriptgeneassociation USING btree (obsolete); +CREATE INDEX transcriptgeneassociation_relation_index ON transcriptgeneassociation USING btree (relation_id); +CREATE INDEX transcriptgeneassociation_transcriptassociationsubject_index ON transcriptgeneassociation USING btree (transcriptassociationsubject_id); +CREATE INDEX transcriptgeneassociation_transcriptgeneassociationobject_index ON transcriptgeneassociation USING btree (transcriptgeneassociationobject_id); +CREATE INDEX transcriptgeneassociation_updatedby_index ON transcriptgeneassociation USING btree (updatedby_id); + +CREATE INDEX idxnu079dovpg7bfrb6uawgtscqs ON transcriptgeneassociation_informationcontententity USING btree (association_id); +CREATE INDEX idxis18nw3pj2ru6wlejbwotqsv9 ON transcriptgeneassociation_informationcontententity USING btree (evidence_id); + +CREATE INDEX idxaicr23temspg10v3f22k52ssd ON transcriptgenomiclocationassociation USING btree (createdby_id); +CREATE INDEX idxd06sc5p3gc11brcoxwp7ppbmr ON transcriptgenomiclocationassociation USING btree (internal); +CREATE INDEX idxgrqw9lxw4l1whho97aose6qh5 ON transcriptgenomiclocationassociation USING btree (obsolete); +CREATE INDEX idxii7jvungodeeudebo6c4kebny ON transcriptgenomiclocationassociation USING btree (phase); +CREATE INDEX idxtqvg5149lyo8q1oof4hhd7mmw ON transcriptgenomiclocationassociation USING btree (relation_id); +CREATE INDEX idx9yipaclxcmb82h69o4k5q3utt ON transcriptgenomiclocationassociation USING btree (strand); +CREATE INDEX idx4yukrngwb6ipj72wujbxa87bb ON transcriptgenomiclocationassociation USING btree (transcriptassociationsubject_id); +CREATE INDEX idxgo4p2kepo9x83moktih7gurb0 ON transcriptgenomiclocationassociation USING btree (transcriptgenomiclocationassociationobject_id); +CREATE INDEX idx1fpq38gqgxatnm69ge6purjbc ON transcriptgenomiclocationassociation USING btree (updatedby_id); + +CREATE INDEX idx5bqn8a8osk6oy4514gpf8xs3 ON transcriptgenomiclocationassociation_informationcontententity USING btree (evidence_id); +CREATE INDEX idxghedmb4mmore7js1d3ni9thpn ON transcriptgenomiclocationassociation_informationcontententity USING btree (association_id); + +-- Missing Index + +CREATE INDEX cellularcomponentqualifiers_cellularcomponentqualifiers_index ON public.anatomicalsite_cellularcomponentqualifiers USING btree (cellularcomponentqualifiers_id); + diff --git a/src/main/resources/db/migration/v0.37.0.55__mappersuperclass__assocations.sql b/src/main/resources/db/migration/v0.37.0.55__mappersuperclass__assocations.sql new file mode 100644 index 000000000..77ce34dcd --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.55__mappersuperclass__assocations.sql @@ -0,0 +1,218 @@ +ALTER TABLE ONLY agmdiseaseannotation ADD CONSTRAINT agmdiseaseannotation_assertedallele_id_fk FOREIGN KEY (assertedallele_id) REFERENCES allele(id); +ALTER TABLE ONLY diseaseannotation ADD CONSTRAINT diseaseannotation_singlereference_id_fk FOREIGN KEY (singlereference_id) REFERENCES reference(id); +ALTER TABLE ONLY diseaseannotation ADD CONSTRAINT diseaseannotation_geneticsex_id_fk FOREIGN KEY (geneticsex_id) REFERENCES vocabularyterm(id); +ALTER TABLE ONLY agmdiseaseannotation ADD CONSTRAINT agmdiseaseannotation_dasubject_id_fk FOREIGN KEY (diseaseannotationsubject_id) REFERENCES affectedgenomicmodel(id) ON DELETE CASCADE; +ALTER TABLE ONLY diseaseannotation ADD CONSTRAINT diseaseannotation_dgmrelation_id_fk FOREIGN KEY (diseasegeneticmodifierrelation_id) REFERENCES vocabularyterm(id); +ALTER TABLE ONLY diseaseannotation ADD CONSTRAINT diseaseannotation_relation_id_fk FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); +ALTER TABLE ONLY diseaseannotation ADD CONSTRAINT diseaseannotation_annotationtype_id_fk FOREIGN KEY (annotationtype_id) REFERENCES vocabularyterm(id); +ALTER TABLE ONLY agmdiseaseannotation ADD CONSTRAINT agmdiseaseannotation_inferredallele_id_fk FOREIGN KEY (inferredallele_id) REFERENCES allele(id); +ALTER TABLE ONLY diseaseannotation ADD CONSTRAINT diseaseannotation_createdby_id_fk FOREIGN KEY (createdby_id) REFERENCES person(id); +ALTER TABLE ONLY diseaseannotation ADD CONSTRAINT diseaseannotation_secondarydataprovider_id_fk FOREIGN KEY (secondarydataprovider_id) REFERENCES dataprovider(id); +ALTER TABLE ONLY diseaseannotation ADD CONSTRAINT diseaseannotation_updatedby_id_fk FOREIGN KEY (updatedby_id) REFERENCES person(id); +ALTER TABLE ONLY agmdiseaseannotation ADD CONSTRAINT agmdiseaseannotation_inferredgene_id_fk FOREIGN KEY (inferredgene_id) REFERENCES gene(id); +ALTER TABLE ONLY diseaseannotation ADD CONSTRAINT diseaseannotation_dataprovider_id_fk FOREIGN KEY (dataprovider_id) REFERENCES dataprovider(id); +ALTER TABLE ONLY diseaseannotation ADD CONSTRAINT diseaseannotation_daobject_id_fk FOREIGN KEY (diseaseannotationobject_id) REFERENCES ontologyterm(id); + +ALTER TABLE ONLY diseaseannotation_biologicalentity ADD CONSTRAINT diseaseannotation_biologicalentity_dgm_id_fk FOREIGN KEY (diseasegeneticmodifiers_id) REFERENCES biologicalentity(id); +ALTER TABLE ONLY diseaseannotation_biologicalentity ADD CONSTRAINT diseaseannotation_biologicalentity_da_id_fk FOREIGN KEY (diseaseannotation_id) REFERENCES diseaseannotation(id); + +ALTER TABLE ONLY diseaseannotation_conditionrelation ADD CONSTRAINT diseaseannotation_conditionrelation_annotation_id_fk FOREIGN KEY (annotation_id) REFERENCES diseaseannotation(id); +ALTER TABLE ONLY diseaseannotation_conditionrelation ADD CONSTRAINT diseaseannotation_conditionrelation_cr_id_fk FOREIGN KEY (conditionrelations_id) REFERENCES conditionrelation(id); + +ALTER TABLE ONLY diseaseannotation_gene ADD CONSTRAINT diseaseannotation_gene_diseaseannotation_id_fk FOREIGN KEY (diseaseannotation_id) REFERENCES diseaseannotation(id); +ALTER TABLE ONLY diseaseannotation_gene ADD CONSTRAINT diseaseannotation_gene_with_id_fk FOREIGN KEY (with_id) REFERENCES gene(id); +ALTER TABLE ONLY agmdiseaseannotation_gene ADD CONSTRAINT agmdiseaseannotation_gene_agmdiseaseannotation_id_fk FOREIGN KEY (agmdiseaseannotation_id) REFERENCES agmdiseaseannotation(id); +ALTER TABLE ONLY agmdiseaseannotation_gene ADD CONSTRAINT agmdiseaseannotation_gene_assertedgenes_id_fk FOREIGN KEY (assertedgenes_id) REFERENCES gene(id); + +ALTER TABLE ONLY diseaseannotation_note ADD CONSTRAINT diseaseannotation_note_annotation_id_fk FOREIGN KEY (annotation_id) REFERENCES diseaseannotation(id); +ALTER TABLE ONLY diseaseannotation_note ADD CONSTRAINT diseaseannotation_note_relatednotes_id_fku9eem1iwfkgx FOREIGN KEY (relatednotes_id) REFERENCES note(id); + +ALTER TABLE ONLY diseaseannotation_ontologyterm ADD CONSTRAINT diseaseannotation_ontologyterm_evidencecodes_id_fk FOREIGN KEY (evidencecodes_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY diseaseannotation_ontologyterm ADD CONSTRAINT diseaseannotation_ontologyterm_diseaseannotation_id_fk FOREIGN KEY (diseaseannotation_id) REFERENCES diseaseannotation(id); + +ALTER TABLE ONLY diseaseannotation_vocabularyterm ADD CONSTRAINT diseaseannotation_vocabularyterm_diseaseannotation_id_fk FOREIGN KEY (diseaseannotation_id) REFERENCES diseaseannotation(id); +ALTER TABLE ONLY diseaseannotation_vocabularyterm ADD CONSTRAINT diseaseannotation_vocabularyterm_diseasequalifiers_id_fk FOREIGN KEY (diseasequalifiers_id) REFERENCES vocabularyterm(id); + +ALTER TABLE ONLY agmphenotypeannotation ADD CONSTRAINT agmphenotypeannotation_inferredallele_id_fk FOREIGN KEY (inferredallele_id) REFERENCES allele(id); +ALTER TABLE ONLY phenotypeannotation ADD CONSTRAINT phenotypeannotation_crossreference_id_fk FOREIGN KEY (crossreference_id) REFERENCES crossreference(id); +ALTER TABLE ONLY agmphenotypeannotation ADD CONSTRAINT agmphenotypeannotation_inferredgene_id_fk FOREIGN KEY (inferredgene_id) REFERENCES gene(id); +ALTER TABLE ONLY phenotypeannotation ADD CONSTRAINT phenotypeannotation_createdby_id_fk FOREIGN KEY (createdby_id) REFERENCES person(id); +ALTER TABLE ONLY phenotypeannotation ADD CONSTRAINT phenotypeannotation_updatedby_id_fk FOREIGN KEY (updatedby_id) REFERENCES person(id); +ALTER TABLE ONLY phenotypeannotation ADD CONSTRAINT phenotypeannotation_dataprovider_id_fk FOREIGN KEY (dataprovider_id) REFERENCES dataprovider(id); +ALTER TABLE ONLY phenotypeannotation ADD CONSTRAINT phenotypeannotation_singlereference_id_fk FOREIGN KEY (singlereference_id) REFERENCES reference(id); +ALTER TABLE ONLY agmphenotypeannotation ADD CONSTRAINT agmphenotypeannotation_assertedallele_id_fk FOREIGN KEY (assertedallele_id) REFERENCES allele(id); +ALTER TABLE ONLY agmphenotypeannotation ADD CONSTRAINT agmphenotypeannotation_pasubject_id_fk FOREIGN KEY (phenotypeannotationsubject_id) REFERENCES affectedgenomicmodel(id) ON DELETE CASCADE; +ALTER TABLE ONLY phenotypeannotation ADD CONSTRAINT phenotypeannotation_relation_id_fk FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); + +ALTER TABLE ONLY phenotypeannotation_conditionrelation ADD CONSTRAINT phenotypeannotation_conditionrelation_cr_id_fk FOREIGN KEY (conditionrelations_id) REFERENCES conditionrelation(id); +ALTER TABLE ONLY phenotypeannotation_conditionrelation ADD CONSTRAINT phenotypeannotation_conditionrelation_annotation_id_fk FOREIGN KEY (annotation_id) REFERENCES phenotypeannotation(id); + +ALTER TABLE ONLY agmphenotypeannotation_gene ADD CONSTRAINT agmphenotypeannotation_gene_agmpa_id_fk FOREIGN KEY (agmphenotypeannotation_id) REFERENCES agmphenotypeannotation(id); +ALTER TABLE ONLY agmphenotypeannotation_gene ADD CONSTRAINT agmphenotypeannotation_gene_assertedgenes_id_fk FOREIGN KEY (assertedgenes_id) REFERENCES gene(id); + +ALTER TABLE ONLY phenotypeannotation_note ADD CONSTRAINT phenotypeannotation_note_annotation_id_fk FOREIGN KEY (annotation_id) REFERENCES phenotypeannotation(id); +ALTER TABLE ONLY phenotypeannotation_note ADD CONSTRAINT phenotypeannotation_note_relatednotes_id_fk FOREIGN KEY (relatednotes_id) REFERENCES note(id); + +ALTER TABLE ONLY phenotypeannotation_ontologyterm ADD CONSTRAINT phenotypeannotation_ontologyterm_pa_id_fk FOREIGN KEY (phenotypeannotation_id) REFERENCES phenotypeannotation(id); +ALTER TABLE ONLY phenotypeannotation_ontologyterm ADD CONSTRAINT phenotypeannotation_ontologyterm_phenotypeterms_id_fk FOREIGN KEY (phenotypeterms_id) REFERENCES ontologyterm(id); + +ALTER TABLE ONLY allelediseaseannotation ADD CONSTRAINT allelediseaseannotation_dasubject_id_fk FOREIGN KEY (diseaseannotationsubject_id) REFERENCES allele(id) ON DELETE CASCADE; +ALTER TABLE ONLY allelediseaseannotation ADD CONSTRAINT allelediseaseannotation_inferredgene_id_fk FOREIGN KEY (inferredgene_id) REFERENCES gene(id); + +ALTER TABLE ONLY allelediseaseannotation_gene ADD CONSTRAINT allelediseaseannotation_gene_assertedgenes_id FOREIGN KEY (assertedgenes_id) REFERENCES gene(id); +ALTER TABLE ONLY allelediseaseannotation_gene ADD CONSTRAINT allelediseaseannotation_gene_ada_id FOREIGN KEY (allelediseaseannotation_id) REFERENCES allelediseaseannotation(id); + +ALTER TABLE ONLY allelegeneassociation ADD CONSTRAINT allelegeneassociation_relation_id_fk FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); +ALTER TABLE ONLY allelegeneassociation ADD CONSTRAINT allelegeneassociation_agaobject_id_fk FOREIGN KEY (allelegeneassociationobject_id) REFERENCES gene(id); +ALTER TABLE ONLY allelegeneassociation ADD CONSTRAINT allelegeneassociation_updatedby_id_fk FOREIGN KEY (updatedby_id) REFERENCES person(id); +ALTER TABLE ONLY allelegeneassociation ADD CONSTRAINT allelegeneassociation_createdby_id_fk FOREIGN KEY (createdby_id) REFERENCES person(id); +ALTER TABLE ONLY allelegeneassociation ADD CONSTRAINT allelegeneassociation_evidencecode_id_fk FOREIGN KEY (evidencecode_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY allelegeneassociation ADD CONSTRAINT allelegeneassociation_relatednote_id_fk FOREIGN KEY (relatednote_id) REFERENCES note(id); +ALTER TABLE ONLY allelegeneassociation ADD CONSTRAINT allelegeneassociation_aasubject_id_fk FOREIGN KEY (alleleassociationsubject_id) REFERENCES allele(id); + +ALTER TABLE ONLY allelegeneassociation_informationcontententity ADD CONSTRAINT allelegeneassociation_ice_evidence_id_fk FOREIGN KEY (evidence_id) REFERENCES informationcontententity(id); +ALTER TABLE ONLY allelegeneassociation_informationcontententity ADD CONSTRAINT allelegeneassociation_ice_association_id_fk FOREIGN KEY (association_id) REFERENCES allelegeneassociation(id); + +ALTER TABLE ONLY allelephenotypeannotation ADD CONSTRAINT allelephenotypeannotation_inferredgene_id_fk FOREIGN KEY (inferredgene_id) REFERENCES gene(id); +ALTER TABLE ONLY allelephenotypeannotation ADD CONSTRAINT allelephenotypeannotation_pasubject_id_fk FOREIGN KEY (phenotypeannotationsubject_id) REFERENCES allele(id) ON DELETE CASCADE; + +ALTER TABLE ONLY allelephenotypeannotation_gene ADD CONSTRAINT allelephenotypeannotation_gene_allelephenotypeannotation_id_fk FOREIGN KEY (allelephenotypeannotation_id) REFERENCES allelephenotypeannotation(id); +ALTER TABLE ONLY allelephenotypeannotation_gene ADD CONSTRAINT allelephenotypeannotation_gene_assertedgenes_id_fk FOREIGN KEY (assertedgenes_id) REFERENCES gene(id); + +ALTER TABLE ONLY codingsequencegenomiclocationassociation ADD CONSTRAINT cdsglassociation_updatedby_id_fk FOREIGN KEY (updatedby_id) REFERENCES person(id); +ALTER TABLE ONLY codingsequencegenomiclocationassociation ADD CONSTRAINT cdsglassociation_cdsglaobject_id_fk FOREIGN KEY (codingsequencegenomiclocationassociationobject_id) REFERENCES assemblycomponent(id); +ALTER TABLE ONLY codingsequencegenomiclocationassociation ADD CONSTRAINT cdsglassociation_createdby_id_fk FOREIGN KEY (createdby_id) REFERENCES person(id); +ALTER TABLE ONLY codingsequencegenomiclocationassociation ADD CONSTRAINT cdsglassociation_cdsglsubject_id_fk FOREIGN KEY (codingsequenceassociationsubject_id) REFERENCES codingsequence(id); +ALTER TABLE ONLY codingsequencegenomiclocationassociation ADD CONSTRAINT cdsglassociation_relation_id_fk FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); + +ALTER TABLE ONLY CodingSequenceGenomicLocationAssociation_InformationContentEntity ADD CONSTRAINT cdsgla_ice_association_id_fk FOREIGN KEY (association_id) REFERENCES codingsequencegenomiclocationassociation(id); +ALTER TABLE ONLY CodingSequenceGenomicLocationAssociation_InformationContentEntity ADD CONSTRAINT cdsgla_ice_evidence_id_fk FOREIGN KEY (evidence_id) REFERENCES informationcontententity(id); + +ALTER TABLE ONLY constructgenomicentityassociation ADD CONSTRAINT constructgenomicentityassociation_updatedby_id_fk FOREIGN KEY (updatedby_id) REFERENCES person(id); +ALTER TABLE ONLY constructgenomicentityassociation ADD CONSTRAINT constructgenomicentityassociation_cgeaobject_id_fk FOREIGN KEY (constructgenomicentityassociationobject_id) REFERENCES genomicentity(id); +ALTER TABLE ONLY constructgenomicentityassociation ADD CONSTRAINT constructgenomicentityassociation_createdby_id_fk FOREIGN KEY (createdby_id) REFERENCES person(id); +ALTER TABLE ONLY constructgenomicentityassociation ADD CONSTRAINT constructgenomicentityassociation_casubject_id_fk FOREIGN KEY (constructassociationsubject_id) REFERENCES construct(id); +ALTER TABLE ONLY constructgenomicentityassociation ADD CONSTRAINT constructgenomicentityassociation_relation_id_fk FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); + +ALTER TABLE ONLY constructgenomicentityassociation_informationcontententity ADD CONSTRAINT cgea_ice_evidence_id_fk FOREIGN KEY (evidence_id) REFERENCES informationcontententity(id); +ALTER TABLE ONLY constructgenomicentityassociation_informationcontententity ADD CONSTRAINT cgea_ice_association_id_fk FOREIGN KEY (association_id) REFERENCES constructgenomicentityassociation(id); + +ALTER TABLE ONLY constructgenomicentityassociation_note ADD CONSTRAINT cgea_note_cgeassociation_id_fk FOREIGN KEY (constructgenomicentityassociation_id) REFERENCES constructgenomicentityassociation(id); +ALTER TABLE ONLY constructgenomicentityassociation_note ADD CONSTRAINT cgea_note_relatednotes_id_fk FOREIGN KEY (relatednotes_id) REFERENCES note(id); + +ALTER TABLE ONLY exongenomiclocationassociation ADD CONSTRAINT exongenomiclocationassociation_relation_id_fk FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); +ALTER TABLE ONLY exongenomiclocationassociation ADD CONSTRAINT exongenomiclocationassociation_createdby_id_fk FOREIGN KEY (createdby_id) REFERENCES person(id); +ALTER TABLE ONLY exongenomiclocationassociation ADD CONSTRAINT exongenomiclocationassociation_updatedby_id_fk FOREIGN KEY (updatedby_id) REFERENCES person(id); +ALTER TABLE ONLY exongenomiclocationassociation ADD CONSTRAINT exongenomiclocationassociation_easubject_id_fk FOREIGN KEY (exonassociationsubject_id) REFERENCES exon(id); +ALTER TABLE ONLY exongenomiclocationassociation ADD CONSTRAINT exongenomiclocationassociation_eglaobject_id_fk FOREIGN KEY (exongenomiclocationassociationobject_id) REFERENCES assemblycomponent(id); + +ALTER TABLE ONLY exongenomiclocationassociation_informationcontententity ADD CONSTRAINT exongla_ice_association_id_fk FOREIGN KEY (association_id) REFERENCES exongenomiclocationassociation(id); +ALTER TABLE ONLY exongenomiclocationassociation_informationcontententity ADD CONSTRAINT exongla_ice_evidence_id_fk FOREIGN KEY (evidence_id) REFERENCES informationcontententity(id); + +ALTER TABLE ONLY genediseaseannotation ADD CONSTRAINT genediseaseannotation_dasubject_id_fk FOREIGN KEY (diseaseannotationsubject_id) REFERENCES gene(id) ON DELETE CASCADE; +ALTER TABLE ONLY genediseaseannotation ADD CONSTRAINT genediseaseannotation_sgdstrainbackground_id_fk FOREIGN KEY (sgdstrainbackground_id) REFERENCES affectedgenomicmodel(id); + +ALTER TABLE ONLY geneexpressionannotation ADD CONSTRAINT geneexpressionannotation_singlereference_id_fk FOREIGN KEY (singlereference_id) REFERENCES reference(id); +ALTER TABLE ONLY geneexpressionannotation ADD CONSTRAINT geneexpressionannotation_createdby_id_fk FOREIGN KEY (createdby_id) REFERENCES person(id); +ALTER TABLE ONLY geneexpressionannotation ADD CONSTRAINT geneexpressionannotation_expressionpattern_id_fk FOREIGN KEY (expressionpattern_id) REFERENCES expressionpattern(id); +ALTER TABLE ONLY geneexpressionannotation ADD CONSTRAINT geneexpressionannotation_updatedby_id_fk FOREIGN KEY (updatedby_id) REFERENCES person(id); +ALTER TABLE ONLY geneexpressionannotation ADD CONSTRAINT geneexpressionannotation_relation_id_fk FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); +ALTER TABLE ONLY geneexpressionannotation ADD CONSTRAINT geneexpressionannotation_expressionassayused_id_fk FOREIGN KEY (expressionassayused_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY geneexpressionannotation ADD CONSTRAINT geneexpressionannotation_dataprovider_id_fk FOREIGN KEY (dataprovider_id) REFERENCES dataprovider(id); +ALTER TABLE ONLY geneexpressionannotation ADD CONSTRAINT geneexpressionannotation_easubject_id_fk FOREIGN KEY (expressionannotationsubject_id) REFERENCES gene(id); + +ALTER TABLE ONLY geneexpressionannotation_conditionrelation ADD CONSTRAINT gea_conditionrelation_annotation_id_fk FOREIGN KEY (annotation_id) REFERENCES geneexpressionannotation(id); +ALTER TABLE ONLY geneexpressionannotation_conditionrelation ADD CONSTRAINT gea_conditionrelation_conditionrelations_id_fk FOREIGN KEY (conditionrelations_id) REFERENCES conditionrelation(id); + +ALTER TABLE ONLY geneexpressionannotation_note ADD CONSTRAINT geneexpressionannotation_note_annotation_id_fk FOREIGN KEY (annotation_id) REFERENCES geneexpressionannotation(id); +ALTER TABLE ONLY geneexpressionannotation_note ADD CONSTRAINT geneexpressionannotation_note_relatednotes_id_fk FOREIGN KEY (relatednotes_id) REFERENCES note(id); + +ALTER TABLE ONLY genegeneticinteraction ADD CONSTRAINT genegeneticinteraction_updatedby_id_fk FOREIGN KEY (updatedby_id) REFERENCES person(id); +ALTER TABLE ONLY genegeneticinteraction ADD CONSTRAINT genegeneticinteraction_interactiontype_id_fk FOREIGN KEY (interactiontype_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY genegeneticinteraction ADD CONSTRAINT genegeneticinteraction_interactorbtype_id_fk FOREIGN KEY (interactorbtype_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY genegeneticinteraction ADD CONSTRAINT genegeneticinteraction_interactorbgeneticperturbation_id_fk FOREIGN KEY (interactorbgeneticperturbation_id) REFERENCES allele(id) ON DELETE CASCADE; +ALTER TABLE ONLY genegeneticinteraction ADD CONSTRAINT genegeneticinteraction_createdby_id_fk FOREIGN KEY (createdby_id) REFERENCES person(id); +ALTER TABLE ONLY genegeneticinteraction ADD CONSTRAINT genegeneticinteraction_interactorbrole_id_fk FOREIGN KEY (interactorbrole_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY genegeneticinteraction ADD CONSTRAINT genegeneticinteraction_interactorageneticperturbation_id_fk FOREIGN KEY (interactorageneticperturbation_id) REFERENCES allele(id) ON DELETE CASCADE; +ALTER TABLE ONLY genegeneticinteraction ADD CONSTRAINT genegeneticinteraction_interactorarole_id_fk FOREIGN KEY (interactorarole_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY genegeneticinteraction ADD CONSTRAINT genegeneticinteraction_interactoratype_id_fk FOREIGN KEY (interactoratype_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY genegeneticinteraction ADD CONSTRAINT genegeneticinteraction_interactionsource_id_fk FOREIGN KEY (interactionsource_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY genegeneticinteraction ADD CONSTRAINT genegeneticinteraction_relation_id_fk FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); +ALTER TABLE ONLY genegeneticinteraction ADD CONSTRAINT genegeneticinteraction_gasubject_id_fk FOREIGN KEY (geneassociationsubject_id) REFERENCES gene(id); +ALTER TABLE ONLY genegeneticinteraction ADD CONSTRAINT genegeneticinteraction_ggaobject_id_fk FOREIGN KEY (genegeneassociationobject_id) REFERENCES gene(id); + +ALTER TABLE ONLY genegeneticinteraction_crossreference ADD CONSTRAINT genegeneticinteraction_xref_geneinteraction_id_fk FOREIGN KEY (geneinteraction_id) REFERENCES genegeneticinteraction(id); +ALTER TABLE ONLY genegeneticinteraction_crossreference ADD CONSTRAINT genegeneticinteraction_xref_crossreferences_id_fk FOREIGN KEY (crossreferences_id) REFERENCES crossreference(id); + +ALTER TABLE ONLY genegeneticinteraction_informationcontententity ADD CONSTRAINT genegeneticinteraction_ice_association_id_fk FOREIGN KEY (association_id) REFERENCES genegeneticinteraction(id); +ALTER TABLE ONLY genegeneticinteraction_informationcontententity ADD CONSTRAINT genegeneticinteraction_ice_evidence_id_fk FOREIGN KEY (evidence_id) REFERENCES informationcontententity(id); + +ALTER TABLE ONLY genegeneticinteraction_phenotypesortraits ADD CONSTRAINT genegeneticinteraction_phenotypesortraits_ggi_id_fk FOREIGN KEY (genegeneticinteraction_id) REFERENCES genegeneticinteraction(id); + +ALTER TABLE ONLY genemolecularinteraction ADD CONSTRAINT genemolecularinteraction_interactorarole_id FOREIGN KEY (interactorarole_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY genemolecularinteraction ADD CONSTRAINT genemolecularinteraction_interactorbtype_id FOREIGN KEY (interactorbtype_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY genemolecularinteraction ADD CONSTRAINT genemolecularinteraction_relation_id FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); +ALTER TABLE ONLY genemolecularinteraction ADD CONSTRAINT genemolecularinteraction_interactiontype_id FOREIGN KEY (interactiontype_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY genemolecularinteraction ADD CONSTRAINT genemolecularinteraction_gasubject_id FOREIGN KEY (geneassociationsubject_id) REFERENCES gene(id); +ALTER TABLE ONLY genemolecularinteraction ADD CONSTRAINT genemolecularinteraction_detectionmethod_id FOREIGN KEY (detectionmethod_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY genemolecularinteraction ADD CONSTRAINT genemolecularinteraction_interactorbrole_id FOREIGN KEY (interactorbrole_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY genemolecularinteraction ADD CONSTRAINT genemolecularinteraction_interactionsource_id FOREIGN KEY (interactionsource_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY genemolecularinteraction ADD CONSTRAINT genemolecularinteraction_interactoratype_id FOREIGN KEY (interactoratype_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY genemolecularinteraction ADD CONSTRAINT genemolecularinteraction_aggregationdatabase_id FOREIGN KEY (aggregationdatabase_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY genemolecularinteraction ADD CONSTRAINT genemolecularinteraction_createdby_id FOREIGN KEY (createdby_id) REFERENCES person(id); +ALTER TABLE ONLY genemolecularinteraction ADD CONSTRAINT genemolecularinteraction_ggaobject_id FOREIGN KEY (genegeneassociationobject_id) REFERENCES gene(id); +ALTER TABLE ONLY genemolecularinteraction ADD CONSTRAINT genemolecularinteraction_updatedby_id FOREIGN KEY (updatedby_id) REFERENCES person(id); + +ALTER TABLE ONLY genemolecularinteraction_crossreference ADD CONSTRAINT genemolecularinteraction_xref_geneinteraction_id_fk FOREIGN KEY (geneinteraction_id) REFERENCES genemolecularinteraction(id); +ALTER TABLE ONLY genemolecularinteraction_crossreference ADD CONSTRAINT genemolecularinteraction_xref_crossreferences_id_fk FOREIGN KEY (crossreferences_id) REFERENCES crossreference(id); + +ALTER TABLE ONLY genemolecularinteraction_informationcontententity ADD CONSTRAINT genemolecularinteraction_ice_evidence_id_fk FOREIGN KEY (evidence_id) REFERENCES informationcontententity(id); +ALTER TABLE ONLY genemolecularinteraction_informationcontententity ADD CONSTRAINT genemolecularinteraction_ice_association_id_fk FOREIGN KEY (association_id) REFERENCES genemolecularinteraction(id); + +ALTER TABLE ONLY genephenotypeannotation ADD CONSTRAINT genephenotypeannotation_sgdstrainbackground_id_fk FOREIGN KEY (sgdstrainbackground_id) REFERENCES affectedgenomicmodel(id); +ALTER TABLE ONLY genephenotypeannotation ADD CONSTRAINT genephenotypeannotation_pasubject_id_fk FOREIGN KEY (phenotypeannotationsubject_id) REFERENCES gene(id) ON DELETE CASCADE; + +ALTER TABLE ONLY sequencetargetingreagentgeneassociation ADD CONSTRAINT sequencetargetingreagentgeneassociation_sqtrasubject_id FOREIGN KEY (sequencetargetingreagentassociationsubject_id) REFERENCES sequencetargetingreagent(id); +ALTER TABLE ONLY sequencetargetingreagentgeneassociation ADD CONSTRAINT sequencetargetingreagentgeneassociation_sqtragobject_id FOREIGN KEY (sequencetargetingreagentgeneassociationobject_id) REFERENCES gene(id); +ALTER TABLE ONLY sequencetargetingreagentgeneassociation ADD CONSTRAINT sequencetargetingreagentgeneassociation_updatedby_id FOREIGN KEY (updatedby_id) REFERENCES person(id); +ALTER TABLE ONLY sequencetargetingreagentgeneassociation ADD CONSTRAINT sequencetargetingreagentgeneassociation_relation_id FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); +ALTER TABLE ONLY sequencetargetingreagentgeneassociation ADD CONSTRAINT sequencetargetingreagentgeneassociation_createdby_id FOREIGN KEY (createdby_id) REFERENCES person(id); + +ALTER TABLE ONLY sequencetargetingreagentgeneassociation_informationcontententit ADD CONSTRAINT sqtrga_ice_association_id_fk FOREIGN KEY (association_id) REFERENCES sequencetargetingreagentgeneassociation(id); +ALTER TABLE ONLY sequencetargetingreagentgeneassociation_informationcontententit ADD CONSTRAINT sqtrga_ice_evidence_id_fk FOREIGN KEY (evidence_id) REFERENCES informationcontententity(id); + +ALTER TABLE ONLY transcriptcodingsequenceassociation ADD CONSTRAINT transcriptcodingsequenceassociation_relation_id_fk FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); +ALTER TABLE ONLY transcriptcodingsequenceassociation ADD CONSTRAINT transcriptcodingsequenceassociation_updatedby_id_fk FOREIGN KEY (updatedby_id) REFERENCES person(id); +ALTER TABLE ONLY transcriptcodingsequenceassociation ADD CONSTRAINT transcriptcodingsequenceassociation_tasubject_id_fk FOREIGN KEY (transcriptassociationsubject_id) REFERENCES transcript(id); +ALTER TABLE ONLY transcriptcodingsequenceassociation ADD CONSTRAINT transcriptcodingsequenceassociation_tcdsaobject_id_fk FOREIGN KEY (transcriptcodingsequenceassociationobject_id) REFERENCES codingsequence(id); +ALTER TABLE ONLY transcriptcodingsequenceassociation ADD CONSTRAINT transcriptcodingsequenceassociation_createdby_id_fk FOREIGN KEY (createdby_id) REFERENCES person(id); + +ALTER TABLE ONLY transcriptcodingsequenceassociation_informationcontententity ADD CONSTRAINT transcriptcdsassociation_ice_evidence_id_fk FOREIGN KEY (evidence_id) REFERENCES informationcontententity(id); +ALTER TABLE ONLY transcriptcodingsequenceassociation_informationcontententity ADD CONSTRAINT transcriptcdsassociation_ice_association_id_fk FOREIGN KEY (association_id) REFERENCES transcriptcodingsequenceassociation(id); + +ALTER TABLE ONLY transcriptexonassociation ADD CONSTRAINT transcriptexonassociation_createdby_id_fk FOREIGN KEY (createdby_id) REFERENCES person(id); +ALTER TABLE ONLY transcriptexonassociation ADD CONSTRAINT transcriptexonassociation_teaobject_id_fk FOREIGN KEY (transcriptexonassociationobject_id) REFERENCES exon(id); +ALTER TABLE ONLY transcriptexonassociation ADD CONSTRAINT transcriptexonassociation_updatedby_id_fk FOREIGN KEY (updatedby_id) REFERENCES person(id); +ALTER TABLE ONLY transcriptexonassociation ADD CONSTRAINT transcriptexonassociation_tasubject_id_fk FOREIGN KEY (transcriptassociationsubject_id) REFERENCES transcript(id); +ALTER TABLE ONLY transcriptexonassociation ADD CONSTRAINT transcriptexonassociation_relation_id_fk FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); + +ALTER TABLE ONLY transcriptexonassociation_informationcontententity ADD CONSTRAINT transcriptexonassociation_ice_evidence_id_fk FOREIGN KEY (evidence_id) REFERENCES informationcontententity(id); +ALTER TABLE ONLY transcriptexonassociation_informationcontententity ADD CONSTRAINT transcriptexonassociation_ice_association_id_fk FOREIGN KEY (association_id) REFERENCES transcriptexonassociation(id); + +ALTER TABLE ONLY transcriptgeneassociation ADD CONSTRAINT transcriptgeneassociation_tgaobject_id_fk FOREIGN KEY (transcriptgeneassociationobject_id) REFERENCES gene(id); +ALTER TABLE ONLY transcriptgeneassociation ADD CONSTRAINT transcriptgeneassociation_tasubject_id_fk FOREIGN KEY (transcriptassociationsubject_id) REFERENCES transcript(id); +ALTER TABLE ONLY transcriptgeneassociation ADD CONSTRAINT transcriptgeneassociation_updatedby_id_fk FOREIGN KEY (updatedby_id) REFERENCES person(id); +ALTER TABLE ONLY transcriptgeneassociation ADD CONSTRAINT transcriptgeneassociation_relation_id_fk FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); +ALTER TABLE ONLY transcriptgeneassociation ADD CONSTRAINT transcriptgeneassociation_createdby_id_fk FOREIGN KEY (createdby_id) REFERENCES person(id); + +ALTER TABLE ONLY transcriptgeneassociation_informationcontententity ADD CONSTRAINT transcriptgeneassoc_ice_association_id_fk FOREIGN KEY (association_id) REFERENCES transcriptgeneassociation(id); +ALTER TABLE ONLY transcriptgeneassociation_informationcontententity ADD CONSTRAINT transcriptgeneassoc_ice_evidence_id_fk FOREIGN KEY (evidence_id) REFERENCES informationcontententity(id); + +ALTER TABLE ONLY transcriptgenomiclocationassociation ADD CONSTRAINT transcriptgla_relation_id_fk FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); +ALTER TABLE ONLY transcriptgenomiclocationassociation ADD CONSTRAINT transcriptgla_updatedby_id_fk FOREIGN KEY (updatedby_id) REFERENCES person(id); +ALTER TABLE ONLY transcriptgenomiclocationassociation ADD CONSTRAINT transcriptgla_tasubject_id_fk FOREIGN KEY (transcriptassociationsubject_id) REFERENCES transcript(id); +ALTER TABLE ONLY transcriptgenomiclocationassociation ADD CONSTRAINT transcriptgla_createdby_id_fk FOREIGN KEY (createdby_id) REFERENCES person(id); +ALTER TABLE ONLY transcriptgenomiclocationassociation ADD CONSTRAINT transcriptgla_tglaobject_id_fk FOREIGN KEY (transcriptgenomiclocationassociationobject_id) REFERENCES assemblycomponent(id); + +ALTER TABLE ONLY transcriptgenomiclocationassociation_informationcontententity ADD CONSTRAINT transcriptgla_ice_association_id_fk FOREIGN KEY (association_id) REFERENCES transcriptgenomiclocationassociation(id); +ALTER TABLE ONLY transcriptgenomiclocationassociation_informationcontententity ADD CONSTRAINT transcriptgla_ice_evidence_id_fk FOREIGN KEY (evidence_id) REFERENCES informationcontententity(id); diff --git a/src/main/resources/db/migration/v0.37.0.56__mappersuperclass__assocations.sql b/src/main/resources/db/migration/v0.37.0.56__mappersuperclass__assocations.sql new file mode 100644 index 000000000..44efb07fc --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.56__mappersuperclass__assocations.sql @@ -0,0 +1,7 @@ +ALTER TABLE CodingSequenceGenomicLocationAssociation RENAME TO CDSGLAssociation; +ALTER TABLE CodingSequenceGenomicLocationAssociation_InformationContentEntity RENAME TO CDSGLAssociation_InformationContentEntity; +ALTER TABLE SequenceTargetingReagentGeneAssociation RENAME TO SQTRGeneAssociation; +ALTER TABLE SequenceTargetingReagentGeneAssociation_InformationContentEntity RENAME TO SQTRGeneAssociation_InformationContentEntity; + +ALTER SEQUENCE codingsequencegenomiclocationassociation_seq RENAME TO cdsglassociation_seq; +ALTER SEQUENCE sequencetargetingreagentgeneassociation_seq RENAME TO sqtrgeneassociation_seq; diff --git a/src/main/resources/db/migration/v0.37.0.57__add_missing_sequence.sql b/src/main/resources/db/migration/v0.37.0.57__add_missing_sequence.sql new file mode 100644 index 000000000..293032f41 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.57__add_missing_sequence.sql @@ -0,0 +1,9 @@ +CREATE SEQUENCE IF NOT EXISTS geneexpressionannotation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +SELECT setval( 'GeneExpressionAnnotation_seq', (SELECT (((MAX(id) + 50) / 50) * 50) FROM GeneExpressionAnnotation) ); + diff --git a/src/main/resources/db/migration/v0.37.0.58__htp_tags_fix.sql b/src/main/resources/db/migration/v0.37.0.58__htp_tags_fix.sql new file mode 100644 index 000000000..2d48e8687 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.58__htp_tags_fix.sql @@ -0,0 +1,13 @@ +DELETE FROM htpexpressiondatasetannotation_categorytags WHERE categorytags_id IN (SELECT id FROM vocabularyterm WHERE name = 'strain study'); +DELETE FROM vocabularyterm_synonyms WHERE vocabularyterm_id IN (SELECT id FROM vocabularyterm WHERE name = 'strain study'); + +DELETE FROM vocabularyterm WHERE name = 'strain study'; + +DELETE FROM vocabularyterm_synonyms WHERE vocabularyterm_id IN (SELECT id FROM vocabularyterm WHERE name = 'anatomical structure'); +DELETE FROM vocabularyterm_synonyms WHERE vocabularyterm_id IN (SELECT id FROM vocabularyterm WHERE name = 'chemical stimulus'); + +INSERT INTO vocabularyterm_synonyms (vocabularyterm_id, synonyms) SELECT id, 'tissue type study' FROM vocabularyterm WHERE name = 'anatomical structure'; +INSERT INTO vocabularyterm_synonyms (vocabularyterm_id, synonyms) SELECT id, 'tissue specific' FROM vocabularyterm WHERE name = 'anatomical structure'; + +INSERT INTO vocabularyterm_synonyms (vocabularyterm_id, synonyms) SELECT id, 'chemical stimulus study' FROM vocabularyterm WHERE name = 'chemical stimulus'; +INSERT INTO vocabularyterm_synonyms (vocabularyterm_id, synonyms) SELECT id, 'response to chemical' FROM vocabularyterm WHERE name = 'chemical stimulus'; \ No newline at end of file diff --git a/src/main/resources/db/migration/v0.37.0.59__htpdatasample_tables.sql b/src/main/resources/db/migration/v0.37.0.59__htpdatasample_tables.sql new file mode 100644 index 000000000..51f2ee4c3 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.59__htpdatasample_tables.sql @@ -0,0 +1,289 @@ +-- To create bulk loads + +INSERT INTO bulkloadgroup (id, name) VALUES (nextval('bulkloadgroup_seq'), 'HTP Expression Dataset Sample Annotation Bulk Loads'); + +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) +SELECT nextval('bulkload_seq'), 'HTPDATASAMPLE', 'FB HTP Expression Dataset Sample Annotation Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'HTP Expression Dataset Sample Annotation Bulk Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) +SELECT nextval('bulkload_seq'), 'HTPDATASAMPLE', 'ZFIN HTP Expression Dataset Sample Annotation Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'HTP Expression Dataset Sample Annotation Bulk Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) +SELECT nextval('bulkload_seq'), 'HTPDATASAMPLE', 'MGI HTP Expression Dataset Sample Annotation Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'HTP Expression Dataset Sample Annotation Bulk Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) +SELECT nextval('bulkload_seq'), 'HTPDATASAMPLE', 'RGD HTP Expression Dataset Sample Annotation Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'HTP Expression Dataset Sample Annotation Bulk Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) +SELECT nextval('bulkload_seq'), 'HTPDATASAMPLE', 'SGD HTP Expression Dataset Sample Annotation Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'HTP Expression Dataset Sample Annotation Bulk Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) +SELECT nextval('bulkload_seq'), 'HTPDATASAMPLE', 'WB HTP Expression Dataset Sample Annotation Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'HTP Expression Dataset Sample Annotation Bulk Loads'; + +INSERT INTO bulkscheduledload (id, cronschedule, scheduleactive) +SELECT id, '0 0 22 ? * SUN-THU', true FROM bulkload WHERE backendbulkloadtype = 'HTPDATASAMPLE'; + +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) +SELECT id, 'HTPDATASAMPLE', 'FB' FROM bulkload WHERE name = 'FB HTP Expression Dataset Sample Annotation Load'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) +SELECT id, 'HTPDATASAMPLE', 'MGI' FROM bulkload WHERE name = 'MGI HTP Expression Dataset Sample Annotation Load'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) +SELECT id, 'HTPDATASAMPLE', 'RGD' FROM bulkload WHERE name = 'RGD HTP Expression Dataset Sample Annotation Load'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) +SELECT id, 'HTPDATASAMPLE', 'SGD' FROM bulkload WHERE name = 'SGD HTP Expression Dataset Sample Annotation Load'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) +SELECT id, 'HTPDATASAMPLE', 'WB' FROM bulkload WHERE name = 'WB HTP Expression Dataset Sample Annotation Load'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) +SELECT id, 'HTPDATASAMPLE', 'ZFIN' FROM bulkload WHERE name = 'ZFIN HTP Expression Dataset Sample Annotation Load'; + +-- To create tables for HTP Expression Dataset Sample Annotation + +CREATE TABLE biosampleage ( + id bigint NOT NULL, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + age character varying(255), + whenexpressedstagename character varying(255), + createdby_id bigint, + updatedby_id bigint, + stage_id bigint +); + +CREATE SEQUENCE biosampleage_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE TABLE biosamplegenomicinformation ( + id bigint NOT NULL, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + biosampletext character varying(255), + createdby_id bigint, + updatedby_id bigint, + biosampleagm_id bigint, + biosampleagmtype_id bigint, + biosampleallele_id bigint +); + +CREATE SEQUENCE biosamplegenomicinformation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE TABLE htpexpressiondatasetsampleannotation ( + id bigint NOT NULL, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + abundance character varying(255), + htpexpressionsampletitle character varying(255), + createdby_id bigint, + updatedby_id bigint, + dataprovider_id bigint, + expressionassayused_id bigint, + geneticsex_id bigint, + genomicinformation_id bigint, + htpexpressionsample_id bigint, + htpexpressionsampleage_id bigint, + htpexpressionsampletype_id bigint, + microarraysampledetails_id bigint, + sequencingformat_id bigint, + taxon_id bigint +); + +CREATE TABLE htpexpressiondatasetsampleannotation_anatomicalsite ( + htpexpressiondatasetsampleannotation_id bigint NOT NULL, + htpexpressionsamplelocations_id bigint NOT NULL +); + +CREATE TABLE htpexpressiondatasetsampleannotation_assemblyversions ( + htpexpressiondatasetsampleannotation_id bigint NOT NULL, + assemblyversions character varying(255) +); + +CREATE TABLE htpexpressiondatasetsampleannotation_externaldatabaseentity ( + htpexpressiondatasetsampleannotation_id bigint NOT NULL, + datasetids_id bigint NOT NULL +); + +CREATE TABLE htpexpressiondatasetsampleannotation_note ( + htpexpressiondatasetsampleannotation_id bigint NOT NULL, + relatednotes_id bigint NOT NULL +); + +CREATE SEQUENCE htpexpressiondatasetsampleannotation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE TABLE microarraysampledetails ( + id bigint NOT NULL, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + channelid character varying(255), + channelnumber integer, + createdby_id bigint, + updatedby_id bigint +); + +CREATE SEQUENCE microarraysampledetails_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +ALTER TABLE biosampleage + ADD CONSTRAINT biosampleage_pkey PRIMARY KEY (id); + +ALTER TABLE biosamplegenomicinformation + ADD CONSTRAINT biosamplegenomicinformation_pkey PRIMARY KEY (id); + +ALTER TABLE htpexpressiondatasetsampleannotation + ADD CONSTRAINT htpexpressiondatasetsampleannotation_pkey PRIMARY KEY (id); + +ALTER TABLE microarraysampledetails + ADD CONSTRAINT microarraysampledetails_pkey PRIMARY KEY (id); + +ALTER TABLE htpexpressiondatasetsampleannotation_note + ADD CONSTRAINT htpdatasample_relatednotes_id_uk UNIQUE (relatednotes_id); + +ALTER TABLE htpexpressiondatasetsampleannotation + ADD CONSTRAINT htpdatasample_microarraysampledetails_id_uk UNIQUE (microarraysampledetails_id); + +ALTER TABLE htpexpressiondatasetsampleannotation + ADD CONSTRAINT htpdatasample_htpexpressionsample_id_uk UNIQUE (htpexpressionsample_id); + +ALTER TABLE htpexpressiondatasetsampleannotation + ADD CONSTRAINT htpdatasample_htpexpressionsampleage_id_uk UNIQUE (htpexpressionsampleage_id); + +ALTER TABLE htpexpressiondatasetsampleannotation + ADD CONSTRAINT htpdatasameple_genomicinformation_id_uk UNIQUE (genomicinformation_id); + +CREATE INDEX biosampleage_stage_index ON biosampleage USING btree (stage_id); + +CREATE INDEX htpdatasample_anatomicalsite_htpdatasample_index ON htpexpressiondatasetsampleannotation_anatomicalsite USING btree (htpexpressiondatasetsampleannotation_id); + +CREATE INDEX htpdatasample_anatomicalsite_samplelocations_index ON htpexpressiondatasetsampleannotation_anatomicalsite USING btree (htpexpressionsamplelocations_id); + +CREATE INDEX htpdatasample_assemblyversions_htpdatasample_index ON htpexpressiondatasetsampleannotation_assemblyversions USING btree (htpexpressiondatasetsampleannotation_id); + +CREATE INDEX htpdatasample_externaldatabaseentity_datasetids_index ON htpexpressiondatasetsampleannotation_externaldatabaseentity USING btree (datasetids_id); + +CREATE INDEX htpdatasample_externaldatabaseentity_htpdatasample_index ON htpexpressiondatasetsampleannotation_externaldatabaseentity USING btree (htpexpressiondatasetsampleannotation_id); + +CREATE INDEX htpdatasample_note_htpdatasample_index ON htpexpressiondatasetsampleannotation_note USING btree (htpexpressiondatasetsampleannotation_id); + +CREATE INDEX htpdatasample_note_relatednotes_index ON htpexpressiondatasetsampleannotation_note USING btree (relatednotes_id); + +CREATE INDEX htpdatasetsampleannotation_createdby_index ON htpexpressiondatasetsampleannotation USING btree (createdby_id); + +CREATE INDEX htpdatasetsampleannotation_dataprovider_index ON htpexpressiondatasetsampleannotation USING btree (dataprovider_id); + +CREATE INDEX htpdatasetsampleannotation_htpexpressionsample_index ON htpexpressiondatasetsampleannotation USING btree (htpexpressionsample_id); + +CREATE INDEX htpdatasetsampleannotation_updatedby_index ON htpexpressiondatasetsampleannotation USING btree (updatedby_id); + +ALTER TABLE biosamplegenomicinformation + ADD CONSTRAINT biosamplegenomicinfo_biosampleagmtype_id_fk FOREIGN KEY (biosampleagmtype_id) REFERENCES vocabularyterm(id); + +ALTER TABLE htpexpressiondatasetsampleannotation + ADD CONSTRAINT htpdatasample_sequencingformat_id_fk FOREIGN KEY (sequencingformat_id) REFERENCES vocabularyterm(id); + +ALTER TABLE htpexpressiondatasetsampleannotation + ADD CONSTRAINT htpdatasample_microarraysampledetails_id_fk FOREIGN KEY (microarraysampledetails_id) REFERENCES microarraysampledetails(id); + +ALTER TABLE htpexpressiondatasetsampleannotation_externaldatabaseentity + ADD CONSTRAINT htpdatasample_externaldbentity_htpdatasample_id_fk FOREIGN KEY (htpexpressiondatasetsampleannotation_id) REFERENCES htpexpressiondatasetsampleannotation(id); + +ALTER TABLE htpexpressiondatasetsampleannotation + ADD CONSTRAINT htpdatasample_dataprovider_id_fk FOREIGN KEY (dataprovider_id) REFERENCES dataprovider(id); + +ALTER TABLE biosamplegenomicinformation + ADD CONSTRAINT biosamplegenomicinformation_createdby_id_fk FOREIGN KEY (createdby_id) REFERENCES person(id); + +ALTER TABLE htpexpressiondatasetsampleannotation + ADD CONSTRAINT htpdatasample_genomicinformation_id_fk FOREIGN KEY (genomicinformation_id) REFERENCES biosamplegenomicinformation(id); + +ALTER TABLE htpexpressiondatasetsampleannotation + ADD CONSTRAINT htpdatasample_geneticsex_id_fk FOREIGN KEY (geneticsex_id) REFERENCES vocabularyterm(id); + +ALTER TABLE biosamplegenomicinformation + ADD CONSTRAINT htpdatasample_biosampleagm_id_fk FOREIGN KEY (biosampleagm_id) REFERENCES affectedgenomicmodel(id); + +ALTER TABLE microarraysampledetails + ADD CONSTRAINT microarraysampledetails_createdby_id_fk FOREIGN KEY (createdby_id) REFERENCES person(id); + +ALTER TABLE htpexpressiondatasetsampleannotation_anatomicalsite + ADD CONSTRAINT htpdatasample_anatomicalsite_htpdatasample_id_fk FOREIGN KEY (htpexpressiondatasetsampleannotation_id) REFERENCES htpexpressiondatasetsampleannotation(id); + +ALTER TABLE biosampleage + ADD CONSTRAINT biosampleage_stage_id_fk FOREIGN KEY (stage_id) REFERENCES temporalcontext(id); + +ALTER TABLE biosampleage + ADD CONSTRAINT biosampleage_updatedby_id_fk FOREIGN KEY (updatedby_id) REFERENCES person(id); + +ALTER TABLE htpexpressiondatasetsampleannotation + ADD CONSTRAINT htpdatasample_htpexpressionsampleage_id_fk FOREIGN KEY (htpexpressionsampleage_id) REFERENCES biosampleage(id); + +ALTER TABLE biosampleage + ADD CONSTRAINT biosampleage_createdby_id_fk FOREIGN KEY (createdby_id) REFERENCES person(id); + +ALTER TABLE htpexpressiondatasetsampleannotation_anatomicalsite + ADD CONSTRAINT htpdatasample_anatomicalsite_htpsamplelocations_id_fk FOREIGN KEY (htpexpressionsamplelocations_id) REFERENCES anatomicalsite(id); + +ALTER TABLE htpexpressiondatasetsampleannotation + ADD CONSTRAINT htpdatasample_createdby_id_fk FOREIGN KEY (createdby_id) REFERENCES person(id); + +ALTER TABLE htpexpressiondatasetsampleannotation + ADD CONSTRAINT htpdatasample_expressionassayused_id_fk FOREIGN KEY (expressionassayused_id) REFERENCES ontologyterm(id); + +ALTER TABLE htpexpressiondatasetsampleannotation + ADD CONSTRAINT htpdatasample_taxon_id_fk FOREIGN KEY (taxon_id) REFERENCES ontologyterm(id); + +ALTER TABLE microarraysampledetails + ADD CONSTRAINT microarraysampledetails_updatedby_id_fk FOREIGN KEY (updatedby_id) REFERENCES person(id); + +ALTER TABLE htpexpressiondatasetsampleannotation + ADD CONSTRAINT htpdatasample_htpexpressionsample_id_fk FOREIGN KEY (htpexpressionsample_id) REFERENCES externaldatabaseentity(id); + +ALTER TABLE biosamplegenomicinformation + ADD CONSTRAINT biosamplegenomicinformation_updatedby_id_fk FOREIGN KEY (updatedby_id) REFERENCES person(id); + +ALTER TABLE htpexpressiondatasetsampleannotation_note + ADD CONSTRAINT htpdatasample_note_relatednotes_id_fk FOREIGN KEY (relatednotes_id) REFERENCES note(id); + +ALTER TABLE htpexpressiondatasetsampleannotation + ADD CONSTRAINT htpdatasample_htpexpressionsampletype_id_fk FOREIGN KEY (htpexpressionsampletype_id) REFERENCES ontologyterm(id); + +ALTER TABLE htpexpressiondatasetsampleannotation_note + ADD CONSTRAINT htpdatasample_note_htpdatasample_id_fk FOREIGN KEY (htpexpressiondatasetsampleannotation_id) REFERENCES htpexpressiondatasetsampleannotation(id); + +ALTER TABLE htpexpressiondatasetsampleannotation + ADD CONSTRAINT htpdatasample_updatedby_id_fk FOREIGN KEY (updatedby_id) REFERENCES person(id); + +ALTER TABLE htpexpressiondatasetsampleannotation_assemblyversions + ADD CONSTRAINT htpdatasample_assemblyversions_htpdatasample_id FOREIGN KEY (htpexpressiondatasetsampleannotation_id) REFERENCES htpexpressiondatasetsampleannotation(id); + +ALTER TABLE biosamplegenomicinformation + ADD CONSTRAINT biosamplegenomicinformation_biosampleallele_id_fk FOREIGN KEY (biosampleallele_id) REFERENCES allele(id); + +ALTER TABLE htpexpressiondatasetsampleannotation_externaldatabaseentity + ADD CONSTRAINT htpdatasample_externaldbentity_datasetids_id_fk FOREIGN KEY (datasetids_id) REFERENCES externaldatabaseentity(id); \ No newline at end of file diff --git a/src/main/resources/db/migration/v0.37.0.5__add_expression_ribbon_terms.sql b/src/main/resources/db/migration/v0.37.0.5__add_expression_ribbon_terms.sql new file mode 100644 index 000000000..3e3b6950f --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.5__add_expression_ribbon_terms.sql @@ -0,0 +1,6 @@ +ALTER TABLE anatomicalsite + ADD COLUMN cellularcomponentother boolean DEFAULT false NOT NULL, + ADD COLUMN cellularcomponentribbonterm_id bigint; + +ALTER TABLE ONLY anatomicalsite + ADD CONSTRAINT fkcuqc7qacirmg4wqcwuou8abjn FOREIGN KEY (cellularcomponentribbonterm_id) REFERENCES public.ontologyterm(id); \ No newline at end of file diff --git a/src/main/resources/db/migration/v0.37.0.60__htpdatasample_adding_new_indexes.sql b/src/main/resources/db/migration/v0.37.0.60__htpdatasample_adding_new_indexes.sql new file mode 100644 index 000000000..262d935e4 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.60__htpdatasample_adding_new_indexes.sql @@ -0,0 +1,24 @@ +--Renaming existing indexes +ALTER INDEX htpdatasetsampleannotation_createdby_index RENAME TO htpdatasample_createdby_index; +ALTER INDEX htpdatasetsampleannotation_updatedby_index RENAME TO htpdatasample_updatedby_index; +ALTER INDEX htpdatasetsampleannotation_dataprovider_index RENAME TO htpdatasample_dataprovider_index; +ALTER INDEX htpdatasetsampleannotation_htpexpressionsample_index RENAME TO htpdatasample_htpexpressionsample_index; + +--Creating new indexes +CREATE INDEX htpdatasample_htpExpressionSampleType_index ON htpexpressiondatasetsampleannotation USING btree (htpExpressionSampleType_id); +CREATE INDEX htpdatasample_expressionAssayUsed_index ON htpexpressiondatasetsampleannotation USING btree (expressionAssayUsed_id); +CREATE INDEX htpdatasample_htpExpressionSampleAge_index ON htpexpressiondatasetsampleannotation USING btree (htpExpressionSampleAge_id); +CREATE INDEX htpdatasample_genomicInformation_index ON htpexpressiondatasetsampleannotation USING btree (genomicInformation_id); +CREATE INDEX htpdatasample_microarraySampleDetails_index ON htpexpressiondatasetsampleannotation USING btree (microarraySampleDetails_id); +CREATE INDEX htpdatasample_geneticSex_index ON htpexpressiondatasetsampleannotation USING btree (geneticSex_id); +CREATE INDEX htpdatasample_sequencingFormat_index ON htpexpressiondatasetsampleannotation USING btree (sequencingFormat_id); +CREATE INDEX htpdatasample_taxon_index ON htpexpressiondatasetsampleannotation USING btree (taxon_id); + +CREATE INDEX biosamplegenomicinfo_bioSampleAllele_index ON biosamplegenomicinformation USING btree (bioSampleAllele_id); +CREATE INDEX biosamplegenomicinfo_bioSampleAgm_index ON biosamplegenomicinformation USING btree (bioSampleAgm_id); +CREATE INDEX biosamplegenomicinfo_bioSampleAgmType_index ON biosamplegenomicinformation USING btree (bioSampleAgmType_id); + +--Adding 3 new htp category tags +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'bulk RNA-seq', id FROM vocabulary WHERE vocabularylabel = 'data_set_category_tags'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'single cell RNA-seq', id FROM vocabulary WHERE vocabularylabel = 'data_set_category_tags'; +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'spatial RNA-seq', id FROM vocabulary WHERE vocabularylabel = 'data_set_category_tags'; \ No newline at end of file diff --git a/src/main/resources/db/migration/v0.37.0.61__expression_atlas-load.sql b/src/main/resources/db/migration/v0.37.0.61__expression_atlas-load.sql new file mode 100644 index 000000000..c8d8391de --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.61__expression_atlas-load.sql @@ -0,0 +1,82 @@ +insert into bulkloadgroup (id, name, internal, obsolete, dbdatecreated) +values (nextval('bulkloadgroup_seq'), 'Expression Atlas Load', false, false, now()); + +insert into bulkload (id, backendbulkloadtype, name, internal, obsolete, group_id, dbdatecreated, bulkloadstatus) +select nextval('bulkload_seq'), 'EXPRESSION_ATLAS','ZFIN Expression Atlas', false, false, id, now(), 'STOPPED' +from bulkloadgroup where name = 'Expression Atlas Load'; + +insert into bulkload (id, backendbulkloadtype, name, internal, obsolete, group_id, dbdatecreated, bulkloadstatus) +select nextval('bulkload_seq'), 'EXPRESSION_ATLAS','SGD Expression Atlas', false, false, id, now(), 'STOPPED' +from bulkloadgroup where name = 'Expression Atlas Load'; + +insert into bulkload (id, backendbulkloadtype, name, internal, obsolete, group_id, dbdatecreated, bulkloadstatus) +select nextval('bulkload_seq'), 'EXPRESSION_ATLAS','WB Expression Atlas', false, false, id, now(), 'STOPPED' +from bulkloadgroup where name = 'Expression Atlas Load'; + +insert into bulkload (id, backendbulkloadtype, name, internal, obsolete, group_id, dbdatecreated, bulkloadstatus) +select nextval('bulkload_seq'), 'EXPRESSION_ATLAS','MGI Expression Atlas', false, false, id, now(), 'STOPPED' +from bulkloadgroup where name = 'Expression Atlas Load'; + +insert into bulkload (id, backendbulkloadtype, name, internal, obsolete, group_id, dbdatecreated, bulkloadstatus) +select nextval('bulkload_seq'), 'EXPRESSION_ATLAS','FB Expression Atlas', false, false, id, now(), 'STOPPED' +from bulkloadgroup where name = 'Expression Atlas Load'; + +insert into bulkload (id, backendbulkloadtype, name, internal, obsolete, group_id, dbdatecreated, bulkloadstatus) +select nextval('bulkload_seq'), 'EXPRESSION_ATLAS','RGD Expression Atlas', false, false, id, now(), 'STOPPED' +from bulkloadgroup where name = 'Expression Atlas Load'; + +insert into bulkload (id, backendbulkloadtype, name, internal, obsolete, group_id, dbdatecreated, bulkloadstatus) +select nextval('bulkload_seq'), 'EXPRESSION_ATLAS','HUMAN Expression Atlas', false, false, id, now(), 'STOPPED' +from bulkloadgroup where name = 'Expression Atlas Load'; + +INSERT INTO bulkscheduledload (id, cronschedule, scheduleactive) +SELECT id, '0 0 22 ? * SUN-THU', true FROM bulkload WHERE name = 'ZFIN Expression Atlas'; + +INSERT INTO bulkscheduledload (id, cronschedule, scheduleactive) +SELECT id, '0 0 22 ? * SUN-THU', true FROM bulkload WHERE name = 'SGD Expression Atlas'; + +INSERT INTO bulkscheduledload (id, cronschedule, scheduleactive) +SELECT id, '0 0 22 ? * SUN-THU', true FROM bulkload WHERE name = 'MGI Expression Atlas'; + +INSERT INTO bulkscheduledload (id, cronschedule, scheduleactive) +SELECT id, '0 0 22 ? * SUN-THU', true FROM bulkload WHERE name = 'WB Expression Atlas'; + +INSERT INTO bulkscheduledload (id, cronschedule, scheduleactive) +SELECT id, '0 0 22 ? * SUN-THU', true FROM bulkload WHERE name = 'FB Expression Atlas'; + +INSERT INTO bulkscheduledload (id, cronschedule, scheduleactive) +SELECT id, '0 0 22 ? * SUN-THU', true FROM bulkload WHERE name = 'RGD Expression Atlas'; + +INSERT INTO bulkscheduledload (id, cronschedule, scheduleactive) +SELECT id, '0 0 22 ? * SUN-THU', true FROM bulkload WHERE name = 'HUMAN Expression Atlas'; + +insert into bulkurlload (id, bulkloadurl) +select id, 'https://www.ebi.ac.uk/gxa/species/Danio_rerio/sitemap.xml?allEntries=true' +from bulkload where name = 'ZFIN Expression Atlas'; + +insert into bulkurlload (id, bulkloadurl) +select id, 'https://www.ebi.ac.uk/gxa/species/Saccharomyces_cerevisiae/sitemap.xml?allEntries=true' +from bulkload where name = 'SGD Expression Atlas'; + +insert into bulkurlload (id, bulkloadurl) +select id, 'https://www.ebi.ac.uk/gxa/species/Caenorhabditis_elegans/sitemap.xml?allEntries=true' +from bulkload where name = 'WB Expression Atlas'; + +insert into bulkurlload (id, bulkloadurl) +select id, 'https://www.ebi.ac.uk/gxa/species/Mus_musculus/sitemap.xml?allEntries=true' +from bulkload where name = 'MGI Expression Atlas'; + +insert into bulkurlload (id, bulkloadurl) +select id, 'https://www.ebi.ac.uk/gxa/species/Drosophila_melanogaster/sitemap.xml?allEntries=true' +from bulkload where name = 'FB Expression Atlas'; + +insert into bulkurlload (id, bulkloadurl) +select id, 'https://www.ebi.ac.uk/gxa/species/Rattus_norvegicus/sitemap.xml?allEntries=true' +from bulkload where name = 'RGD Expression Atlas'; + +insert into bulkurlload (id, bulkloadurl) +select id, 'https://www.ebi.ac.uk/gxa/species/Homo_sapiens/sitemap.xml?allEntries=true' +from bulkload where name = 'HUMAN Expression Atlas'; + +insert into organization (id, abbreviation, fullname) +VALUES (nextval('organization_seq'),'HUMAN','Human'); diff --git a/src/main/resources/db/migration/v0.37.0.62__disease_genetic_modifier_split.sql b/src/main/resources/db/migration/v0.37.0.62__disease_genetic_modifier_split.sql new file mode 100644 index 000000000..ea06da0a3 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.62__disease_genetic_modifier_split.sql @@ -0,0 +1,73 @@ +CREATE TABLE diseaseannotation_modifieragm ( + diseaseannotation_id bigint NOT NUlL, + diseasegeneticmodifieragms_id bigint NOT NULL + ); + +ALTER TABLE diseaseannotation_modifieragm + ADD CONSTRAINT diseaseannotation_modifieragm_diseaseannotation_id_fk + FOREIGN KEY (diseaseannotation_id) REFERENCES diseaseannotation (id); + +ALTER TABLE diseaseannotation_modifieragm + ADD CONSTRAINT diseaseannotation_modifieragm_dgmagms_id_fk + FOREIGN KEY (diseasegeneticmodifieragms_id) REFERENCES affectedgenomicmodel (id); + +INSERT INTO diseaseannotation_modifieragm (diseaseannotation_id, diseasegeneticmodifieragms_id) + SELECT diseaseannotation_id, diseasegeneticmodifiers_id + FROM diseaseannotation_biologicalentity + WHERE diseasegeneticmodifiers_id IN (SELECT id FROM affectedgenomicmodel); + +CREATE INDEX diseaseannotation_modifieragm_da_index ON diseaseannotation_modifieragm + USING btree (diseaseannotation_id); + +CREATE INDEX diseaseannotation_modifieragm_dgma_index ON diseaseannotation_modifieragm + USING btree (diseasegeneticmodifieragms_id); + +CREATE TABLE diseaseannotation_modifierallele ( + diseaseannotation_id bigint NOT NUlL, + diseasegeneticmodifieralleles_id bigint NOT NULL + ); + +ALTER TABLE diseaseannotation_modifierallele + ADD CONSTRAINT diseaseannotation_modifierallele_diseaseannotation_id_fk + FOREIGN KEY (diseaseannotation_id) REFERENCES diseaseannotation (id); + +ALTER TABLE diseaseannotation_modifierallele + ADD CONSTRAINT diseaseannotation_modifierallele_dgmalleles_id_fk + FOREIGN KEY (diseasegeneticmodifieralleles_id) REFERENCES allele (id); + +INSERT INTO diseaseannotation_modifierallele (diseaseannotation_id, diseasegeneticmodifieralleles_id) + SELECT diseaseannotation_id, diseasegeneticmodifiers_id + FROM diseaseannotation_biologicalentity + WHERE diseasegeneticmodifiers_id IN (SELECT id FROM allele); + +CREATE INDEX diseaseannotation_modifierallele_da_index ON diseaseannotation_modifierallele + USING btree (diseaseannotation_id); + +CREATE INDEX diseaseannotation_modifierallele_dgma_index ON diseaseannotation_modifierallele + USING btree (diseasegeneticmodifieralleles_id); + +CREATE TABLE diseaseannotation_modifiergene( + diseaseannotation_id bigint NOT NUlL, + diseasegeneticmodifiergenes_id bigint NOT NULL + ); + +ALTER TABLE diseaseannotation_modifiergene + ADD CONSTRAINT diseaseannotation_modifiergene_diseaseannotation_id_fk + FOREIGN KEY (diseaseannotation_id) REFERENCES diseaseannotation (id); + +ALTER TABLE diseaseannotation_modifiergene + ADD CONSTRAINT diseaseannotation_modifiergene_dgmgenes_id_fk + FOREIGN KEY (diseasegeneticmodifiergenes_id) REFERENCES gene (id); + +INSERT INTO diseaseannotation_modifiergene (diseaseannotation_id, diseasegeneticmodifiergenes_id) + SELECT diseaseannotation_id, diseasegeneticmodifiers_id + FROM diseaseannotation_biologicalentity + WHERE diseasegeneticmodifiers_id IN (SELECT id FROM gene); + +CREATE INDEX diseaseannotation_modifiergene_da_index ON diseaseannotation_modifiergene + USING btree (diseaseannotation_id); + +CREATE INDEX diseaseannotation_modifiergene_dgmg_index ON diseaseannotation_modifiergene + USING btree (diseasegeneticmodifiergenes_id); + +DROP TABLE diseaseannotation_biologicalentity; \ No newline at end of file diff --git a/src/main/resources/db/migration/v0.37.0.63__biogrid_orcs_load.sql b/src/main/resources/db/migration/v0.37.0.63__biogrid_orcs_load.sql new file mode 100644 index 000000000..fd5ee1266 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.63__biogrid_orcs_load.sql @@ -0,0 +1,41 @@ +-- Create bulk loads + +INSERT INTO bulkloadgroup (id, name) VALUES (nextval('bulkloadgroup_seq'), 'File Management System (FMS) Biogrid Orcs Loads'); +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) + SELECT nextval('bulkload_seq'), 'BIOGRID_ORCS', 'FB Biogrid Orcs Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) Biogrid Orcs Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) + SELECT nextval('bulkload_seq'), 'BIOGRID_ORCS', 'HUMAN Biogrid Orcs Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) Biogrid Orcs Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) + SELECT nextval('bulkload_seq'), 'BIOGRID_ORCS', 'MGI Biogrid Orcs Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) Biogrid Orcs Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) + SELECT nextval('bulkload_seq'), 'BIOGRID_ORCS', 'RGD Biogrid Orcs Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) Biogrid Orcs Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) + SELECT nextval('bulkload_seq'), 'BIOGRID_ORCS', 'SGD Biogrid Orcs Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) Biogrid Orcs Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) + SELECT nextval('bulkload_seq'), 'BIOGRID_ORCS', 'WB Biogrid Orcs Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) Biogrid Orcs Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) + SELECT nextval('bulkload_seq'), 'BIOGRID_ORCS', 'XBXL Biogrid Orcs Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) Biogrid Orcs Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) + SELECT nextval('bulkload_seq'), 'BIOGRID_ORCS', 'XBXT Biogrid Orcs Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) Biogrid Orcs Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) + SELECT nextval('bulkload_seq'), 'BIOGRID_ORCS', 'ZFIN Biogrid Orcs Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) Biogrid Orcs Loads'; +INSERT INTO bulkscheduledload (id, cronschedule, scheduleactive) + SELECT id, '0 0 22 ? * SUN-THU', false FROM bulkload WHERE backendbulkloadtype = 'BIOGRID_ORCS'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) + SELECT id, 'BIOGRID-ORCS', 'FB' FROM bulkload WHERE name = 'FB Biogrid Orcs Load'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) + SELECT id, 'BIOGRID-ORCS', 'HUMAN' FROM bulkload WHERE name = 'HUMAN Biogrid Orcs Load'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) + SELECT id, 'BIOGRID-ORCS', 'MGI' FROM bulkload WHERE name = 'MGI Biogrid Orcs Load'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) + SELECT id, 'BIOGRID-ORCS', 'RGD' FROM bulkload WHERE name = 'RGD Biogrid Orcs Load'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) + SELECT id, 'BIOGRID-ORCS', 'SGD' FROM bulkload WHERE name = 'SGD Biogrid Orcs Load'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) + SELECT id, 'BIOGRID-ORCS', 'WB' FROM bulkload WHERE name = 'WB Biogrid Orcs Load'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) + SELECT id, 'BIOGRID-ORCS', 'XBSL' FROM bulkload WHERE name = 'XBXL Biogrid Orcs Load'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) + SELECT id, 'BIOGRID-ORCS', 'XBXT' FROM bulkload WHERE name = 'XBXT Biogrid Orcs Load'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) + SELECT id, 'BIOGRID-ORCS', 'ZFIN' FROM bulkload WHERE name = 'ZFIN Biogrid Orcs Load'; \ No newline at end of file diff --git a/src/main/resources/db/migration/v0.37.0.64__curated_variant_genomic_location_association.sql b/src/main/resources/db/migration/v0.37.0.64__curated_variant_genomic_location_association.sql new file mode 100644 index 000000000..e6e8b5c2c --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.64__curated_variant_genomic_location_association.sql @@ -0,0 +1,187 @@ +CREATE TABLE curatedvariantgenomiclocation ( + id bigint PRIMARY KEY, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + "end" integer, + start integer, + phase integer, + variationstrand character varying(1), + hgvs text, + paddedbase character varying(1), + insertedsequence text, + deletedsequence text, + numberadditionaldnabasepairs integer, + numberremoveddnabasepairs integer, + createdby_id bigint, + updatedby_id bigint, + relation_id bigint, + variantassociationsubject_id bigint, + variantgenomiclocationassociationobject_id bigint, + dnamutationtype_id bigint, + genelocalizationtype_id bigint, + consequence_id bigint, + curatedconsequence_id bigint, + referencesequence text, + variantsequence text +); + +CREATE TABLE curatedvariantgenomiclocation_informationcontententity ( + association_id bigint NOT NULL, + evidence_id bigint NOT NULL +); + +CREATE SEQUENCE curatedvariantgenomiclocation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE INDEX cvgla_internal_index ON curatedvariantgenomiclocation USING btree (internal); +CREATE INDEX cvgla_obsolete_index ON curatedvariantgenomiclocation USING btree (obsolete); +CREATE INDEX cvgla_hgvs_index ON curatedvariantgenomiclocation USING btree (hgvs); +CREATE INDEX cvgla_createdby_index ON curatedvariantgenomiclocation USING btree (createdby_id); +CREATE INDEX cvgla_updatedby_index ON curatedvariantgenomiclocation USING btree (updatedby_id); +CREATE INDEX cvgla_relation_index ON curatedvariantgenomiclocation USING btree (relation_id); +CREATE INDEX cvgla_consequence_index ON curatedvariantgenomiclocation USING btree (consequence_id); +CREATE INDEX cvgla_curatedconsequence_index ON curatedvariantgenomiclocation USING btree (curatedconsequence_id); +CREATE INDEX cvgla_dnamutationtype_index ON curatedvariantgenomiclocation USING btree (dnamutationtype_id); +CREATE INDEX cvgla_genelocalizationtype_index ON curatedvariantgenomiclocation USING btree (genelocalizationtype_id); +CREATE INDEX cvgla_variantassociationsubject_index ON curatedvariantgenomiclocation USING btree (variantassociationsubject_id); +CREATE INDEX cvgla_vglaobject_index ON curatedvariantgenomiclocation USING btree (variantgenomiclocationassociationobject_id); + +CREATE INDEX idxf6ue9897y96ts14v3cxil0rr3 ON curatedvariantgenomiclocation_informationcontententity USING btree (association_id); +CREATE INDEX idxf71i1k78crgfhf7pnaewvc1ia ON curatedvariantgenomiclocation_informationcontententity USING btree (evidence_id); + +ALTER TABLE ONLY curatedvariantgenomiclocation ADD CONSTRAINT cvgla_createdby_id_fk FOREIGN KEY (createdby_id) REFERENCES person(id); +ALTER TABLE ONLY curatedvariantgenomiclocation ADD CONSTRAINT cvgla_updatedby_id_fk FOREIGN KEY (updatedby_id) REFERENCES person(id); +ALTER TABLE ONLY curatedvariantgenomiclocation ADD CONSTRAINT cvgla_relation_id_fk FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); +ALTER TABLE ONLY curatedvariantgenomiclocation ADD CONSTRAINT cvgla_variantassociationsubject_id_fk FOREIGN KEY (variantassociationsubject_id) REFERENCES variant(id); +ALTER TABLE ONLY curatedvariantgenomiclocation ADD CONSTRAINT cvgla_variantgenomiclocationassociationobject_id_fk FOREIGN KEY (variantgenomiclocationassociationobject_id) REFERENCES assemblycomponent(id); +ALTER TABLE ONLY curatedvariantgenomiclocation ADD CONSTRAINT cvgla_dnamutationtype_id_fk FOREIGN KEY (dnamutationtype_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY curatedvariantgenomiclocation ADD CONSTRAINT cvgla_genelocalizationtype_id_fk FOREIGN KEY (genelocalizationtype_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY curatedvariantgenomiclocation ADD CONSTRAINT cvgla_curatedconsequence_id_fk FOREIGN KEY (curatedconsequence_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY curatedvariantgenomiclocation ADD CONSTRAINT cvgla_consequence_id_fk FOREIGN KEY (consequence_id) REFERENCES ontologyterm(id); + + +ALTER TABLE ONLY curatedvariantgenomiclocation_informationcontententity ADD CONSTRAINT cvgla_ice_association_id_fk FOREIGN KEY (association_id) REFERENCES curatedvariantgenomiclocation(id); +ALTER TABLE ONLY curatedvariantgenomiclocation_informationcontententity ADD CONSTRAINT cvgla_ice_evidence_id_fk FOREIGN KEY (evidence_id) REFERENCES informationcontententity(id); + +CREATE TABLE allelevariantassociation ( + id bigint PRIMARY KEY, + datecreated timestamp(6) with time zone, + dateupdated timestamp(6) with time zone, + dbdatecreated timestamp(6) with time zone, + dbdateupdated timestamp(6) with time zone, + internal boolean DEFAULT false NOT NULL, + obsolete boolean DEFAULT false NOT NULL, + createdby_id bigint, + updatedby_id bigint, + alleleassociationsubject_id bigint, + allelevariantassociationobject_id bigint, + relation_id bigint, + evidencecode_id bigint, + relatednote_id bigint +); + +CREATE TABLE allelevariantassociation_informationcontententity ( + association_id bigint NOT NULL, + evidence_id bigint NOT NULL +); + +CREATE SEQUENCE allelevariantassociation_seq + START WITH 1 + INCREMENT BY 50 + NO MINVALUE + NO MAXVALUE + CACHE 1; + +CREATE INDEX allelevariantassociation_internal_index ON allelevariantassociation USING btree (internal); +CREATE INDEX allelevariantassociation_obsolete_index ON allelevariantassociation USING btree (obsolete); +CREATE INDEX allelevariantassociation_createdby_index ON allelevariantassociation USING btree (createdby_id); +CREATE INDEX allelevariantassociation_updatedby_index ON allelevariantassociation USING btree (updatedby_id); +CREATE INDEX allelevariantassociation_relation_index ON allelevariantassociation USING btree (relation_id); +CREATE INDEX allelevariantassociation_evidencecode_index ON allelevariantassociation USING btree (evidencecode_id); +CREATE INDEX allelevariantassociation_relatednote_index ON allelevariantassociation USING btree (relatednote_id); +CREATE INDEX allelevariantassociation_alleleassociationsubject_index ON allelevariantassociation USING btree (alleleassociationsubject_id); +CREATE INDEX allelevariantassociation_allelevariantassociationobject_index ON allelevariantassociation USING btree (allelevariantassociationobject_id); + + +CREATE INDEX idxlptd4iugnh74h5rnm4rhwwmgt ON allelevariantassociation_informationcontententity USING btree (association_id); +CREATE INDEX idxfkin7xx0kjoew8umur1riadtv ON allelevariantassociation_informationcontententity USING btree (evidence_id); + +ALTER TABLE ONLY allelevariantassociation ADD CONSTRAINT allelevariantassociation_createdby_id_fk FOREIGN KEY (createdby_id) REFERENCES person(id); +ALTER TABLE ONLY allelevariantassociation ADD CONSTRAINT allelevariantassociation_updatedby_id_fk FOREIGN KEY (updatedby_id) REFERENCES person(id); +ALTER TABLE ONLY allelevariantassociation ADD CONSTRAINT allelevariantassociation_evidencecode_id_fk FOREIGN KEY (evidencecode_id) REFERENCES ontologyterm(id); +ALTER TABLE ONLY allelevariantassociation ADD CONSTRAINT allelevariantassociation_relatednote_id_fk FOREIGN KEY (relatednote_id) REFERENCES note(id); +ALTER TABLE ONLY allelevariantassociation ADD CONSTRAINT allelevariantassociation_relation_id_fk FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); +ALTER TABLE ONLY allelevariantassociation ADD CONSTRAINT allelevariantassociation_aasubject_id_fk FOREIGN KEY (alleleassociationsubject_id) REFERENCES allele(id); +ALTER TABLE ONLY allelevariantassociation ADD CONSTRAINT allelevariantassociation_avaobject_id_fk FOREIGN KEY (allelevariantassociationobject_id) REFERENCES variant(id); + +ALTER TABLE ONLY allelevariantassociation_informationcontententity ADD CONSTRAINT allelevariantassociation_ice_association_id_fk FOREIGN KEY (association_id) REFERENCES allelevariantassociation(id); +ALTER TABLE ONLY allelevariantassociation_informationcontententity ADD CONSTRAINT allelevariantassociation_ice_evidence_id_fk FOREIGN KEY (evidence_id) REFERENCES informationcontententity(id); + +INSERT INTO vocabularytermset (id, name, vocabularylabel, vocabularytermsetvocabulary_id) + SELECT nextval('vocabularytermset_seq'), 'Allele Variant Association Relation', 'allele_variant_relation', id FROM vocabulary WHERE vocabularylabel = 'allele_relation'; + +INSERT INTO vocabularyterm (id, name, vocabulary_id) SELECT nextval('vocabularyterm_seq'), 'has_variant', id FROM vocabulary WHERE vocabularylabel = 'allele_relation'; + +INSERT INTO vocabularytermset_vocabularyterm (vocabularytermsets_id, memberterms_id) + WITH + t1 AS ( + SELECT id FROM vocabularytermset WHERE vocabularylabel = 'allele_variant_relation' + ), + t2 AS ( + SELECT id FROM vocabularyterm WHERE name = 'has_variant' AND vocabulary_id = ( + SELECT id FROM vocabulary WHERE vocabularylabel = 'allele_relation' + ) + ) + SELECT t1.id, t2.id FROM t1,t2; + +DELETE FROM bulkloadfileexception WHERE bulkloadfilehistory_id IN (SELECT id FROM bulkloadfilehistory WHERE bulkload_id IN (SELECT id FROM bulkload WHERE backendbulkloadtype = 'VARIANT')); +DELETE FROM bulkloadfilehistory WHERE bulkload_id IN (SELECT id FROM bulkload WHERE backendbulkloadtype = 'VARIANT'); +DELETE FROM bulkloadfile WHERE id NOT IN (SELECT DISTINCT bulkloadfile_id FROM bulkloadfilehistory); +DELETE FROM bulkmanualload WHERE id IN (SELECT id FROM bulkload WHERE backendbulkloadtype = 'VARIANT'); +DELETE FROM bulkload WHERE backendbulkloadtype = 'VARIANT'; +DELETE FROM bulkloadgroup WHERE name = 'Direct (LinkML) DQM Variant Loads'; + +UPDATE bulkloadgroup SET name = 'File Management System (FMS) Expression Loads' WHERE name = 'Expression Bulk Loads'; +UPDATE bulkloadgroup SET name = 'File Management System (FMS) HTP Expression Dataset Annotation Loads' WHERE name = 'HTP Expression Dataset Annotation Bulk Loads'; +UPDATE bulkloadgroup SET name = 'File Management System (FMS) HTP Expression Dataset Sample Annotation Loads' WHERE name = 'HTP Expression Dataset Sample Annotation Bulk Loads'; +UPDATE bulkloadgroup SET name = 'File Management System (FMS) Interaction Loads' WHERE name = 'Interaction Bulk Loads'; +UPDATE bulkloadgroup SET name = 'File Management System (FMS) Molecule Loads' WHERE name = 'Molecule Bulk Loads'; +UPDATE bulkloadgroup SET name = 'File Management System (FMS) Orthology Loads' WHERE name = 'Orthology Bulk Loads'; +UPDATE bulkloadgroup SET name = 'File Management System (FMS) Paralogy Loads' WHERE name = 'Paralogy Bulk Loads'; +UPDATE bulkloadgroup SET name = 'File Management System (FMS) Phenotype Loads' WHERE name = 'Phenotype Bulk Loads'; +UPDATE bulkloadgroup SET name = 'File Management System (FMS) Sequence Targeting Reagent Loads' WHERE name = 'Sequence Targeting Reagent Bulk Loads'; +UPDATE bulkloadgroup SET name = 'Expression Atlas Loads' WHERE name = 'Expression Atlas Load'; + +INSERT INTO bulkloadgroup (id, name) VALUES (nextval('bulkloadgroup_seq'), 'File Management System (FMS) Variant Loads'); +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) + SELECT nextval('bulkload_seq'), 'VARIATION', 'FB Variant Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) Variant Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) + SELECT nextval('bulkload_seq'), 'VARIATION', 'MGI Variant Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) Variant Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) + SELECT nextval('bulkload_seq'), 'VARIATION', 'RGD Variant Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) Variant Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) + SELECT nextval('bulkload_seq'), 'VARIATION', 'WB Variant Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) Variant Loads'; +INSERT INTO bulkload (id, backendbulkloadtype, name, bulkloadstatus, group_id) + SELECT nextval('bulkload_seq'), 'VARIATION', 'ZFIN Variant Load', 'STOPPED', id FROM bulkloadgroup WHERE name = 'File Management System (FMS) Variant Loads'; +INSERT INTO bulkscheduledload (id, cronschedule, scheduleactive) + SELECT id, '0 0 22 ? * SUN-THU', false FROM bulkload WHERE backendbulkloadtype = 'VARIATION'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) + SELECT id, 'VARIATION', 'FB' FROM bulkload WHERE name = 'FB Variant Load'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) + SELECT id, 'VARIATION', 'MGI' FROM bulkload WHERE name = 'MGI Variant Load'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) + SELECT id, 'VARIATION', 'RGD' FROM bulkload WHERE name = 'RGD Variant Load'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) + SELECT id, 'VARIATION', 'WB' FROM bulkload WHERE name = 'WB Variant Load'; +INSERT INTO bulkfmsload (id, fmsdatatype, fmsdatasubtype) + SELECT id, 'VARIATION', 'ZFIN' FROM bulkload WHERE name = 'ZFIN Variant Load'; + + \ No newline at end of file diff --git a/src/main/resources/db/migration/v0.37.0.6__flatten_slotannotation_tables.sql b/src/main/resources/db/migration/v0.37.0.6__flatten_slotannotation_tables.sql new file mode 100644 index 000000000..ed116f482 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.6__flatten_slotannotation_tables.sql @@ -0,0 +1,262 @@ +ALTER TABLE SlotAnnotation + ADD COLUMN phenotypestatement text, + ADD COLUMN secondaryid character varying(255), + ADD COLUMN displaytext text, + ADD COLUMN formattext text, + ADD COLUMN synonymurl character varying(255), + ADD COLUMN componentsymbol character varying(255), + ADD COLUMN taxontext character varying(255), + + ADD COLUMN inheritancemode_id bigint, + ADD COLUMN phenotypeterm_id bigint, + ADD COLUMN singleallele_id bigint, + ADD COLUMN nomenclatureevent_id bigint, + ADD COLUMN nametype_id bigint, + ADD COLUMN synonymscope_id bigint, + ADD COLUMN singleconstruct_id bigint, + ADD COLUMN singlegene_id bigint, + ADD COLUMN databasestatus_id bigint, + ADD COLUMN germlinetransmissionstatus_id bigint, + ADD COLUMN relation_id bigint, + ADD COLUMN taxon_id bigint, + ADD COLUMN slotannotationtype character varying(96); + + +UPDATE SlotAnnotation s SET + SlotAnnotationType = 'AlleleDatabaseStatusSlotAnnotation', + databasestatus_id = a.databasestatus_id, + singleallele_id = a.singleallele_id +FROM alleledatabasestatusslotannotation a WHERE s.id = a.id; + +DROP TABLE AlleleDatabaseStatusSlotAnnotation; + +UPDATE SlotAnnotation s SET + SlotAnnotationType = 'AlleleFullNameSlotAnnotation', + singleallele_id = a.singleallele_id +FROM AlleleFullNameSlotAnnotation a WHERE s.id = a.id; + +DROP TABLE AlleleFullNameSlotAnnotation; + +UPDATE SlotAnnotation s SET + SlotAnnotationType = 'AlleleFunctionalImpactSlotAnnotation', + singleallele_id = a.singleallele_id, + phenotypestatement = a.phenotypestatement, + phenotypeterm_id = a.phenotypeterm_id +FROM AlleleFunctionalImpactSlotAnnotation a WHERE s.id = a.id; + +ALTER TABLE allelefunctionalimpactslotannotation_vocabularyterm RENAME TO slotannotation_vocabularyterm; +ALTER TABLE slotannotation_vocabularyterm RENAME COLUMN allelefunctionalimpactslotannotation_id TO slotannotation_id; +ALTER TABLE SlotAnnotation_vocabularyterm DROP CONSTRAINT allelefunctionalimpactsa_vocabterm_afisa_id_fk; +ALTER TABLE SlotAnnotation_vocabularyterm DROP CONSTRAINT allelefunctionalimpactsa_vocabterm_functionalimpacts_id_fk; +ALTER TABLE SlotAnnotation_vocabularyterm ADD CONSTRAINT fk8q2b6xm3sbackqpj60xo24nk2 FOREIGN KEY (slotannotation_id) REFERENCES slotannotation(id); +ALTER TABLE SlotAnnotation_vocabularyterm ADD CONSTRAINT fkaj5ybyv1kfuy92vmxnlplvu58 FOREIGN KEY (functionalimpacts_id) REFERENCES vocabularyterm(id); +DROP INDEX allelefunctionalimpactsa_vocabterm_afisa_index; +DROP INDEX allelefunctionalimpactsa_vocabterm_functionalimpacts_index; +CREATE INDEX slotannotation_id_index ON SlotAnnotation_vocabularyterm USING btree (slotannotation_id); +CREATE INDEX slotannotation_functionalimpacts_index ON SlotAnnotation_vocabularyterm USING btree (functionalimpacts_id); + +DROP TABLE AlleleFunctionalImpactSlotAnnotation; + +UPDATE SlotAnnotation s SET + SlotAnnotationType = 'AlleleGermlineTransmissionStatusSlotAnnotation', + singleallele_id = a.singleallele_id, + germlinetransmissionstatus_id = a.germlinetransmissionstatus_id +FROM AlleleGermlineTransmissionStatusSlotAnnotation a WHERE s.id = a.id; + +DROP TABLE AlleleGermlineTransmissionStatusSlotAnnotation; + +UPDATE SlotAnnotation s SET + SlotAnnotationType = 'AlleleInheritanceModeSlotAnnotation', + inheritancemode_id = a.inheritancemode_id, + phenotypestatement = a.phenotypestatement, + singleallele_id = a.singleallele_id, + phenotypeterm_id = a.phenotypeterm_id +FROM AlleleInheritanceModeSlotAnnotation a WHERE s.id = a.id; + +DROP TABLE AlleleInheritanceModeSlotAnnotation; + +UPDATE SlotAnnotation s SET + SlotAnnotationType = 'AlleleMutationTypeSlotAnnotation', + singleallele_id = a.singleallele_id +FROM AlleleMutationTypeSlotAnnotation a WHERE s.id = a.id; + +ALTER TABLE allelemutationtypeslotannotation_ontologyterm RENAME TO slotannotation_ontologyterm; +ALTER TABLE slotannotation_ontologyterm RENAME COLUMN allelemutationtypeslotannotation_id TO slotannotation_id; +ALTER TABLE slotannotation_ontologyterm DROP CONSTRAINT allelemutationtypesa_soterm_amsa_id_fk; +ALTER TABLE slotannotation_ontologyterm DROP CONSTRAINT allelemutationtypesa_soterm_mutationtypes_id_fk; +ALTER TABLE SlotAnnotation_ontologyterm ADD CONSTRAINT fkm3aokfd4q1j2okqsyaj5v95kj FOREIGN KEY (slotannotation_id) REFERENCES slotannotation(id); +ALTER TABLE SlotAnnotation_ontologyterm ADD CONSTRAINT fklaf991287ttlt4yb8fbaimrqo FOREIGN KEY (mutationtypes_id) REFERENCES ontologyterm(id); +DROP INDEX allelemutationtypesa_soterm_amsa_index; +DROP INDEX allelemutationtypesa_soterm_mutationtypes_index; +CREATE INDEX slotannotation_soterm_amsa_index ON slotannotation_ontologyterm USING btree (slotannotation_id); +CREATE INDEX slotannotation_soterm_mutationtypes_index ON slotannotation_ontologyterm USING btree (mutationtypes_id); + +DROP TABLE AlleleMutationTypeSlotAnnotation; + +UPDATE SlotAnnotation s SET + SlotAnnotationType = 'AlleleNomenclatureEventSlotAnnotation', + singleallele_id = a.singleallele_id, + nomenclatureevent_id = a.nomenclatureevent_id +FROM AlleleNomenclatureEventSlotAnnotation a WHERE s.id = a.id; + +DROP TABLE AlleleNomenclatureEventSlotAnnotation; + +UPDATE SlotAnnotation s SET + SlotAnnotationType = 'AlleleSecondaryIdSlotAnnotation', + singleallele_id = a.singleallele_id +FROM AlleleSecondaryIdSlotAnnotation a WHERE s.id = a.id; + +DROP TABLE AlleleSecondaryIdSlotAnnotation; + +UPDATE SlotAnnotation s SET + SlotAnnotationType = 'AlleleSymbolSlotAnnotation', + singleallele_id = a.singleallele_id +FROM AlleleSymbolSlotAnnotation a WHERE s.id = a.id; + +DROP TABLE AlleleSymbolSlotAnnotation; + +UPDATE SlotAnnotation s SET + SlotAnnotationType = 'AlleleSynonymSlotAnnotation', + singleallele_id = a.singleallele_id +FROM AlleleSynonymSlotAnnotation a WHERE s.id = a.id; + +DROP TABLE AlleleSynonymSlotAnnotation; + +UPDATE SlotAnnotation s SET + SlotAnnotationType = 'ConstructComponentSlotAnnotation', + singleconstruct_id = a.singleconstruct_id, + componentsymbol = a.componentsymbol, + taxontext = a.taxontext, + relation_id = a.relation_id, + taxon_id = a.taxon_id +FROM ConstructComponentSlotAnnotation a WHERE s.id = a.id; + +ALTER TABLE constructcomponentslotannotation_note RENAME TO slotannotation_note; +ALTER TABLE slotannotation_note RENAME COLUMN constructcomponentslotannotation_id TO slotannotation_id; +ALTER TABLE slotannotation_note DROP CONSTRAINT constructcomponentslotannotation_note_ccsa_id_fk; +ALTER TABLE slotannotation_note DROP CONSTRAINT constructcomponentslotannotation_note_relatednotes_id_fk; +ALTER TABLE SlotAnnotation_note ADD CONSTRAINT fk4m4koh58321p1igpp8prt03wl FOREIGN KEY (slotannotation_id) REFERENCES slotannotation(id); +ALTER TABLE SlotAnnotation_note ADD CONSTRAINT fk4yafsa344go9s548rca9vwv6m FOREIGN KEY (relatednotes_id) REFERENCES note(id); +DROP INDEX constructcomponentsa_note_ccsa_index; +DROP INDEX constructcomponentsa_note_relatednotes_index; +CREATE INDEX slotannotation_note_ccsa_index ON slotannotation_note USING btree (slotannotation_id); +CREATE INDEX slotannotation_note_relatednotes_index ON slotannotation_note USING btree (relatednotes_id); + +DROP TABLE ConstructComponentSlotAnnotation; + +UPDATE SlotAnnotation s SET + SlotAnnotationType = 'ConstructFullNameSlotAnnotation', + singleconstruct_id = a.singleconstruct_id +FROM ConstructFullNameSlotAnnotation a WHERE s.id = a.id; + +DROP TABLE ConstructFullNameSlotAnnotation; + +UPDATE SlotAnnotation s SET + SlotAnnotationType = 'ConstructSymbolSlotAnnotation', + singleconstruct_id = a.singleconstruct_id +FROM ConstructSymbolSlotAnnotation a WHERE s.id = a.id; + +DROP TABLE ConstructSymbolSlotAnnotation; + +UPDATE SlotAnnotation s SET + SlotAnnotationType = 'ConstructSynonymSlotAnnotation', + singleconstruct_id = a.singleconstruct_id +FROM ConstructSynonymSlotAnnotation a WHERE s.id = a.id; + +DROP TABLE ConstructSynonymSlotAnnotation; + +UPDATE SlotAnnotation s SET + SlotAnnotationType = 'GeneFullNameSlotAnnotation', + singlegene_id = a.singlegene_id +FROM GeneFullNameSlotAnnotation a WHERE s.id = a.id; + +DROP TABLE GeneFullNameSlotAnnotation; + +UPDATE SlotAnnotation s SET + SlotAnnotationType = 'GeneSecondaryIdSlotAnnotation', + singlegene_id = a.singlegene_id +FROM GeneSecondaryIdSlotAnnotation a WHERE s.id = a.id; + +DROP TABLE GeneSecondaryIdSlotAnnotation; + +UPDATE SlotAnnotation s SET + SlotAnnotationType = 'GeneSymbolSlotAnnotation', + singlegene_id = a.singlegene_id +FROM GeneSymbolSlotAnnotation a WHERE s.id = a.id; + +DROP TABLE GeneSymbolSlotAnnotation; + +UPDATE SlotAnnotation s SET + SlotAnnotationType = 'GeneSynonymSlotAnnotation', + singlegene_id = a.singlegene_id +FROM GeneSynonymSlotAnnotation a WHERE s.id = a.id; + +DROP TABLE GeneSynonymSlotAnnotation; + +UPDATE SlotAnnotation s SET + SlotAnnotationType = 'GeneSystematicNameSlotAnnotation', + singlegene_id = a.singlegene_id +FROM GeneSystematicNameSlotAnnotation a WHERE s.id = a.id; + +DROP TABLE GeneSystematicNameSlotAnnotation; + +UPDATE SlotAnnotation s SET + secondaryid = a.secondaryid +FROM SecondaryIdSlotAnnotation a WHERE s.id = a.id; + +DROP TABLE SecondaryIdSlotAnnotation; + +UPDATE SlotAnnotation s SET + displaytext = a.displaytext, + formattext = a.formattext, + synonymurl = a.synonymurl, + nametype_id = a.nametype_id, + synonymscope_id = a.synonymscope_id +FROM NameSlotAnnotation a WHERE s.id = a.id; + +DROP TABLE NameSlotAnnotation; + +ALTER TABLE SlotAnnotation ADD CONSTRAINT fk19ret4dubt1ckfrbkng18lovq FOREIGN KEY (inheritancemode_id) REFERENCES vocabularyterm(id); +ALTER TABLE SlotAnnotation ADD CONSTRAINT fk7gu3slsry4u26f33ns6gc7w0m FOREIGN KEY (taxon_id) REFERENCES ontologyterm(id); +ALTER TABLE SlotAnnotation ADD CONSTRAINT fk8whffy7l5ievs39b0nnbir6ph FOREIGN KEY (nametype_id) REFERENCES vocabularyterm(id); +ALTER TABLE SlotAnnotation ADD CONSTRAINT fkbg9tp7mj2818od5n7ysaj37tf FOREIGN KEY (synonymscope_id) REFERENCES vocabularyterm(id); +ALTER TABLE SlotAnnotation ADD CONSTRAINT fkc8o0sm7ank0efy810051wfqsd FOREIGN KEY (germlinetransmissionstatus_id) REFERENCES vocabularyterm(id); +ALTER TABLE SlotAnnotation ADD CONSTRAINT fke3jo24un80y5wbimk8q3vi8ij FOREIGN KEY (nomenclatureevent_id) REFERENCES vocabularyterm(id); +ALTER TABLE SlotAnnotation ADD CONSTRAINT fkhg0s2w84inbudpe523k2568vr FOREIGN KEY (singleallele_id) REFERENCES allele(id); +ALTER TABLE SlotAnnotation ADD CONSTRAINT fkju1yhk6ryh61926japwdojk54 FOREIGN KEY (singlegene_id) REFERENCES gene(id); +ALTER TABLE SlotAnnotation ADD CONSTRAINT fkp4p1tdkllrsmx3v1jfr5iyk6y FOREIGN KEY (relation_id) REFERENCES vocabularyterm(id); +ALTER TABLE SlotAnnotation ADD CONSTRAINT fkq8ci945lhcjeysbmhgc96op5r FOREIGN KEY (phenotypeterm_id) REFERENCES ontologyterm(id); +ALTER TABLE SlotAnnotation ADD CONSTRAINT fkqkk6210gn4gugy1eae8uxp443 FOREIGN KEY (singleconstruct_id) REFERENCES construct(id); +ALTER TABLE SlotAnnotation ADD CONSTRAINT fksjf0g4ao72a95jqwpp332d84q FOREIGN KEY (databasestatus_id) REFERENCES vocabularyterm(id); + +CREATE INDEX slotannotation_inheritancemode_index ON slotannotation USING btree (inheritancemode_id); +CREATE INDEX slotannotation_taxon_index ON slotannotation USING btree (taxon_id); +CREATE INDEX slotannotation_nametype_index ON slotannotation USING btree (nametype_id); +CREATE INDEX slotannotation_synonymscope_index ON slotannotation USING btree (synonymscope_id); +CREATE INDEX slotannotation_status_index ON slotannotation USING btree (germlinetransmissionstatus_id); +CREATE INDEX slotannotation_nomenclatureevent_index ON slotannotation USING btree (nomenclatureevent_id); +CREATE INDEX slotannotation_singleallele_index ON slotannotation USING btree (singleallele_id); +CREATE INDEX slotannotation_singlegene_index ON slotannotation USING btree (singlegene_id); +CREATE INDEX slotannotation_relation_index ON slotannotation USING btree (relation_id); +CREATE INDEX slotannotation_phenotypeterm_index ON slotannotation USING btree (phenotypeterm_id); +CREATE INDEX slotannotation_singleconstruct_index ON slotannotation USING btree (singleconstruct_id); +CREATE INDEX slotannotation_databasestatus_index ON slotannotation USING btree (databasestatus_id); +CREATE INDEX slotannotation_componentsymbol_index ON slotannotation USING btree (componentsymbol); + +CREATE TABLE evidence_ids_to_delete ( id bigint PRIMARY KEY); + +INSERT INTO evidence_ids_to_delete (id) + SELECT distinct i.id + FROM slotannotation s, slotannotation_informationcontententity si, informationcontententity i + WHERE s.id = si.slotannotation_id and si.evidence_id = i.id and s.slotannotationtype is null; + +DELETE FROM slotannotation_informationcontententity WHERE evidence_id in (SELECT id FROM evidence_ids_to_delete); + +DROP TABLE evidence_ids_to_delete; + +DELETE FROM SlotAnnotation WHERE slotannotationtype is null; + +ALTER TABLE SlotAnnotation ALTER COLUMN slotannotationtype SET NOT null; +ALTER TABLE OntologyTerm ALTER COLUMN ontologytermtype SET NOT null; -- Missed this on the last flattening exercise. + +CREATE INDEX slotannotation_slotannotationtype ON slotannotation USING btree (slotannotationtype); diff --git a/src/main/resources/db/migration/v0.37.0.7__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.7__remove_dataprovider_dups.sql new file mode 100644 index 000000000..31bd82544 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.7__remove_dataprovider_dups.sql @@ -0,0 +1,19 @@ +-- Update the null resourcedescriptorpage_id to the XB home page because Xenbase != XB + +update crossreference + set resourcedescriptorpage_id = ( + SELECT rp.id + FROM resourcedescriptorpage rp, resourcedescriptor rd + WHERE rp.resourcedescriptor_id=rd.id and rd.prefix = 'Xenbase' and rp.name = 'homepage' +) +WHERE resourcedescriptorpage_id is null and referencedCurie = 'XB'; + +-- Add missing indexes +CREATE INDEX organization_abbreviation_index ON organization USING btree (abbreviation); +CREATE INDEX codingsequence_cdsType_index ON codingsequence USING btree (cdstype_id); +CREATE INDEX transcript_transcriptType_index ON transcript USING btree (transcripttype_id); +CREATE INDEX exon_exonType_index ON exon USING btree (exontype_id); +CREATE INDEX ontologyterm_name_index ON ontologyterm USING btree (name); + +CREATE INDEX assemblycomponent_mapsToChromosome_index ON AssemblyComponent USING btree (mapsToChromosome_id); +CREATE INDEX assemblycomponent_name_index ON AssemblyComponent USING btree (name); diff --git a/src/main/resources/db/migration/v0.37.0.8__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.8__remove_dataprovider_dups.sql new file mode 100644 index 000000000..86f4e1279 --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.8__remove_dataprovider_dups.sql @@ -0,0 +1,36 @@ +-- Update all BiologicalEntity.dataProvider to point to a XB dataprovider that is first in the DB + +UPDATE biologicalentity be +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1, crossreference cr1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id = cr1.id + AND o1.abbreviation = 'XB' + AND cr1.referencedCurie = 'XB' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o, crossreference cr +WHERE + be.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id = cr.id AND + o.abbreviation = cr.referencedCurie AND + o.abbreviation = 'XB'; + +UPDATE biologicalentity be +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id is null + AND o1.abbreviation = 'XB' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o +WHERE + be.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id is null AND + o.abbreviation = 'XB'; + diff --git a/src/main/resources/db/migration/v0.37.0.9__remove_dataprovider_dups.sql b/src/main/resources/db/migration/v0.37.0.9__remove_dataprovider_dups.sql new file mode 100644 index 000000000..7b62392ee --- /dev/null +++ b/src/main/resources/db/migration/v0.37.0.9__remove_dataprovider_dups.sql @@ -0,0 +1,36 @@ +-- Update all BiologicalEntity.dataProvider to point to a FB dataprovider that is first in the DB + +UPDATE biologicalentity be +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1, crossreference cr1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id = cr1.id + AND o1.abbreviation = 'FB' + AND cr1.referencedCurie = 'FB' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o, crossreference cr +WHERE + be.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id = cr.id AND + o.abbreviation = cr.referencedCurie AND + o.abbreviation = 'FB'; + +UPDATE biologicalentity be +SET dataprovider_id = ( + SELECT dp1.id + FROM dataprovider dp1, organization o1 + WHERE o1.id = dp1.sourceorganization_id + AND dp1.crossreference_id is null + AND o1.abbreviation = 'FB' + ORDER BY dp1.id ASC LIMIT 1 +) +FROM dataprovider dp, organization o +WHERE + be.dataprovider_id=dp.id AND + dp.sourceorganization_id=o.id AND + dp.crossreference_id is null AND + o.abbreviation = 'FB'; + diff --git a/src/test/java/org/alliancegenome/curation_api/AlleleBulkUploadITCase.java b/src/test/java/org/alliancegenome/curation_api/AlleleBulkUploadITCase.java index 692f7302d..5b8f69c76 100644 --- a/src/test/java/org/alliancegenome/curation_api/AlleleBulkUploadITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/AlleleBulkUploadITCase.java @@ -56,10 +56,10 @@ public void init() { private final String alleleTestFilePath = "src/test/resources/bulk/02_allele/"; private void loadRequiredEntities() throws Exception { - loadSOTerm(requiredSoTerm, "Test SOTerm"); - loadSOTerm(requiredSoTerm2, "Test SOTerm2"); - loadMPTerm(requiredMpTerm, "Test MPTerm"); - loadMPTerm(requiredMpTerm2, "Test MPTerm2"); + createSoTerm(requiredSoTerm, "Test SOTerm", false); + createSoTerm(requiredSoTerm2, "Test SOTerm2", false); + createMpTerm(requiredMpTerm, "Test MPTerm"); + createMpTerm(requiredMpTerm2, "Test MPTerm2"); } @Test diff --git a/src/test/java/org/alliancegenome/curation_api/AlleleGeneAssociationITCase.java b/src/test/java/org/alliancegenome/curation_api/AlleleGeneAssociationITCase.java index 89133587b..8ab1144aa 100644 --- a/src/test/java/org/alliancegenome/curation_api/AlleleGeneAssociationITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/AlleleGeneAssociationITCase.java @@ -67,12 +67,12 @@ public class AlleleGeneAssociationITCase extends BaseITCase { private void loadRequiredEntities() { Vocabulary nameTypeVocabulary = getVocabulary(VocabularyConstants.NAME_TYPE_VOCABULARY); VocabularyTerm symbolNameType = getVocabularyTerm(nameTypeVocabulary, "nomenclature_symbol"); - allele = createAllele("AGA:Allele0001", "NCBITaxon:6239", false, symbolNameType); - allele2 = createAllele("AGA:Allele0002", "NCBITaxon:6239", false, symbolNameType); - obsoleteAllele = createAllele("AGA:Allele0003", "NCBITaxon:6239", true, symbolNameType); - gene = createGene("AGA:Gene0001", "NCBITaxon:6239", false, symbolNameType); - gene2 = createGene("AGA:Gene0002", "NCBITaxon:6239", false, symbolNameType); - obsoleteGene = createGene("AGA:Gene0003", "NCBITaxon:6239", true, symbolNameType); + allele = createAllele("AGA:Allele0001", "NCBITaxon:6239", symbolNameType, false); + allele2 = createAllele("AGA:Allele0002", "NCBITaxon:6239", symbolNameType, false); + obsoleteAllele = createAllele("AGA:Allele0003", "NCBITaxon:6239", symbolNameType, true); + gene = createGene("AGA:Gene0001", "NCBITaxon:6239", symbolNameType, false); + gene2 = createGene("AGA:Gene0002", "NCBITaxon:6239", symbolNameType, false); + obsoleteGene = createGene("AGA:Gene0003", "NCBITaxon:6239", symbolNameType, true); Vocabulary relationVocabulary = getVocabulary(VocabularyConstants.ALLELE_RELATION_VOCABULARY); relation = getVocabularyTerm(relationVocabulary, "is_allele_of"); relation2 = getVocabularyTerm(relationVocabulary, "mutation_excludes"); diff --git a/src/test/java/org/alliancegenome/curation_api/AlleleITCase.java b/src/test/java/org/alliancegenome/curation_api/AlleleITCase.java index 0eefb703a..891683641 100644 --- a/src/test/java/org/alliancegenome/curation_api/AlleleITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/AlleleITCase.java @@ -206,8 +206,8 @@ private void loadRequiredEntities() { nonPersistedOrganization = new Organization(); nonPersistedOrganization.setAbbreviation("INV"); VocabularyTerm symbolNameType = getVocabularyTerm(nameTypeVocabulary, "nomenclature_symbol"); - gene = createGene("TEST:AssociatedGene1", "NCBITaxon:6239", false, symbolNameType); - gene2 = createGene("TEST:AssociatedGene2", "NCBITaxon:6239", false, symbolNameType); + gene = createGene("TEST:AssociatedGene1", "NCBITaxon:6239", symbolNameType, false); + gene2 = createGene("TEST:AssociatedGene2", "NCBITaxon:6239", symbolNameType, false); Vocabulary relationVocabulary = getVocabulary(VocabularyConstants.ALLELE_RELATION_VOCABULARY); geneAssociationRelation = getVocabularyTerm(relationVocabulary, "is_allele_of"); geneAssociationRelation2 = getVocabularyTerm(relationVocabulary, "duplication"); diff --git a/src/test/java/org/alliancegenome/curation_api/ConstructGenomicEntityAssociationITCase.java b/src/test/java/org/alliancegenome/curation_api/ConstructGenomicEntityAssociationITCase.java index 47fd87120..05382712c 100644 --- a/src/test/java/org/alliancegenome/curation_api/ConstructGenomicEntityAssociationITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/ConstructGenomicEntityAssociationITCase.java @@ -67,9 +67,9 @@ private void loadRequiredEntities() { construct = createConstruct("CGEA:Construct0001", false, symbolNameType); construct2 = createConstruct("CGEA:Construct0002", false, symbolNameType); obsoleteConstruct = createConstruct("CGEA:Construct0003", true, symbolNameType); - gene = createGene("CGEA:Gene0001", "NCBITaxon:6239", false, symbolNameType); - gene2 = createGene("CGEA:Gene0002", "NCBITaxon:6239", false, symbolNameType); - obsoleteGene = createGene("CGEA:Gene0003", "NCBITaxon:6239", true, symbolNameType); + gene = createGene("CGEA:Gene0001", "NCBITaxon:6239", symbolNameType, false); + gene2 = createGene("CGEA:Gene0002", "NCBITaxon:6239", symbolNameType, false); + obsoleteGene = createGene("CGEA:Gene0003", "NCBITaxon:6239", symbolNameType, true); Vocabulary relationVocabulary = getVocabulary(VocabularyConstants.CONSTRUCT_RELATION_VOCABULARY); relation = getVocabularyTerm(relationVocabulary, "is_regulated_by"); relation2 = getVocabularyTerm(relationVocabulary, "targets"); diff --git a/src/test/java/org/alliancegenome/curation_api/ConstructITCase.java b/src/test/java/org/alliancegenome/curation_api/ConstructITCase.java index d30ee762d..dc690e728 100644 --- a/src/test/java/org/alliancegenome/curation_api/ConstructITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/ConstructITCase.java @@ -133,7 +133,7 @@ private void loadRequiredEntities() { constructFullName = createConstructFullNameSlotAnnotation(List.of(reference), "Test name", fullNameType, exactSynonymScope, "https://test.org"); constructSynonym = createConstructSynonymSlotAnnotation(List.of(reference), "Test synonym", systematicNameType, exactSynonymScope, "https://test.org"); VocabularyTerm symbolNameType = getVocabularyTerm(nameTypeVocabulary, "nomenclature_symbol"); - gene = createGene("TEST:AssociatedGenomicEntity1", "NCBITaxon:6239", false, symbolNameType); + gene = createGene("TEST:AssociatedGenomicEntity1", "NCBITaxon:6239", symbolNameType, false); Vocabulary relationVocabulary = getVocabulary(VocabularyConstants.CONSTRUCT_RELATION_VOCABULARY); geAssociationRelation = getVocabularyTerm(relationVocabulary, "is_regulated_by"); } diff --git a/src/test/java/org/alliancegenome/curation_api/DiseaseAnnotationBulkUploadITCase.java b/src/test/java/org/alliancegenome/curation_api/DiseaseAnnotationBulkUploadITCase.java index bd17c4ce7..bda9fcd2a 100644 --- a/src/test/java/org/alliancegenome/curation_api/DiseaseAnnotationBulkUploadITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/DiseaseAnnotationBulkUploadITCase.java @@ -117,41 +117,40 @@ public void init() { private final String daTestFilePath = "src/test/resources/bulk/04_disease_annotation/"; private void loadRequiredEntities() throws Exception { - loadDOTerm(doTerm, "Test DOTerm"); - loadDOTerm(doTerm2, "Test DOTerm 2"); + createDoTerm(doTerm, "Test DOTerm"); + createDoTerm(doTerm2, "Test DOTerm 2"); createEcoTerm(ecoTerm, "Test ECOTerm", false, true); createEcoTerm(ecoTerm2, "Test ECOTerm 2", false, true); createEcoTerm(unsupportedEcoTerm, "Test unsupported ECOTerm", false, false); - loadGOTerm(goTerm, "Test GOTerm"); - loadGOTerm(goTerm2, "Test GOTerm 2"); - loadExperimentalConditionTerm(expCondTerm, "Test ExperimentalConditionOntologyTerm"); - loadZecoTerm(zecoTerm, "Test ExperimentalConditionOntologyTerm", OntologyConstants.ZECO_AGR_SLIM_SUBSET); - loadZecoTerm(zecoTerm2, "Test ExperimentalConditionOntologyTerm 2", OntologyConstants.ZECO_AGR_SLIM_SUBSET); - loadZecoTerm(nonSlimZecoTerm, "Test ExperimentalConditionOntologyTerm", null); - loadChemicalTerm(chemicalTerm, "Test ChemicalTerm"); - loadChemicalTerm(chemicalTerm2, "Test ChemicalTerm 2"); - loadAnatomyTerm(anatomyTerm, "Test AnatomicalTerm"); - loadAnatomyTerm(anatomyTerm2, "Test AnatomicalTerm 2"); + createGoTerm(goTerm, "Test GOTerm", false); + createGoTerm(goTerm2, "Test GOTerm 2", false); + createExperimentalConditionOntologyTerm(expCondTerm, "Test ExperimentalConditionOntologyTerm"); + createZecoTerm(zecoTerm, "Test ExperimentalConditionOntologyTerm", false, OntologyConstants.ZECO_AGR_SLIM_SUBSET); + createZecoTerm(zecoTerm2, "Test ExperimentalConditionOntologyTerm 2", false, OntologyConstants.ZECO_AGR_SLIM_SUBSET); + createZecoTerm(nonSlimZecoTerm, "Test ExperimentalConditionOntologyTerm", false); + createChemicalTerm(chemicalTerm, "Test ChemicalTerm"); + createChemicalTerm(chemicalTerm2, "Test ChemicalTerm 2"); + createAnatomicalTerm(anatomyTerm, "Test AnatomicalTerm"); + createAnatomicalTerm(anatomyTerm2, "Test AnatomicalTerm 2"); Vocabulary nameTypeVocabulary = getVocabulary(VocabularyConstants.NAME_TYPE_VOCABULARY); VocabularyTerm symbolTerm = getVocabularyTerm(nameTypeVocabulary, "nomenclature_symbol"); DataProvider dataProvider = createDataProvider("WB", false); DataProvider ratDataProvider = createDataProvider("RGD", false); - loadGenes(List.of(gene, gene2), "NCBITaxon:6239", symbolTerm, dataProvider); - loadGenes(List.of(withGene, withGene2), "NCBITaxon:9606", symbolTerm, dataProvider); - loadGenes(List.of(ratGene), "NCBITaxon:10116", symbolTerm, ratDataProvider); - loadGenes(List.of(humanGene), "NCBITaxon:9606", symbolTerm, ratDataProvider); - loadAllele(allele, "TestAllele", "NCBITaxon:6239", symbolTerm, dataProvider); - loadAllele(allele2, "TestAllele2", "NCBITaxon:6239", symbolTerm, dataProvider); - loadAllele(ratAllele, "TestAllele3", "NCBITaxon:10116", symbolTerm, ratDataProvider); - loadAllele(humanAllele, "TestAllele4", "NCBITaxon:9606", symbolTerm, ratDataProvider); - loadAffectedGenomicModel(agm, "Test AGM", "NCBITaxon:6239", "fish", dataProvider); - loadAffectedGenomicModel(agm2, "Test AGM2", "NCBITaxon:6239", "genotype", dataProvider); - loadAffectedGenomicModel(ratAgm, "TestAGM3", "NCBITaxon:10116", "genotype", ratDataProvider); - loadAffectedGenomicModel(humanAgm, "TestAGM4", "NCBITaxon:9606", "genotype", ratDataProvider); - loadAffectedGenomicModel(sgdBackgroundStrain, "Test SGD AGM", "NCBITaxon:559292", "strain", dataProvider); - loadAffectedGenomicModel(sgdBackgroundStrain2, "Test SGD AGM2", "NCBITaxon:559292", "strain", dataProvider); - loadReference(reference, referenceXref); - loadOrganization("OBSOLETE"); + createGenes(List.of(gene, gene2), "NCBITaxon:6239", symbolTerm, false, dataProvider); + createGenes(List.of(withGene, withGene2), "NCBITaxon:9606", symbolTerm, false, dataProvider); + createGenes(List.of(ratGene), "NCBITaxon:10116", symbolTerm, false, ratDataProvider); + createGenes(List.of(humanGene), "NCBITaxon:9606", symbolTerm, false, ratDataProvider); + createAllele(allele, "TestAllele", "NCBITaxon:6239", symbolTerm, false, dataProvider); + createAllele(allele2, "TestAllele2", "NCBITaxon:6239", symbolTerm, false, dataProvider); + createAllele(ratAllele, "TestAllele3", "NCBITaxon:10116", symbolTerm, false, ratDataProvider); + createAllele(humanAllele, "TestAllele4", "NCBITaxon:9606", symbolTerm, false, ratDataProvider); + createAffectedGenomicModel(agm, "Test AGM", "NCBITaxon:6239", "fish", false, dataProvider); + createAffectedGenomicModel(agm2, "Test AGM2", "NCBITaxon:6239", "genotype", false, dataProvider); + createAffectedGenomicModel(ratAgm, "TestAGM3", "NCBITaxon:10116", "genotype", false, ratDataProvider); + createAffectedGenomicModel(humanAgm, "TestAGM4", "NCBITaxon:9606", "genotype", false, ratDataProvider); + createAffectedGenomicModel(sgdBackgroundStrain, "Test SGD AGM", "NCBITaxon:559292", "strain", false, dataProvider); + createAffectedGenomicModel(sgdBackgroundStrain2, "Test SGD AGM2", "NCBITaxon:559292", "strain", false, dataProvider); + createReference(reference, referenceXref); Vocabulary noteTypeVocabulary = getVocabulary(VocabularyConstants.NOTE_TYPE_VOCABULARY); Vocabulary relationVocabulary = createVocabulary(VocabularyConstants.DISEASE_RELATION_VOCABULARY, false); @@ -202,7 +201,8 @@ public void geneDiseaseAnnotationBulkUploadCheckFields() throws Exception { body("entity.createdBy.uniqueId", is("DATEST:Person0001")). body("entity.dateUpdated", is(OffsetDateTime.parse("2022-03-10T22:10:12Z").toString())). body("entity.dateCreated", is(OffsetDateTime.parse("2022-03-09T22:10:12Z").toString())). - body("entity.uniqueId", is("DATEST:Gene0001|is_implicated_in|true|DATEST:Disease0001|AGRKB:000000002|DATEST:Evidence0001|HGNC:0001|exacerbated_by|DATEST:ExpCondTerm0001|DATEST:ExpCondTerm0002|DATEST:AnatomyTerm0001|DATEST:ChemicalTerm0001|DATEST:GOTerm0001|NCBITaxon:6239|Some amount|Free text|susceptibility|ameliorated_by|DATEST:Gene0002|SGD:AGM0001")). + body("entity.uniqueId", is("DATEST:Gene0001|is_implicated_in|true|DATEST:Disease0001|AGRKB:000000002|DATEST:Evidence0001|HGNC:0001|" + + "exacerbated_by|DATEST:ExpCondTerm0001|DATEST:ExpCondTerm0002|DATEST:AnatomyTerm0001|DATEST:ChemicalTerm0001|DATEST:GOTerm0001|NCBITaxon:6239|Some amount|Free text|susceptibility|ameliorated_by|DATEST:AGM0002|DATEST:Allele0002|DATEST:Gene0002|SGD:AGM0001")). body("entity.diseaseAnnotationSubject.modEntityId", is(gene)). body("entity.diseaseAnnotationObject.curie", is(doTerm)). body("entity.relation.name", is(alleleAndGeneRelation)). @@ -234,7 +234,9 @@ public void geneDiseaseAnnotationBulkUploadCheckFields() throws Exception { body("entity.conditionRelations[0].conditions[0].conditionChemical.curie", is(chemicalTerm)). body("entity.conditionRelations[0].conditions[0].conditionFreeText", is("Free text")). body("entity.conditionRelations[0].conditions[0].conditionSummary", is("Test ExperimentalConditionOntologyTerm:Test ExperimentalConditionOntologyTerm:Test AnatomicalTerm:Test GOTerm:Test ChemicalTerm:Caenorhabditis elegans:Some amount:Free text")). - body("entity.diseaseGeneticModifiers[0].modEntityId", is(gene2)). + body("entity.diseaseGeneticModifierAgms[0].modEntityId", is(agm2)). + body("entity.diseaseGeneticModifierAlleles[0].modEntityId", is(allele2)). + body("entity.diseaseGeneticModifierGenes[0].modEntityId", is(gene2)). body("entity.diseaseGeneticModifierRelation.name", is(diseaseGeneticModifierRelation)). body("entity.with", hasSize(1)). body("entity.with[0].modEntityId", is(withGene)). @@ -282,7 +284,8 @@ public void alleleDiseaseAnnotationBulkUploadCheckFields() throws Exception { body("entity.createdBy.uniqueId", is("DATEST:Person0001")). body("entity.dateUpdated", is(OffsetDateTime.parse("2022-03-10T22:10:12Z").toString())). body("entity.dateCreated", is(OffsetDateTime.parse("2022-03-09T22:10:12Z").toString())). - body("entity.uniqueId", is("DATEST:Allele0001|is_implicated_in|true|DATEST:Disease0001|AGRKB:000000002|DATEST:Evidence0001|HGNC:0001|exacerbated_by|DATEST:ExpCondTerm0001|DATEST:ExpCondTerm0002|DATEST:AnatomyTerm0001|DATEST:ChemicalTerm0001|DATEST:GOTerm0001|NCBITaxon:6239|Some amount|Free text|susceptibility|ameliorated_by|DATEST:Gene0002")). + body("entity.uniqueId", + is("DATEST:Allele0001|is_implicated_in|true|DATEST:Disease0001|AGRKB:000000002|DATEST:Evidence0001|HGNC:0001|exacerbated_by|DATEST:ExpCondTerm0001|DATEST:ExpCondTerm0002|DATEST:AnatomyTerm0001|DATEST:ChemicalTerm0001|DATEST:GOTerm0001|NCBITaxon:6239|Some amount|Free text|susceptibility|ameliorated_by|DATEST:AGM0002|DATEST:Allele0002|DATEST:Gene0002")). body("entity.diseaseAnnotationSubject.modEntityId", is(allele)). body("entity.diseaseAnnotationObject.curie", is(doTerm)). body("entity.relation.name", is(alleleAndGeneRelation)). @@ -314,7 +317,9 @@ public void alleleDiseaseAnnotationBulkUploadCheckFields() throws Exception { body("entity.conditionRelations[0].conditions[0].conditionChemical.curie", is(chemicalTerm)). body("entity.conditionRelations[0].conditions[0].conditionFreeText", is("Free text")). body("entity.conditionRelations[0].conditions[0].conditionSummary", is("Test ExperimentalConditionOntologyTerm:Test ExperimentalConditionOntologyTerm:Test AnatomicalTerm:Test GOTerm:Test ChemicalTerm:Caenorhabditis elegans:Some amount:Free text")). - body("entity.diseaseGeneticModifiers[0].modEntityId", is(gene2)). + body("entity.diseaseGeneticModifierAgms[0].modEntityId", is(agm2)). + body("entity.diseaseGeneticModifierAlleles[0].modEntityId", is(allele2)). + body("entity.diseaseGeneticModifierGenes[0].modEntityId", is(gene2)). body("entity.diseaseGeneticModifierRelation.name", is(diseaseGeneticModifierRelation)). body("entity.with", hasSize(1)). body("entity.with[0].modEntityId", is(withGene)). @@ -363,7 +368,7 @@ public void agmDiseaseAnnotationBulkUploadCheckFields() throws Exception { body("entity.createdBy.uniqueId", is("DATEST:Person0001")). body("entity.dateUpdated", is(OffsetDateTime.parse("2022-03-10T22:10:12Z").toString())). body("entity.dateCreated", is(OffsetDateTime.parse("2022-03-09T22:10:12Z").toString())). - body("entity.uniqueId", is("DATEST:AGM0001|is_model_of|true|DATEST:Disease0001|AGRKB:000000002|DATEST:Evidence0001|HGNC:0001|exacerbated_by|DATEST:ExpCondTerm0001|DATEST:ExpCondTerm0002|DATEST:AnatomyTerm0001|DATEST:ChemicalTerm0001|DATEST:GOTerm0001|NCBITaxon:6239|Some amount|Free text|susceptibility|ameliorated_by|DATEST:Gene0002")). + body("entity.uniqueId", is("DATEST:AGM0001|is_model_of|true|DATEST:Disease0001|AGRKB:000000002|DATEST:Evidence0001|HGNC:0001|exacerbated_by|DATEST:ExpCondTerm0001|DATEST:ExpCondTerm0002|DATEST:AnatomyTerm0001|DATEST:ChemicalTerm0001|DATEST:GOTerm0001|NCBITaxon:6239|Some amount|Free text|susceptibility|ameliorated_by|DATEST:AGM0002|DATEST:Allele0002|DATEST:Gene0002")). body("entity.diseaseAnnotationSubject.modEntityId", is(agm)). body("entity.diseaseAnnotationObject.curie", is(doTerm)). body("entity.relation.name", is(agmRelation)). @@ -395,7 +400,9 @@ public void agmDiseaseAnnotationBulkUploadCheckFields() throws Exception { body("entity.conditionRelations[0].conditions[0].conditionChemical.curie", is(chemicalTerm)). body("entity.conditionRelations[0].conditions[0].conditionFreeText", is("Free text")). body("entity.conditionRelations[0].conditions[0].conditionSummary", is("Test ExperimentalConditionOntologyTerm:Test ExperimentalConditionOntologyTerm:Test AnatomicalTerm:Test GOTerm:Test ChemicalTerm:Caenorhabditis elegans:Some amount:Free text")). - body("entity.diseaseGeneticModifiers[0].modEntityId", is(gene2)). + body("entity.diseaseGeneticModifierAgms[0].modEntityId", is(agm2)). + body("entity.diseaseGeneticModifierAlleles[0].modEntityId", is(allele2)). + body("entity.diseaseGeneticModifierGenes[0].modEntityId", is(gene2)). body("entity.diseaseGeneticModifierRelation.name", is(diseaseGeneticModifierRelation)). body("entity.with", hasSize(1)). body("entity.with[0].modEntityId", is(withGene)). @@ -446,7 +453,8 @@ public void geneDiseaseAnnotationBulkUploadUpdateCheckFields() throws Exception body("entity.createdBy.uniqueId", is("DATEST:Person0002")). body("entity.dateUpdated", is(OffsetDateTime.parse("2022-03-20T22:10:12Z").toString())). body("entity.dateCreated", is(OffsetDateTime.parse("2022-03-19T22:10:12Z").toString())). - body("entity.uniqueId", is("DATEST:Gene0002|is_marker_for|false|DATEST:Disease0002|AGRKB:000000021|DATEST:Evidence0002|HGNC:0002|induced_by|DATEST:ExpCondTerm0003|DATEST:ExpCondTerm0001|DATEST:AnatomyTerm0002|DATEST:ChemicalTerm0002|DATEST:GOTerm0002|NCBITaxon:9606|Some amount 2|Free text 2|severity|exacerbated_by|DATEST:Gene0001|SGD:AGM0002")). + body("entity.uniqueId", + is("DATEST:Gene0002|is_marker_for|false|DATEST:Disease0002|AGRKB:000000021|DATEST:Evidence0002|HGNC:0002|induced_by|DATEST:ExpCondTerm0003|DATEST:ExpCondTerm0001|DATEST:AnatomyTerm0002|DATEST:ChemicalTerm0002|DATEST:GOTerm0002|NCBITaxon:9606|Some amount 2|Free text 2|severity|exacerbated_by|DATEST:AGM0001|DATEST:Allele0001|DATEST:Gene0001|SGD:AGM0002")). body("entity.diseaseAnnotationSubject.modEntityId", is(gene2)). body("entity.diseaseAnnotationObject.curie", is(doTerm2)). body("entity.relation.name", is(geneRelation)). @@ -478,7 +486,9 @@ public void geneDiseaseAnnotationBulkUploadUpdateCheckFields() throws Exception body("entity.conditionRelations[0].conditions[0].conditionChemical.curie", is(chemicalTerm2)). body("entity.conditionRelations[0].conditions[0].conditionFreeText", is("Free text 2")). body("entity.conditionRelations[0].conditions[0].conditionSummary", is("Test ExperimentalConditionOntologyTerm 2:Test ExperimentalConditionOntologyTerm:Test AnatomicalTerm 2:Test GOTerm 2:Test ChemicalTerm 2:Homo sapiens:Some amount 2:Free text 2")). - body("entity.diseaseGeneticModifiers[0].modEntityId", is(gene)). + body("entity.diseaseGeneticModifierAgms[0].modEntityId", is(agm)). + body("entity.diseaseGeneticModifierAlleles[0].modEntityId", is(allele)). + body("entity.diseaseGeneticModifierGenes[0].modEntityId", is(gene)). body("entity.diseaseGeneticModifierRelation.name", is(diseaseGeneticModifierRelation2)). body("entity.with", hasSize(1)). body("entity.with[0].modEntityId", is(withGene2)). @@ -526,7 +536,7 @@ public void alleleDiseaseAnnotationBulkUploadUpdateCheckFields() throws Exceptio body("entity.createdBy.uniqueId", is("DATEST:Person0002")). body("entity.dateUpdated", is(OffsetDateTime.parse("2022-03-20T22:10:12Z").toString())). body("entity.dateCreated", is(OffsetDateTime.parse("2022-03-19T22:10:12Z").toString())). - body("entity.uniqueId", is("DATEST:Allele0002|is_implicated_in|false|DATEST:Disease0002|AGRKB:000000021|DATEST:Evidence0002|HGNC:0002|induced_by|DATEST:ExpCondTerm0003|DATEST:ExpCondTerm0001|DATEST:AnatomyTerm0002|DATEST:ChemicalTerm0002|DATEST:GOTerm0002|NCBITaxon:9606|Some amount 2|Free text 2|severity|exacerbated_by|DATEST:Gene0001")). + body("entity.uniqueId", is("DATEST:Allele0002|is_implicated_in|false|DATEST:Disease0002|AGRKB:000000021|DATEST:Evidence0002|HGNC:0002|induced_by|DATEST:ExpCondTerm0003|DATEST:ExpCondTerm0001|DATEST:AnatomyTerm0002|DATEST:ChemicalTerm0002|DATEST:GOTerm0002|NCBITaxon:9606|Some amount 2|Free text 2|severity|exacerbated_by|DATEST:AGM0001|DATEST:Allele0001|DATEST:Gene0001")). body("entity.diseaseAnnotationSubject.modEntityId", is(allele2)). body("entity.diseaseAnnotationObject.curie", is(doTerm2)). body("entity.relation.name", is(alleleAndGeneRelation)). @@ -558,7 +568,9 @@ public void alleleDiseaseAnnotationBulkUploadUpdateCheckFields() throws Exceptio body("entity.conditionRelations[0].conditions[0].conditionChemical.curie", is(chemicalTerm2)). body("entity.conditionRelations[0].conditions[0].conditionFreeText", is("Free text 2")). body("entity.conditionRelations[0].conditions[0].conditionSummary", is("Test ExperimentalConditionOntologyTerm 2:Test ExperimentalConditionOntologyTerm:Test AnatomicalTerm 2:Test GOTerm 2:Test ChemicalTerm 2:Homo sapiens:Some amount 2:Free text 2")). - body("entity.diseaseGeneticModifiers[0].modEntityId", is(gene)). + body("entity.diseaseGeneticModifierAgms[0].modEntityId", is(agm)). + body("entity.diseaseGeneticModifierAlleles[0].modEntityId", is(allele)). + body("entity.diseaseGeneticModifierGenes[0].modEntityId", is(gene)). body("entity.diseaseGeneticModifierRelation.name", is(diseaseGeneticModifierRelation2)). body("entity.with", hasSize(1)). body("entity.with[0].modEntityId", is(withGene2)). @@ -607,7 +619,8 @@ public void agmDiseaseAnnotationBulkUploadUpdateCheckFields() throws Exception { body("entity.createdBy.uniqueId", is("DATEST:Person0002")). body("entity.dateUpdated", is(OffsetDateTime.parse("2022-03-20T22:10:12Z").toString())). body("entity.dateCreated", is(OffsetDateTime.parse("2022-03-19T22:10:12Z").toString())). - body("entity.uniqueId", is("DATEST:AGM0002|is_exacerbated_model_of|false|DATEST:Disease0002|AGRKB:000000021|DATEST:Evidence0002|HGNC:0002|induced_by|DATEST:ExpCondTerm0003|DATEST:ExpCondTerm0001|DATEST:AnatomyTerm0002|DATEST:ChemicalTerm0002|DATEST:GOTerm0002|NCBITaxon:9606|Some amount 2|Free text 2|severity|exacerbated_by|DATEST:Gene0001")). + body("entity.uniqueId", + is("DATEST:AGM0002|is_exacerbated_model_of|false|DATEST:Disease0002|AGRKB:000000021|DATEST:Evidence0002|HGNC:0002|induced_by|DATEST:ExpCondTerm0003|DATEST:ExpCondTerm0001|DATEST:AnatomyTerm0002|DATEST:ChemicalTerm0002|DATEST:GOTerm0002|NCBITaxon:9606|Some amount 2|Free text 2|severity|exacerbated_by|DATEST:AGM0001|DATEST:Allele0001|DATEST:Gene0001")). body("entity.diseaseAnnotationSubject.modEntityId", is(agm2)). body("entity.diseaseAnnotationObject.curie", is(doTerm2)). body("entity.relation.name", is(agmRelation2)). @@ -639,7 +652,9 @@ public void agmDiseaseAnnotationBulkUploadUpdateCheckFields() throws Exception { body("entity.conditionRelations[0].conditions[0].conditionChemical.curie", is(chemicalTerm2)). body("entity.conditionRelations[0].conditions[0].conditionFreeText", is("Free text 2")). body("entity.conditionRelations[0].conditions[0].conditionSummary", is("Test ExperimentalConditionOntologyTerm 2:Test ExperimentalConditionOntologyTerm:Test AnatomicalTerm 2:Test GOTerm 2:Test ChemicalTerm 2:Homo sapiens:Some amount 2:Free text 2")). - body("entity.diseaseGeneticModifiers[0].modEntityId", is(gene)). + body("entity.diseaseGeneticModifierAgms[0].modEntityId", is(agm)). + body("entity.diseaseGeneticModifierAlleles[0].modEntityId", is(allele)). + body("entity.diseaseGeneticModifierGenes[0].modEntityId", is(gene)). body("entity.diseaseGeneticModifierRelation.name", is(diseaseGeneticModifierRelation2)). body("entity.with", hasSize(1)). body("entity.with[0].modEntityId", is(withGene2)). @@ -818,7 +833,9 @@ public void geneDiseaseAnnotationUpdateMissingNonRequiredFieldsLevel1() throws E body("entity", not(hasKey("geneticSex"))). body("entity", not(hasKey("secondaryDataProvider"))). body("entity", not(hasKey("conditionRelations"))). - body("entity", not(hasKey("diseaseGeneticModifiers"))). + body("entity", not(hasKey("diseaseGeneticModifierAgms"))). + body("entity", not(hasKey("diseaseGeneticModifierAlleles"))). + body("entity", not(hasKey("diseaseGeneticModifierGenes"))). body("entity", not(hasKey("diseaseGeneticModifierRelation"))). body("entity", not(hasKey("with"))). body("entity", not(hasKey("relatedNotes"))). @@ -846,7 +863,9 @@ public void alleleDiseaseAnnotationUpdateMissingNonRequiredFieldsLevel1() throws body("entity", not(hasKey("geneticSex"))). body("entity", not(hasKey("secondaryDataProvider"))). body("entity", not(hasKey("conditionRelations"))). - body("entity", not(hasKey("diseaseGeneticModifiers"))). + body("entity", not(hasKey("diseaseGeneticModifierAgms"))). + body("entity", not(hasKey("diseaseGeneticModifierAlleles"))). + body("entity", not(hasKey("diseaseGeneticModifierGenes"))). body("entity", not(hasKey("diseaseGeneticModifierRelation"))). body("entity", not(hasKey("with"))). body("entity", not(hasKey("relatedNotes"))). @@ -875,7 +894,9 @@ public void agmDiseaseAnnotationUpdateMissingNonRequiredFieldsLevel1() throws Ex body("entity", not(hasKey("geneticSex"))). body("entity", not(hasKey("secondaryDataProvider"))). body("entity", not(hasKey("conditionRelations"))). - body("entity", not(hasKey("diseaseGeneticModifiers"))). + body("entity", not(hasKey("diseaseGeneticModifierAgms"))). + body("entity", not(hasKey("diseaseGeneticModifierAlleles"))). + body("entity", not(hasKey("diseaseGeneticModifierGenes"))). body("entity", not(hasKey("diseaseGeneticModifierRelation"))). body("entity", not(hasKey("with"))). body("entity", not(hasKey("relatedNotes"))). @@ -944,7 +965,9 @@ public void geneDiseaseAnnotationUpdateEmptyNonRequiredFieldsLevel1() throws Exc body("entity", not(hasKey("geneticSex"))). body("entity", not(hasKey("secondaryDataProvider"))). body("entity", not(hasKey("conditionRelations"))). - body("entity", not(hasKey("diseaseGeneticModifiers"))). + body("entity", not(hasKey("diseaseGeneticModifierAgms"))). + body("entity", not(hasKey("diseaseGeneticModifierAlleles"))). + body("entity", not(hasKey("diseaseGeneticModifierGenes"))). body("entity", not(hasKey("diseaseGeneticModifierRelation"))). body("entity", not(hasKey("with"))). body("entity", not(hasKey("relatedNotes"))). @@ -972,7 +995,9 @@ public void alleleDiseaseAnnotationUpdateEmptyNonRequiredFieldsLevel1() throws E body("entity", not(hasKey("geneticSex"))). body("entity", not(hasKey("secondaryDataProvider"))). body("entity", not(hasKey("conditionRelations"))). - body("entity", not(hasKey("diseaseGeneticModifiers"))). + body("entity", not(hasKey("diseaseGeneticModifierAgms"))). + body("entity", not(hasKey("diseaseGeneticModifierAlleles"))). + body("entity", not(hasKey("diseaseGeneticModifierGenes"))). body("entity", not(hasKey("diseaseGeneticModifierRelation"))). body("entity", not(hasKey("with"))). body("entity", not(hasKey("relatedNotes"))). @@ -1001,7 +1026,9 @@ public void agmDiseaseAnnotationUpdateEmptyNonRequiredFieldsLevel1() throws Exce body("entity", not(hasKey("geneticSex"))). body("entity", not(hasKey("secondaryDataProvider"))). body("entity", not(hasKey("conditionRelations"))). - body("entity", not(hasKey("diseaseGeneticModifiers"))). + body("entity", not(hasKey("diseaseGeneticModifierAgms"))). + body("entity", not(hasKey("diseaseGeneticModifierAlleles"))). + body("entity", not(hasKey("diseaseGeneticModifierGenes"))). body("entity", not(hasKey("diseaseGeneticModifierRelation"))). body("entity", not(hasKey("with"))). body("entity", not(hasKey("relatedNotes"))). diff --git a/src/test/java/org/alliancegenome/curation_api/DiseaseAnnotationITCase.java b/src/test/java/org/alliancegenome/curation_api/DiseaseAnnotationITCase.java index a35498688..9efcb43e0 100644 --- a/src/test/java/org/alliancegenome/curation_api/DiseaseAnnotationITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/DiseaseAnnotationITCase.java @@ -129,7 +129,7 @@ public class DiseaseAnnotationITCase extends BaseITCase { private ExperimentalCondition nonPersistedCondition; - private void loadRequiredEntities() { + private void loadRequiredEntities() throws Exception { reference = createReference("AGRKB:100000005", false); reference2 = createReference("AGRKB:100000006", false); obsoleteReference = createReference("AGRKB:100000009", true); @@ -142,20 +142,20 @@ private void loadRequiredEntities() { unsupportedEcoTerm = createEcoTerm("ECO:da00004", "Test unsupported evidence code", false, false); nameTypeVocabulary = getVocabulary(VocabularyConstants.NAME_TYPE_VOCABULARY); symbolNameType = getVocabularyTerm(nameTypeVocabulary, "nomenclature_symbol"); - gene = createGene("GENE:da0001", "NCBITaxon:9606", false, symbolNameType); - gene2 = createGene("GENE:da0002", "NCBITaxon:9606", false, symbolNameType); - obsoleteGene = createGene("HGNC:da0003", "NCBITaxon:9606", true, symbolNameType); - withGene = createGene("HGNC:1", "NCBITaxon:9606", false, symbolNameType); - withGene2 = createGene("HGNC:2", "NCBITaxon:9606", false, symbolNameType); - allele = createAllele("ALLELE:da0001", "NCBITaxon:9606", false, symbolNameType); - allele2 = createAllele("ALLELE:da0002", "NCBITaxon:9606", false, symbolNameType); - obsoleteAllele = createAllele("ALLELE:da0003", "NCBITaxon:9606", true, symbolNameType); + gene = createGene("GENE:da0001", "NCBITaxon:9606", symbolNameType, false); + gene2 = createGene("GENE:da0002", "NCBITaxon:9606", symbolNameType, false); + obsoleteGene = createGene("HGNC:da0003", "NCBITaxon:9606", symbolNameType, true); + withGene = createGene("HGNC:1", "NCBITaxon:9606", symbolNameType, false); + withGene2 = createGene("HGNC:2", "NCBITaxon:9606", symbolNameType, false); + allele = createAllele("ALLELE:da0001", "NCBITaxon:9606", symbolNameType, false); + allele2 = createAllele("ALLELE:da0002", "NCBITaxon:9606", symbolNameType, false); + obsoleteAllele = createAllele("ALLELE:da0003", "NCBITaxon:9606", symbolNameType, true); datetime = OffsetDateTime.parse("2022-03-09T22:10:12+00:00"); datetime2 = OffsetDateTime.parse("2022-04-10T22:10:11+00:00"); - agm = createAffectedGenomicModel("SGD:da0001", "NCBITaxon:559292", "strain", "TestAGM", false); - agm2 = createAffectedGenomicModel("SGD:da0002", "NCBITaxon:559292", "strain", "TestAGM2", false); - obsoleteAgm = createAffectedGenomicModel("SGD:da0003", "NCBITaxon:559292", "strain", "TestAGM3", true); - nonSgdAgm = createAffectedGenomicModel("WB:da0004", "NCBITaxon:6239", "genotype", "TestAGM4", false); + agm = createAffectedGenomicModel("SGD:da0001", "TestAGM", "NCBITaxon:559292", "strain", false); + agm2 = createAffectedGenomicModel("SGD:da0002", "TestAGM2", "NCBITaxon:559292", "strain", false); + obsoleteAgm = createAffectedGenomicModel("SGD:da0003", "TestAGM3", "NCBITaxon:559292", "strain", true); + nonSgdAgm = createAffectedGenomicModel("WB:da0004", "TestAGM4", "NCBITaxon:6239", "genotype", false); experimentalCondition = createExperimentalCondition("Statement", "ZECO:da001", "Test"); experimentalCondition2 = createExperimentalCondition("Statement2", "ZECO:da002", "Test2"); relationVocabulary = getVocabulary(VocabularyConstants.DISEASE_RELATION_VOCABULARY); @@ -217,7 +217,7 @@ private void loadRequiredEntities() { @Test @Order(1) - public void createGeneDiseaseAnnotation() { + public void createGeneDiseaseAnnotation() throws Exception { loadRequiredEntities(); GeneDiseaseAnnotation diseaseAnnotation = new GeneDiseaseAnnotation(); @@ -238,7 +238,9 @@ public void createGeneDiseaseAnnotation() { diseaseAnnotation.setAnnotationType(annotationType); diseaseAnnotation.setDiseaseQualifiers(List.of(diseaseQualifier)); diseaseAnnotation.setGeneticSex(geneticSex); - diseaseAnnotation.setDiseaseGeneticModifiers(List.of(agm2)); + diseaseAnnotation.setDiseaseGeneticModifierAgms(List.of(agm2)); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(List.of(allele2)); + diseaseAnnotation.setDiseaseGeneticModifierGenes(List.of(gene2)); diseaseAnnotation.setDiseaseGeneticModifierRelation(diseaseGeneticModifierRelation); RestAssured.given(). @@ -253,7 +255,7 @@ public void createGeneDiseaseAnnotation() { get("/api/gene-disease-annotation/findBy/" + GENE_DISEASE_ANNOTATION). then(). statusCode(200). - body("entity.uniqueId", is("GENE:da0001|is_implicated_in|false|DOID:da0001|AGRKB:100000005|ECO:da00001|HGNC:1|has_condition|ZECO:da001|severity|ameliorated_by|SGD:da0001|SGD:da0002")). + body("entity.uniqueId", is("GENE:da0001|is_implicated_in|false|DOID:da0001|AGRKB:100000005|ECO:da00001|HGNC:1|has_condition|ZECO:da001|severity|ameliorated_by|SGD:da0001|ALLELE:da0002|GENE:da0002|SGD:da0002")). body("entity.modEntityId", is(GENE_DISEASE_ANNOTATION)). body("entity.diseaseAnnotationSubject.modEntityId", is(gene.getModEntityId())). body("entity.diseaseAnnotationObject.curie", is(doTerm.getCurie())). @@ -268,7 +270,9 @@ public void createGeneDiseaseAnnotation() { body("entity.dateCreated", is(datetime.toString())). body("entity.geneticSex.name", is(geneticSex.getName())). body("entity.diseaseGeneticModifierRelation.name", is(diseaseGeneticModifierRelation.getName())). - body("entity.diseaseGeneticModifiers[0].modEntityId", is(agm2.getModEntityId())). + body("entity.diseaseGeneticModifierAgms[0].modEntityId", is(agm2.getModEntityId())). + body("entity.diseaseGeneticModifierAlleles[0].modEntityId", is(allele2.getModEntityId())). + body("entity.diseaseGeneticModifierGenes[0].modEntityId", is(gene2.getModEntityId())). body("entity.annotationType.name", is(annotationType.getName())). body("entity.diseaseQualifiers[0].name", is(diseaseQualifier.getName())). body("entity.with[0].modEntityId", is(withGene.getModEntityId())). @@ -307,7 +311,9 @@ public void createAlleleDiseaseAnnotation() { diseaseAnnotation.setAnnotationType(annotationType); diseaseAnnotation.setDiseaseQualifiers(List.of(diseaseQualifier)); diseaseAnnotation.setGeneticSex(geneticSex); - diseaseAnnotation.setDiseaseGeneticModifiers(List.of(agm2)); + diseaseAnnotation.setDiseaseGeneticModifierAgms(List.of(agm2)); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(List.of(allele2)); + diseaseAnnotation.setDiseaseGeneticModifierGenes(List.of(gene2)); diseaseAnnotation.setDiseaseGeneticModifierRelation(diseaseGeneticModifierRelation); diseaseAnnotation.setInferredGene(gene); diseaseAnnotation.setAssertedGenes(List.of(gene2)); @@ -324,7 +330,7 @@ public void createAlleleDiseaseAnnotation() { get("/api/allele-disease-annotation/findBy/" + ALLELE_DISEASE_ANNOTATION). then(). statusCode(200). - body("entity.uniqueId", is("ALLELE:da0001|is_implicated_in|false|DOID:da0001|AGRKB:100000005|ECO:da00001|HGNC:1|has_condition|ZECO:da001|severity|ameliorated_by|SGD:da0002")). + body("entity.uniqueId", is("ALLELE:da0001|is_implicated_in|false|DOID:da0001|AGRKB:100000005|ECO:da00001|HGNC:1|has_condition|ZECO:da001|severity|ameliorated_by|ALLELE:da0002|GENE:da0002|SGD:da0002")). body("entity.modEntityId", is(ALLELE_DISEASE_ANNOTATION)). body("entity.diseaseAnnotationSubject.modEntityId", is(allele.getModEntityId())). body("entity.diseaseAnnotationObject.curie", is(doTerm.getCurie())). @@ -339,7 +345,9 @@ public void createAlleleDiseaseAnnotation() { body("entity.dateCreated", is(datetime.toString())). body("entity.geneticSex.name", is(geneticSex.getName())). body("entity.diseaseGeneticModifierRelation.name", is(diseaseGeneticModifierRelation.getName())). - body("entity.diseaseGeneticModifiers[0].modEntityId", is(agm2.getModEntityId())). + body("entity.diseaseGeneticModifierAgms[0].modEntityId", is(agm2.getModEntityId())). + body("entity.diseaseGeneticModifierAlleles[0].modEntityId", is(allele2.getModEntityId())). + body("entity.diseaseGeneticModifierGenes[0].modEntityId", is(gene2.getModEntityId())). body("entity.annotationType.name", is(annotationType.getName())). body("entity.diseaseQualifiers[0].name", is(diseaseQualifier.getName())). body("entity.with[0].modEntityId", is(withGene.getModEntityId())). @@ -380,7 +388,9 @@ public void createAgmDiseaseAnnotation() { diseaseAnnotation.setAnnotationType(annotationType); diseaseAnnotation.setDiseaseQualifiers(List.of(diseaseQualifier)); diseaseAnnotation.setGeneticSex(geneticSex); - diseaseAnnotation.setDiseaseGeneticModifiers(List.of(agm2)); + diseaseAnnotation.setDiseaseGeneticModifierAgms(List.of(agm2)); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(List.of(allele2)); + diseaseAnnotation.setDiseaseGeneticModifierGenes(List.of(gene2)); diseaseAnnotation.setDiseaseGeneticModifierRelation(diseaseGeneticModifierRelation); diseaseAnnotation.setInferredGene(gene); diseaseAnnotation.setAssertedGenes(List.of(gene2)); @@ -399,7 +409,7 @@ public void createAgmDiseaseAnnotation() { get("/api/agm-disease-annotation/findBy/" + AGM_DISEASE_ANNOTATION). then(). statusCode(200). - body("entity.uniqueId", is("SGD:da0001|is_model_of|false|DOID:da0001|AGRKB:100000005|ECO:da00001|HGNC:1|has_condition|ZECO:da001|severity|ameliorated_by|SGD:da0002")). + body("entity.uniqueId", is("SGD:da0001|is_model_of|false|DOID:da0001|AGRKB:100000005|ECO:da00001|HGNC:1|has_condition|ZECO:da001|severity|ameliorated_by|ALLELE:da0002|GENE:da0002|SGD:da0002")). body("entity.modEntityId", is(AGM_DISEASE_ANNOTATION)). body("entity.diseaseAnnotationSubject.modEntityId", is(agm.getModEntityId())). body("entity.diseaseAnnotationObject.curie", is(doTerm.getCurie())). @@ -414,7 +424,9 @@ public void createAgmDiseaseAnnotation() { body("entity.dateCreated", is(datetime.toString())). body("entity.geneticSex.name", is(geneticSex.getName())). body("entity.diseaseGeneticModifierRelation.name", is(diseaseGeneticModifierRelation.getName())). - body("entity.diseaseGeneticModifiers[0].modEntityId", is(agm2.getModEntityId())). + body("entity.diseaseGeneticModifierAgms[0].modEntityId", is(agm2.getModEntityId())). + body("entity.diseaseGeneticModifierAlleles[0].modEntityId", is(allele2.getModEntityId())). + body("entity.diseaseGeneticModifierGenes[0].modEntityId", is(gene2.getModEntityId())). body("entity.annotationType.name", is(annotationType.getName())). body("entity.diseaseQualifiers[0].name", is(diseaseQualifier.getName())). body("entity.with[0].modEntityId", is(withGene.getModEntityId())). @@ -458,7 +470,9 @@ public void editGeneDiseaseAnnotation() { diseaseAnnotation.setAnnotationType(annotationType2); diseaseAnnotation.setDiseaseQualifiers(List.of(diseaseQualifier2)); diseaseAnnotation.setGeneticSex(geneticSex2); - diseaseAnnotation.setDiseaseGeneticModifiers(List.of(agm)); + diseaseAnnotation.setDiseaseGeneticModifierAgms(List.of(agm)); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(List.of(allele)); + diseaseAnnotation.setDiseaseGeneticModifierGenes(List.of(gene)); diseaseAnnotation.setDiseaseGeneticModifierRelation(diseaseGeneticModifierRelation2); Note editedNote = diseaseAnnotation.getRelatedNotes().get(0); @@ -487,7 +501,7 @@ public void editGeneDiseaseAnnotation() { get("/api/gene-disease-annotation/findBy/" + GENE_DISEASE_ANNOTATION). then(). statusCode(200). - body("entity.uniqueId", is("GENE:da0002|is_marker_for|true|DOID:da0002|AGRKB:100000006|ECO:da00002|HGNC:2|induced_by|ZECO:da002|onset|exacerbated_by|SGD:da0002|SGD:da0001")). + body("entity.uniqueId", is("GENE:da0002|is_marker_for|true|DOID:da0002|AGRKB:100000006|ECO:da00002|HGNC:2|induced_by|ZECO:da002|onset|exacerbated_by|SGD:da0002|ALLELE:da0001|GENE:da0001|SGD:da0001")). body("entity.modEntityId", is(GENE_DISEASE_ANNOTATION)). body("entity.diseaseAnnotationSubject.modEntityId", is(gene2.getModEntityId())). body("entity.diseaseAnnotationObject.curie", is(doTerm2.getCurie())). @@ -502,7 +516,9 @@ public void editGeneDiseaseAnnotation() { body("entity.dateCreated", is(datetime2.toString())). body("entity.geneticSex.name", is(geneticSex2.getName())). body("entity.diseaseGeneticModifierRelation.name", is(diseaseGeneticModifierRelation2.getName())). - body("entity.diseaseGeneticModifiers[0].modEntityId", is(agm.getModEntityId())). + body("entity.diseaseGeneticModifierAgms[0].modEntityId", is(agm.getModEntityId())). + body("entity.diseaseGeneticModifierAlleles[0].modEntityId", is(allele.getModEntityId())). + body("entity.diseaseGeneticModifierGenes[0].modEntityId", is(gene.getModEntityId())). body("entity.annotationType.name", is(annotationType2.getName())). body("entity.diseaseQualifiers[0].name", is(diseaseQualifier2.getName())). body("entity.with[0].modEntityId", is(withGene2.getModEntityId())). @@ -540,7 +556,9 @@ public void editAlleleDiseaseAnnotation() { diseaseAnnotation.setAnnotationType(annotationType2); diseaseAnnotation.setDiseaseQualifiers(List.of(diseaseQualifier2)); diseaseAnnotation.setGeneticSex(geneticSex2); - diseaseAnnotation.setDiseaseGeneticModifiers(List.of(agm)); + diseaseAnnotation.setDiseaseGeneticModifierAgms(List.of(agm)); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(List.of(allele)); + diseaseAnnotation.setDiseaseGeneticModifierGenes(List.of(gene)); diseaseAnnotation.setDiseaseGeneticModifierRelation(diseaseGeneticModifierRelation2); diseaseAnnotation.setInferredGene(gene2); diseaseAnnotation.setAssertedGenes(List.of(gene)); @@ -571,7 +589,7 @@ public void editAlleleDiseaseAnnotation() { get("/api/allele-disease-annotation/findBy/" + ALLELE_DISEASE_ANNOTATION). then(). statusCode(200). - body("entity.uniqueId", is("ALLELE:da0002|is_implicated_in|true|DOID:da0002|AGRKB:100000006|ECO:da00002|HGNC:2|induced_by|ZECO:da002|onset|exacerbated_by|SGD:da0001")). + body("entity.uniqueId", is("ALLELE:da0002|is_implicated_in|true|DOID:da0002|AGRKB:100000006|ECO:da00002|HGNC:2|induced_by|ZECO:da002|onset|exacerbated_by|ALLELE:da0001|GENE:da0001|SGD:da0001")). body("entity.modEntityId", is(ALLELE_DISEASE_ANNOTATION)). body("entity.diseaseAnnotationSubject.modEntityId", is(allele2.getModEntityId())). body("entity.diseaseAnnotationObject.curie", is(doTerm2.getCurie())). @@ -586,7 +604,9 @@ public void editAlleleDiseaseAnnotation() { body("entity.dateCreated", is(datetime2.toString())). body("entity.geneticSex.name", is(geneticSex2.getName())). body("entity.diseaseGeneticModifierRelation.name", is(diseaseGeneticModifierRelation2.getName())). - body("entity.diseaseGeneticModifiers[0].modEntityId", is(agm.getModEntityId())). + body("entity.diseaseGeneticModifierAgms[0].modEntityId", is(agm.getModEntityId())). + body("entity.diseaseGeneticModifierAlleles[0].modEntityId", is(allele.getModEntityId())). + body("entity.diseaseGeneticModifierGenes[0].modEntityId", is(gene.getModEntityId())). body("entity.annotationType.name", is(annotationType2.getName())). body("entity.diseaseQualifiers[0].name", is(diseaseQualifier2.getName())). body("entity.with[0].modEntityId", is(withGene2.getModEntityId())). @@ -627,7 +647,9 @@ public void editAgmDiseaseAnnotation() { diseaseAnnotation.setAnnotationType(annotationType2); diseaseAnnotation.setDiseaseQualifiers(List.of(diseaseQualifier2)); diseaseAnnotation.setGeneticSex(geneticSex2); - diseaseAnnotation.setDiseaseGeneticModifiers(List.of(agm)); + diseaseAnnotation.setDiseaseGeneticModifierAgms(List.of(agm)); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(List.of(allele)); + diseaseAnnotation.setDiseaseGeneticModifierGenes(List.of(gene)); diseaseAnnotation.setDiseaseGeneticModifierRelation(diseaseGeneticModifierRelation2); diseaseAnnotation.setInferredGene(gene2); diseaseAnnotation.setAssertedGenes(List.of(gene)); @@ -660,7 +682,7 @@ public void editAgmDiseaseAnnotation() { get("/api/agm-disease-annotation/findBy/" + AGM_DISEASE_ANNOTATION). then(). statusCode(200). - body("entity.uniqueId", is("SGD:da0002|is_exacerbated_model_of|true|DOID:da0002|AGRKB:100000006|ECO:da00002|HGNC:2|induced_by|ZECO:da002|onset|exacerbated_by|SGD:da0001")). + body("entity.uniqueId", is("SGD:da0002|is_exacerbated_model_of|true|DOID:da0002|AGRKB:100000006|ECO:da00002|HGNC:2|induced_by|ZECO:da002|onset|exacerbated_by|ALLELE:da0001|GENE:da0001|SGD:da0001")). body("entity.modEntityId", is(AGM_DISEASE_ANNOTATION)). body("entity.diseaseAnnotationSubject.modEntityId", is(agm2.getModEntityId())). body("entity.diseaseAnnotationObject.curie", is(doTerm2.getCurie())). @@ -675,7 +697,9 @@ public void editAgmDiseaseAnnotation() { body("entity.dateCreated", is(datetime2.toString())). body("entity.geneticSex.name", is(geneticSex2.getName())). body("entity.diseaseGeneticModifierRelation.name", is(diseaseGeneticModifierRelation2.getName())). - body("entity.diseaseGeneticModifiers[0].modEntityId", is(agm.getModEntityId())). + body("entity.diseaseGeneticModifierAgms[0].modEntityId", is(agm.getModEntityId())). + body("entity.diseaseGeneticModifierAlleles[0].modEntityId", is(allele.getModEntityId())). + body("entity.diseaseGeneticModifierGenes[0].modEntityId", is(gene.getModEntityId())). body("entity.annotationType.name", is(annotationType2.getName())). body("entity.diseaseQualifiers[0].name", is(diseaseQualifier2.getName())). body("entity.with[0].modEntityId", is(withGene2.getModEntityId())). @@ -1232,7 +1256,9 @@ public void createGeneDiseaseAnnotationWithInvalidFields() { diseaseAnnotation.setAnnotationType(diseaseQualifier); diseaseAnnotation.setDiseaseQualifiers(List.of(geneticSex)); diseaseAnnotation.setGeneticSex(annotationType); - diseaseAnnotation.setDiseaseGeneticModifiers(List.of(nonPersistedAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAgms(List.of(nonPersistedAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(List.of(nonPersistedAllele)); + diseaseAnnotation.setDiseaseGeneticModifierGenes(List.of(nonPersistedGene)); diseaseAnnotation.setDiseaseGeneticModifierRelation(agmRelation); ConditionRelation newRelation = new ConditionRelation(); @@ -1254,7 +1280,7 @@ public void createGeneDiseaseAnnotationWithInvalidFields() { post("/api/gene-disease-annotation"). then(). statusCode(400). - body("errorMessages", is(aMapWithSize(16))). + body("errorMessages", is(aMapWithSize(18))). body("errorMessages.diseaseAnnotationSubject", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.diseaseAnnotationObject", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.relation", is(ValidationConstants.INVALID_MESSAGE)). @@ -1267,7 +1293,9 @@ public void createGeneDiseaseAnnotationWithInvalidFields() { body("errorMessages.annotationType", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.diseaseQualifiers", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.geneticSex", is(ValidationConstants.INVALID_MESSAGE)). - body("errorMessages.diseaseGeneticModifiers", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAgms", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAlleles", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.diseaseGeneticModifierGenes", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.diseaseGeneticModifierRelation", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.conditionRelations", is(String.join(" | ", List.of( "conditionRelationType - " + ValidationConstants.INVALID_MESSAGE, @@ -1295,7 +1323,9 @@ public void createAlleleDiseaseAnnotationWithInvalidFields() { diseaseAnnotation.setAnnotationType(diseaseQualifier); diseaseAnnotation.setDiseaseQualifiers(List.of(geneticSex)); diseaseAnnotation.setGeneticSex(annotationType); - diseaseAnnotation.setDiseaseGeneticModifiers(List.of(nonPersistedAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAgms(List.of(nonPersistedAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(List.of(nonPersistedAllele)); + diseaseAnnotation.setDiseaseGeneticModifierGenes(List.of(nonPersistedGene)); diseaseAnnotation.setDiseaseGeneticModifierRelation(agmRelation); diseaseAnnotation.setInferredGene(nonPersistedGene); diseaseAnnotation.setAssertedGenes(List.of(nonPersistedGene)); @@ -1319,7 +1349,7 @@ public void createAlleleDiseaseAnnotationWithInvalidFields() { post("/api/allele-disease-annotation"). then(). statusCode(400). - body("errorMessages", is(aMapWithSize(17))). + body("errorMessages", is(aMapWithSize(19))). body("errorMessages.diseaseAnnotationSubject", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.diseaseAnnotationObject", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.relation", is(ValidationConstants.INVALID_MESSAGE)). @@ -1331,7 +1361,9 @@ public void createAlleleDiseaseAnnotationWithInvalidFields() { body("errorMessages.annotationType", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.diseaseQualifiers", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.geneticSex", is(ValidationConstants.INVALID_MESSAGE)). - body("errorMessages.diseaseGeneticModifiers", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAgms", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAlleles", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.diseaseGeneticModifierGenes", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.diseaseGeneticModifierRelation", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.inferredGene", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.assertedGenes", is(ValidationConstants.INVALID_MESSAGE)). @@ -1361,7 +1393,9 @@ public void createAgmDiseaseAnnotationWithInvalidFields() { diseaseAnnotation.setAnnotationType(diseaseQualifier); diseaseAnnotation.setDiseaseQualifiers(List.of(geneticSex)); diseaseAnnotation.setGeneticSex(annotationType); - diseaseAnnotation.setDiseaseGeneticModifiers(List.of(nonPersistedAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAgms(List.of(nonPersistedAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(List.of(nonPersistedAllele)); + diseaseAnnotation.setDiseaseGeneticModifierGenes(List.of(nonPersistedGene)); diseaseAnnotation.setDiseaseGeneticModifierRelation(agmRelation); diseaseAnnotation.setInferredGene(nonPersistedGene); diseaseAnnotation.setAssertedGenes(List.of(nonPersistedGene)); @@ -1387,7 +1421,7 @@ public void createAgmDiseaseAnnotationWithInvalidFields() { post("/api/agm-disease-annotation"). then(). statusCode(400). - body("errorMessages", is(aMapWithSize(19))). + body("errorMessages", is(aMapWithSize(21))). body("errorMessages.diseaseAnnotationSubject", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.diseaseAnnotationObject", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.relation", is(ValidationConstants.INVALID_MESSAGE)). @@ -1399,7 +1433,9 @@ public void createAgmDiseaseAnnotationWithInvalidFields() { body("errorMessages.annotationType", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.diseaseQualifiers", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.geneticSex", is(ValidationConstants.INVALID_MESSAGE)). - body("errorMessages.diseaseGeneticModifiers", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAgms", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAlleles", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.diseaseGeneticModifierGenes", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.diseaseGeneticModifierRelation", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.inferredGene", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.assertedGenes", is(ValidationConstants.INVALID_MESSAGE)). @@ -1432,7 +1468,9 @@ public void editGeneDiseaseAnnotationWithInvalidFields() { diseaseAnnotation.setAnnotationType(diseaseQualifier); diseaseAnnotation.setDiseaseQualifiers(List.of(geneticSex)); diseaseAnnotation.setGeneticSex(annotationType); - diseaseAnnotation.setDiseaseGeneticModifiers(List.of(nonPersistedAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAgms(List.of(nonPersistedAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(List.of(nonPersistedAllele)); + diseaseAnnotation.setDiseaseGeneticModifierGenes(List.of(nonPersistedGene)); diseaseAnnotation.setDiseaseGeneticModifierRelation(agmRelation); ConditionRelation editedRelation = diseaseAnnotation.getConditionRelations().get(0); @@ -1453,7 +1491,7 @@ public void editGeneDiseaseAnnotationWithInvalidFields() { put("/api/gene-disease-annotation"). then(). statusCode(400). - body("errorMessages", is(aMapWithSize(16))). + body("errorMessages", is(aMapWithSize(18))). body("errorMessages.diseaseAnnotationSubject", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.diseaseAnnotationObject", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.relation", is(ValidationConstants.INVALID_MESSAGE)). @@ -1466,7 +1504,9 @@ public void editGeneDiseaseAnnotationWithInvalidFields() { body("errorMessages.annotationType", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.diseaseQualifiers", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.geneticSex", is(ValidationConstants.INVALID_MESSAGE)). - body("errorMessages.diseaseGeneticModifiers", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAgms", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAlleles", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.diseaseGeneticModifierGenes", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.diseaseGeneticModifierRelation", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.conditionRelations", is(String.join(" | ", List.of( "conditionRelationType - " + ValidationConstants.INVALID_MESSAGE, @@ -1494,7 +1534,9 @@ public void editAlleleDiseaseAnnotationWithInvalidFields() { diseaseAnnotation.setAnnotationType(diseaseQualifier); diseaseAnnotation.setDiseaseQualifiers(List.of(geneticSex)); diseaseAnnotation.setGeneticSex(annotationType); - diseaseAnnotation.setDiseaseGeneticModifiers(List.of(nonPersistedAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAgms(List.of(nonPersistedAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(List.of(nonPersistedAllele)); + diseaseAnnotation.setDiseaseGeneticModifierGenes(List.of(nonPersistedGene)); diseaseAnnotation.setDiseaseGeneticModifierRelation(agmRelation); diseaseAnnotation.setInferredGene(nonPersistedGene); diseaseAnnotation.setAssertedGenes(List.of(nonPersistedGene)); @@ -1517,7 +1559,7 @@ public void editAlleleDiseaseAnnotationWithInvalidFields() { put("/api/allele-disease-annotation"). then(). statusCode(400). - body("errorMessages", is(aMapWithSize(17))). + body("errorMessages", is(aMapWithSize(19))). body("errorMessages.diseaseAnnotationSubject", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.diseaseAnnotationObject", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.relation", is(ValidationConstants.INVALID_MESSAGE)). @@ -1529,7 +1571,9 @@ public void editAlleleDiseaseAnnotationWithInvalidFields() { body("errorMessages.annotationType", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.diseaseQualifiers", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.geneticSex", is(ValidationConstants.INVALID_MESSAGE)). - body("errorMessages.diseaseGeneticModifiers", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAgms", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAlleles", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.diseaseGeneticModifierGenes", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.diseaseGeneticModifierRelation", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.inferredGene", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.assertedGenes", is(ValidationConstants.INVALID_MESSAGE)). @@ -1559,7 +1603,9 @@ public void editAgmDiseaseAnnotationWithInvalidFields() { diseaseAnnotation.setAnnotationType(diseaseQualifier); diseaseAnnotation.setDiseaseQualifiers(List.of(geneticSex)); diseaseAnnotation.setGeneticSex(annotationType); - diseaseAnnotation.setDiseaseGeneticModifiers(List.of(nonPersistedAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAgms(List.of(nonPersistedAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(List.of(nonPersistedAllele)); + diseaseAnnotation.setDiseaseGeneticModifierGenes(List.of(nonPersistedGene)); diseaseAnnotation.setDiseaseGeneticModifierRelation(agmRelation); diseaseAnnotation.setInferredGene(nonPersistedGene); diseaseAnnotation.setAssertedGenes(List.of(nonPersistedGene)); @@ -1584,7 +1630,7 @@ public void editAgmDiseaseAnnotationWithInvalidFields() { put("/api/agm-disease-annotation"). then(). statusCode(400). - body("errorMessages", is(aMapWithSize(19))). + body("errorMessages", is(aMapWithSize(21))). body("errorMessages.diseaseAnnotationSubject", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.diseaseAnnotationObject", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.relation", is(ValidationConstants.INVALID_MESSAGE)). @@ -1596,7 +1642,9 @@ public void editAgmDiseaseAnnotationWithInvalidFields() { body("errorMessages.annotationType", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.diseaseQualifiers", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.geneticSex", is(ValidationConstants.INVALID_MESSAGE)). - body("errorMessages.diseaseGeneticModifiers", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAgms", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAlleles", is(ValidationConstants.INVALID_MESSAGE)). + body("errorMessages.diseaseGeneticModifierGenes", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.diseaseGeneticModifierRelation", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.inferredGene", is(ValidationConstants.INVALID_MESSAGE)). body("errorMessages.assertedGenes", is(ValidationConstants.INVALID_MESSAGE)). @@ -1628,7 +1676,9 @@ public void createGeneDiseaseAnnotationWithObsoleteFields() { diseaseAnnotation.setAnnotationType(obsoleteAnnotationType); diseaseAnnotation.setDiseaseQualifiers(List.of(obsoleteDiseaseQualifier)); diseaseAnnotation.setGeneticSex(obsoleteGeneticSex); - diseaseAnnotation.setDiseaseGeneticModifiers(List.of(obsoleteAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAgms(List.of(obsoleteAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(List.of(obsoleteAllele)); + diseaseAnnotation.setDiseaseGeneticModifierGenes(List.of(obsoleteGene)); diseaseAnnotation.setDiseaseGeneticModifierRelation(obsoleteDiseaseGeneticModifierRelation); ConditionRelation newRelation = new ConditionRelation(); @@ -1650,7 +1700,7 @@ public void createGeneDiseaseAnnotationWithObsoleteFields() { post("/api/gene-disease-annotation"). then(). statusCode(400). - body("errorMessages", is(aMapWithSize(16))). + body("errorMessages", is(aMapWithSize(18))). body("errorMessages.diseaseAnnotationSubject", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.diseaseAnnotationObject", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.relation", is(ValidationConstants.OBSOLETE_MESSAGE)). @@ -1663,7 +1713,9 @@ public void createGeneDiseaseAnnotationWithObsoleteFields() { body("errorMessages.annotationType", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.diseaseQualifiers", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.geneticSex", is(ValidationConstants.OBSOLETE_MESSAGE)). - body("errorMessages.diseaseGeneticModifiers", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAgms", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAlleles", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.diseaseGeneticModifierGenes", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.diseaseGeneticModifierRelation", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.conditionRelations", is(String.join(" | ", List.of( "conditionRelationType - " + ValidationConstants.OBSOLETE_MESSAGE, @@ -1688,7 +1740,9 @@ public void createAlleleDiseaseAnnotationWithObsoleteFields() { diseaseAnnotation.setAnnotationType(obsoleteAnnotationType); diseaseAnnotation.setDiseaseQualifiers(List.of(obsoleteDiseaseQualifier)); diseaseAnnotation.setGeneticSex(obsoleteGeneticSex); - diseaseAnnotation.setDiseaseGeneticModifiers(List.of(obsoleteAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAgms(List.of(obsoleteAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(List.of(obsoleteAllele)); + diseaseAnnotation.setDiseaseGeneticModifierGenes(List.of(obsoleteGene)); diseaseAnnotation.setDiseaseGeneticModifierRelation(obsoleteDiseaseGeneticModifierRelation); diseaseAnnotation.setInferredGene(obsoleteGene); diseaseAnnotation.setAssertedGenes(List.of(obsoleteGene)); @@ -1712,7 +1766,7 @@ public void createAlleleDiseaseAnnotationWithObsoleteFields() { post("/api/allele-disease-annotation"). then(). statusCode(400). - body("errorMessages", is(aMapWithSize(17))). + body("errorMessages", is(aMapWithSize(19))). body("errorMessages.diseaseAnnotationSubject", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.diseaseAnnotationObject", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.relation", is(ValidationConstants.OBSOLETE_MESSAGE)). @@ -1724,7 +1778,9 @@ public void createAlleleDiseaseAnnotationWithObsoleteFields() { body("errorMessages.annotationType", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.diseaseQualifiers", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.geneticSex", is(ValidationConstants.OBSOLETE_MESSAGE)). - body("errorMessages.diseaseGeneticModifiers", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAgms", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAlleles", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.diseaseGeneticModifierGenes", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.diseaseGeneticModifierRelation", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.inferredGene", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.assertedGenes", is(ValidationConstants.OBSOLETE_MESSAGE)). @@ -1751,7 +1807,9 @@ public void createAgmDiseaseAnnotationWithObsoleteFields() { diseaseAnnotation.setAnnotationType(obsoleteAnnotationType); diseaseAnnotation.setDiseaseQualifiers(List.of(obsoleteDiseaseQualifier)); diseaseAnnotation.setGeneticSex(obsoleteGeneticSex); - diseaseAnnotation.setDiseaseGeneticModifiers(List.of(obsoleteAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAgms(List.of(obsoleteAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(List.of(obsoleteAllele)); + diseaseAnnotation.setDiseaseGeneticModifierGenes(List.of(obsoleteGene)); diseaseAnnotation.setDiseaseGeneticModifierRelation(obsoleteDiseaseGeneticModifierRelation); diseaseAnnotation.setInferredGene(obsoleteGene); diseaseAnnotation.setAssertedGenes(List.of(obsoleteGene)); @@ -1777,7 +1835,7 @@ public void createAgmDiseaseAnnotationWithObsoleteFields() { post("/api/agm-disease-annotation"). then(). statusCode(400). - body("errorMessages", is(aMapWithSize(19))). + body("errorMessages", is(aMapWithSize(21))). body("errorMessages.diseaseAnnotationSubject", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.diseaseAnnotationObject", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.relation", is(ValidationConstants.OBSOLETE_MESSAGE)). @@ -1789,7 +1847,9 @@ public void createAgmDiseaseAnnotationWithObsoleteFields() { body("errorMessages.annotationType", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.diseaseQualifiers", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.geneticSex", is(ValidationConstants.OBSOLETE_MESSAGE)). - body("errorMessages.diseaseGeneticModifiers", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAgms", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAlleles", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.diseaseGeneticModifierGenes", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.diseaseGeneticModifierRelation", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.inferredGene", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.assertedGenes", is(ValidationConstants.OBSOLETE_MESSAGE)). @@ -1821,7 +1881,9 @@ public void editGeneDiseaseAnnotationWithObsoleteFields() { diseaseAnnotation.setAnnotationType(obsoleteAnnotationType); diseaseAnnotation.setDiseaseQualifiers(List.of(obsoleteDiseaseQualifier)); diseaseAnnotation.setGeneticSex(obsoleteGeneticSex); - diseaseAnnotation.setDiseaseGeneticModifiers(List.of(obsoleteAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAgms(List.of(obsoleteAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(List.of(obsoleteAllele)); + diseaseAnnotation.setDiseaseGeneticModifierGenes(List.of(obsoleteGene)); diseaseAnnotation.setDiseaseGeneticModifierRelation(obsoleteDiseaseGeneticModifierRelation); ConditionRelation editedRelation = diseaseAnnotation.getConditionRelations().get(0); @@ -1841,7 +1903,7 @@ public void editGeneDiseaseAnnotationWithObsoleteFields() { put("/api/gene-disease-annotation"). then(). statusCode(400). - body("errorMessages", is(aMapWithSize(16))). + body("errorMessages", is(aMapWithSize(18))). body("errorMessages.diseaseAnnotationSubject", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.diseaseAnnotationObject", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.relation", is(ValidationConstants.OBSOLETE_MESSAGE)). @@ -1854,7 +1916,9 @@ public void editGeneDiseaseAnnotationWithObsoleteFields() { body("errorMessages.annotationType", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.diseaseQualifiers", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.geneticSex", is(ValidationConstants.OBSOLETE_MESSAGE)). - body("errorMessages.diseaseGeneticModifiers", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAgms", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAlleles", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.diseaseGeneticModifierGenes", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.diseaseGeneticModifierRelation", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.conditionRelations", is(String.join(" | ", List.of( "conditionRelationType - " + ValidationConstants.OBSOLETE_MESSAGE, @@ -1879,7 +1943,9 @@ public void editAlleleDiseaseAnnotationWithObsoleteFields() { diseaseAnnotation.setAnnotationType(obsoleteAnnotationType); diseaseAnnotation.setDiseaseQualifiers(List.of(obsoleteDiseaseQualifier)); diseaseAnnotation.setGeneticSex(obsoleteGeneticSex); - diseaseAnnotation.setDiseaseGeneticModifiers(List.of(obsoleteAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAgms(List.of(obsoleteAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(List.of(obsoleteAllele)); + diseaseAnnotation.setDiseaseGeneticModifierGenes(List.of(obsoleteGene)); diseaseAnnotation.setDiseaseGeneticModifierRelation(obsoleteDiseaseGeneticModifierRelation); diseaseAnnotation.setInferredGene(obsoleteGene); diseaseAnnotation.setAssertedGenes(List.of(obsoleteGene)); @@ -1901,7 +1967,7 @@ public void editAlleleDiseaseAnnotationWithObsoleteFields() { put("/api/allele-disease-annotation"). then(). statusCode(400). - body("errorMessages", is(aMapWithSize(17))). + body("errorMessages", is(aMapWithSize(19))). body("errorMessages.diseaseAnnotationSubject", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.diseaseAnnotationObject", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.relation", is(ValidationConstants.OBSOLETE_MESSAGE)). @@ -1913,7 +1979,9 @@ public void editAlleleDiseaseAnnotationWithObsoleteFields() { body("errorMessages.annotationType", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.diseaseQualifiers", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.geneticSex", is(ValidationConstants.OBSOLETE_MESSAGE)). - body("errorMessages.diseaseGeneticModifiers", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAgms", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAlleles", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.diseaseGeneticModifierGenes", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.diseaseGeneticModifierRelation", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.inferredGene", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.assertedGenes", is(ValidationConstants.OBSOLETE_MESSAGE)). @@ -1940,7 +2008,9 @@ public void editAgmDiseaseAnnotationWithObsoleteFields() { diseaseAnnotation.setAnnotationType(obsoleteAnnotationType); diseaseAnnotation.setDiseaseQualifiers(List.of(obsoleteDiseaseQualifier)); diseaseAnnotation.setGeneticSex(obsoleteGeneticSex); - diseaseAnnotation.setDiseaseGeneticModifiers(List.of(obsoleteAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAgms(List.of(obsoleteAgm)); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(List.of(obsoleteAllele)); + diseaseAnnotation.setDiseaseGeneticModifierGenes(List.of(obsoleteGene)); diseaseAnnotation.setDiseaseGeneticModifierRelation(obsoleteDiseaseGeneticModifierRelation); diseaseAnnotation.setInferredGene(obsoleteGene); diseaseAnnotation.setAssertedGenes(List.of(obsoleteGene)); @@ -1964,7 +2034,7 @@ public void editAgmDiseaseAnnotationWithObsoleteFields() { put("/api/agm-disease-annotation"). then(). statusCode(400). - body("errorMessages", is(aMapWithSize(19))). + body("errorMessages", is(aMapWithSize(21))). body("errorMessages.diseaseAnnotationSubject", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.diseaseAnnotationObject", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.relation", is(ValidationConstants.OBSOLETE_MESSAGE)). @@ -1976,7 +2046,9 @@ public void editAgmDiseaseAnnotationWithObsoleteFields() { body("errorMessages.annotationType", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.diseaseQualifiers", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.geneticSex", is(ValidationConstants.OBSOLETE_MESSAGE)). - body("errorMessages.diseaseGeneticModifiers", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAgms", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.diseaseGeneticModifierAlleles", is(ValidationConstants.OBSOLETE_MESSAGE)). + body("errorMessages.diseaseGeneticModifierGenes", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.diseaseGeneticModifierRelation", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.inferredGene", is(ValidationConstants.OBSOLETE_MESSAGE)). body("errorMessages.assertedGenes", is(ValidationConstants.OBSOLETE_MESSAGE)). @@ -2043,7 +2115,9 @@ public void createDiseaseAnnotationWithMissingDependentFields() { diseaseAnnotation.setSingleReference(reference); diseaseAnnotation.setDataProvider(dataProvider); - diseaseAnnotation.setDiseaseGeneticModifiers(List.of(allele)); + diseaseAnnotation.setDiseaseGeneticModifierAgms(List.of(agm)); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(List.of(allele)); + diseaseAnnotation.setDiseaseGeneticModifierGenes(List.of(gene)); RestAssured.given(). contentType("application/json"). @@ -2052,10 +2126,14 @@ public void createDiseaseAnnotationWithMissingDependentFields() { post("/api/gene-disease-annotation"). then(). statusCode(400). - body("errorMessages", is(aMapWithSize(1))). - body("errorMessages.diseaseGeneticModifiers", is(ValidationConstants.DEPENDENCY_MESSAGE_PREFIX + "diseaseGeneticModifierRelation")); - - diseaseAnnotation.setDiseaseGeneticModifiers(null); + body("errorMessages", is(aMapWithSize(3))). + body("errorMessages.diseaseGeneticModifierAgms", is(ValidationConstants.DEPENDENCY_MESSAGE_PREFIX + "diseaseGeneticModifierRelation")). + body("errorMessages.diseaseGeneticModifierAlleles", is(ValidationConstants.DEPENDENCY_MESSAGE_PREFIX + "diseaseGeneticModifierRelation")). + body("errorMessages.diseaseGeneticModifierGenes", is(ValidationConstants.DEPENDENCY_MESSAGE_PREFIX + "diseaseGeneticModifierRelation")); + + diseaseAnnotation.setDiseaseGeneticModifierAgms(null); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(null); + diseaseAnnotation.setDiseaseGeneticModifierGenes(null); diseaseAnnotation.setDiseaseGeneticModifierRelation(diseaseGeneticModifierRelation); RestAssured.given(). @@ -2066,7 +2144,7 @@ public void createDiseaseAnnotationWithMissingDependentFields() { then(). statusCode(400). body("errorMessages", is(aMapWithSize(1))). - body("errorMessages.diseaseGeneticModifierRelation", is(ValidationConstants.DEPENDENCY_MESSAGE_PREFIX + "diseaseGeneticModifiers")); + body("errorMessages.diseaseGeneticModifierRelation", is(ValidationConstants.DEPENDENCY_MESSAGE_PREFIX + "diseaseGeneticModifierGenes / diseaseGeneticModifierAlleles / diseaseGeneticModifierAgms")); } @@ -2083,11 +2161,15 @@ public void editDiseaseAnnotationWithMissingDependentFields() { put("/api/gene-disease-annotation"). then(). statusCode(400). - body("errorMessages", is(aMapWithSize(1))). - body("errorMessages.diseaseGeneticModifiers", is(ValidationConstants.DEPENDENCY_MESSAGE_PREFIX + "diseaseGeneticModifierRelation")); + body("errorMessages", is(aMapWithSize(3))). + body("errorMessages.diseaseGeneticModifierAgms", is(ValidationConstants.DEPENDENCY_MESSAGE_PREFIX + "diseaseGeneticModifierRelation")). + body("errorMessages.diseaseGeneticModifierAlleles", is(ValidationConstants.DEPENDENCY_MESSAGE_PREFIX + "diseaseGeneticModifierRelation")). + body("errorMessages.diseaseGeneticModifierGenes", is(ValidationConstants.DEPENDENCY_MESSAGE_PREFIX + "diseaseGeneticModifierRelation")); diseaseAnnotation.setDiseaseGeneticModifierRelation(diseaseGeneticModifierRelation); - diseaseAnnotation.setDiseaseGeneticModifiers(null); + diseaseAnnotation.setDiseaseGeneticModifierAgms(null); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(null); + diseaseAnnotation.setDiseaseGeneticModifierGenes(null); RestAssured.given(). contentType("application/json"). @@ -2097,7 +2179,7 @@ public void editDiseaseAnnotationWithMissingDependentFields() { then(). statusCode(400). body("errorMessages", is(aMapWithSize(1))). - body("errorMessages.diseaseGeneticModifierRelation", is(ValidationConstants.DEPENDENCY_MESSAGE_PREFIX + "diseaseGeneticModifiers")); + body("errorMessages.diseaseGeneticModifierRelation", is(ValidationConstants.DEPENDENCY_MESSAGE_PREFIX + "diseaseGeneticModifierGenes / diseaseGeneticModifierAlleles / diseaseGeneticModifierAgms")); } @@ -2226,7 +2308,9 @@ public void editGeneDiseaseAnnotationWithNullNonRequiredFieldsLevel() { diseaseAnnotation.setAnnotationType(null); diseaseAnnotation.setDiseaseQualifiers(null); diseaseAnnotation.setGeneticSex(null); - diseaseAnnotation.setDiseaseGeneticModifiers(null); + diseaseAnnotation.setDiseaseGeneticModifierAgms(null); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(null); + diseaseAnnotation.setDiseaseGeneticModifierGenes(null); diseaseAnnotation.setDiseaseGeneticModifierRelation(null); diseaseAnnotation.setConditionRelations(null); diseaseAnnotation.setRelatedNotes(null); @@ -2251,7 +2335,9 @@ public void editGeneDiseaseAnnotationWithNullNonRequiredFieldsLevel() { body("entity", not(hasKey("annotationType"))). body("entity", not(hasKey("diseaseQualifiers"))). body("entity", not(hasKey("geneticSex"))). - body("entity", not(hasKey("diseaseGeneticModifiers"))). + body("entity", not(hasKey("diseaseGeneticModifierAgms"))). + body("entity", not(hasKey("diseaseGeneticModifierAlleles"))). + body("entity", not(hasKey("diseaseGeneticModifierGenes"))). body("entity", not(hasKey("diseaseGeneticModifierRelation"))). body("entity", not(hasKey("conditionRelations"))). body("entity", not(hasKey("relatedNotes"))); @@ -2267,7 +2353,9 @@ public void editAlleleDiseaseAnnotationWithNullNonRequiredFieldsLevel() { diseaseAnnotation.setAnnotationType(null); diseaseAnnotation.setDiseaseQualifiers(null); diseaseAnnotation.setGeneticSex(null); - diseaseAnnotation.setDiseaseGeneticModifiers(null); + diseaseAnnotation.setDiseaseGeneticModifierAgms(null); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(null); + diseaseAnnotation.setDiseaseGeneticModifierGenes(null); diseaseAnnotation.setDiseaseGeneticModifierRelation(null); diseaseAnnotation.setConditionRelations(null); diseaseAnnotation.setRelatedNotes(null); @@ -2293,7 +2381,9 @@ public void editAlleleDiseaseAnnotationWithNullNonRequiredFieldsLevel() { body("entity", not(hasKey("annotationType"))). body("entity", not(hasKey("diseaseQualifiers"))). body("entity", not(hasKey("geneticSex"))). - body("entity", not(hasKey("diseaseGeneticModifiers"))). + body("entity", not(hasKey("diseaseGeneticModifierAgms"))). + body("entity", not(hasKey("diseaseGeneticModifierAlleles"))). + body("entity", not(hasKey("diseaseGeneticModifierGenes"))). body("entity", not(hasKey("diseaseGeneticModifierRelation"))). body("entity", not(hasKey("conditionRelations"))). body("entity", not(hasKey("relatedNotes"))). @@ -2311,7 +2401,9 @@ public void editAgmDiseaseAnnotationWithNullNonRequiredFieldsLevel() { diseaseAnnotation.setAnnotationType(null); diseaseAnnotation.setDiseaseQualifiers(null); diseaseAnnotation.setGeneticSex(null); - diseaseAnnotation.setDiseaseGeneticModifiers(null); + diseaseAnnotation.setDiseaseGeneticModifierAgms(null); + diseaseAnnotation.setDiseaseGeneticModifierAlleles(null); + diseaseAnnotation.setDiseaseGeneticModifierGenes(null); diseaseAnnotation.setDiseaseGeneticModifierRelation(null); diseaseAnnotation.setConditionRelations(null); diseaseAnnotation.setRelatedNotes(null); @@ -2339,7 +2431,9 @@ public void editAgmDiseaseAnnotationWithNullNonRequiredFieldsLevel() { body("entity", not(hasKey("annotationType"))). body("entity", not(hasKey("diseaseQualifiers"))). body("entity", not(hasKey("geneticSex"))). - body("entity", not(hasKey("diseaseGeneticModifiers"))). + body("entity", not(hasKey("diseaseGeneticModifierAgms"))). + body("entity", not(hasKey("diseaseGeneticModifierAlleles"))). + body("entity", not(hasKey("diseaseGeneticModifierGenes"))). body("entity", not(hasKey("diseaseGeneticModifierRelation"))). body("entity", not(hasKey("conditionRelations"))). body("entity", not(hasKey("relatedNotes"))). diff --git a/src/test/java/org/alliancegenome/curation_api/ExpressionBulkUploadFmsITCase.java b/src/test/java/org/alliancegenome/curation_api/ExpressionBulkUploadFmsITCase.java index c883ff20e..9d9d9ab02 100644 --- a/src/test/java/org/alliancegenome/curation_api/ExpressionBulkUploadFmsITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/ExpressionBulkUploadFmsITCase.java @@ -7,13 +7,12 @@ import io.restassured.config.RestAssuredConfig; import org.alliancegenome.curation_api.base.BaseITCase; import org.alliancegenome.curation_api.constants.VocabularyConstants; -import org.alliancegenome.curation_api.model.entities.DataProvider; -import org.alliancegenome.curation_api.model.entities.ResourceDescriptor; -import org.alliancegenome.curation_api.model.entities.Vocabulary; -import org.alliancegenome.curation_api.model.entities.VocabularyTerm; +import org.alliancegenome.curation_api.model.entities.*; +import org.alliancegenome.curation_api.model.entities.ontology.GOTerm; import org.alliancegenome.curation_api.resources.TestContainerResource; import org.junit.jupiter.api.*; +import java.util.ArrayList; import java.util.List; import static org.hamcrest.Matchers.hasSize; @@ -39,6 +38,21 @@ public class ExpressionBulkUploadFmsITCase extends BaseITCase { private final String publicationId = "PMID:009"; private final String agrPublicationId = "AGRKB:101000000668376"; + private final String stageTermId = "ZFS:001"; + private final String stageUberonTermId = "UBERON:001"; + + private final String anatomicalStructureTermId = "ANAT:001"; + private final String anatomicalSubstructureTermId = "ANAT:002"; + private final String cellularComponentTermId = "GOTEST:0012"; + private final String cellularComponentRibbonTermId = "GOSLIMTEST:0012"; + private final String anatomicalStructureQualifierTermId = "UBERON:002"; + private final String anatomicalSubstructureQualifierTermId = "UBERON:003"; + private final String cellularComponentQualifierTermId = "FBCV:001"; + private final String anatomicalStructureUberonTermId1 = "UBERON:004"; + private final String anatomicalStructureUberonTermId2 = "UBERON:005"; + private final String anatomicalSubstructureUberonTermId1 = "UBERON:006"; + private final String anatomicalSubstructureUberonTermId2 = "UBERON:007"; + @BeforeEach public void init() { RestAssured.config = RestAssuredConfig.config() @@ -60,7 +74,6 @@ public void expressionBulkUploadAllFields() throws Exception { .statusCode(200) .body("totalResults", is(1)) .body("results", hasSize(1)) - .body("results[0].type", is("GeneExpressionAnnotation")) .body("results[0].dateCreated", is("2024-01-17T15:31:34Z")) .body("results[0].dataProvider.sourceOrganization.abbreviation", is("ZFIN")) .body("results[0].expressionAnnotationSubject.modEntityId", is(gene)) @@ -68,7 +81,21 @@ public void expressionBulkUploadAllFields() throws Exception { .body("results[0].whereExpressedStatement", is("trunk")) .body("results[0].whenExpressedStageName", is("stage1")) .body("results[0].singleReference.crossReferences[0].referencedCurie", is(publicationId)) - .body("results[0].relation.name", is(VocabularyConstants.GENE_EXPRESSION_RELATION_TERM)); + .body("results[0].relation.name", is(VocabularyConstants.GENE_EXPRESSION_RELATION_TERM)) + .body("results[0].expressionPattern.whenExpressed.developmentalStageStart.curie", is(stageTermId)) + .body("results[0].expressionPattern.whenExpressed.stageUberonSlimTerms[0].name", is(stageUberonTermId)) + .body("results[0].expressionPattern.whereExpressed.anatomicalStructure.curie", is(anatomicalStructureTermId)) + .body("results[0].expressionPattern.whereExpressed.anatomicalSubstructure.curie", is(anatomicalSubstructureTermId)) + .body("results[0].expressionPattern.whereExpressed.cellularComponentTerm.curie", is(cellularComponentTermId)) + .body("results[0].expressionPattern.whereExpressed.cellularComponentRibbonTerm.curie", is(cellularComponentRibbonTermId)) + .body("results[0].expressionPattern.whereExpressed.cellularComponentOther", is(false)) + .body("results[0].expressionPattern.whereExpressed.anatomicalStructureQualifiers[0].curie", is(anatomicalStructureQualifierTermId)) + .body("results[0].expressionPattern.whereExpressed.anatomicalSubstructureQualifiers[0].curie", is(anatomicalSubstructureQualifierTermId)) + .body("results[0].expressionPattern.whereExpressed.cellularComponentQualifiers[0].curie", is(cellularComponentQualifierTermId)) + .body("results[0].expressionPattern.whereExpressed.anatomicalStructureUberonTerms[0].curie", is(anatomicalStructureUberonTermId1)) + .body("results[0].expressionPattern.whereExpressed.anatomicalStructureUberonTerms[1].curie", is(anatomicalStructureUberonTermId2)) + .body("results[0].expressionPattern.whereExpressed.anatomicalSubstructureUberonTerms[0].curie", is(anatomicalSubstructureUberonTermId1)) + .body("results[0].expressionPattern.whereExpressed.anatomicalSubstructureUberonTerms[1].curie", is(anatomicalSubstructureUberonTermId2)); } @Test @@ -82,6 +109,7 @@ public void expressionBulkUploadMissingRequiredFields() throws Exception { checkFailedBulkLoad(expressionBulkPostEndpoint, expressionTestFilePath + "MR_06_no_whereExpressed.json"); checkFailedBulkLoad(expressionBulkPostEndpoint, expressionTestFilePath + "MR_07_nowhenExpressedStageName.json"); checkFailedBulkLoad(expressionBulkPostEndpoint, expressionTestFilePath + "MR_08_nowhereExpressedStatement.json"); + checkFailedBulkLoad(expressionBulkPostEndpoint, expressionTestFilePath + "MR_09_norCellComponentNORanatStructure.json"); } @Test @@ -101,20 +129,52 @@ public void expressionBulkUploadInvalidFields() throws Exception { checkFailedBulkLoad(expressionBulkPostEndpoint, expressionTestFilePath + "IV_02_invalid_dateAssigned.json"); checkFailedBulkLoad(expressionBulkPostEndpoint, expressionTestFilePath + "IV_03_invalid_assay.json"); checkFailedBulkLoad(expressionBulkPostEndpoint, expressionTestFilePath + "IV_04_invalid_publicationId.json"); + checkFailedBulkLoad(expressionBulkPostEndpoint, expressionTestFilePath + "IV_05_invalid_stageterm.json"); + checkFailedBulkLoad(expressionBulkPostEndpoint, expressionTestFilePath + "IV_06_invalid_anatomical_structure.json"); + checkFailedBulkLoad(expressionBulkPostEndpoint, expressionTestFilePath + "IV_07_invalid_anatomical_substructure.json"); + checkFailedBulkLoad(expressionBulkPostEndpoint, expressionTestFilePath + "IV_08_invalid_cellularcomponent.json"); + checkFailedBulkLoad(expressionBulkPostEndpoint, expressionTestFilePath + "IV_09_invalid_anatomicalstructurequalifier.json"); + checkFailedBulkLoad(expressionBulkPostEndpoint, expressionTestFilePath + "IV_10_invalid_anatomicalsubstructurequalifier.json"); + checkFailedBulkLoad(expressionBulkPostEndpoint, expressionTestFilePath + "IV_11_invalid_cellularcomponentqualifier.json"); + checkFailedBulkLoad(expressionBulkPostEndpoint, expressionTestFilePath + "IV_12_invalid_anatomicalstructureuberonslimterms.json"); + checkFailedBulkLoad(expressionBulkPostEndpoint, expressionTestFilePath + "IV_13_invalid_anatomicalsubstructureuberonslimterms.json"); } private void loadRequiredEntities() throws Exception { DataProvider dataProvider = createDataProvider("ZFIN", false); Vocabulary vocabulary1 = getVocabulary(VocabularyConstants.NAME_TYPE_VOCABULARY); VocabularyTerm symbolTerm = getVocabularyTerm(vocabulary1, "nomenclature_symbol"); - loadGenes(List.of(gene), taxon, symbolTerm, dataProvider); - loadMMOTerm(mmoTerm, "assay001"); + createGene(gene, taxon, symbolTerm, false, dataProvider); + createMmoTerm(mmoTerm, "assay001"); ResourceDescriptor rd1 = createResourceDescriptor("ZFIN"); createResourceDescriptorPage("homepage", "https://zfin.org/", rd1); createResourceDescriptorPage("reference", "https://zfin.org/[%s]", rd1); - loadReference(agrPublicationId, publicationId); - loadReference(agrReferenceId, referenceId); + createReference(agrPublicationId, publicationId); + createReference(agrReferenceId, referenceId); Vocabulary vocabulary2 = createVocabulary(VocabularyConstants.GENE_EXPRESSION_VOCABULARY, false); - VocabularyTerm isExpressed = createVocabularyTerm(vocabulary2, VocabularyConstants.GENE_EXPRESSION_RELATION_TERM, false); + createVocabularyTerm(vocabulary2, VocabularyConstants.GENE_EXPRESSION_RELATION_TERM, false); + Vocabulary stageUberonTermVocabulary = getVocabulary(VocabularyConstants.STAGE_UBERON_SLIM_TERMS); + Vocabulary spatialExpressionQualififerVocabulary = getVocabulary(VocabularyConstants.SPATIAL_EXPRESSION_QUALIFIERS); + VocabularyTermSet anatatomicalStructureQualifierTermset = getVocabularyTermSet(VocabularyConstants.ANATOMICAL_STRUCTURE_QUALIFIER); + VocabularyTermSet anatatomicalSubstructureQualifierTermset = getVocabularyTermSet(VocabularyConstants.ANATOMICAL_SUBSTRUCTURE_QUALIFIER); + VocabularyTermSet cellularComponentQualifierTermset = getVocabularyTermSet(VocabularyConstants.CELLULAR_COMPONENT_QUALIFIER); + createStageTerm(stageTermId, "StageTermTest"); + createVocabularyTerm(stageUberonTermVocabulary, stageUberonTermId, false); + createAnatomicalTerm(anatomicalStructureTermId, "AnatomicalStructureTermTest"); + createAnatomicalTerm(anatomicalSubstructureTermId, "AnatomicalSubStructureTermTest"); + createOntologyTerm(anatomicalStructureQualifierTermId, "anatomicalSubstructureQualifierTermId", false); + createOntologyTerm(anatomicalSubstructureQualifierTermId, "anatomicalSubstructureQualifierTermId", false); + createOntologyTerm(cellularComponentQualifierTermId, "anatomicalSubstructureQualifierTermId", false); + createVocabularyTerm(anatatomicalStructureQualifierTermset, anatomicalStructureQualifierTermId, false); + createVocabularyTerm(anatatomicalSubstructureQualifierTermset, anatomicalSubstructureQualifierTermId, false); + createVocabularyTerm(cellularComponentQualifierTermset, cellularComponentQualifierTermId, false); + List subsets = new ArrayList(); + subsets.add("goslim_agr"); + GOTerm isaAncestor = createGoTerm(cellularComponentRibbonTermId, "CellularComponentRibbonTermTest", false, subsets); + createGoTerm(cellularComponentTermId, "CellularComponentTermTest", false, isaAncestor); + createUberonTerm(anatomicalStructureUberonTermId1, "UberonTermTest1"); + createUberonTerm(anatomicalStructureUberonTermId2, "UberonTermTest2"); + createUberonTerm(anatomicalSubstructureUberonTermId1, "UberonTermTest3"); + createUberonTerm(anatomicalSubstructureUberonTermId2, "UberonTermTest4"); } } diff --git a/src/test/java/org/alliancegenome/curation_api/GeneBulkUploadITCase.java b/src/test/java/org/alliancegenome/curation_api/GeneBulkUploadITCase.java index f42adcd72..8351574f4 100644 --- a/src/test/java/org/alliancegenome/curation_api/GeneBulkUploadITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/GeneBulkUploadITCase.java @@ -56,8 +56,8 @@ public void init() { private final String geneTestFilePath = "src/test/resources/bulk/01_gene/"; private void loadRequiredEntities() throws Exception { - loadReference(requiredReference, requiredReferenceXref); - loadReference(requiredReference2, requiredReferenceXref2); + createReference(requiredReference, requiredReferenceXref); + createReference(requiredReference2, requiredReferenceXref2); ResourceDescriptor rd = createResourceDescriptor("TEST"); createResourceDescriptorPage("homepage", "http://test.org", rd); ResourceDescriptor rd2 = createResourceDescriptor("TEST2"); diff --git a/src/test/java/org/alliancegenome/curation_api/GeneInteractionBulkUploadFmsITCase.java b/src/test/java/org/alliancegenome/curation_api/GeneInteractionBulkUploadFmsITCase.java index 8c00612e3..2856af58e 100644 --- a/src/test/java/org/alliancegenome/curation_api/GeneInteractionBulkUploadFmsITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/GeneInteractionBulkUploadFmsITCase.java @@ -78,20 +78,20 @@ private void loadRequiredEntities() throws Exception { VocabularyTerm symbolTerm = getVocabularyTerm(nameTypeVocabulary, "nomenclature_symbol"); DataProvider dataProvider = createDataProvider("WB", false); DataProvider dataProvider2 = createDataProvider("RGD", false); - loadGenes(List.of(gene1, gene2), "NCBITaxon:6239", symbolTerm, dataProvider); - loadGeneWithXref(gene3, "NCBITaxon:6239", symbolTerm, dataProvider, gene3xref); - loadGeneWithXref(gene4, "NCBITaxon:9606", symbolTerm, dataProvider2, gene4xref); - loadAllele(allele1, "GGITestVar1", "NCBITaxon:6239", symbolTerm, dataProvider); - loadAllele(allele2, "GGITestVar2", "NCBITaxon:6239", symbolTerm, dataProvider); - loadMITerm(miTerm1, "Test MITerm 1"); - loadMITerm(miTerm2, "Test MITerm 2"); - loadMITerm(miTerm3, "Test MITerm 3"); - loadMITerm(miTerm4, "Test MITerm 4"); - loadMITerm(miTerm5, "Test MITerm 5"); - loadMITerm(miTerm6, "Test MITerm 6"); - loadMITerm(miTerm7, "Test MITerm 7"); - loadMITerm(defaultAggregationDbTerm, "IMEX"); - loadWbPhenotypeTerm(wbPhenotypeTerm, "Test WBPhenotype term"); + createGenes(List.of(gene1, gene2), "NCBITaxon:6239", symbolTerm, false, dataProvider); + createGeneWithXref(gene3, "NCBITaxon:6239", symbolTerm, false, dataProvider, gene3xref); + createGeneWithXref(gene4, "NCBITaxon:9606", symbolTerm, false, dataProvider2, gene4xref); + createAllele(allele1, "GGITestVar1", "NCBITaxon:6239", symbolTerm, false, dataProvider); + createAllele(allele2, "GGITestVar2", "NCBITaxon:6239", symbolTerm, false, dataProvider); + createMiTerm(miTerm1, "Test MITerm 1"); + createMiTerm(miTerm2, "Test MITerm 2"); + createMiTerm(miTerm3, "Test MITerm 3"); + createMiTerm(miTerm4, "Test MITerm 4"); + createMiTerm(miTerm5, "Test MITerm 5"); + createMiTerm(miTerm6, "Test MITerm 6"); + createMiTerm(miTerm7, "Test MITerm 7"); + createMiTerm(defaultAggregationDbTerm, "IMEX"); + createWbPhenotypeTerm(wbPhenotypeTerm, "Test WBPhenotype term"); ResourceDescriptor rd = createResourceDescriptor("WB"); createResourceDescriptorPage("gene/interactions", "http://test.org", rd); } diff --git a/src/test/java/org/alliancegenome/curation_api/Gff3BulkUploadITCase.java b/src/test/java/org/alliancegenome/curation_api/Gff3BulkUploadITCase.java index 5ea4d9709..13f5ae5a9 100644 --- a/src/test/java/org/alliancegenome/curation_api/Gff3BulkUploadITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/Gff3BulkUploadITCase.java @@ -1,9 +1,12 @@ package org.alliancegenome.curation_api; -import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; + +import java.util.HashMap; import org.alliancegenome.curation_api.base.BaseITCase; +import org.alliancegenome.curation_api.constants.VocabularyConstants; import org.alliancegenome.curation_api.resources.TestContainerResource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -27,6 +30,8 @@ @Order(608) public class Gff3BulkUploadITCase extends BaseITCase { + // These tests require: GeneBulkUploadITCase and VocabularyTermITCase + @BeforeEach public void init() { RestAssured.config = RestAssuredConfig.config() @@ -51,14 +56,20 @@ private void loadRequiredEntities() throws Exception { createSoTerm("SO:0001035", "piRNA", false); createSoTerm("SO:0000147", "exon", false); createSoTerm("SO:0000316", "CDS", false); + createGene("WB:WBGene00022276", "NCBITaxon:6239", getVocabularyTerm(getVocabulary(VocabularyConstants.NAME_TYPE_VOCABULARY), "nomenclature_symbol"), false); } @Test @Order(1) public void gff3DataBulkUploadTranscriptEntity() throws Exception { loadRequiredEntities(); - - checkSuccessfulBulkLoad(transcriptBulkPostEndpoint, gffDataTestFilePath + "GFF_01_transcript.json", 3); + + HashMap> params = new HashMap<>(); + params.put("Entities", createCountParams(1, 0, 1, 0)); + params.put("Locations", createCountParams(1, 0, 1, 0)); + params.put("Associations", createCountParams(1, 0, 1, 0)); + + checkBulkLoadRecordCounts(transcriptBulkPostEndpoint, gffDataTestFilePath + "GFF_01_transcript.json", params); RestAssured.given(). when(). @@ -73,18 +84,28 @@ public void gff3DataBulkUploadTranscriptEntity() throws Exception { body("entity.transcriptGenomicLocationAssociations", hasSize(1)). body("entity.transcriptGenomicLocationAssociations[0].relation.name", is("located_on")). body("entity.transcriptGenomicLocationAssociations[0].transcriptGenomicLocationAssociationObject.name", is("I")). + body("entity.transcriptGenomicLocationAssociations[0].transcriptGenomicLocationAssociationObject.modEntityId", is("RefSeq:NC_003279.8")). body("entity.transcriptGenomicLocationAssociations[0].transcriptGenomicLocationAssociationObject.taxon.curie", is("NCBITaxon:6239")). body("entity.transcriptGenomicLocationAssociations[0].start", is(1)). body("entity.transcriptGenomicLocationAssociations[0].end", is(1000)). body("entity.transcriptGenomicLocationAssociations[0].phase", is(0)). - body("entity.transcriptGenomicLocationAssociations[0].strand", is("+")); + body("entity.transcriptGenomicLocationAssociations[0].strand", is("+")). + body("entity.transcriptGeneAssociations", hasSize(1)). + body("entity.transcriptGeneAssociations[0].relation.name", is("is_child_of")). + body("entity.transcriptGeneAssociations[0].transcriptGeneAssociationObject.modEntityId", is("WB:WBGene00022276")); } - + @Test @Order(2) public void gff3DataBulkUploadExonEntity() throws Exception { - checkSuccessfulBulkLoad(exonBulkPostEndpoint, gffDataTestFilePath + "GFF_02_exon.json", 3); + + HashMap> params = new HashMap<>(); + params.put("Entities", createCountParams(1, 0, 1, 0)); + params.put("Locations", createCountParams(1, 0, 1, 0)); + params.put("Associations", createCountParams(1, 0, 1, 0)); + + checkBulkLoadRecordCounts(exonBulkPostEndpoint, gffDataTestFilePath + "GFF_02_exon.json", params); RestAssured.given(). when(). @@ -97,17 +118,32 @@ public void gff3DataBulkUploadExonEntity() throws Exception { body("entity.exonGenomicLocationAssociations", hasSize(1)). body("entity.exonGenomicLocationAssociations[0].relation.name", is("located_on")). body("entity.exonGenomicLocationAssociations[0].exonGenomicLocationAssociationObject.name", is("I")). + body("entity.exonGenomicLocationAssociations[0].exonGenomicLocationAssociationObject.modEntityId", is("RefSeq:NC_003279.8")). body("entity.exonGenomicLocationAssociations[0].exonGenomicLocationAssociationObject.taxon.curie", is("NCBITaxon:6239")). body("entity.exonGenomicLocationAssociations[0].start", is(1)). body("entity.exonGenomicLocationAssociations[0].end", is(100)). body("entity.exonGenomicLocationAssociations[0].strand", is("+")); + RestAssured.given(). + when(). + get(transcriptGetEndpoint + transcriptId). + then(). + statusCode(200). + body("entity.transcriptExonAssociations", hasSize(1)). + body("entity.transcriptExonAssociations[0].relation.name", is("is_parent_of")). + body("entity.transcriptExonAssociations[0].transcriptExonAssociationObject.uniqueId", is(exonUniqueId)); } @Test @Order(3) public void gff3DataBulkUploadCodingSequenceEntity() throws Exception { - checkSuccessfulBulkLoad(cdsBulkPostEndpoint, gffDataTestFilePath + "GFF_03_CDS.json", 3); + + HashMap> params = new HashMap<>(); + params.put("Entities", createCountParams(1, 0, 1, 0)); + params.put("Locations", createCountParams(1, 0, 1, 0)); + params.put("Associations", createCountParams(1, 0, 1, 0)); + + checkBulkLoadRecordCounts(cdsBulkPostEndpoint, gffDataTestFilePath + "GFF_03_CDS.json", params); RestAssured.given(). when(). @@ -120,18 +156,34 @@ public void gff3DataBulkUploadCodingSequenceEntity() throws Exception { body("entity.codingSequenceGenomicLocationAssociations", hasSize(1)). body("entity.codingSequenceGenomicLocationAssociations[0].relation.name", is("located_on")). body("entity.codingSequenceGenomicLocationAssociations[0].codingSequenceGenomicLocationAssociationObject.name", is("I")). + body("entity.codingSequenceGenomicLocationAssociations[0].codingSequenceGenomicLocationAssociationObject.modEntityId", is("RefSeq:NC_003279.8")). body("entity.codingSequenceGenomicLocationAssociations[0].codingSequenceGenomicLocationAssociationObject.taxon.curie", is("NCBITaxon:6239")). body("entity.codingSequenceGenomicLocationAssociations[0].start", is(10)). body("entity.codingSequenceGenomicLocationAssociations[0].end", is(100)). body("entity.codingSequenceGenomicLocationAssociations[0].phase", is(1)). body("entity.codingSequenceGenomicLocationAssociations[0].strand", is("+")); + RestAssured.given(). + when(). + get(transcriptGetEndpoint + transcriptId). + then(). + statusCode(200). + body("entity.transcriptCodingSequenceAssociations", hasSize(1)). + body("entity.transcriptCodingSequenceAssociations[0].relation.name", is("is_parent_of")). + body("entity.transcriptCodingSequenceAssociations[0].transcriptCodingSequenceAssociationObject.uniqueId", is(cdsUniqueId)); + } @Test @Order(4) public void gff3DataBulkUploadUpdateTranscriptEntity() throws Exception { - checkSuccessfulBulkLoad(transcriptBulkPostEndpoint, gffDataTestFilePath + "UD_01_update_transcript.json", 3); + + HashMap> params = new HashMap<>(); + params.put("Entities", createCountParams(1, 0, 1, 0)); + params.put("Locations", createCountParams(1, 0, 1, 0)); + params.put("Associations", createCountParams(1, 0, 1, 0)); + + checkBulkLoadRecordCounts(transcriptBulkPostEndpoint, gffDataTestFilePath + "UD_01_update_transcript.json", params); RestAssured.given(). when(). @@ -146,6 +198,7 @@ public void gff3DataBulkUploadUpdateTranscriptEntity() throws Exception { body("entity.transcriptGenomicLocationAssociations", hasSize(1)). body("entity.transcriptGenomicLocationAssociations[0].relation.name", is("located_on")). body("entity.transcriptGenomicLocationAssociations[0].transcriptGenomicLocationAssociationObject.name", is("II")). + body("entity.transcriptGenomicLocationAssociations[0].transcriptGenomicLocationAssociationObject.modEntityId", is("RefSeq:NC_003280.10")). body("entity.transcriptGenomicLocationAssociations[0].transcriptGenomicLocationAssociationObject.taxon.curie", is("NCBITaxon:6239")). body("entity.transcriptGenomicLocationAssociations[0].start", is(2)). body("entity.transcriptGenomicLocationAssociations[0].end", is(2000)). @@ -157,24 +210,60 @@ public void gff3DataBulkUploadUpdateTranscriptEntity() throws Exception { @Test @Order(5) public void gff3DataBulkUploadMissingRequiredFields() throws Exception { - checkFailedBulkLoad(transcriptBulkPostEndpoint, gffDataTestFilePath + "MR_01_no_seq_id.json", 3, 1, 2); - checkFailedBulkLoad(transcriptBulkPostEndpoint, gffDataTestFilePath + "MR_02_no_start.json", 3, 1, 2); - checkFailedBulkLoad(transcriptBulkPostEndpoint, gffDataTestFilePath + "MR_03_no_end.json", 3, 1, 2); - checkFailedBulkLoad(transcriptBulkPostEndpoint, gffDataTestFilePath + "MR_04_no_strand.json", 3, 1, 2); + + HashMap> params = new HashMap<>(); + params.put("Entities", createCountParams(1, 0, 1, 0)); + params.put("Locations", createCountParams(1, 1, 0, 0)); + params.put("Associations", createCountParams(1, 0, 1, 0)); + + checkBulkLoadRecordCounts(transcriptBulkPostEndpoint, gffDataTestFilePath + "MR_01_no_seq_id.json", params); + checkBulkLoadRecordCounts(transcriptBulkPostEndpoint, gffDataTestFilePath + "MR_02_no_start.json", params); + checkBulkLoadRecordCounts(transcriptBulkPostEndpoint, gffDataTestFilePath + "MR_03_no_end.json", params); + checkBulkLoadRecordCounts(transcriptBulkPostEndpoint, gffDataTestFilePath + "MR_04_no_strand.json", params); + + params.put("Locations", createCountParams(1, 0, 1, 0)); + params.put("Associations", createCountParams(1, 1, 0, 0)); + checkBulkLoadRecordCounts(transcriptBulkPostEndpoint, gffDataTestFilePath + "MR_05_no_transcript_parent.json", params); + checkBulkLoadRecordCounts(exonBulkPostEndpoint, gffDataTestFilePath + "MR_06_no_exon_parent.json", params); + checkBulkLoadRecordCounts(cdsBulkPostEndpoint, gffDataTestFilePath + "MR_07_no_cds_parent.json", params); } - + @Test @Order(6) public void gff3DataBulkUploadEmptyRequiredFields() throws Exception { - checkFailedBulkLoad(transcriptBulkPostEndpoint, gffDataTestFilePath + "ER_01_empty_seq_id.json", 3, 1, 2); - checkFailedBulkLoad(transcriptBulkPostEndpoint, gffDataTestFilePath + "ER_02_empty_strand.json", 3, 1, 2); - } + + HashMap> params = new HashMap<>(); + params.put("Entities", createCountParams(1, 0, 1, 0)); + params.put("Locations", createCountParams(1, 1, 0, 0)); + params.put("Associations", createCountParams(1, 0, 1, 0)); + checkBulkLoadRecordCounts(transcriptBulkPostEndpoint, gffDataTestFilePath + "ER_01_empty_seq_id.json", params); + checkBulkLoadRecordCounts(transcriptBulkPostEndpoint, gffDataTestFilePath + "ER_02_empty_strand.json", params); + + params.put("Locations", createCountParams(1, 0, 1, 0)); + params.put("Associations", createCountParams(1, 1, 0, 0)); + checkBulkLoadRecordCounts(transcriptBulkPostEndpoint, gffDataTestFilePath + "ER_03_empty_transcript_parent.json", params); + checkBulkLoadRecordCounts(exonBulkPostEndpoint, gffDataTestFilePath + "ER_04_empty_exon_parent.json", params); + checkBulkLoadRecordCounts(cdsBulkPostEndpoint, gffDataTestFilePath + "ER_05_empty_cds_parent.json", params); + } + @Test @Order(7) public void gff3DataBulkUploadInvalidFields() throws Exception { - checkFailedBulkLoad(transcriptBulkPostEndpoint, gffDataTestFilePath + "IV_01_invalid_strand.json", 3, 1, 2); - checkFailedBulkLoad(transcriptBulkPostEndpoint, gffDataTestFilePath + "IV_02_invalid_phase.json", 3, 1, 2); + + HashMap> params = new HashMap<>(); + params.put("Entities", createCountParams(1, 0, 1, 0)); + params.put("Locations", createCountParams(1, 1, 0, 0)); + params.put("Associations", createCountParams(1, 0, 1, 0)); + + checkBulkLoadRecordCounts(transcriptBulkPostEndpoint, gffDataTestFilePath + "IV_01_invalid_strand.json", params); + checkBulkLoadRecordCounts(transcriptBulkPostEndpoint, gffDataTestFilePath + "IV_02_invalid_phase.json", params); + + params.put("Locations", createCountParams(1, 0, 1, 0)); + params.put("Associations", createCountParams(1, 1, 0, 0)); + checkBulkLoadRecordCounts(transcriptBulkPostEndpoint, gffDataTestFilePath + "IV_03_invalid_transcript_parent.json", params); + checkBulkLoadRecordCounts(exonBulkPostEndpoint, gffDataTestFilePath + "IV_04_invalid_exon_parent.json", params); + checkBulkLoadRecordCounts(cdsBulkPostEndpoint, gffDataTestFilePath + "IV_05_invalid_cds_parent.json", params); } } diff --git a/src/test/java/org/alliancegenome/curation_api/HTPExpressionDatasetAnnotationFmsITCase.java b/src/test/java/org/alliancegenome/curation_api/HTPExpressionDatasetAnnotationFmsITCase.java new file mode 100644 index 000000000..d8b4facc6 --- /dev/null +++ b/src/test/java/org/alliancegenome/curation_api/HTPExpressionDatasetAnnotationFmsITCase.java @@ -0,0 +1,137 @@ +package org.alliancegenome.curation_api; + +import org.alliancegenome.curation_api.base.BaseITCase; +import org.alliancegenome.curation_api.resources.TestContainerResource; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestMethodOrder; + +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.hasKey; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.restassured.RestAssured; +import io.restassured.config.HttpClientConfig; +import io.restassured.config.RestAssuredConfig; + +@QuarkusIntegrationTest +@QuarkusTestResource(TestContainerResource.Initializer.class) +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +@DisplayName("610 - HTPExpressionDatasetAnnotation bulk upload - FMS") +@Order(610) +public class HTPExpressionDatasetAnnotationFmsITCase extends BaseITCase { + + @BeforeEach + public void init() { + RestAssured.config = RestAssuredConfig.config() + .httpClient(HttpClientConfig.httpClientConfig() + .setParam("http.socket.timeout", 100000) + .setParam("http.connection.timeout", 100000)); + } + + private final String htpDatasetBulkPostEndpoint = "/api/htpexpressiondatasetannotation/bulk/FB/htpexpressiondatasetannotationfile"; + private final String htpDatasetTestFilePath = "src/test/resources/bulk/fms/09_htp_dataset/"; + private final String htpDatasetFindEndpoint = "/api/htpexpressiondatasetannotation/find?limit=100&page=0"; + + @Test + @Order(1) + public void htpDatasetBulkUploadCheckFields() throws Exception { + checkSuccessfulBulkLoad(htpDatasetBulkPostEndpoint, htpDatasetTestFilePath + "AF_01_all_fields.json"); + + RestAssured.given().when().header("Content-Type", "application/json").body("{}").post(htpDatasetFindEndpoint) + .then().statusCode(200).body("totalResults", is(1)).body("results", hasSize(1)) + .body("results[0].htpExpressionDataset.curie", is("FB:FBlc0003342")) + .body("results[0].htpExpressionDataset.crossReferences", hasSize(2)) + .body("results[0].htpExpressionDataset.crossReferences[0].referencedCurie", is("TEST:TestMol00000001")) + .body("results[0].htpExpressionDataset.preferredCrossReference.referencedCurie", is("TEST:TestMol00000001")) + .body("results[0].htpExpressionDataset.secondaryIdentifiers", hasSize(1)) + .body("results[0].htpExpressionDataset.secondaryIdentifiers[0]", is("GEO:GSE38764")) + .body("results[0].references", hasSize(2)) + .body("results[0].references[0].crossReferences[0].referencedCurie", is("PMID:25920554")) + .body("results[0].subSeries", hasSize(1)) + .body("results[0].subSeries[0].curie", is("FB:FBlc0003342")) + .body("results[0].subSeries[0].crossReferences", hasSize(2)) + .body("results[0].numberOfChannels", is(2)) + .body("results[0].name", is("TEST TITLE")) + .body("results[0].relatedNote.freeText", is("TEST_SUMMARY")) + .body("results[0].categoryTags[0].name", is("anatomical structure")); + } + + @Test + @Order(2) + public void htpDatasetBulkUploadMissingRequiredFields() throws Exception { + + checkFailedBulkLoad(htpDatasetBulkPostEndpoint, htpDatasetTestFilePath + "MR_01_no_dataset_id.json"); + checkFailedBulkLoad(htpDatasetBulkPostEndpoint, htpDatasetTestFilePath + "MR_02_no_title.json"); + checkFailedBulkLoad(htpDatasetBulkPostEndpoint, htpDatasetTestFilePath + "MR_03_no_category_tags.json"); + checkFailedBulkLoad(htpDatasetBulkPostEndpoint, htpDatasetTestFilePath + "MR_04_no_primary_id.json"); + } + + @Test + @Order(3) + public void htpDatasetBulkUploadEmptyRequiredFields() throws Exception { + + checkFailedBulkLoad(htpDatasetBulkPostEndpoint, htpDatasetTestFilePath + "ER_01_empty_dataset_id.json"); + checkFailedBulkLoad(htpDatasetBulkPostEndpoint, htpDatasetTestFilePath + "ER_02_empty_title.json"); + checkFailedBulkLoad(htpDatasetBulkPostEndpoint, htpDatasetTestFilePath + "ER_03_empty_category_tags.json"); + checkFailedBulkLoad(htpDatasetBulkPostEndpoint, htpDatasetTestFilePath + "ER_04_empty_primary_id.json"); + } + + @Test + @Order(4) + public void htpDatasetBulkUploadInvalidFields() throws Exception { + + checkFailedBulkLoad(htpDatasetBulkPostEndpoint, htpDatasetTestFilePath + "IV_01_invalid_publication.json"); + checkFailedBulkLoad(htpDatasetBulkPostEndpoint, htpDatasetTestFilePath + "IV_02_invalid_number_of_channels.json"); + checkFailedBulkLoad(htpDatasetBulkPostEndpoint, htpDatasetTestFilePath + "IV_03_invalid_sub_series.json"); + checkFailedBulkLoad(htpDatasetBulkPostEndpoint, htpDatasetTestFilePath + "IV_04_invalid_category_tag.json"); + } + + @Test + @Order(5) + public void htpDatasetBulkUploadUpdateMissingNonRequiredFields() throws Exception { + + checkSuccessfulBulkLoad(htpDatasetBulkPostEndpoint, htpDatasetTestFilePath + "UM_01_update_no_non_required_fields.json"); + + RestAssured.given(). + when(). + header("Content-Type", "application/json"). + body("{}"). + post(htpDatasetFindEndpoint). + then(). + statusCode(200). + body("totalResults", is(1)). + body("results", hasSize(1)). + body("results[0]", not(hasKey("references"))). + body("results[0]", not(hasKey("subSeries"))). + body("results[0]", not(hasKey("numberOfChannels"))). + body("results[0]", not(hasKey("relatedNote"))); + } + + @Test + @Order(6) + public void htpDatasetBulkUploadUpdateEmptyNonRequiredFields() throws Exception { + + checkSuccessfulBulkLoad(htpDatasetBulkPostEndpoint, htpDatasetTestFilePath + "UE_01_update_empty_non_required_fields.json"); + + RestAssured.given(). + when(). + header("Content-Type", "application/json"). + body("{}"). + post(htpDatasetFindEndpoint). + then(). + statusCode(200). + body("totalResults", is(1)). + body("results", hasSize(1)). + body("results[0]", not(hasKey("references"))). + body("results[0]", not(hasKey("subSeries"))). + body("results[0]", not(hasKey("relatedNote"))); + } +} \ No newline at end of file diff --git a/src/test/java/org/alliancegenome/curation_api/OrthologyBulkUploadFmsITCase.java b/src/test/java/org/alliancegenome/curation_api/OrthologyBulkUploadFmsITCase.java index 29b9cbf32..271bdb623 100644 --- a/src/test/java/org/alliancegenome/curation_api/OrthologyBulkUploadFmsITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/OrthologyBulkUploadFmsITCase.java @@ -101,8 +101,8 @@ public void orthologyBulkUploadEmptyRequiredFields() throws Exception { @Order(4) public void orthologyBulkUploadInvalidFields() throws Exception { - checkFailedBulkLoad(orthologyBulkPostEndpoint, orthologyTestFilePath + "IV_01_invalid_gene1.json"); - checkFailedBulkLoad(orthologyBulkPostEndpoint, orthologyTestFilePath + "IV_02_invalid_gene2.json"); + checkSkippedBulkLoad(orthologyBulkPostEndpoint, orthologyTestFilePath + "IV_01_invalid_gene1.json"); + checkSkippedBulkLoad(orthologyBulkPostEndpoint, orthologyTestFilePath + "IV_02_invalid_gene2.json"); checkFailedBulkLoad(orthologyBulkPostEndpoint, orthologyTestFilePath + "IV_03_invalid_gene1Species.json"); checkFailedBulkLoad(orthologyBulkPostEndpoint, orthologyTestFilePath + "IV_04_invalid_gene2Species.json"); checkFailedBulkLoad(orthologyBulkPostEndpoint, orthologyTestFilePath + "IV_05_invalid_isBestScore.json"); diff --git a/src/test/java/org/alliancegenome/curation_api/ParalogyBulkUploadFmsITCase.java b/src/test/java/org/alliancegenome/curation_api/ParalogyBulkUploadFmsITCase.java index e70784e4e..69de7e46c 100644 --- a/src/test/java/org/alliancegenome/curation_api/ParalogyBulkUploadFmsITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/ParalogyBulkUploadFmsITCase.java @@ -31,8 +31,8 @@ @QuarkusTestResource(TestContainerResource.Initializer.class) @TestMethodOrder(MethodOrderer.OrderAnnotation.class) @TestInstance(TestInstance.Lifecycle.PER_CLASS) -@DisplayName("605 - Paralogy bulk upload - FMS") -@Order(605) +@DisplayName("607 - Paralogy bulk upload - FMS") +@Order(607) public class ParalogyBulkUploadFmsITCase extends BaseITCase { @BeforeEach @@ -53,7 +53,7 @@ private void loadRequiredEntities() throws Exception { Vocabulary nameTypeVocabulary = getVocabulary(VocabularyConstants.NAME_TYPE_VOCABULARY); VocabularyTerm symbolTerm = getVocabularyTerm(nameTypeVocabulary, "nomenclature_symbol"); DataProvider dataProvider = createDataProvider("WB", false); - loadGenes(List.of(gene1, gene2), "NCBITaxon:6239", symbolTerm, dataProvider); + createGenes(List.of(gene1, gene2), "NCBITaxon:6239", symbolTerm, false, dataProvider); } @Test @@ -89,10 +89,7 @@ public void paralogyBulkUploadMissingRequiredFields() throws Exception { checkFailedBulkLoad(paralogyBulkPostEndpoint, paralogyTestFilePath + "MR_02_no_gene2.json"); checkFailedBulkLoad(paralogyBulkPostEndpoint, paralogyTestFilePath + "MR_03_no_species.json"); checkFailedBulkLoad(paralogyBulkPostEndpoint, paralogyTestFilePath + "MR_04_no_confidence.json"); - checkFailedBulkLoad(paralogyBulkPostEndpoint, paralogyTestFilePath + "MR_05_no_identity.json"); - checkFailedBulkLoad(paralogyBulkPostEndpoint, paralogyTestFilePath + "MR_06_no_length.json"); checkFailedBulkLoad(paralogyBulkPostEndpoint, paralogyTestFilePath + "MR_07_no_rank.json"); - checkFailedBulkLoad(paralogyBulkPostEndpoint, paralogyTestFilePath + "MR_08_no_similarity.json"); } @Test diff --git a/src/test/java/org/alliancegenome/curation_api/PhenotypeAnnotationBulkUploadFmsITCase.java b/src/test/java/org/alliancegenome/curation_api/PhenotypeAnnotationBulkUploadFmsITCase.java index 116d02737..af1b2a9e3 100644 --- a/src/test/java/org/alliancegenome/curation_api/PhenotypeAnnotationBulkUploadFmsITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/PhenotypeAnnotationBulkUploadFmsITCase.java @@ -5,8 +5,6 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; -import java.util.List; - import org.alliancegenome.curation_api.base.BaseITCase; import org.alliancegenome.curation_api.constants.OntologyConstants; import org.alliancegenome.curation_api.constants.VocabularyConstants; @@ -73,21 +71,21 @@ public void init() { private final String phenotypeStatement = "test phenotype statement"; private void loadRequiredEntities() throws Exception { - loadGOTerm(goTerm, "Test GOTerm"); - loadExperimentalConditionTerm(expCondTerm, "Test ExperimentalConditionOntologyTerm"); - loadZecoTerm(zecoTerm, "Test ExperimentalConditionOntologyTerm", OntologyConstants.ZECO_AGR_SLIM_SUBSET); - loadZecoTerm(nonSlimZecoTerm, "Test ExperimentalConditionOntologyTerm", null); - loadChemicalTerm(chemicalTerm, "Test ChemicalTerm"); - loadAnatomyTerm(anatomyTerm, "Test AnatomicalTerm"); + createGoTerm(goTerm, "Test GOTerm", false); + createExperimentalConditionOntologyTerm(expCondTerm, "Test ExperimentalConditionOntologyTerm"); + createZecoTerm(zecoTerm, "Test ExperimentalConditionOntologyTerm", false, OntologyConstants.ZECO_AGR_SLIM_SUBSET); + createZecoTerm(nonSlimZecoTerm, "Test ExperimentalConditionOntologyTerm", false); + createChemicalTerm(chemicalTerm, "Test ChemicalTerm"); + createAnatomicalTerm(anatomyTerm, "Test AnatomicalTerm"); Vocabulary nameTypeVocabulary = getVocabulary(VocabularyConstants.NAME_TYPE_VOCABULARY); VocabularyTerm symbolTerm = getVocabularyTerm(nameTypeVocabulary, "nomenclature_symbol"); DataProvider dataProvider = createDataProvider("WB", false); - loadGenes(List.of(gene), "NCBITaxon:6239", symbolTerm, dataProvider); - loadAllele(allele, "TestAllele", "NCBITaxon:6239", symbolTerm, dataProvider); - loadAllele(allele2, "TestAllele2", "NCBITaxon:6239", symbolTerm, dataProvider); - loadAffectedGenomicModel(agm, "Test AGM", "NCBITaxon:6239", "strain", dataProvider); - loadAffectedGenomicModel(agm2, "Test AGM2", "NCBITaxon:6239", "strain", dataProvider); - loadMPTerm(mpTerm, "Test PhenotypeTerm"); + createGene(gene, "NCBITaxon:6239", symbolTerm, false, dataProvider); + createAllele(allele, "TestAllele", "NCBITaxon:6239", symbolTerm, false, dataProvider); + createAllele(allele2, "TestAllele2", "NCBITaxon:6239", symbolTerm, false, dataProvider); + createAffectedGenomicModel(agm, "Test AGM", "NCBITaxon:6239", "strain", false, dataProvider); + createAffectedGenomicModel(agm2, "Test AGM2", "NCBITaxon:6239", "strain", false, dataProvider); + createMpTerm(mpTerm, "Test PhenotypeTerm"); ResourceDescriptor rd = createResourceDescriptor("PMID"); createResourceDescriptorPage("default", "https://www.ncbi.nlm.nih.gov/pubmed/[%s]", rd); } diff --git a/src/test/java/org/alliancegenome/curation_api/SequenceTargetingReagentBulkUploadFmsITCase.java b/src/test/java/org/alliancegenome/curation_api/SequenceTargetingReagentBulkUploadFmsITCase.java index 03a2df0a4..5bb9fe659 100644 --- a/src/test/java/org/alliancegenome/curation_api/SequenceTargetingReagentBulkUploadFmsITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/SequenceTargetingReagentBulkUploadFmsITCase.java @@ -67,17 +67,16 @@ public void sqtrBulkUploadCheckFields() throws Exception { @Order(2) public void sqtrBulkUploadMissingRequiredFields() throws Exception { - checkFailedBulkLoad(sqtrBulkPostEndpoint, sqtrTestFilePath + "MR_01_no_name.json", 2, 1, 1); - checkFailedBulkLoad(sqtrBulkPostEndpoint, sqtrTestFilePath + "MR_02_no_taxon.json", 2, 1, 1); + checkBulkLoadRecordCounts(sqtrBulkPostEndpoint, sqtrTestFilePath + "MR_01_no_name.json", "Records", 2, 1, 1, 0); + checkBulkLoadRecordCounts(sqtrBulkPostEndpoint, sqtrTestFilePath + "MR_02_no_taxon.json", "Records", 2, 1, 1, 0); } @Test @Order(3) public void sqtrBulkUploadEmptyRequiredFields() throws Exception { - checkFailedBulkLoad(sqtrBulkPostEndpoint, sqtrTestFilePath + "ER_01_empty_name.json", 2, 1, 1); - - checkFailedBulkLoad(sqtrBulkPostEndpoint, sqtrTestFilePath + "ER_02_empty_taxon.json", 2, 1, 1); + checkBulkLoadRecordCounts(sqtrBulkPostEndpoint, sqtrTestFilePath + "ER_01_empty_name.json", "Records", 2, 1, 1, 0); + checkBulkLoadRecordCounts(sqtrBulkPostEndpoint, sqtrTestFilePath + "ER_02_empty_taxon.json", "Records", 2, 1, 1, 0); } diff --git a/src/test/java/org/alliancegenome/curation_api/SequenceTargetingReagentGeneAssociationBulkUploadFmsITCase.java b/src/test/java/org/alliancegenome/curation_api/SequenceTargetingReagentGeneAssociationBulkUploadFmsITCase.java index 5c9bd1bf7..46158106e 100644 --- a/src/test/java/org/alliancegenome/curation_api/SequenceTargetingReagentGeneAssociationBulkUploadFmsITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/SequenceTargetingReagentGeneAssociationBulkUploadFmsITCase.java @@ -11,7 +11,6 @@ import org.alliancegenome.curation_api.model.entities.Vocabulary; import org.alliancegenome.curation_api.model.entities.VocabularyTerm; import org.alliancegenome.curation_api.resources.TestContainerResource; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; @@ -23,7 +22,6 @@ import io.quarkus.test.junit.QuarkusIntegrationTest; import io.restassured.RestAssured; -@Disabled @QuarkusIntegrationTest @QuarkusTestResource(TestContainerResource.Initializer.class) @TestMethodOrder(MethodOrderer.OrderAnnotation.class) @@ -37,7 +35,6 @@ public class SequenceTargetingReagentGeneAssociationBulkUploadFmsITCase extends private VocabularyTerm relation; private String relationName = "targets"; private String geneCurie = "GENETEST:Gene0001"; - private String sqtrId = "83"; private String sqtrModEntityId = "ZFIN:ZDB-TALEN-180503-1"; private final String sqtrGeneAssociationGetEndpoint = "/api/sqtrgeneassociation/findBy"; @@ -51,7 +48,7 @@ private void loadRequiredEntities() throws Exception { Vocabulary noteTypeVocab = getVocabulary("construct_relation"); relation = getVocabularyTerm(noteTypeVocab, relationName); gene = getGene(geneCurie); - sqtr = getSequenceTargetingReagent(sqtrId); + sqtr = getSequenceTargetingReagent(sqtrModEntityId); } @Test @@ -72,7 +69,7 @@ public void sqtrGeneAssociationBulkUploadCheckFields() throws Exception { RestAssured.given(). when(). - get(sqtrGetEndpoint + sqtrId). + get(sqtrGetEndpoint + sqtrModEntityId). then(). statusCode(200). body("entity.sequenceTargetingReagentGeneAssociations", hasSize(1)). @@ -94,13 +91,13 @@ public void sqtrGeneAssociationBulkUploadCheckFields() throws Exception { @Test @Order(2) public void sqtrGeneAssociationBulkUploadInvalidGenes() throws Exception { - checkFailedBulkLoad(sqtrBulkPostEndpoint, sqtrGeneAssociationTestFilePath + "IV_01_invalid_gene_ids.json", 2, 1, 1); + checkBulkLoadRecordCounts(sqtrBulkPostEndpoint, sqtrGeneAssociationTestFilePath + "IV_01_invalid_gene_ids.json", "Records", 2, 1, 1, 0); } @Test @Order(3) public void sqtrGeneAssociationBulkUploadMissingGenes() throws Exception { - checkFailedBulkLoad(sqtrBulkPostEndpoint, sqtrGeneAssociationTestFilePath + "UE_01_update_empty_gene_ids.json", 2, 0, 2); + checkBulkLoadRecordCounts(sqtrBulkPostEndpoint, sqtrGeneAssociationTestFilePath + "UE_01_update_empty_gene_ids.json", "Records", 2, 0, 2, 0); } diff --git a/src/test/java/org/alliancegenome/curation_api/VariantBulkUploadITCase.java b/src/test/java/org/alliancegenome/curation_api/VariantBulkUploadITCase.java index e582b39ac..5f598180f 100644 --- a/src/test/java/org/alliancegenome/curation_api/VariantBulkUploadITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/VariantBulkUploadITCase.java @@ -59,10 +59,10 @@ public void init() { private final String variantTestFilePath = "src/test/resources/bulk/06_variant/"; private void loadRequiredEntities() throws Exception { - loadSOTerm(variantType, "Test variant type SOTerm"); - loadSOTerm(variantType2, "Second test variant type SOTerm"); - loadSOTerm(sourceGeneralConsequence, "Test source general consequence SOTerm"); - loadSOTerm(sourceGeneralConsequence2, "Second test source general consequence SOTerm"); + createSoTerm(variantType, "Test variant type SOTerm", false); + createSoTerm(variantType2, "Second test variant type SOTerm", false); + createSoTerm(sourceGeneralConsequence, "Test source general consequence SOTerm", false); + createSoTerm(sourceGeneralConsequence2, "Second test source general consequence SOTerm", false); Vocabulary variantStatusVocabulary = getVocabulary(VocabularyConstants.VARIANT_STATUS_VOCABULARY); createVocabularyTerm(variantStatusVocabulary, variantStatus, false); createVocabularyTerm(variantStatusVocabulary, variantStatus2, false); diff --git a/src/test/java/org/alliancegenome/curation_api/VariantFmsITCase.java b/src/test/java/org/alliancegenome/curation_api/VariantFmsITCase.java new file mode 100644 index 000000000..b78e22251 --- /dev/null +++ b/src/test/java/org/alliancegenome/curation_api/VariantFmsITCase.java @@ -0,0 +1,218 @@ +package org.alliancegenome.curation_api; + +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; + +import java.util.HashMap; + +import org.alliancegenome.curation_api.base.BaseITCase; +import org.alliancegenome.curation_api.constants.VocabularyConstants; +import org.alliancegenome.curation_api.model.entities.DataProvider; +import org.alliancegenome.curation_api.model.entities.Vocabulary; +import org.alliancegenome.curation_api.model.entities.VocabularyTerm; +import org.alliancegenome.curation_api.resources.TestContainerResource; +import org.apache.commons.codec.digest.DigestUtils; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestMethodOrder; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.restassured.RestAssured; +import io.restassured.config.HttpClientConfig; +import io.restassured.config.RestAssuredConfig; + +@QuarkusIntegrationTest +@QuarkusTestResource(TestContainerResource.Initializer.class) +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +@DisplayName("610 - Variant data bulk upload - FMS") +@Order(610) +public class VariantFmsITCase extends BaseITCase { + + // These tests require: GeneBulkUploadITCase and VocabularyTermITCase + + @BeforeEach + public void init() { + RestAssured.config = RestAssuredConfig.config() + .httpClient(HttpClientConfig.httpClientConfig() + .setParam("http.socket.timeout", 100000) + .setParam("http.connection.timeout", 100000)); + } + + private final String variantFmsTestFilePath = "src/test/resources/bulk/fms/10_variant/"; + private final String variantFmsBulkPostEndpoint = "/api/variant/bulk/WB/fmsvariants"; + private final String variantGetEndpoint = "/api/variant/"; + private final String allele = "WB:AlleleWithVar1"; + private final String allele2 = "WB:AlleleWithVar2"; + private final String variantId = DigestUtils.md5Hex("NC_003279.8:g.1A>T"); + private final String reference = "AGRKB:000000001"; + private final String reference2 = "AGRKB:000000021"; + + private void loadRequiredEntities() throws Exception { + createSoTerm("SO:1000002", "substitution", false); + createSoTerm("SO:0000667", "insertion", false); + createSoTerm("SO:0002007", "MNV", false); + createSoTerm("SO:1000008", "point_mutation", false); + createSoTerm("SO:0000159", "deletion", false); + createSoTerm("SO:1000032", "delins", false); + createSoTerm("SO:0001587", "stop_gained", false); + createSoTerm("SO:0001578", "stop_lost", false); + Vocabulary nameTypeVocabulary = getVocabulary(VocabularyConstants.NAME_TYPE_VOCABULARY); + VocabularyTerm symbolTerm = getVocabularyTerm(nameTypeVocabulary, "nomenclature_symbol"); + DataProvider dataProvider = createDataProvider("WB", false); + createAllele(allele, "TestAlleleWithVariant", "NCBITaxon:6239", symbolTerm, false, dataProvider); + createAllele(allele2, "TestAlleleWithVariant2", "NCBITaxon:6239", symbolTerm, false, dataProvider); + + } + + @Test + @Order(1) + public void variantFmsBulkUpload() throws Exception { + loadRequiredEntities(); + + HashMap> params = new HashMap<>(); + params.put("Entities", createCountParams(1, 0, 1, 0)); + params.put("Locations", createCountParams(1, 0, 1, 0)); + params.put("Associations", createCountParams(1, 0, 1, 0)); + + checkBulkLoadRecordCounts(variantFmsBulkPostEndpoint, variantFmsTestFilePath + "AF_01_all_fields.json", params); + + RestAssured.given(). + when(). + get(variantGetEndpoint + variantId). + then(). + statusCode(200). + body("entity.modInternalId", is(variantId)). + body("entity.taxon.curie", is("NCBITaxon:6239")). + body("entity.dataProvider.sourceOrganization.abbreviation", is("WB")). + body("entity.variantType.curie", is("SO:1000002")). + body("entity.sourceGeneralConsequence.curie", is("SO:0001587")). + body("entity.curatedVariantGenomicLocations", hasSize(1)). + body("entity.curatedVariantGenomicLocations[0].hgvs", is("NC_003279.8:g.1A>T")). + body("entity.curatedVariantGenomicLocations[0].relation.name", is("located_on")). + body("entity.curatedVariantGenomicLocations[0].variantGenomicLocationAssociationObject.name", is("I")). + body("entity.curatedVariantGenomicLocations[0].start", is(1)). + body("entity.curatedVariantGenomicLocations[0].end", is(1000)). + body("entity.alleleVariantAssociations", hasSize(1)). + body("entity.alleleVariantAssociations[0].relation.name", is("has_variant")). + body("entity.alleleVariantAssociations[0].alleleAssociationSubject.modEntityId", is("WB:AlleleWithVar1")). + body("entity.relatedNotes", hasSize(1)). + body("entity.relatedNotes[0].internal", is(false)). + body("entity.relatedNotes[0].freeText", is("This is a test note.")). + body("entity.relatedNotes[0].noteType.name", is("comment")). + body("entity.relatedNotes[0].references[0].curie", is(reference)). + body("entity.crossReferences", hasSize(1)). + body("entity.crossReferences[0].referencedCurie", is("TEST:WBVar00252636")). + body("entity.crossReferences[0].displayName", is("TEST:WBVar00252636")). + body("entity.crossReferences[0].resourceDescriptorPage.name", is("homepage")); + + } + + @Test + @Order(2) + public void variantFmsBulkUploadUpdate() throws Exception { + HashMap> params = new HashMap<>(); + params.put("Entities", createCountParams(1, 0, 1, 0)); + params.put("Locations", createCountParams(1, 0, 1, 0)); + params.put("Associations", createCountParams(1, 0, 1, 0)); + + checkBulkLoadRecordCounts(variantFmsBulkPostEndpoint, variantFmsTestFilePath + "UD_01_update_variant.json", params); + + RestAssured.given(). + when(). + get(variantGetEndpoint + variantId). + then(). + statusCode(200). + body("entity.modInternalId", is(variantId)). + body("entity.taxon.curie", is("NCBITaxon:6239")). + body("entity.dataProvider.sourceOrganization.abbreviation", is("WB")). + body("entity.variantType.curie", is("SO:1000008")). + body("entity.sourceGeneralConsequence.curie", is("SO:0001578")). + body("entity.curatedVariantGenomicLocations", hasSize(1)). + body("entity.curatedVariantGenomicLocations[0].hgvs", is("NC_003279.8:g.1A>T")). + body("entity.curatedVariantGenomicLocations[0].relation.name", is("located_on")). + body("entity.curatedVariantGenomicLocations[0].variantGenomicLocationAssociationObject.name", is("I")). + body("entity.curatedVariantGenomicLocations[0].start", is(1)). + body("entity.curatedVariantGenomicLocations[0].end", is(1000)). + body("entity.alleleVariantAssociations", hasSize(2)). + body("entity.alleleVariantAssociations[0].relation.name", is("has_variant")). + body("entity.alleleVariantAssociations[0].alleleAssociationSubject.modEntityId", is("WB:AlleleWithVar1")). + body("entity.alleleVariantAssociations[1].relation.name", is("has_variant")). + body("entity.alleleVariantAssociations[1].alleleAssociationSubject.modEntityId", is("WB:AlleleWithVar2")). + body("entity.relatedNotes", hasSize(1)). + body("entity.relatedNotes[0].internal", is(false)). + body("entity.relatedNotes[0].freeText", is("This is an updated test note.")). + body("entity.relatedNotes[0].noteType.name", is("comment")). + body("entity.relatedNotes[0].references[0].curie", is(reference2)). + body("entity.crossReferences", hasSize(1)). + body("entity.crossReferences[0].referencedCurie", is("TEST:WBVar00252637")). + body("entity.crossReferences[0].displayName", is("TEST:WBVar00252637")). + body("entity.crossReferences[0].resourceDescriptorPage.name", is("homepage")); + + } + + @Test + @Order(3) + public void variantFmsBulkUploadMissingRequiredFields() throws Exception { + HashMap> params = new HashMap<>(); + params.put("Entities", createCountParams(1, 1, 0, 0)); + params.put("Locations", createCountParams(1, 1, 0, 0)); + params.put("Associations", createCountParams(1, 1, 0, 0)); + + checkBulkLoadRecordCounts(variantFmsBulkPostEndpoint, variantFmsTestFilePath + "MR_01_no_start.json", params); + checkBulkLoadRecordCounts(variantFmsBulkPostEndpoint, variantFmsTestFilePath + "MR_02_no_end.json", params); + checkBulkLoadRecordCounts(variantFmsBulkPostEndpoint, variantFmsTestFilePath + "MR_03_no_sequence_of_reference_accession_number.json", params); + checkBulkLoadRecordCounts(variantFmsBulkPostEndpoint, variantFmsTestFilePath + "MR_04_no_type.json", params); + checkBulkLoadRecordCounts(variantFmsBulkPostEndpoint, variantFmsTestFilePath + "MR_05_no_genomic_reference_sequence.json", params); + checkBulkLoadRecordCounts(variantFmsBulkPostEndpoint, variantFmsTestFilePath + "MR_06_no_genomic_variant_sequence.json", params); + + params.put("Entities", createCountParams(1, 0, 1, 0)); + params.put("Locations", createCountParams(1, 0, 1, 0)); + checkBulkLoadRecordCounts(variantFmsBulkPostEndpoint, variantFmsTestFilePath + "MR_07_no_allele_id.json", params); + } + + @Test + @Order(4) + public void variantFmsBulkUploadEmptyRequiredFields() throws Exception { + HashMap> params = new HashMap<>(); + params.put("Entities", createCountParams(1, 1, 0, 0)); + params.put("Locations", createCountParams(1, 1, 0, 0)); + params.put("Associations", createCountParams(1, 1, 0, 0)); + + checkBulkLoadRecordCounts(variantFmsBulkPostEndpoint, variantFmsTestFilePath + "ER_01_empty_sequence_of_reference_accession_number.json", params); + checkBulkLoadRecordCounts(variantFmsBulkPostEndpoint, variantFmsTestFilePath + "ER_02_empty_type.json", params); + checkBulkLoadRecordCounts(variantFmsBulkPostEndpoint, variantFmsTestFilePath + "ER_03_empty_genomic_reference_sequence.json", params); + checkBulkLoadRecordCounts(variantFmsBulkPostEndpoint, variantFmsTestFilePath + "ER_04_empty_genomic_variant_sequence.json", params); + + params.put("Entities", createCountParams(1, 0, 1, 0)); + params.put("Locations", createCountParams(1, 0, 1, 0)); + checkBulkLoadRecordCounts(variantFmsBulkPostEndpoint, variantFmsTestFilePath + "ER_05_empty_allele_id.json", params); + } + + @Test + @Order(3) + public void variantFmsBulkUploadInvalidFields() throws Exception { + HashMap> params = new HashMap<>(); + params.put("Entities", createCountParams(1, 1, 0, 0)); + params.put("Locations", createCountParams(1, 1, 0, 0)); + params.put("Associations", createCountParams(1, 1, 0, 0)); + checkBulkLoadRecordCounts(variantFmsBulkPostEndpoint, variantFmsTestFilePath + "IV_01_invalid_type.json", params); + checkBulkLoadRecordCounts(variantFmsBulkPostEndpoint, variantFmsTestFilePath + "IV_02_invalid_type_for_fms_submissions.json", params); + checkBulkLoadRecordCounts(variantFmsBulkPostEndpoint, variantFmsTestFilePath + "IV_03_invalid_consequence.json", params); + + params.put("Entities", createCountParams(1, 0, 1, 0)); + params.put("Associations", createCountParams(1, 0, 1, 0)); + + checkBulkLoadRecordCounts(variantFmsBulkPostEndpoint, variantFmsTestFilePath + "IV_04_invalid_sequence_of_reference_accession_number.json", params); + + params.put("Locations", createCountParams(1, 0, 1, 0)); + params.put("Associations", createCountParams(1, 1, 0, 0)); + checkBulkLoadRecordCounts(variantFmsBulkPostEndpoint, variantFmsTestFilePath + "IV_05_invalid_allele_id.json", params); + } + +} diff --git a/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java b/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java index b32949a87..34bb40b0a 100644 --- a/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java +++ b/src/test/java/org/alliancegenome/curation_api/base/BaseITCase.java @@ -6,8 +6,9 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; -import java.util.regex.Pattern; +import java.util.Map.Entry; import org.alliancegenome.curation_api.constants.OntologyConstants; import org.alliancegenome.curation_api.constants.VocabularyConstants; @@ -17,6 +18,7 @@ import org.alliancegenome.curation_api.model.entities.Allele; import org.alliancegenome.curation_api.model.entities.AlleleDiseaseAnnotation; import org.alliancegenome.curation_api.model.entities.AllelePhenotypeAnnotation; +import org.alliancegenome.curation_api.model.entities.AssemblyComponent; import org.alliancegenome.curation_api.model.entities.BiologicalEntity; import org.alliancegenome.curation_api.model.entities.ConditionRelation; import org.alliancegenome.curation_api.model.entities.Construct; @@ -25,6 +27,7 @@ import org.alliancegenome.curation_api.model.entities.ExperimentalCondition; import org.alliancegenome.curation_api.model.entities.Gene; import org.alliancegenome.curation_api.model.entities.GeneDiseaseAnnotation; +import org.alliancegenome.curation_api.model.entities.GenomeAssembly; import org.alliancegenome.curation_api.model.entities.Note; import org.alliancegenome.curation_api.model.entities.Organization; import org.alliancegenome.curation_api.model.entities.Person; @@ -46,9 +49,13 @@ import org.alliancegenome.curation_api.model.entities.ontology.ExperimentalConditionOntologyTerm; import org.alliancegenome.curation_api.model.entities.ontology.GOTerm; import org.alliancegenome.curation_api.model.entities.ontology.MITerm; +import org.alliancegenome.curation_api.model.entities.ontology.MMOTerm; import org.alliancegenome.curation_api.model.entities.ontology.MPTerm; import org.alliancegenome.curation_api.model.entities.ontology.NCBITaxonTerm; +import org.alliancegenome.curation_api.model.entities.ontology.OntologyTerm; import org.alliancegenome.curation_api.model.entities.ontology.SOTerm; +import org.alliancegenome.curation_api.model.entities.ontology.StageTerm; +import org.alliancegenome.curation_api.model.entities.ontology.UBERONTerm; import org.alliancegenome.curation_api.model.entities.ontology.WBPhenotypeTerm; import org.alliancegenome.curation_api.model.entities.ontology.ZECOTerm; import org.alliancegenome.curation_api.model.entities.ontology.ZFATerm; @@ -62,11 +69,10 @@ import io.restassured.RestAssured; import io.restassured.common.mapper.TypeRef; +import io.restassured.response.ValidatableResponse; public class BaseITCase { - private static Pattern keyPattern = Pattern.compile("^(.+)\\.([^\\.]+)$"); - public VocabularyTerm addVocabularyTermToSet(String setName, String termName, Vocabulary vocabulary, Boolean obsolete) { VocabularyTermSet set = getVocabularyTermSet(setName); VocabularyTerm term = createVocabularyTerm(vocabulary, termName, false); @@ -97,11 +103,7 @@ public VocabularyTerm addVocabularyTermToSet(String setName, String termName, Vo return response.getEntity(); } - public void checkFailedBulkLoad(String endpoint, String filePath) throws Exception { - checkFailedBulkLoad(endpoint, filePath, 1, 1, 0); - } - - public void checkFailedBulkLoad(String endpoint, String filePath, int expectedTotalRecords, int expectedFailedRecords, int expectedCompletedRecords) throws Exception { + public void checkBulkLoadRecordCounts(String endpoint, String filePath, String countType, int expectedTotalRecords, int expectedFailedRecords, int expectedCompletedRecords, int expectedSkippedRecords) throws Exception { String content = Files.readString(Path.of(filePath)); RestAssured.given(). @@ -111,31 +113,65 @@ public void checkFailedBulkLoad(String endpoint, String filePath, int expectedTo post(endpoint). then(). statusCode(200). - body("history.totalRecords", is(expectedTotalRecords)). - body("history.failedRecords", is(expectedFailedRecords)). - body("history.completedRecords", is(expectedCompletedRecords)); - } - - public void checkSuccessfulBulkLoad(String endpoint, String filePath) throws Exception { - checkSuccessfulBulkLoad(endpoint, filePath, 1); + body("history.counts." + countType + ".total", is(expectedTotalRecords)). + body("history.counts." + countType + ".failed", is(expectedFailedRecords)). + body("history.counts." + countType + ".completed", is(expectedCompletedRecords)). + body("history.counts." + countType + ".skipped", is(expectedSkippedRecords)); } - public void checkSuccessfulBulkLoad(String endpoint, String filePath, int nrRecords) throws Exception { + public void checkBulkLoadRecordCounts(String endpoint, String filePath, HashMap> params) throws Exception { String content = Files.readString(Path.of(filePath)); - RestAssured.given(). + ValidatableResponse resp = RestAssured.given(). contentType("application/json"). body(content). when(). post(endpoint). then(). - statusCode(200). - body("history.totalRecords", is(nrRecords)). - body("history.failedRecords", is(0)). - body("history.completedRecords", is(nrRecords)); + statusCode(200); + + for (Entry> entry: params.entrySet()) { + resp.body("history.counts." + entry.getKey() + ".total", is(entry.getValue().get("total"))); + resp.body("history.counts." + entry.getKey() + ".failed", is(entry.getValue().get("failed"))); + resp.body("history.counts." + entry.getKey() + ".completed", is(entry.getValue().get("completed"))); + resp.body("history.counts." + entry.getKey() + ".skipped", is(entry.getValue().get("skipped"))); + } + } + + public void checkFailedBulkLoad(String endpoint, String filePath) throws Exception { + checkBulkLoadRecordCounts(endpoint, filePath, "Records", 1, 1, 0, 0); + } + + public void checkSkippedBulkLoad(String endpoint, String filePath) throws Exception { + checkBulkLoadRecordCounts(endpoint, filePath, "Records", 1, 0, 0, 1); + } + + public void checkSkippedBulkLoad(String endpoint, String filePath, int nrRecords) throws Exception { + checkBulkLoadRecordCounts(endpoint, filePath, "Records", nrRecords, 0, 0, nrRecords); + } + + public void checkSuccessfulBulkLoad(String endpoint, String filePath) throws Exception { + checkSuccessfulBulkLoad(endpoint, filePath, 1); + } + + public void checkSuccessfulBulkLoad(String endpoint, String filePath, int nrRecords) throws Exception { + checkBulkLoadRecordCounts(endpoint, filePath, "Records", nrRecords, 0, nrRecords, 0); + } + + public HashMap createCountParams(int total, int failed, int completed, int skipped) { + HashMap map = new HashMap(); + map.put("total", total); + map.put("failed", failed); + map.put("completed", completed); + map.put("skipped", skipped); + return map; + } + + public AffectedGenomicModel createAffectedGenomicModel(String modEntityId, String name, String taxonCurie, String subtypeName, Boolean obsolete) throws Exception { + return createAffectedGenomicModel(modEntityId, name, taxonCurie, subtypeName, obsolete, null); } - public AffectedGenomicModel createAffectedGenomicModel(String modEntityId, String taxonCurie, String subtypeName, String name, Boolean obsolete) { + public AffectedGenomicModel createAffectedGenomicModel(String modEntityId, String name, String taxonCurie, String subtypeName, Boolean obsolete, DataProvider dataProvider) { Vocabulary subtypeVocabulary = getVocabulary(VocabularyConstants.AGM_SUBTYPE_VOCABULARY); VocabularyTerm subtype = getVocabularyTerm(subtypeVocabulary, subtypeName); @@ -145,6 +181,7 @@ public AffectedGenomicModel createAffectedGenomicModel(String modEntityId, Strin model.setSubtype(subtype); model.setName(name); model.setObsolete(obsolete); + model.setDataProvider(dataProvider); ObjectResponse response = given(). contentType("application/json"). @@ -157,19 +194,24 @@ public AffectedGenomicModel createAffectedGenomicModel(String modEntityId, Strin return response.getEntity(); } - public Allele createAllele(String modEntityId, String taxonCurie, Boolean obsolete, VocabularyTerm symbolNameTerm) { + public Allele createAllele(String modEntityId, String taxonCurie, VocabularyTerm symbolNameTerm, Boolean obsolete) { + return createAllele(modEntityId, modEntityId, taxonCurie, symbolNameTerm, obsolete, null); + } + + public Allele createAllele(String modEntityId, String symbol, String taxonCurie, VocabularyTerm symbolNameTerm, Boolean obsolete, DataProvider dataProvider) { Allele allele = new Allele(); allele.setModEntityId(modEntityId); allele.setTaxon(getNCBITaxonTerm(taxonCurie)); allele.setObsolete(obsolete); allele.setInternal(false); + allele.setDataProvider(dataProvider); - AlleleSymbolSlotAnnotation symbol = new AlleleSymbolSlotAnnotation(); - symbol.setNameType(symbolNameTerm); - symbol.setDisplayText(modEntityId); - symbol.setFormatText(modEntityId); + AlleleSymbolSlotAnnotation alleleSymbol = new AlleleSymbolSlotAnnotation(); + alleleSymbol.setNameType(symbolNameTerm); + alleleSymbol.setDisplayText(symbol); + alleleSymbol.setFormatText(symbol); - allele.setAlleleSymbol(symbol); + allele.setAlleleSymbol(alleleSymbol); ObjectResponse response = given(). contentType("application/json"). @@ -182,6 +224,44 @@ public Allele createAllele(String modEntityId, String taxonCurie, Boolean obsole return response.getEntity(); } + public AnatomicalTerm createAnatomicalTerm(String curie, String name) throws Exception { + AnatomicalTerm anatomicalTerm = new AnatomicalTerm(); + anatomicalTerm.setCurie(curie); + anatomicalTerm.setName(name); + anatomicalTerm.setObsolete(false); + anatomicalTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); + + ObjectResponse response = RestAssured.given(). + contentType("application/json"). + body(anatomicalTerm). + when(). + put("/api/anatomicalterm"). + then(). + statusCode(200). + extract().body().as(getObjectResponseTypeRefAnatomicalTerm()); + + return response.getEntity(); + } + + public AssemblyComponent createAssemblyComponent(String modEntityId, String name, GenomeAssembly assembly, DataProvider dataProvider) throws Exception { + AssemblyComponent assemblyComponent = new AssemblyComponent(); + assemblyComponent.setModEntityId(modEntityId); + assemblyComponent.setName(name); + assemblyComponent.setDataProvider(dataProvider); + assemblyComponent.setGenomeAssembly(assembly); + + ObjectResponse response = RestAssured.given(). + contentType("application/json"). + body(assemblyComponent). + when(). + put("/api/assemblycomponent"). + then(). + statusCode(200). + extract().body().as(getObjectResponseTypeRefAssemblyComponent()); + + return response.getEntity(); + } + public BiologicalEntity createBiologicalEntity(String modEntityId, String taxonCurie) { BiologicalEntity bioEntity = new BiologicalEntity(); bioEntity.setModEntityId(modEntityId); @@ -214,6 +294,26 @@ public CHEBITerm createChebiTerm(String curie, String name, Boolean obsolete) { then(). statusCode(200). extract().body().as(getObjectResponseTypeRefCHEBITerm()); + + return response.getEntity(); + } + + public ChemicalTerm createChemicalTerm(String curie, String name) throws Exception { + ChemicalTerm chemicalTerm = new ChemicalTerm(); + chemicalTerm.setCurie(curie); + chemicalTerm.setName(name); + chemicalTerm.setObsolete(false); + chemicalTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); + + ObjectResponse response = RestAssured.given(). + contentType("application/json"). + body(chemicalTerm). + when(). + put("/api/chemicalterm"). + then(). + statusCode(200). + extract().body().as(getObjectResponseTypeRefChemicalTerm()); + return response.getEntity(); } @@ -282,9 +382,18 @@ public DataProvider createDataProvider(String organizationAbbreviation, Boolean return response.getEntity(); } + public DOTerm createDoTerm(String curie, String name) { + return createDoTerm(curie, name, false); + } + public DOTerm createDoTerm(String curie, Boolean obsolete) { + return createDoTerm(curie, curie, obsolete); + } + + public DOTerm createDoTerm(String curie, String name, Boolean obsolete) { DOTerm doTerm = new DOTerm(); doTerm.setCurie(curie); + doTerm.setName(name); doTerm.setObsolete(obsolete); doTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); @@ -296,6 +405,7 @@ public DOTerm createDoTerm(String curie, Boolean obsolete) { then(). statusCode(200). extract().body().as(getObjectResponseTypeRefDOTerm()); + return response.getEntity(); } @@ -337,10 +447,47 @@ public ExperimentalCondition createExperimentalCondition(String uniqueId, String return response.getEntity(); } - public Gene createGene(String modEntityId, String taxonCurie, Boolean obsolete, VocabularyTerm symbolNameTerm) { + public ExperimentalConditionOntologyTerm createExperimentalConditionOntologyTerm(String curie, String name) throws Exception { + ExperimentalConditionOntologyTerm ecTerm = new ExperimentalConditionOntologyTerm(); + ecTerm.setCurie(curie); + ecTerm.setName(name); + ecTerm.setObsolete(false); + ecTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); + + ObjectResponse response = RestAssured.given(). + contentType("application/json"). + body(ecTerm). + when(). + post("/api/experimentalconditionontologyterm"). + then(). + statusCode(200). + extract().body().as(getObjectResponseTypeRefExperimentalConditionOntologyTerm()); + + return response.getEntity(); + } + + public Gene createGene(String modEntityId, String taxonCurie, VocabularyTerm symbolNameTerm, Boolean obsolete) { + return createGene(modEntityId, taxonCurie, symbolNameTerm, obsolete, null); + } + + public Gene createGene(String modEntityId, String taxonCurie, VocabularyTerm symbolNameTerm, Boolean obsolete, DataProvider dataProvider) { + return createGeneWithXref(modEntityId, taxonCurie, symbolNameTerm, obsolete, dataProvider, null); + } + + public List createGenes(List modEntityIds, String taxonCurie, VocabularyTerm symbolNameTerm, Boolean obsolete, DataProvider dataProvider) { + List geneList = new ArrayList<>(); + for (String modEntityId : modEntityIds) { + geneList.add(createGene(modEntityId, taxonCurie, symbolNameTerm, obsolete, dataProvider)); + } + + return geneList; + } + + public Gene createGeneWithXref(String modEntityId, String taxonCurie, VocabularyTerm symbolNameTerm, Boolean obsolete, DataProvider dataProvider, String xrefCurie) { Gene gene = new Gene(); gene.setModEntityId(modEntityId); gene.setTaxon(getNCBITaxonTerm(taxonCurie)); + gene.setDataProvider(dataProvider); gene.setObsolete(obsolete); GeneSymbolSlotAnnotation symbol = new GeneSymbolSlotAnnotation(); @@ -349,10 +496,17 @@ public Gene createGene(String modEntityId, String taxonCurie, Boolean obsolete, symbol.setFormatText(modEntityId); gene.setGeneSymbol(symbol); - + SOTerm geneType = getSoTerm("SO:0001217"); gene.setGeneType(geneType); + if (StringUtils.isNotBlank(xrefCurie)) { + CrossReference xref = new CrossReference(); + xref.setReferencedCurie(xrefCurie); + xref.setDisplayName(xrefCurie); + gene.setCrossReferences(List.of(xref)); + } + ObjectResponse response = given(). contentType("application/json"). body(gene). @@ -364,12 +518,42 @@ public Gene createGene(String modEntityId, String taxonCurie, Boolean obsolete, return response.getEntity(); } + public OntologyTerm createOntologyTerm(String curie, String name, Boolean obsolete) { + OntologyTerm ontologyTerm = new OntologyTerm(); + ontologyTerm.setCurie(curie); + ontologyTerm.setName(name); + ontologyTerm.setObsolete(obsolete); + ObjectResponse response = given(). + contentType("application/json"). + body(ontologyTerm). + when(). + post("/api/ontologyterm"). + then(). + statusCode(200). + extract().body().as(getObjectResponseTypeRefOntologyTerm()); + return response.getEntity(); + } + public GOTerm createGoTerm(String curie, String name, Boolean obsolete) { + return createGoTerm(curie, name, obsolete, null, null); + } + + public GOTerm createGoTerm(String curie, String name, Boolean obsolete, List subsets) { + return createGoTerm(curie, name, obsolete, null, subsets); + } + + public GOTerm createGoTerm(String curie, String name, Boolean obsolete, GOTerm ancestor) { + return createGoTerm(curie, name, obsolete, ancestor, null); + } + + public GOTerm createGoTerm(String curie, String name, Boolean obsolete, GOTerm ancestor, List subsets) { GOTerm goTerm = new GOTerm(); goTerm.setCurie(curie); goTerm.setObsolete(obsolete); goTerm.setName(name); goTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); + goTerm.setSubsets(subsets); + goTerm.addIsaAncestor(ancestor); ObjectResponse response = given(). contentType("application/json"). @@ -382,11 +566,57 @@ public GOTerm createGoTerm(String curie, String name, Boolean obsolete) { return response.getEntity(); } + public MITerm createMiTerm(String curie, String name) throws Exception { + MITerm miTerm = new MITerm(); + miTerm.setCurie(curie); + miTerm.setName(name); + miTerm.setObsolete(false); + miTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); + + ObjectResponse response = RestAssured.given(). + contentType("application/json"). + body(miTerm). + when(). + put("/api/miterm"). + then(). + statusCode(200). + extract().body().as(getObjectResponseTypeRefMITerm()); + + return response.getEntity(); + } + + public MMOTerm createMmoTerm(String curie, String name) throws Exception { + MMOTerm mmoTerm = new MMOTerm(); + mmoTerm.setCurie(curie); + mmoTerm.setName(name); + mmoTerm.setObsolete(false); + mmoTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); + + ObjectResponse response = RestAssured.given(). + contentType("application/json"). + body(mmoTerm). + when(). + put("/api/mmoterm"). + then(). + statusCode(200). + extract().body().as(getObjectResponseTypeRefMMOTerm()); + + return response.getEntity(); + } + + public MPTerm createMpTerm(String curie, String name) { + return createMpTerm(curie, name, false); + } + public MPTerm createMpTerm(String curie, Boolean obsolete) { + return createMpTerm(curie, "Test MPTerm", obsolete); + } + + public MPTerm createMpTerm(String curie, String name, Boolean obsolete) { MPTerm mpTerm = new MPTerm(); mpTerm.setCurie(curie); mpTerm.setObsolete(obsolete); - mpTerm.setName("Test MPTerm"); + mpTerm.setName(name); mpTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); ObjectResponse response = given(). @@ -397,6 +627,7 @@ public MPTerm createMpTerm(String curie, Boolean obsolete) { then(). statusCode(200). extract().body().as(getObjectResponseTypeRefMPTerm()); + return response.getEntity(); } @@ -464,12 +695,19 @@ public Person createPerson(String uniqueId) { return person; } + public Reference createReference(String curie, String xrefCurie) { + return createReference(curie, xrefCurie, false); + } + public Reference createReference(String curie, Boolean obsolete) { + return createReference(curie, "PMID:TestXref", obsolete); + } + + public Reference createReference(String curie, String xrefCurie, Boolean obsolete) { Reference reference = new Reference(); reference.setCurie(curie); reference.setObsolete(obsolete); - String xrefCurie = "PMID:TestXref"; CrossReference xref = new CrossReference(); xref.setReferencedCurie(xrefCurie); xref.setDisplayName(xrefCurie); @@ -530,6 +768,23 @@ public ResourceDescriptorPage createResourceDescriptorPage(String name, String u return response.getEntity(); } + public SequenceTargetingReagent createSequenceTargetingReagent(String modEntityId, Boolean obsolete, String name) { + SequenceTargetingReagent sqtr = new SequenceTargetingReagent(); + sqtr.setModEntityId(modEntityId); + sqtr.setObsolete(obsolete); + sqtr.setName(name); + + ObjectResponse response = given(). + contentType("application/json"). + body(sqtr). + when(). + post("/api/sqtr"). + then(). + statusCode(200). + extract().body().as(getObjectResponseTypeRefSequenceTargetingReagent()); + return response.getEntity(); + } + public SOTerm createSoTerm(String curie, String name, Boolean obsolete) { SOTerm term = new SOTerm(); term.setCurie(curie); @@ -549,6 +804,44 @@ public SOTerm createSoTerm(String curie, String name, Boolean obsolete) { return response.getEntity(); } + public StageTerm createStageTerm(String curie, String name) throws Exception { + StageTerm stageTerm = new StageTerm(); + stageTerm.setCurie(curie); + stageTerm.setName(name); + stageTerm.setObsolete(false); + stageTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); + + ObjectResponse response = RestAssured.given(). + contentType("application/json"). + body(stageTerm). + when(). + put("/api/stageterm"). + then(). + statusCode(200). + extract().body().as(getObjectResponseTypeRefStageTerm()); + + return response.getEntity(); + } + + public UBERONTerm createUberonTerm(String curie, String name) throws Exception { + UBERONTerm uberonTerm = new UBERONTerm(); + uberonTerm.setCurie(curie); + uberonTerm.setName(name); + uberonTerm.setObsolete(false); + uberonTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); + + ObjectResponse response = RestAssured.given(). + contentType("application/json"). + body(uberonTerm). + when(). + put("/api/uberonterm"). + then(). + statusCode(200). + extract().body().as(getObjectResponseTypeRefUBERONTerm()); + + return response.getEntity(); + } + public Vocabulary createVocabulary(String name, Boolean obsolete) { Vocabulary vocabulary = new Vocabulary(); vocabulary.setName(name); @@ -591,6 +884,27 @@ public VocabularyTerm createVocabularyTerm(Vocabulary vocabulary, String name, B return response.getEntity(); } + public VocabularyTerm createVocabularyTerm(VocabularyTermSet vocabularyTermSet, String name, Boolean obsolete) { + VocabularyTerm vocabularyTerm = new VocabularyTerm(); + vocabularyTerm.setName(name); + vocabularyTerm.setVocabulary(vocabularyTermSet.getVocabularyTermSetVocabulary()); + vocabularyTerm.setVocabularyTermSets(List.of(vocabularyTermSet)); + vocabularyTerm.setObsolete(obsolete); + vocabularyTerm.setInternal(false); + + ObjectResponse response = + RestAssured.given(). + contentType("application/json"). + body(vocabularyTerm). + when(). + post("/api/vocabularyterm"). + then(). + statusCode(200). + extract().body().as(getObjectResponseTypeRefVocabularyTerm()); + + return response.getEntity(); + } + public void createVocabularyTermSet(String name, Vocabulary vocabulary, List terms) { VocabularyTermSet vocabularyTermSet = new VocabularyTermSet(); vocabularyTermSet.setName(name); @@ -608,6 +922,29 @@ public void createVocabularyTermSet(String name, Vocabulary vocabulary, List response = RestAssured.given(). + contentType("application/json"). + body(wbTerm). + when(). + put("/api/wbphenotypeterm"). + then(). + statusCode(200). + extract().body().as(getObjectResponseTypeRefWBPhenotypeTerm()); + + return response.getEntity(); + } + + public ZECOTerm createZecoTerm(String curie, String name, Boolean obsolete) { + return createZecoTerm(curie, name, obsolete, null); + } + public ZECOTerm createZecoTerm(String curie, String name, Boolean obsolete, String subset) { ZECOTerm zecoTerm = new ZECOTerm(); zecoTerm.setCurie(curie); @@ -782,6 +1119,17 @@ public GeneDiseaseAnnotation getGeneDiseaseAnnotation(String uniqueId) { return res.getEntity(); } + + public GenomeAssembly getGenomeAssembly(String modEntityId) throws Exception { + ObjectResponse response = RestAssured.given(). + when(). + get("/api/genomeassembly/" + modEntityId). + then(). + statusCode(200). + extract().body().as(getObjectResponseTypeRefGenomeAssembly()); + + return response.getEntity(); + } public MPTerm getMpTerm(String curie) { ObjectResponse response = RestAssured.given(). @@ -850,6 +1198,16 @@ private TypeRef> getObjectResponseTypeRefA }; } + private TypeRef> getObjectResponseTypeRefAnatomicalTerm() { + return new TypeRef>() { + }; + } + + private TypeRef> getObjectResponseTypeRefAssemblyComponent() { + return new TypeRef>() { + }; + } + private TypeRef> getObjectResponseTypeRefBiologicalEntity() { return new TypeRef>() { }; @@ -860,6 +1218,11 @@ private TypeRef> getObjectResponseTypeRefCHEBITerm() { }; } + private TypeRef> getObjectResponseTypeRefChemicalTerm() { + return new TypeRef>() { + }; + } + public TypeRef> getObjectResponseTypeRefConditionRelation() { return new TypeRef>() { }; @@ -900,11 +1263,21 @@ private TypeRef> getObjectResponseTypeRefE }; } + private TypeRef> getObjectResponseTypeRefExperimentalConditionOntologyTerm() { + return new TypeRef>() { + }; + } + private TypeRef> getObjectResponseTypeRefGene() { return new TypeRef>() { }; } + private TypeRef> getObjectResponseTypeRefGenomeAssembly() { + return new TypeRef>() { + }; + } + private TypeRef> getObjectResponseTypeRefSequenceTargetingReagent() { return new TypeRef>() { }; @@ -925,6 +1298,16 @@ private TypeRef> getObjectResponseTypeRefLoggedInPerson() }; } + private TypeRef> getObjectResponseTypeRefMITerm() { + return new TypeRef>() { + }; + } + + private TypeRef> getObjectResponseTypeRefMMOTerm() { + return new TypeRef>() { + }; + } + private TypeRef> getObjectResponseTypeRefMPTerm() { return new TypeRef>() { }; @@ -940,6 +1323,11 @@ public TypeRef> getObjectResponseTypeRefNote() { }; } + private TypeRef> getObjectResponseTypeRefOntologyTerm() { + return new TypeRef>() { + }; + } + private TypeRef> getObjectResponseTypeRefOrganization() { return new TypeRef>() { }; @@ -965,6 +1353,16 @@ private TypeRef> getObjectResponseTypeRefSOTerm() { }; } + private TypeRef> getObjectResponseTypeRefStageTerm() { + return new TypeRef>() { + }; + } + + private TypeRef> getObjectResponseTypeRefUBERONTerm() { + return new TypeRef>() { + }; + } + private TypeRef> getObjectResponseTypeRefVariant() { return new TypeRef>() { }; @@ -980,8 +1378,13 @@ private TypeRef> getObjectResponseTypeRefVocabula }; } + private TypeRef> getObjectResponseTypeRefWBPhenotypeTerm() { + return new TypeRef>() { + }; + } + private TypeRef> getObjectResponseTypeRefZecoTerm() { - return new TypeRef<>() { + return new TypeRef>() { }; } @@ -1112,312 +1515,4 @@ public ZECOTerm getZecoTerm(String curie) { return response.getEntity(); } - - public void loadAffectedGenomicModel(String modEntityId, String name, String taxonCurie, String subtypeName, DataProvider dataProvider) throws Exception { - Vocabulary subtypeVocabulary = getVocabulary(VocabularyConstants.AGM_SUBTYPE_VOCABULARY); - VocabularyTerm subtype = getVocabularyTerm(subtypeVocabulary, subtypeName); - - AffectedGenomicModel agm = new AffectedGenomicModel(); - agm.setModEntityId(modEntityId); - agm.setTaxon(getNCBITaxonTerm(taxonCurie)); - agm.setName(name); - agm.setSubtype(subtype); - agm.setDataProvider(dataProvider); - RestAssured.given(). - contentType("application/json"). - body(agm). - when(). - post("/api/agm"). - then(). - statusCode(200); - } - - public void loadAllele(String identifier, String symbol, String taxonCurie, VocabularyTerm symbolNameTerm, DataProvider dataProvider) throws Exception { - Allele allele = new Allele(); - allele.setModEntityId(identifier); - allele.setTaxon(getNCBITaxonTerm(taxonCurie)); - allele.setInternal(false); - allele.setDataProvider(dataProvider); - - AlleleSymbolSlotAnnotation alleleSymbol = new AlleleSymbolSlotAnnotation(); - alleleSymbol.setNameType(symbolNameTerm); - alleleSymbol.setDisplayText(symbol); - alleleSymbol.setFormatText(symbol); - - allele.setAlleleSymbol(alleleSymbol); - - RestAssured.given(). - contentType("application/json"). - body(allele). - when(). - post("/api/allele"). - then(). - statusCode(200); - } - - public void loadAnatomyTerm(String curie, String name) throws Exception { - AnatomicalTerm anatomicalTerm = new AnatomicalTerm(); - anatomicalTerm.setCurie(curie); - anatomicalTerm.setName(name); - anatomicalTerm.setObsolete(false); - anatomicalTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); - - RestAssured.given(). - contentType("application/json"). - body(anatomicalTerm). - when(). - put("/api/anatomicalterm"). - then(). - statusCode(200); - } - - public void loadChemicalTerm(String curie, String name) throws Exception { - ChemicalTerm chemicalTerm = new ChemicalTerm(); - chemicalTerm.setCurie(curie); - chemicalTerm.setName(name); - chemicalTerm.setObsolete(false); - chemicalTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); - - RestAssured.given(). - contentType("application/json"). - body(chemicalTerm). - when(). - put("/api/chemicalterm"). - then(). - statusCode(200); - } - - public void loadDOTerm(String curie, String name) throws Exception { - DOTerm doTerm = new DOTerm(); - doTerm.setCurie(curie); - doTerm.setName(name); - doTerm.setObsolete(false); - doTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); - - RestAssured.given(). - contentType("application/json"). - body(doTerm). - when(). - put("/api/doterm"). - then(). - statusCode(200); - } - - public void loadExperimentalConditionTerm(String curie, String name) throws Exception { - ExperimentalConditionOntologyTerm ecTerm = new ExperimentalConditionOntologyTerm(); - ecTerm.setCurie(curie); - ecTerm.setName(name); - ecTerm.setObsolete(false); - ecTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); - - RestAssured.given(). - contentType("application/json"). - body(ecTerm). - when(). - post("/api/experimentalconditionontologyterm"). - then(). - statusCode(200); - } - - public void loadGene(String modEntityId, String taxonCurie, VocabularyTerm symbolNameTerm, DataProvider dataProvider) { - loadGeneWithXref(modEntityId, taxonCurie, symbolNameTerm, dataProvider, null); - } - - public void loadGeneWithXref(String modEntityId, String taxonCurie, VocabularyTerm symbolNameTerm, DataProvider dataProvider, String xrefCurie) { - Gene gene = new Gene(); - gene.setModEntityId(modEntityId); - gene.setTaxon(getNCBITaxonTerm(taxonCurie)); - gene.setDataProvider(dataProvider); - - GeneSymbolSlotAnnotation symbol = new GeneSymbolSlotAnnotation(); - symbol.setNameType(symbolNameTerm); - symbol.setDisplayText(modEntityId); - symbol.setFormatText(modEntityId); - - gene.setGeneSymbol(symbol); - - SOTerm geneType = getSoTerm("SO:0001217"); - gene.setGeneType(geneType); - - if (StringUtils.isNotBlank(xrefCurie)) { - CrossReference xref = new CrossReference(); - xref.setReferencedCurie(xrefCurie); - xref.setDisplayName(xrefCurie); - gene.setCrossReferences(List.of(xref)); - } - - RestAssured.given(). - contentType("application/json"). - body(gene). - when(). - post("/api/gene"). - then(). - statusCode(200); - } - - public void loadGenes(List modEntityIds, String taxonCurie, VocabularyTerm symbolNameTerm, DataProvider dataProvider) throws Exception { - for (String modEntityId : modEntityIds) { - loadGene(modEntityId, taxonCurie, symbolNameTerm, dataProvider); - } - } - - public void loadGOTerm(String curie, String name) throws Exception { - GOTerm goTerm = new GOTerm(); - goTerm.setCurie(curie); - goTerm.setName(name); - goTerm.setObsolete(false); - goTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); - - RestAssured.given(). - contentType("application/json"). - body(goTerm). - when(). - put("/api/goterm"). - then(). - statusCode(200); - } - - public void loadMITerm(String curie, String name) throws Exception { - MITerm miTerm = new MITerm(); - miTerm.setCurie(curie); - miTerm.setName(name); - miTerm.setObsolete(false); - miTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); - - RestAssured.given(). - contentType("application/json"). - body(miTerm). - when(). - put("/api/miterm"). - then(). - statusCode(200); - } - public void loadMMOTerm(String curie, String name) throws Exception { - MPTerm mpTerm = new MPTerm(); - mpTerm.setCurie(curie); - mpTerm.setName(name); - mpTerm.setObsolete(false); - mpTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); - - RestAssured.given(). - contentType("application/json"). - body(mpTerm). - when(). - put("/api/mmoterm"). - then(). - statusCode(200); - } - - public void loadMPTerm(String curie, String name) throws Exception { - MPTerm mpTerm = new MPTerm(); - mpTerm.setCurie(curie); - mpTerm.setName(name); - mpTerm.setObsolete(false); - mpTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); - - RestAssured.given(). - contentType("application/json"). - body(mpTerm). - when(). - put("/api/mpterm"). - then(). - statusCode(200); - } - - public void loadOrganization(String abbreviation) throws Exception { - Organization organization = new Organization(); - organization.setAbbreviation(abbreviation); - organization.setObsolete(false); - - RestAssured.given(). - contentType("application/json"). - body(organization). - when(). - put("/api/organization"). - then(). - statusCode(200); - } - - public void loadReference(String curie, String xrefCurie) throws Exception { - - CrossReference xref = new CrossReference(); - xref.setReferencedCurie(xrefCurie); - xref.setDisplayName(xrefCurie); - - ObjectResponse response = - RestAssured.given(). - contentType("application/json"). - body(xref). - when(). - post("/api/cross-reference"). - then(). - statusCode(200). - extract().body().as(getObjectResponseTypeRefCrossReference()); - - Reference reference = new Reference(); - reference.setCurie(curie); - reference.setCrossReferences(List.of(response.getEntity())); - reference.setObsolete(false); - - RestAssured.given(). - contentType("application/json"). - body(reference). - when(). - post("/api/reference"). - then(). - statusCode(200); - } - - public void loadSOTerm(String curie, String name) throws Exception { - SOTerm soTerm = new SOTerm(); - soTerm.setCurie(curie); - soTerm.setName(name); - soTerm.setObsolete(false); - soTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); - - RestAssured.given(). - contentType("application/json"). - body(soTerm). - when(). - put("/api/soterm"). - then(). - statusCode(200); - } - - public void loadWbPhenotypeTerm(String curie, String name) throws Exception { - WBPhenotypeTerm wbTerm = new WBPhenotypeTerm(); - wbTerm.setCurie(curie); - wbTerm.setName(name); - wbTerm.setObsolete(false); - wbTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); - - RestAssured.given(). - contentType("application/json"). - body(wbTerm). - when(). - put("/api/wbphenotypeterm"). - then(). - statusCode(200); - } - - public void loadZecoTerm(String curie, String name, String subset) throws Exception { - ZECOTerm zecoTerm = new ZECOTerm(); - zecoTerm.setCurie(curie); - zecoTerm.setName(name); - zecoTerm.setObsolete(false); - List subsets = new ArrayList(); - if (subset != null) { - subsets.add(subset); - zecoTerm.setSubsets(subsets); - } - zecoTerm.setSecondaryIdentifiers(List.of(curie + "secondary")); - - RestAssured.given(). - contentType("application/json"). - body(zecoTerm). - when(). - post("/api/zecoterm"). - then(). - statusCode(200); - } } diff --git a/src/test/java/org/alliancegenome/curation_api/resources/TestContainerResource.java b/src/test/java/org/alliancegenome/curation_api/resources/TestContainerResource.java index 5f63ea6b2..36e7e4151 100644 --- a/src/test/java/org/alliancegenome/curation_api/resources/TestContainerResource.java +++ b/src/test/java/org/alliancegenome/curation_api/resources/TestContainerResource.java @@ -24,7 +24,7 @@ public Map start() { DockerImageName esImage = DockerImageName.parse("docker.elastic.co/elasticsearch/elasticsearch:7.10.2").asCompatibleSubstituteFor("docker.elastic.co/elasticsearch/elasticsearch"); //esContainer = new ElasticsearchContainer(esImage); - osContainer = new OpenSearchContainer("opensearchproject/opensearch:1.2.4"); + osContainer = new OpenSearchContainer("opensearchproject/opensearch:2.16.0"); pgContainer = new PostgreSQLContainer("postgres:14.2"); diff --git a/src/test/resources/bulk/04_disease_annotation/AF_01_all_fields_gene_annotation.json b/src/test/resources/bulk/04_disease_annotation/AF_01_all_fields_gene_annotation.json index 34b0a2b0e..34eaac35a 100644 --- a/src/test/resources/bulk/04_disease_annotation/AF_01_all_fields_gene_annotation.json +++ b/src/test/resources/bulk/04_disease_annotation/AF_01_all_fields_gene_annotation.json @@ -73,7 +73,9 @@ } ], "disease_genetic_modifier_identifiers": [ - "DATEST:Gene0002" + "DATEST:Gene0002", + "DATEST:Allele0002", + "DATEST:AGM0002" ], "disease_genetic_modifier_relation_name": "ameliorated_by", "with_gene_identifiers": [ diff --git a/src/test/resources/bulk/04_disease_annotation/AF_02_all_fields_allele_annotation.json b/src/test/resources/bulk/04_disease_annotation/AF_02_all_fields_allele_annotation.json index e9eb039a5..30b884705 100644 --- a/src/test/resources/bulk/04_disease_annotation/AF_02_all_fields_allele_annotation.json +++ b/src/test/resources/bulk/04_disease_annotation/AF_02_all_fields_allele_annotation.json @@ -73,7 +73,9 @@ } ], "disease_genetic_modifier_identifiers": [ - "DATEST:Gene0002" + "DATEST:Gene0002", + "DATEST:Allele0002", + "DATEST:AGM0002" ], "disease_genetic_modifier_relation_name": "ameliorated_by", "with_gene_identifiers": [ diff --git a/src/test/resources/bulk/04_disease_annotation/AF_03_all_fields_agm_annotation.json b/src/test/resources/bulk/04_disease_annotation/AF_03_all_fields_agm_annotation.json index abcb54cc5..86b0bd796 100644 --- a/src/test/resources/bulk/04_disease_annotation/AF_03_all_fields_agm_annotation.json +++ b/src/test/resources/bulk/04_disease_annotation/AF_03_all_fields_agm_annotation.json @@ -73,7 +73,9 @@ } ], "disease_genetic_modifier_identifiers": [ - "DATEST:Gene0002" + "DATEST:Gene0002", + "DATEST:Allele0002", + "DATEST:AGM0002" ], "disease_genetic_modifier_relation_name": "ameliorated_by", "with_gene_identifiers": [ diff --git a/src/test/resources/bulk/04_disease_annotation/UD_01_update_all_except_default_fields_gene_annotation.json b/src/test/resources/bulk/04_disease_annotation/UD_01_update_all_except_default_fields_gene_annotation.json index 9c54c14e4..bd50ea07d 100644 --- a/src/test/resources/bulk/04_disease_annotation/UD_01_update_all_except_default_fields_gene_annotation.json +++ b/src/test/resources/bulk/04_disease_annotation/UD_01_update_all_except_default_fields_gene_annotation.json @@ -66,7 +66,9 @@ } ], "disease_genetic_modifier_identifiers": [ - "DATEST:Gene0001" + "DATEST:Gene0001", + "DATEST:Allele0001", + "DATEST:AGM0001" ], "disease_genetic_modifier_relation_name": "exacerbated_by", "with_gene_identifiers": [ diff --git a/src/test/resources/bulk/04_disease_annotation/UD_02_update_all_except_default_fields_allele_annotation.json b/src/test/resources/bulk/04_disease_annotation/UD_02_update_all_except_default_fields_allele_annotation.json index ffd5920ad..c661fb381 100644 --- a/src/test/resources/bulk/04_disease_annotation/UD_02_update_all_except_default_fields_allele_annotation.json +++ b/src/test/resources/bulk/04_disease_annotation/UD_02_update_all_except_default_fields_allele_annotation.json @@ -66,7 +66,9 @@ } ], "disease_genetic_modifier_identifiers": [ - "DATEST:Gene0001" + "DATEST:Gene0001", + "DATEST:Allele0001", + "DATEST:AGM0001" ], "disease_genetic_modifier_relation_name": "exacerbated_by", "with_gene_identifiers": [ diff --git a/src/test/resources/bulk/04_disease_annotation/UD_03_update_all_except_default_fields_agm_annotation.json b/src/test/resources/bulk/04_disease_annotation/UD_03_update_all_except_default_fields_agm_annotation.json index f0cc1fe3f..b8836be43 100644 --- a/src/test/resources/bulk/04_disease_annotation/UD_03_update_all_except_default_fields_agm_annotation.json +++ b/src/test/resources/bulk/04_disease_annotation/UD_03_update_all_except_default_fields_agm_annotation.json @@ -66,7 +66,9 @@ } ], "disease_genetic_modifier_identifiers": [ - "DATEST:Gene0001" + "DATEST:Gene0001", + "DATEST:Allele0001", + "DATEST:AGM0001" ], "disease_genetic_modifier_relation_name": "exacerbated_by", "with_gene_identifiers": [ diff --git a/src/test/resources/bulk/fms/07_expression/AF_01_all_fields.json b/src/test/resources/bulk/fms/07_expression/AF_01_all_fields.json index 1eb527bc4..a9873c0ca 100644 --- a/src/test/resources/bulk/fms/07_expression/AF_01_all_fields.json +++ b/src/test/resources/bulk/fms/07_expression/AF_01_all_fields.json @@ -23,10 +23,20 @@ }, "whereExpressed" : { "whereExpressedStatement" : "trunk", - "anatomicalStructureTermId" : "ZFA:001", - "anatomicalStructureUberonSlimTermIds" : [ { - "uberonTerm" : "Other" - } ] + "anatomicalStructureTermId" : "ANAT:001", + "anatomicalSubStructureTermId" : "ANAT:002", + "cellularComponentTermId" : "GOTEST:0012", + "anatomicalStructureQualifierTermId": "UBERON:002", + "anatomicalSubStructureQualifierTermId": "UBERON:003", + "cellularComponentQualifierTermId": "FBCV:001", + "anatomicalStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:004"}, + {"uberonTerm" : "UBERON:005"} + ], + "anatomicalSubStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:006"}, + {"uberonTerm" : "UBERON:007"} + ] } } ] diff --git a/src/test/resources/bulk/fms/07_expression/IV_05_invalid_stageterm.json b/src/test/resources/bulk/fms/07_expression/IV_05_invalid_stageterm.json new file mode 100644 index 000000000..c47a34dd2 --- /dev/null +++ b/src/test/resources/bulk/fms/07_expression/IV_05_invalid_stageterm.json @@ -0,0 +1,43 @@ +[ + { + "dateAssigned" : "2024-01-17T07:31:34-08:00", + "geneId" : "GEXPTEST:GENE001", + "evidence" : { + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ "reference" ] + }, + "publicationId" : "PMID:009" + }, + "crossReference" : { + "id" : "ZFIN:ZDB-FIG-170413-34", + "pages" : [ "gene/expression/annotation/detail" ] + }, + "assay" : "GEXPTEST:assay001", + "whenExpressed" : { + "stageName" : "stage1", + "stageTermId" : "ZFS:NOTFOUND", + "stageUberonSlimTerm" : { + "uberonTerm" : "UBERON:001" + } + }, + "whereExpressed" : { + "whereExpressedStatement" : "trunk", + "anatomicalStructureTermId" : "ANAT:001", + "anatomicalSubStructureTermId" : "ANAT:002", + "cellularComponentTermId" : "GOTEST:0012", + "anatomicalStructureQualifierTermId": "UBERON:002", + "anatomicalSubStructureQualifierTermId": "UBERON:003", + "cellularComponentQualifierTermId": "FBCV:001", + "anatomicalStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:004"}, + {"uberonTerm" : "UBERON:005"} + ], + "anatomicalSubStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:006"}, + {"uberonTerm" : "UBERON:007"} + ] + } + } +] + diff --git a/src/test/resources/bulk/fms/07_expression/IV_06_invalid_anatomical_structure.json b/src/test/resources/bulk/fms/07_expression/IV_06_invalid_anatomical_structure.json new file mode 100644 index 000000000..991893a1a --- /dev/null +++ b/src/test/resources/bulk/fms/07_expression/IV_06_invalid_anatomical_structure.json @@ -0,0 +1,43 @@ +[ + { + "dateAssigned" : "2024-01-17T07:31:34-08:00", + "geneId" : "GEXPTEST:GENE001", + "evidence" : { + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ "reference" ] + }, + "publicationId" : "PMID:009" + }, + "crossReference" : { + "id" : "ZFIN:ZDB-FIG-170413-34", + "pages" : [ "gene/expression/annotation/detail" ] + }, + "assay" : "GEXPTEST:assay001", + "whenExpressed" : { + "stageName" : "stage1", + "stageTermId" : "ZFS:001", + "stageUberonSlimTerm" : { + "uberonTerm" : "UBERON:001" + } + }, + "whereExpressed" : { + "whereExpressedStatement" : "trunk", + "anatomicalStructureTermId" : "ANAT:NOTFOUND", + "anatomicalSubStructureTermId" : "ANAT:002", + "cellularComponentTermId" : "GOTEST:0012", + "anatomicalStructureQualifierTermId": "UBERON:002", + "anatomicalSubStructureQualifierTermId": "UBERON:003", + "cellularComponentQualifierTermId": "FBCV:001", + "anatomicalStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:004"}, + {"uberonTerm" : "UBERON:005"} + ], + "anatomicalSubStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:006"}, + {"uberonTerm" : "UBERON:007"} + ] + } + } +] + diff --git a/src/test/resources/bulk/fms/07_expression/IV_07_invalid_anatomical_substructure.json b/src/test/resources/bulk/fms/07_expression/IV_07_invalid_anatomical_substructure.json new file mode 100644 index 000000000..1026a1c28 --- /dev/null +++ b/src/test/resources/bulk/fms/07_expression/IV_07_invalid_anatomical_substructure.json @@ -0,0 +1,43 @@ +[ + { + "dateAssigned" : "2024-01-17T07:31:34-08:00", + "geneId" : "GEXPTEST:GENE001", + "evidence" : { + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ "reference" ] + }, + "publicationId" : "PMID:009" + }, + "crossReference" : { + "id" : "ZFIN:ZDB-FIG-170413-34", + "pages" : [ "gene/expression/annotation/detail" ] + }, + "assay" : "GEXPTEST:assay001", + "whenExpressed" : { + "stageName" : "stage1", + "stageTermId" : "ZFS:001", + "stageUberonSlimTerm" : { + "uberonTerm" : "UBERON:001" + } + }, + "whereExpressed" : { + "whereExpressedStatement" : "trunk", + "anatomicalStructureTermId" : "ANAT:001", + "anatomicalSubStructureTermId" : "ANAT:NOTFOUND", + "cellularComponentTermId" : "GOTEST:0012", + "anatomicalStructureQualifierTermId": "UBERON:002", + "anatomicalSubStructureQualifierTermId": "UBERON:003", + "cellularComponentQualifierTermId": "FBCV:001", + "anatomicalStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:004"}, + {"uberonTerm" : "UBERON:005"} + ], + "anatomicalSubStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:006"}, + {"uberonTerm" : "UBERON:007"} + ] + } + } +] + diff --git a/src/test/resources/bulk/fms/07_expression/IV_08_invalid_cellularcomponent.json b/src/test/resources/bulk/fms/07_expression/IV_08_invalid_cellularcomponent.json new file mode 100644 index 000000000..e05d9c8a0 --- /dev/null +++ b/src/test/resources/bulk/fms/07_expression/IV_08_invalid_cellularcomponent.json @@ -0,0 +1,43 @@ +[ + { + "dateAssigned" : "2024-01-17T07:31:34-08:00", + "geneId" : "GEXPTEST:GENE001", + "evidence" : { + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ "reference" ] + }, + "publicationId" : "PMID:009" + }, + "crossReference" : { + "id" : "ZFIN:ZDB-FIG-170413-34", + "pages" : [ "gene/expression/annotation/detail" ] + }, + "assay" : "GEXPTEST:assay001", + "whenExpressed" : { + "stageName" : "stage1", + "stageTermId" : "ZFS:001", + "stageUberonSlimTerm" : { + "uberonTerm" : "UBERON:001" + } + }, + "whereExpressed" : { + "whereExpressedStatement" : "trunk", + "anatomicalStructureTermId" : "ANAT:001", + "anatomicalSubStructureTermId" : "ANAT:002", + "cellularComponentTermId" : "GOTEST:NOTFOUND", + "anatomicalStructureQualifierTermId": "UBERON:002", + "anatomicalSubStructureQualifierTermId": "UBERON:003", + "cellularComponentQualifierTermId": "FBCV:001", + "anatomicalStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:004"}, + {"uberonTerm" : "UBERON:005"} + ], + "anatomicalSubStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:006"}, + {"uberonTerm" : "UBERON:007"} + ] + } + } +] + diff --git a/src/test/resources/bulk/fms/07_expression/IV_09_invalid_anatomicalstructurequalifier.json b/src/test/resources/bulk/fms/07_expression/IV_09_invalid_anatomicalstructurequalifier.json new file mode 100644 index 000000000..e18c849b8 --- /dev/null +++ b/src/test/resources/bulk/fms/07_expression/IV_09_invalid_anatomicalstructurequalifier.json @@ -0,0 +1,43 @@ +[ + { + "dateAssigned" : "2024-01-17T07:31:34-08:00", + "geneId" : "GEXPTEST:GENE001", + "evidence" : { + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ "reference" ] + }, + "publicationId" : "PMID:009" + }, + "crossReference" : { + "id" : "ZFIN:ZDB-FIG-170413-34", + "pages" : [ "gene/expression/annotation/detail" ] + }, + "assay" : "GEXPTEST:assay001", + "whenExpressed" : { + "stageName" : "stage1", + "stageTermId" : "ZFS:001", + "stageUberonSlimTerm" : { + "uberonTerm" : "UBERON:001" + } + }, + "whereExpressed" : { + "whereExpressedStatement" : "trunk", + "anatomicalStructureTermId" : "ANAT:001", + "anatomicalSubStructureTermId" : "ANAT:002", + "cellularComponentTermId" : "GOTEST:0012", + "anatomicalStructureQualifierTermId": "UBERON:NOTFOUND", + "anatomicalSubStructureQualifierTermId": "UBERON:003", + "cellularComponentQualifierTermId": "FBCV:001", + "anatomicalStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:004"}, + {"uberonTerm" : "UBERON:005"} + ], + "anatomicalSubStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:006"}, + {"uberonTerm" : "UBERON:007"} + ] + } + } +] + diff --git a/src/test/resources/bulk/fms/07_expression/IV_10_invalid_anatomicalsubstructurequalifier.json b/src/test/resources/bulk/fms/07_expression/IV_10_invalid_anatomicalsubstructurequalifier.json new file mode 100644 index 000000000..99239825c --- /dev/null +++ b/src/test/resources/bulk/fms/07_expression/IV_10_invalid_anatomicalsubstructurequalifier.json @@ -0,0 +1,43 @@ +[ + { + "dateAssigned" : "2024-01-17T07:31:34-08:00", + "geneId" : "GEXPTEST:GENE001", + "evidence" : { + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ "reference" ] + }, + "publicationId" : "PMID:009" + }, + "crossReference" : { + "id" : "ZFIN:ZDB-FIG-170413-34", + "pages" : [ "gene/expression/annotation/detail" ] + }, + "assay" : "GEXPTEST:assay001", + "whenExpressed" : { + "stageName" : "stage1", + "stageTermId" : "ZFS:001", + "stageUberonSlimTerm" : { + "uberonTerm" : "UBERON:001" + } + }, + "whereExpressed" : { + "whereExpressedStatement" : "trunk", + "anatomicalStructureTermId" : "ANAT:001", + "anatomicalSubStructureTermId" : "ANAT:002", + "cellularComponentTermId" : "GOTEST:0012", + "anatomicalStructureQualifierTermId": "UBERON:002", + "anatomicalSubStructureQualifierTermId": "UBERON:NOTFOUND", + "cellularComponentQualifierTermId": "FBCV:001", + "anatomicalStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:004"}, + {"uberonTerm" : "UBERON:005"} + ], + "anatomicalSubStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:006"}, + {"uberonTerm" : "UBERON:007"} + ] + } + } +] + diff --git a/src/test/resources/bulk/fms/07_expression/IV_11_invalid_cellularcomponentqualifier.json b/src/test/resources/bulk/fms/07_expression/IV_11_invalid_cellularcomponentqualifier.json new file mode 100644 index 000000000..607930b10 --- /dev/null +++ b/src/test/resources/bulk/fms/07_expression/IV_11_invalid_cellularcomponentqualifier.json @@ -0,0 +1,43 @@ +[ + { + "dateAssigned" : "2024-01-17T07:31:34-08:00", + "geneId" : "GEXPTEST:GENE001", + "evidence" : { + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ "reference" ] + }, + "publicationId" : "PMID:009" + }, + "crossReference" : { + "id" : "ZFIN:ZDB-FIG-170413-34", + "pages" : [ "gene/expression/annotation/detail" ] + }, + "assay" : "GEXPTEST:assay001", + "whenExpressed" : { + "stageName" : "stage1", + "stageTermId" : "ZFS:001", + "stageUberonSlimTerm" : { + "uberonTerm" : "UBERON:001" + } + }, + "whereExpressed" : { + "whereExpressedStatement" : "trunk", + "anatomicalStructureTermId" : "ANAT:001", + "anatomicalSubStructureTermId" : "ANAT:002", + "cellularComponentTermId" : "GOTEST:0012", + "anatomicalStructureQualifierTermId": "UBERON:002", + "anatomicalSubStructureQualifierTermId": "UBERON:003", + "cellularComponentQualifierTermId": "FBCV:NOTFOUND", + "anatomicalStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:004"}, + {"uberonTerm" : "UBERON:005"} + ], + "anatomicalSubStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:006"}, + {"uberonTerm" : "UBERON:007"} + ] + } + } +] + diff --git a/src/test/resources/bulk/fms/07_expression/IV_12_invalid_anatomicalstructureuberonslimterms.json b/src/test/resources/bulk/fms/07_expression/IV_12_invalid_anatomicalstructureuberonslimterms.json new file mode 100644 index 000000000..4c25ca67f --- /dev/null +++ b/src/test/resources/bulk/fms/07_expression/IV_12_invalid_anatomicalstructureuberonslimterms.json @@ -0,0 +1,43 @@ +[ + { + "dateAssigned" : "2024-01-17T07:31:34-08:00", + "geneId" : "GEXPTEST:GENE001", + "evidence" : { + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ "reference" ] + }, + "publicationId" : "PMID:009" + }, + "crossReference" : { + "id" : "ZFIN:ZDB-FIG-170413-34", + "pages" : [ "gene/expression/annotation/detail" ] + }, + "assay" : "GEXPTEST:assay001", + "whenExpressed" : { + "stageName" : "stage1", + "stageTermId" : "ZFS:001", + "stageUberonSlimTerm" : { + "uberonTerm" : "UBERON:001" + } + }, + "whereExpressed" : { + "whereExpressedStatement" : "trunk", + "anatomicalStructureTermId" : "ANAT:001", + "anatomicalSubStructureTermId" : "ANAT:002", + "cellularComponentTermId" : "GOTEST:0012", + "anatomicalStructureQualifierTermId": "UBERON:002", + "anatomicalSubStructureQualifierTermId": "UBERON:003", + "cellularComponentQualifierTermId": "FBCV:001", + "anatomicalStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:NOTFOUND"}, + {"uberonTerm" : "UBERON:005"} + ], + "anatomicalSubStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:006"}, + {"uberonTerm" : "UBERON:007"} + ] + } + } +] + diff --git a/src/test/resources/bulk/fms/07_expression/IV_13_invalid_anatomicalsubstructureuberonslimterms.json b/src/test/resources/bulk/fms/07_expression/IV_13_invalid_anatomicalsubstructureuberonslimterms.json new file mode 100644 index 000000000..27e216911 --- /dev/null +++ b/src/test/resources/bulk/fms/07_expression/IV_13_invalid_anatomicalsubstructureuberonslimterms.json @@ -0,0 +1,43 @@ +[ + { + "dateAssigned" : "2024-01-17T07:31:34-08:00", + "geneId" : "GEXPTEST:GENE001", + "evidence" : { + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ "reference" ] + }, + "publicationId" : "PMID:009" + }, + "crossReference" : { + "id" : "ZFIN:ZDB-FIG-170413-34", + "pages" : [ "gene/expression/annotation/detail" ] + }, + "assay" : "GEXPTEST:assay001", + "whenExpressed" : { + "stageName" : "stage1", + "stageTermId" : "ZFS:001", + "stageUberonSlimTerm" : { + "uberonTerm" : "UBERON:001" + } + }, + "whereExpressed" : { + "whereExpressedStatement" : "trunk", + "anatomicalStructureTermId" : "ANAT:001", + "anatomicalSubStructureTermId" : "ANAT:002", + "cellularComponentTermId" : "GOTEST:0012", + "anatomicalStructureQualifierTermId": "UBERON:002", + "anatomicalSubStructureQualifierTermId": "UBERON:003", + "cellularComponentQualifierTermId": "FBCV:001", + "anatomicalStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:004"}, + {"uberonTerm" : "UBERON:005"} + ], + "anatomicalSubStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:006"}, + {"uberonTerm" : "UBERON:NOTFOUND"} + ] + } + } +] + diff --git a/src/test/resources/bulk/fms/07_expression/MR_09_norCellComponentNORanatStructure.json b/src/test/resources/bulk/fms/07_expression/MR_09_norCellComponentNORanatStructure.json new file mode 100644 index 000000000..f392bf65a --- /dev/null +++ b/src/test/resources/bulk/fms/07_expression/MR_09_norCellComponentNORanatStructure.json @@ -0,0 +1,40 @@ +[ + { + "dateAssigned" : "2024-01-17T07:31:34-08:00", + "geneId" : "GEXPTEST:GENE001", + "evidence" : { + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ "reference" ] + }, + "publicationId" : "PMID:009" + }, + "crossReference" : { + "id" : "ZFIN:ZDB-FIG-170413-34", + "pages" : [ "gene/expression/annotation/detail" ] + }, + "assay" : "GEXPTEST:assay001", + "whenExpressed" : { + "stageName" : "stage1", + "stageTermId" : "ZFS:001", + "stageUberonSlimTerm" : { + "uberonTerm" : "UBERON:001" + } + }, + "whereExpressed" : { + "whereExpressedStatement" : "trunk", + "anatomicalSubStructureTermId" : "ANAT:002", + "anatomicalSubStructureQualifierTermId": "UBERON:003", + "cellularComponentQualifierTermId": "FBCV:001", + "anatomicalStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:004"}, + {"uberonTerm" : "UBERON:005"} + ], + "anatomicalSubStructureUberonSlimTermIds" : [ + {"uberonTerm" : "UBERON:006"}, + {"uberonTerm" : "UBERON:007"} + ] + } + } +] + diff --git a/src/test/resources/bulk/fms/08_gff_data/ER_03_empty_transcript_parent.json b/src/test/resources/bulk/fms/08_gff_data/ER_03_empty_transcript_parent.json new file mode 100644 index 000000000..3e262c924 --- /dev/null +++ b/src/test/resources/bulk/fms/08_gff_data/ER_03_empty_transcript_parent.json @@ -0,0 +1,16 @@ +[ + { + "seqId": "I", + "source": "WormBase", + "type": "mRNA", + "start": 1, + "end": 1000, + "strand": "+", + "phase": 0, + "attributes": [ + "ID=Transcript:Y74C9A.2a.1", + "Parent=", + "Name=Y74C9A.2a.1" + ] + } +] diff --git a/src/test/resources/bulk/fms/08_gff_data/ER_04_empty_exon_parent.json b/src/test/resources/bulk/fms/08_gff_data/ER_04_empty_exon_parent.json new file mode 100644 index 000000000..7be8e5a63 --- /dev/null +++ b/src/test/resources/bulk/fms/08_gff_data/ER_04_empty_exon_parent.json @@ -0,0 +1,14 @@ +[ + { + "seqId": "I", + "source": "WormBase", + "type": "exon", + "start": 1, + "end": 100, + "strand": "+", + "attributes": [ + "ID=Exon:Y74C9A.2a_exon", + "Parent=" + ] + } +] diff --git a/src/test/resources/bulk/fms/08_gff_data/ER_05_empty_cds_parent.json b/src/test/resources/bulk/fms/08_gff_data/ER_05_empty_cds_parent.json new file mode 100644 index 000000000..3664e5b32 --- /dev/null +++ b/src/test/resources/bulk/fms/08_gff_data/ER_05_empty_cds_parent.json @@ -0,0 +1,15 @@ +[ + { + "seqId": "I", + "source": "WormBase", + "type": "CDS", + "start": 10, + "end": 100, + "strand": "+", + "phase": 1, + "attributes": [ + "ID=CDS:Y74C9A.2a", + "Parent=" + ] + } +] diff --git a/src/test/resources/bulk/fms/08_gff_data/GFF_02_exon.json b/src/test/resources/bulk/fms/08_gff_data/GFF_02_exon.json index 06b8abf5c..fe01268c0 100644 --- a/src/test/resources/bulk/fms/08_gff_data/GFF_02_exon.json +++ b/src/test/resources/bulk/fms/08_gff_data/GFF_02_exon.json @@ -7,7 +7,7 @@ "end": 100, "strand": "+", "attributes": [ - "ID=Exon:Y74C9A.2a_exon", + "ID=Y74C9A.2a_exon", "Parent=Transcript:Y74C9A.2a.1" ] } diff --git a/src/test/resources/bulk/fms/08_gff_data/IV_03_invalid_transcript_parent.json b/src/test/resources/bulk/fms/08_gff_data/IV_03_invalid_transcript_parent.json new file mode 100644 index 000000000..8d524dd08 --- /dev/null +++ b/src/test/resources/bulk/fms/08_gff_data/IV_03_invalid_transcript_parent.json @@ -0,0 +1,16 @@ +[ + { + "seqId": "I", + "source": "WormBase", + "type": "mRNA", + "start": 1, + "end": 1000, + "strand": "+", + "phase": 0, + "attributes": [ + "ID=Transcript:Y74C9A.2a.1", + "Parent=Gene:Invalid", + "Name=Y74C9A.2a.1" + ] + } +] diff --git a/src/test/resources/bulk/fms/08_gff_data/IV_04_invalid_exon_parent.json b/src/test/resources/bulk/fms/08_gff_data/IV_04_invalid_exon_parent.json new file mode 100644 index 000000000..34d56074e --- /dev/null +++ b/src/test/resources/bulk/fms/08_gff_data/IV_04_invalid_exon_parent.json @@ -0,0 +1,14 @@ +[ + { + "seqId": "I", + "source": "WormBase", + "type": "exon", + "start": 1, + "end": 100, + "strand": "+", + "attributes": [ + "ID=Y74C9A.2a_exon", + "Parent=Transcript:Invalid" + ] + } +] diff --git a/src/test/resources/bulk/fms/08_gff_data/IV_05_invalid_cds_parent.json b/src/test/resources/bulk/fms/08_gff_data/IV_05_invalid_cds_parent.json new file mode 100644 index 000000000..122837faf --- /dev/null +++ b/src/test/resources/bulk/fms/08_gff_data/IV_05_invalid_cds_parent.json @@ -0,0 +1,15 @@ +[ + { + "seqId": "I", + "source": "WormBase", + "type": "CDS", + "start": 10, + "end": 100, + "strand": "+", + "phase": 1, + "attributes": [ + "ID=CDS:Y74C9A.2a", + "Parent=Transcript:Invalid" + ] + } +] diff --git a/src/test/resources/bulk/fms/08_gff_data/MR_05_no_transcript_parent.json b/src/test/resources/bulk/fms/08_gff_data/MR_05_no_transcript_parent.json new file mode 100644 index 000000000..123f5e739 --- /dev/null +++ b/src/test/resources/bulk/fms/08_gff_data/MR_05_no_transcript_parent.json @@ -0,0 +1,15 @@ +[ + { + "seqId": "I", + "source": "WormBase", + "type": "mRNA", + "start": 1, + "end": 1000, + "strand": "+", + "phase": 0, + "attributes": [ + "ID=Transcript:Y74C9A.2a.1", + "Name=Y74C9A.2a.1" + ] + } +] diff --git a/src/test/resources/bulk/fms/08_gff_data/MR_06_no_exon_parent.json b/src/test/resources/bulk/fms/08_gff_data/MR_06_no_exon_parent.json new file mode 100644 index 000000000..9f7dd01f4 --- /dev/null +++ b/src/test/resources/bulk/fms/08_gff_data/MR_06_no_exon_parent.json @@ -0,0 +1,13 @@ +[ + { + "seqId": "I", + "source": "WormBase", + "type": "exon", + "start": 1, + "end": 100, + "strand": "+", + "attributes": [ + "ID=Y74C9A.2a_exon" + ] + } +] diff --git a/src/test/resources/bulk/fms/08_gff_data/MR_07_no_cds_parent.json b/src/test/resources/bulk/fms/08_gff_data/MR_07_no_cds_parent.json new file mode 100644 index 000000000..a50ccf660 --- /dev/null +++ b/src/test/resources/bulk/fms/08_gff_data/MR_07_no_cds_parent.json @@ -0,0 +1,14 @@ +[ + { + "seqId": "I", + "source": "WormBase", + "type": "CDS", + "start": 10, + "end": 100, + "strand": "+", + "phase": 1, + "attributes": [ + "ID=CDS:Y74C9A.2a" + ] + } +] diff --git a/src/test/resources/bulk/fms/09_htp_dataset/AF_01_all_fields.json b/src/test/resources/bulk/fms/09_htp_dataset/AF_01_all_fields.json new file mode 100644 index 000000000..9a28a4e56 --- /dev/null +++ b/src/test/resources/bulk/fms/09_htp_dataset/AF_01_all_fields.json @@ -0,0 +1,76 @@ +{ + "data": [ + { + "categoryTags": [ + "anatomical structure" + ], + "datasetId": { + "alternateIds": [ + "GEO:GSE38764" + ], + "crossReferences": [ + { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + { + "id": "TEST:TestMol00000002", + "pages": [ + "homepage" + ] + } + ], + "preferredCrossReference": { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + "primaryId": "FB:FBlc0003342" + }, + "dateAssigned": "2024-07-12T12:36:21-04:00", + "publications": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "ZFIN:ZDB-PUB-130927-9", + "pages": [ + "reference" + ], + "curie": "ZFIN:ZDB-PUB-130927-9" + } + }, + { + "publicationId" : "PMID:009", + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ + "reference" + ] + } + } + ], + "title": "TEST TITLE", + "summary" : "TEST_SUMMARY", + "numChannels" : 2, + "subSeries": [ + "FB:FBlc0003342" + ] + } + ], + "metaData": { + "dataProvider": { + "crossReference": { + "id": "FB", + "pages": [ + "homepage" + ] + }, + "type": "curated" + }, + "dateProduced": "2024-07-12T12:36:21-04:00", + "release": "2024_03" + } +} \ No newline at end of file diff --git a/src/test/resources/bulk/fms/09_htp_dataset/ER_01_empty_dataset_id.json b/src/test/resources/bulk/fms/09_htp_dataset/ER_01_empty_dataset_id.json new file mode 100644 index 000000000..ba7d9d312 --- /dev/null +++ b/src/test/resources/bulk/fms/09_htp_dataset/ER_01_empty_dataset_id.json @@ -0,0 +1,52 @@ +{ + "data": [ + { + "categoryTags": [ + "anatomical structure" + ], + "datasetId": { + }, + "dateAssigned": "2024-07-12T12:36:21-04:00", + "publications": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "ZFIN:ZDB-PUB-130927-9", + "pages": [ + "reference" + ], + "curie": "ZFIN:ZDB-PUB-130927-9" + } + }, + { + "publicationId" : "PMID:009", + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ + "reference" + ] + } + } + ], + "title": "TEST TITLE", + "summary" : "TEST_SUMMARY", + "numChannels" : 2, + "subSeries": [ + "FB:FBlc0003342" + ] + } + ], + "metaData": { + "dataProvider": { + "crossReference": { + "id": "FB", + "pages": [ + "homepage" + ] + }, + "type": "curated" + }, + "dateProduced": "2024-07-12T12:36:21-04:00", + "release": "2024_03" + } +} \ No newline at end of file diff --git a/src/test/resources/bulk/fms/09_htp_dataset/ER_02_empty_title.json b/src/test/resources/bulk/fms/09_htp_dataset/ER_02_empty_title.json new file mode 100644 index 000000000..1e1b06974 --- /dev/null +++ b/src/test/resources/bulk/fms/09_htp_dataset/ER_02_empty_title.json @@ -0,0 +1,76 @@ +{ + "data": [ + { + "categoryTags": [ + "anatomical structure" + ], + "datasetId": { + "alternateIds": [ + "GEO:GSE38764" + ], + "crossReferences": [ + { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + { + "id": "TEST:TestMol00000002", + "pages": [ + "homepage" + ] + } + ], + "preferredCrossReference": { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + "primaryId": "FB:FBlc0003342" + }, + "dateAssigned": "2024-07-12T12:36:21-04:00", + "publications": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "ZFIN:ZDB-PUB-130927-9", + "pages": [ + "reference" + ], + "curie": "ZFIN:ZDB-PUB-130927-9" + } + }, + { + "publicationId" : "PMID:009", + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ + "reference" + ] + } + } + ], + "title": "", + "summary" : "TEST_SUMMARY", + "numChannels" : 2, + "subSeries": [ + "FB:FBlc0003342" + ] + } + ], + "metaData": { + "dataProvider": { + "crossReference": { + "id": "FB", + "pages": [ + "homepage" + ] + }, + "type": "curated" + }, + "dateProduced": "2024-07-12T12:36:21-04:00", + "release": "2024_03" + } +} \ No newline at end of file diff --git a/src/test/resources/bulk/fms/09_htp_dataset/ER_03_empty_category_tags.json b/src/test/resources/bulk/fms/09_htp_dataset/ER_03_empty_category_tags.json new file mode 100644 index 000000000..f1c05539a --- /dev/null +++ b/src/test/resources/bulk/fms/09_htp_dataset/ER_03_empty_category_tags.json @@ -0,0 +1,75 @@ +{ + "data": [ + { + "categoryTags": [ + ], + "datasetId": { + "alternateIds": [ + "GEO:GSE38764" + ], + "crossReferences": [ + { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + { + "id": "TEST:TestMol00000002", + "pages": [ + "homepage" + ] + } + ], + "preferredCrossReference": { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + "primaryId": "FB:FBlc0003342" + }, + "dateAssigned": "2024-07-12T12:36:21-04:00", + "publications": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "ZFIN:ZDB-PUB-130927-9", + "pages": [ + "reference" + ], + "curie": "ZFIN:ZDB-PUB-130927-9" + } + }, + { + "publicationId" : "PMID:009", + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ + "reference" + ] + } + } + ], + "title": "TEST TITLE", + "summary" : "TEST_SUMMARY", + "numChannels" : 2, + "subSeries": [ + "FB:FBlc0003342" + ] + } + ], + "metaData": { + "dataProvider": { + "crossReference": { + "id": "FB", + "pages": [ + "homepage" + ] + }, + "type": "curated" + }, + "dateProduced": "2024-07-12T12:36:21-04:00", + "release": "2024_03" + } +} \ No newline at end of file diff --git a/src/test/resources/bulk/fms/09_htp_dataset/ER_04_empty_primary_id.json b/src/test/resources/bulk/fms/09_htp_dataset/ER_04_empty_primary_id.json new file mode 100644 index 000000000..ddc532d0a --- /dev/null +++ b/src/test/resources/bulk/fms/09_htp_dataset/ER_04_empty_primary_id.json @@ -0,0 +1,76 @@ +{ + "data": [ + { + "categoryTags": [ + "anatomical structure" + ], + "datasetId": { + "alternateIds": [ + "GEO:GSE38764" + ], + "crossReferences": [ + { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + { + "id": "TEST:TestMol00000002", + "pages": [ + "homepage" + ] + } + ], + "preferredCrossReference": { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + "primaryId": "" + }, + "dateAssigned": "2024-07-12T12:36:21-04:00", + "publications": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "ZFIN:ZDB-PUB-130927-9", + "pages": [ + "reference" + ], + "curie": "ZFIN:ZDB-PUB-130927-9" + } + }, + { + "publicationId" : "PMID:009", + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ + "reference" + ] + } + } + ], + "title": "TEST TITLE", + "summary" : "TEST_SUMMARY", + "numChannels" : 2, + "subSeries": [ + "FB:FBlc0003342" + ] + } + ], + "metaData": { + "dataProvider": { + "crossReference": { + "id": "FB", + "pages": [ + "homepage" + ] + }, + "type": "curated" + }, + "dateProduced": "2024-07-12T12:36:21-04:00", + "release": "2024_03" + } +} \ No newline at end of file diff --git a/src/test/resources/bulk/fms/09_htp_dataset/IV_01_invalid_publication.json b/src/test/resources/bulk/fms/09_htp_dataset/IV_01_invalid_publication.json new file mode 100644 index 000000000..2e1098c06 --- /dev/null +++ b/src/test/resources/bulk/fms/09_htp_dataset/IV_01_invalid_publication.json @@ -0,0 +1,76 @@ +{ + "data": [ + { + "categoryTags": [ + "anatomical structure" + ], + "datasetId": { + "alternateIds": [ + "GEO:GSE38764" + ], + "crossReferences": [ + { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + { + "id": "TEST:TestMol00000002", + "pages": [ + "homepage" + ] + } + ], + "preferredCrossReference": { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + "primaryId": "FB:FBlc0003342" + }, + "dateAssigned": "2024-07-12T12:36:21-04:00", + "publications": [ + { + "publicationId": "INVALID", + "crossReference": { + "id": "ZFIN:ZDB-PUB-130927-9", + "pages": [ + "reference" + ], + "curie": "ZFIN:ZDB-PUB-130927-9" + } + }, + { + "publicationId" : "PMID:009", + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ + "reference" + ] + } + } + ], + "title": "TEST TITLE", + "summary" : "TEST_SUMMARY", + "numChannels" : 2, + "subSeries": [ + "FB:FBlc0003342" + ] + } + ], + "metaData": { + "dataProvider": { + "crossReference": { + "id": "FB", + "pages": [ + "homepage" + ] + }, + "type": "curated" + }, + "dateProduced": "2024-07-12T12:36:21-04:00", + "release": "2024_03" + } +} \ No newline at end of file diff --git a/src/test/resources/bulk/fms/09_htp_dataset/IV_02_invalid_number_of_channels.json b/src/test/resources/bulk/fms/09_htp_dataset/IV_02_invalid_number_of_channels.json new file mode 100644 index 000000000..73e02efca --- /dev/null +++ b/src/test/resources/bulk/fms/09_htp_dataset/IV_02_invalid_number_of_channels.json @@ -0,0 +1,76 @@ +{ + "data": [ + { + "categoryTags": [ + "anatomical structure" + ], + "datasetId": { + "alternateIds": [ + "GEO:GSE38764" + ], + "crossReferences": [ + { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + { + "id": "TEST:TestMol00000002", + "pages": [ + "homepage" + ] + } + ], + "preferredCrossReference": { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + "primaryId": "FB:FBlc0003342" + }, + "dateAssigned": "2024-07-12T12:36:21-04:00", + "publications": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "ZFIN:ZDB-PUB-130927-9", + "pages": [ + "reference" + ], + "curie": "ZFIN:ZDB-PUB-130927-9" + } + }, + { + "publicationId" : "PMID:009", + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ + "reference" + ] + } + } + ], + "title": "TEST TITLE", + "summary" : "TEST_SUMMARY", + "numChannels" : 3, + "subSeries": [ + "FB:FBlc0003342" + ] + } + ], + "metaData": { + "dataProvider": { + "crossReference": { + "id": "FB", + "pages": [ + "homepage" + ] + }, + "type": "curated" + }, + "dateProduced": "2024-07-12T12:36:21-04:00", + "release": "2024_03" + } +} \ No newline at end of file diff --git a/src/test/resources/bulk/fms/09_htp_dataset/IV_03_invalid_sub_series.json b/src/test/resources/bulk/fms/09_htp_dataset/IV_03_invalid_sub_series.json new file mode 100644 index 000000000..0859762cf --- /dev/null +++ b/src/test/resources/bulk/fms/09_htp_dataset/IV_03_invalid_sub_series.json @@ -0,0 +1,76 @@ +{ + "data": [ + { + "categoryTags": [ + "anatomical structure" + ], + "datasetId": { + "alternateIds": [ + "GEO:GSE38764" + ], + "crossReferences": [ + { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + { + "id": "TEST:TestMol00000002", + "pages": [ + "homepage" + ] + } + ], + "preferredCrossReference": { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + "primaryId": "FB:FBlc0003342" + }, + "dateAssigned": "2024-07-12T12:36:21-04:00", + "publications": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "ZFIN:ZDB-PUB-130927-9", + "pages": [ + "reference" + ], + "curie": "ZFIN:ZDB-PUB-130927-9" + } + }, + { + "publicationId" : "PMID:009", + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ + "reference" + ] + } + } + ], + "title": "TEST TITLE", + "summary" : "TEST_SUMMARY", + "numChannels" : 2, + "subSeries": [ + "INVALID" + ] + } + ], + "metaData": { + "dataProvider": { + "crossReference": { + "id": "FB", + "pages": [ + "homepage" + ] + }, + "type": "curated" + }, + "dateProduced": "2024-07-12T12:36:21-04:00", + "release": "2024_03" + } +} \ No newline at end of file diff --git a/src/test/resources/bulk/fms/09_htp_dataset/IV_04_invalid_category_tag.json b/src/test/resources/bulk/fms/09_htp_dataset/IV_04_invalid_category_tag.json new file mode 100644 index 000000000..bd3d7c33e --- /dev/null +++ b/src/test/resources/bulk/fms/09_htp_dataset/IV_04_invalid_category_tag.json @@ -0,0 +1,76 @@ +{ + "data": [ + { + "categoryTags": [ + "INVALID_CATEGORY_TAG" + ], + "datasetId": { + "alternateIds": [ + "GEO:GSE38764" + ], + "crossReferences": [ + { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + { + "id": "TEST:TestMol00000002", + "pages": [ + "homepage" + ] + } + ], + "preferredCrossReference": { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + "primaryId": "FB:FBlc0003342" + }, + "dateAssigned": "2024-07-12T12:36:21-04:00", + "publications": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "ZFIN:ZDB-PUB-130927-9", + "pages": [ + "reference" + ], + "curie": "ZFIN:ZDB-PUB-130927-9" + } + }, + { + "publicationId" : "PMID:009", + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ + "reference" + ] + } + } + ], + "title": "TEST TITLE", + "summary" : "TEST_SUMMARY", + "numChannels" : 2, + "subSeries": [ + "FB:FBlc0003342" + ] + } + ], + "metaData": { + "dataProvider": { + "crossReference": { + "id": "FB", + "pages": [ + "homepage" + ] + }, + "type": "curated" + }, + "dateProduced": "2024-07-12T12:36:21-04:00", + "release": "2024_03" + } +} \ No newline at end of file diff --git a/src/test/resources/bulk/fms/09_htp_dataset/MR_01_no_dataset_id.json b/src/test/resources/bulk/fms/09_htp_dataset/MR_01_no_dataset_id.json new file mode 100644 index 000000000..0a623f46c --- /dev/null +++ b/src/test/resources/bulk/fms/09_htp_dataset/MR_01_no_dataset_id.json @@ -0,0 +1,50 @@ +{ + "data": [ + { + "categoryTags": [ + "anatomical structure" + ], + "dateAssigned": "2024-07-12T12:36:21-04:00", + "publications": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "ZFIN:ZDB-PUB-130927-9", + "pages": [ + "reference" + ], + "curie": "ZFIN:ZDB-PUB-130927-9" + } + }, + { + "publicationId" : "PMID:009", + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ + "reference" + ] + } + } + ], + "title": "TEST TITLE", + "summary" : "TEST_SUMMARY", + "numChannels" : 2, + "subSeries": [ + "FB:FBlc0003342" + ] + } + ], + "metaData": { + "dataProvider": { + "crossReference": { + "id": "FB", + "pages": [ + "homepage" + ] + }, + "type": "curated" + }, + "dateProduced": "2024-07-12T12:36:21-04:00", + "release": "2024_03" + } +} \ No newline at end of file diff --git a/src/test/resources/bulk/fms/09_htp_dataset/MR_02_no_title.json b/src/test/resources/bulk/fms/09_htp_dataset/MR_02_no_title.json new file mode 100644 index 000000000..c1fca6c31 --- /dev/null +++ b/src/test/resources/bulk/fms/09_htp_dataset/MR_02_no_title.json @@ -0,0 +1,75 @@ +{ + "data": [ + { + "categoryTags": [ + "anatomical structure" + ], + "datasetId": { + "alternateIds": [ + "GEO:GSE38764" + ], + "crossReferences": [ + { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + { + "id": "TEST:TestMol00000002", + "pages": [ + "homepage" + ] + } + ], + "preferredCrossReference": { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + "primaryId": "FB:FBlc0003342" + }, + "dateAssigned": "2024-07-12T12:36:21-04:00", + "publications": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "ZFIN:ZDB-PUB-130927-9", + "pages": [ + "reference" + ], + "curie": "ZFIN:ZDB-PUB-130927-9" + } + }, + { + "publicationId" : "PMID:009", + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ + "reference" + ] + } + } + ], + "summary" : "TEST_SUMMARY", + "numChannels" : 2, + "subSeries": [ + "FB:FBlc0003342" + ] + } + ], + "metaData": { + "dataProvider": { + "crossReference": { + "id": "FB", + "pages": [ + "homepage" + ] + }, + "type": "curated" + }, + "dateProduced": "2024-07-12T12:36:21-04:00", + "release": "2024_03" + } +} \ No newline at end of file diff --git a/src/test/resources/bulk/fms/09_htp_dataset/MR_03_no_category_tags.json b/src/test/resources/bulk/fms/09_htp_dataset/MR_03_no_category_tags.json new file mode 100644 index 000000000..67f2c15c4 --- /dev/null +++ b/src/test/resources/bulk/fms/09_htp_dataset/MR_03_no_category_tags.json @@ -0,0 +1,73 @@ +{ + "data": [ + { + "datasetId": { + "alternateIds": [ + "GEO:GSE38764" + ], + "crossReferences": [ + { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + { + "id": "TEST:TestMol00000002", + "pages": [ + "homepage" + ] + } + ], + "preferredCrossReference": { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + "primaryId": "FB:FBlc0003342" + }, + "dateAssigned": "2024-07-12T12:36:21-04:00", + "publications": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "ZFIN:ZDB-PUB-130927-9", + "pages": [ + "reference" + ], + "curie": "ZFIN:ZDB-PUB-130927-9" + } + }, + { + "publicationId" : "PMID:009", + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ + "reference" + ] + } + } + ], + "title": "TEST TITLE", + "summary" : "TEST_SUMMARY", + "numChannels" : 2, + "subSeries": [ + "FB:FBlc0003342" + ] + } + ], + "metaData": { + "dataProvider": { + "crossReference": { + "id": "FB", + "pages": [ + "homepage" + ] + }, + "type": "curated" + }, + "dateProduced": "2024-07-12T12:36:21-04:00", + "release": "2024_03" + } +} \ No newline at end of file diff --git a/src/test/resources/bulk/fms/09_htp_dataset/MR_04_no_primary_id.json b/src/test/resources/bulk/fms/09_htp_dataset/MR_04_no_primary_id.json new file mode 100644 index 000000000..5771ce51b --- /dev/null +++ b/src/test/resources/bulk/fms/09_htp_dataset/MR_04_no_primary_id.json @@ -0,0 +1,75 @@ +{ + "data": [ + { + "categoryTags": [ + "anatomical structure" + ], + "datasetId": { + "alternateIds": [ + "GEO:GSE38764" + ], + "crossReferences": [ + { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + { + "id": "TEST:TestMol00000002", + "pages": [ + "homepage" + ] + } + ], + "preferredCrossReference": { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + } + }, + "dateAssigned": "2024-07-12T12:36:21-04:00", + "publications": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "ZFIN:ZDB-PUB-130927-9", + "pages": [ + "reference" + ], + "curie": "ZFIN:ZDB-PUB-130927-9" + } + }, + { + "publicationId" : "PMID:009", + "crossReference" : { + "id" : "ZFIN:PUB001", + "pages" : [ + "reference" + ] + } + } + ], + "title": "TEST TITLE", + "summary" : "TEST_SUMMARY", + "numChannels" : 2, + "subSeries": [ + "FB:FBlc0003342" + ] + } + ], + "metaData": { + "dataProvider": { + "crossReference": { + "id": "FB", + "pages": [ + "homepage" + ] + }, + "type": "curated" + }, + "dateProduced": "2024-07-12T12:36:21-04:00", + "release": "2024_03" + } +} \ No newline at end of file diff --git a/src/test/resources/bulk/fms/09_htp_dataset/UE_01_update_empty_non_required_fields.json b/src/test/resources/bulk/fms/09_htp_dataset/UE_01_update_empty_non_required_fields.json new file mode 100644 index 000000000..587c293d2 --- /dev/null +++ b/src/test/resources/bulk/fms/09_htp_dataset/UE_01_update_empty_non_required_fields.json @@ -0,0 +1,54 @@ +{ + "data": [ + { + "categoryTags": [ + "anatomical structure" + ], + "datasetId": { + "alternateIds": [ + "GEO:GSE38764" + ], + "crossReferences": [ + { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + { + "id": "TEST:TestMol00000002", + "pages": [ + "homepage" + ] + } + ], + "preferredCrossReference": { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + "primaryId": "FB:FBlc0003342" + }, + "dateAssigned": "2024-07-12T12:36:21-04:00", + "publications": [], + "title": "TEST TITLE", + "summary" : "", + "numChannels" : 2, + "subSeries": [] + } + ], + "metaData": { + "dataProvider": { + "crossReference": { + "id": "FB", + "pages": [ + "homepage" + ] + }, + "type": "curated" + }, + "dateProduced": "2024-07-12T12:36:21-04:00", + "release": "2024_03" + } +} \ No newline at end of file diff --git a/src/test/resources/bulk/fms/09_htp_dataset/UM_01_update_no_non_required_fields.json b/src/test/resources/bulk/fms/09_htp_dataset/UM_01_update_no_non_required_fields.json new file mode 100644 index 000000000..0ba0c9046 --- /dev/null +++ b/src/test/resources/bulk/fms/09_htp_dataset/UM_01_update_no_non_required_fields.json @@ -0,0 +1,50 @@ +{ + "data": [ + { + "categoryTags": [ + "anatomical structure" + ], + "datasetId": { + "alternateIds": [ + "GEO:GSE38764" + ], + "crossReferences": [ + { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + { + "id": "TEST:TestMol00000002", + "pages": [ + "homepage" + ] + } + ], + "preferredCrossReference": { + "id": "TEST:TestMol00000001", + "pages": [ + "homepage" + ] + }, + "primaryId": "FB:FBlc0003342" + }, + "dateAssigned": "2024-07-12T12:36:21-04:00", + "title": "TEST TITLE" + } + ], + "metaData": { + "dataProvider": { + "crossReference": { + "id": "FB", + "pages": [ + "homepage" + ] + }, + "type": "curated" + }, + "dateProduced": "2024-07-12T12:36:21-04:00", + "release": "2024_03" + } +} \ No newline at end of file diff --git a/src/test/resources/bulk/fms/10_variant/AF_01_all_fields.json b/src/test/resources/bulk/fms/10_variant/AF_01_all_fields.json new file mode 100644 index 000000000..08ab80653 --- /dev/null +++ b/src/test/resources/bulk/fms/10_variant/AF_01_all_fields.json @@ -0,0 +1,48 @@ +[ + { + "alleleId": "WB:AlleleWithVar1", + "sequenceOfReferenceAccessionNumber": "RefSeq:NC_003279.8", + "start": 1, + "end": 1000, + "genomicReferenceSequence": "A", + "genomicVariantSequence": "T", + "type": "SO:1000002", + "consequence": "SO:0001587", + "references": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "WB:WBPaper00042242", + "pages": [ + "reference" + ] + } + } + ], + "notes": [ + { + "note": "This is a test note.", + "references": [ + { + "publicationId": "PMID:25920550", + "crossReference": { + "id": "WB:WBPaper00042241", + "pages": [ + "reference" + ] + } + } + ] + } + ], + "crossReferences": [ + { + "id": "TEST:WBVar00252636", + "pages": [ + "homepage" + ] + } + ] + } +] + diff --git a/src/test/resources/bulk/fms/10_variant/ER_01_empty_sequence_of_reference_accession_number.json b/src/test/resources/bulk/fms/10_variant/ER_01_empty_sequence_of_reference_accession_number.json new file mode 100644 index 000000000..2262e85c7 --- /dev/null +++ b/src/test/resources/bulk/fms/10_variant/ER_01_empty_sequence_of_reference_accession_number.json @@ -0,0 +1,48 @@ +[ + { + "alleleId": "WB:AlleleWithVar1", + "sequenceOfReferenceAccessionNumber": "", + "start": 1, + "end": 1000, + "genomicReferenceSequence": "A", + "genomicVariantSequence": "T", + "type": "SO:1000002", + "consequence": "SO:0001587", + "references": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "WB:WBPaper00042242", + "pages": [ + "reference" + ] + } + } + ], + "notes": [ + { + "note": "This is a test note.", + "references": [ + { + "publicationId": "PMID:25920550", + "crossReference": { + "id": "WB:WBPaper00042241", + "pages": [ + "reference" + ] + } + } + ] + } + ], + "crossReferences": [ + { + "id": "TEST:WBVar00252636", + "pages": [ + "homepage" + ] + } + ] + } +] + diff --git a/src/test/resources/bulk/fms/10_variant/ER_02_empty_type.json b/src/test/resources/bulk/fms/10_variant/ER_02_empty_type.json new file mode 100644 index 000000000..195de9a76 --- /dev/null +++ b/src/test/resources/bulk/fms/10_variant/ER_02_empty_type.json @@ -0,0 +1,48 @@ +[ + { + "alleleId": "WB:AlleleWithVar1", + "sequenceOfReferenceAccessionNumber": "RefSeq:NC_003279.8", + "start": 1, + "end": 1000, + "genomicReferenceSequence": "A", + "genomicVariantSequence": "T", + "type": "", + "consequence": "SO:0001587", + "references": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "WB:WBPaper00042242", + "pages": [ + "reference" + ] + } + } + ], + "notes": [ + { + "note": "This is a test note.", + "references": [ + { + "publicationId": "PMID:25920550", + "crossReference": { + "id": "WB:WBPaper00042241", + "pages": [ + "reference" + ] + } + } + ] + } + ], + "crossReferences": [ + { + "id": "TEST:WBVar00252636", + "pages": [ + "homepage" + ] + } + ] + } +] + diff --git a/src/test/resources/bulk/fms/10_variant/ER_03_empty_genomic_reference_sequence.json b/src/test/resources/bulk/fms/10_variant/ER_03_empty_genomic_reference_sequence.json new file mode 100644 index 000000000..d7a853664 --- /dev/null +++ b/src/test/resources/bulk/fms/10_variant/ER_03_empty_genomic_reference_sequence.json @@ -0,0 +1,48 @@ +[ + { + "alleleId": "WB:AlleleWithVar1", + "sequenceOfReferenceAccessionNumber": "RefSeq:NC_003279.8", + "start": 1, + "end": 1000, + "genomicReferenceSequence": "", + "genomicVariantSequence": "T", + "type": "SO:1000002", + "consequence": "SO:0001587", + "references": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "WB:WBPaper00042242", + "pages": [ + "reference" + ] + } + } + ], + "notes": [ + { + "note": "This is a test note.", + "references": [ + { + "publicationId": "PMID:25920550", + "crossReference": { + "id": "WB:WBPaper00042241", + "pages": [ + "reference" + ] + } + } + ] + } + ], + "crossReferences": [ + { + "id": "TEST:WBVar00252636", + "pages": [ + "homepage" + ] + } + ] + } +] + diff --git a/src/test/resources/bulk/fms/10_variant/ER_04_empty_genomic_variant_sequence.json b/src/test/resources/bulk/fms/10_variant/ER_04_empty_genomic_variant_sequence.json new file mode 100644 index 000000000..37d803915 --- /dev/null +++ b/src/test/resources/bulk/fms/10_variant/ER_04_empty_genomic_variant_sequence.json @@ -0,0 +1,48 @@ +[ + { + "alleleId": "WB:AlleleWithVar1", + "sequenceOfReferenceAccessionNumber": "RefSeq:NC_003279.8", + "start": 1, + "end": 1000, + "genomicReferenceSequence": "A", + "genomicVariantSequence": "", + "type": "SO:1000002", + "consequence": "SO:0001587", + "references": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "WB:WBPaper00042242", + "pages": [ + "reference" + ] + } + } + ], + "notes": [ + { + "note": "This is a test note.", + "references": [ + { + "publicationId": "PMID:25920550", + "crossReference": { + "id": "WB:WBPaper00042241", + "pages": [ + "reference" + ] + } + } + ] + } + ], + "crossReferences": [ + { + "id": "TEST:WBVar00252636", + "pages": [ + "homepage" + ] + } + ] + } +] + diff --git a/src/test/resources/bulk/fms/10_variant/ER_05_empty_allele_id.json b/src/test/resources/bulk/fms/10_variant/ER_05_empty_allele_id.json new file mode 100644 index 000000000..4128735e4 --- /dev/null +++ b/src/test/resources/bulk/fms/10_variant/ER_05_empty_allele_id.json @@ -0,0 +1,48 @@ +[ + { + "alleleId": "", + "sequenceOfReferenceAccessionNumber": "RefSeq:NC_003279.8", + "start": 1, + "end": 1000, + "genomicReferenceSequence": "A", + "genomicVariantSequence": "T", + "type": "SO:1000002", + "consequence": "SO:0001587", + "references": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "WB:WBPaper00042242", + "pages": [ + "reference" + ] + } + } + ], + "notes": [ + { + "note": "This is a test note.", + "references": [ + { + "publicationId": "PMID:25920550", + "crossReference": { + "id": "WB:WBPaper00042241", + "pages": [ + "reference" + ] + } + } + ] + } + ], + "crossReferences": [ + { + "id": "TEST:WBVar00252636", + "pages": [ + "homepage" + ] + } + ] + } +] + diff --git a/src/test/resources/bulk/fms/10_variant/IV_01_invalid_type.json b/src/test/resources/bulk/fms/10_variant/IV_01_invalid_type.json new file mode 100644 index 000000000..cf64872c9 --- /dev/null +++ b/src/test/resources/bulk/fms/10_variant/IV_01_invalid_type.json @@ -0,0 +1,48 @@ +[ + { + "alleleId": "WB:AlleleWithVar1", + "sequenceOfReferenceAccessionNumber": "RefSeq:NC_003279.8", + "start": 1, + "end": 1000, + "genomicReferenceSequence": "A", + "genomicVariantSequence": "T", + "type": "SO:Invalid", + "consequence": "SO:0001587", + "references": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "WB:WBPaper00042242", + "pages": [ + "reference" + ] + } + } + ], + "notes": [ + { + "note": "This is a test note.", + "references": [ + { + "publicationId": "PMID:25920550", + "crossReference": { + "id": "WB:WBPaper00042241", + "pages": [ + "reference" + ] + } + } + ] + } + ], + "crossReferences": [ + { + "id": "TEST:WBVar00252636", + "pages": [ + "homepage" + ] + } + ] + } +] + diff --git a/src/test/resources/bulk/fms/10_variant/IV_02_invalid_type_for_fms_submissions.json b/src/test/resources/bulk/fms/10_variant/IV_02_invalid_type_for_fms_submissions.json new file mode 100644 index 000000000..4e26a3b13 --- /dev/null +++ b/src/test/resources/bulk/fms/10_variant/IV_02_invalid_type_for_fms_submissions.json @@ -0,0 +1,48 @@ +[ + { + "alleleId": "WB:AlleleWithVar1", + "sequenceOfReferenceAccessionNumber": "RefSeq:NC_003279.8", + "start": 1, + "end": 1000, + "genomicReferenceSequence": "A", + "genomicVariantSequence": "T", + "type": "SO:0001587", + "consequence": "SO:0001587", + "references": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "WB:WBPaper00042242", + "pages": [ + "reference" + ] + } + } + ], + "notes": [ + { + "note": "This is a test note.", + "references": [ + { + "publicationId": "PMID:25920550", + "crossReference": { + "id": "WB:WBPaper00042241", + "pages": [ + "reference" + ] + } + } + ] + } + ], + "crossReferences": [ + { + "id": "TEST:WBVar00252636", + "pages": [ + "homepage" + ] + } + ] + } +] + diff --git a/src/test/resources/bulk/fms/10_variant/IV_03_invalid_consequence.json b/src/test/resources/bulk/fms/10_variant/IV_03_invalid_consequence.json new file mode 100644 index 000000000..71aeb2580 --- /dev/null +++ b/src/test/resources/bulk/fms/10_variant/IV_03_invalid_consequence.json @@ -0,0 +1,48 @@ +[ + { + "alleleId": "WB:AlleleWithVar1", + "sequenceOfReferenceAccessionNumber": "RefSeq:NC_003279.8", + "start": 1, + "end": 1000, + "genomicReferenceSequence": "A", + "genomicVariantSequence": "T", + "type": "SO:1000002", + "consequence": "SO:Invalid", + "references": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "WB:WBPaper00042242", + "pages": [ + "reference" + ] + } + } + ], + "notes": [ + { + "note": "This is a test note.", + "references": [ + { + "publicationId": "PMID:25920550", + "crossReference": { + "id": "WB:WBPaper00042241", + "pages": [ + "reference" + ] + } + } + ] + } + ], + "crossReferences": [ + { + "id": "TEST:WBVar00252636", + "pages": [ + "homepage" + ] + } + ] + } +] + diff --git a/src/test/resources/bulk/fms/10_variant/IV_04_invalid_sequence_of_reference_accession_number.json b/src/test/resources/bulk/fms/10_variant/IV_04_invalid_sequence_of_reference_accession_number.json new file mode 100644 index 000000000..c9ba16122 --- /dev/null +++ b/src/test/resources/bulk/fms/10_variant/IV_04_invalid_sequence_of_reference_accession_number.json @@ -0,0 +1,48 @@ +[ + { + "alleleId": "WB:AlleleWithVar1", + "sequenceOfReferenceAccessionNumber": "RefSeq:Invalid", + "start": 1, + "end": 1000, + "genomicReferenceSequence": "A", + "genomicVariantSequence": "T", + "type": "SO:1000002", + "consequence": "SO:0001587", + "references": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "WB:WBPaper00042242", + "pages": [ + "reference" + ] + } + } + ], + "notes": [ + { + "note": "This is a test note.", + "references": [ + { + "publicationId": "PMID:25920550", + "crossReference": { + "id": "WB:WBPaper00042241", + "pages": [ + "reference" + ] + } + } + ] + } + ], + "crossReferences": [ + { + "id": "TEST:WBVar00252636", + "pages": [ + "homepage" + ] + } + ] + } +] + diff --git a/src/test/resources/bulk/fms/10_variant/IV_05_invalid_allele_id.json b/src/test/resources/bulk/fms/10_variant/IV_05_invalid_allele_id.json new file mode 100644 index 000000000..4b30042ec --- /dev/null +++ b/src/test/resources/bulk/fms/10_variant/IV_05_invalid_allele_id.json @@ -0,0 +1,48 @@ +[ + { + "alleleId": "WB:Invalid", + "sequenceOfReferenceAccessionNumber": "RefSeq:NC_003279.8", + "start": 1, + "end": 1000, + "genomicReferenceSequence": "A", + "genomicVariantSequence": "T", + "type": "SO:1000002", + "consequence": "SO:0001587", + "references": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "WB:WBPaper00042242", + "pages": [ + "reference" + ] + } + } + ], + "notes": [ + { + "note": "This is a test note.", + "references": [ + { + "publicationId": "PMID:25920550", + "crossReference": { + "id": "WB:WBPaper00042241", + "pages": [ + "reference" + ] + } + } + ] + } + ], + "crossReferences": [ + { + "id": "TEST:WBVar00252636", + "pages": [ + "homepage" + ] + } + ] + } +] + diff --git a/src/test/resources/bulk/fms/10_variant/MR_01_no_start.json b/src/test/resources/bulk/fms/10_variant/MR_01_no_start.json new file mode 100644 index 000000000..79abce088 --- /dev/null +++ b/src/test/resources/bulk/fms/10_variant/MR_01_no_start.json @@ -0,0 +1,47 @@ +[ + { + "alleleId": "WB:AlleleWithVar1", + "sequenceOfReferenceAccessionNumber": "RefSeq:NC_003279.8", + "end": 1000, + "genomicReferenceSequence": "A", + "genomicVariantSequence": "T", + "type": "SO:1000002", + "consequence": "SO:0001587", + "references": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "WB:WBPaper00042242", + "pages": [ + "reference" + ] + } + } + ], + "notes": [ + { + "note": "This is a test note.", + "references": [ + { + "publicationId": "PMID:25920550", + "crossReference": { + "id": "WB:WBPaper00042241", + "pages": [ + "reference" + ] + } + } + ] + } + ], + "crossReferences": [ + { + "id": "TEST:WBVar00252636", + "pages": [ + "homepage" + ] + } + ] + } +] + diff --git a/src/test/resources/bulk/fms/10_variant/MR_02_no_end.json b/src/test/resources/bulk/fms/10_variant/MR_02_no_end.json new file mode 100644 index 000000000..735f8aa64 --- /dev/null +++ b/src/test/resources/bulk/fms/10_variant/MR_02_no_end.json @@ -0,0 +1,47 @@ +[ + { + "alleleId": "WB:AlleleWithVar1", + "sequenceOfReferenceAccessionNumber": "RefSeq:NC_003279.8", + "start": 1, + "genomicReferenceSequence": "A", + "genomicVariantSequence": "T", + "type": "SO:1000002", + "consequence": "SO:0001587", + "references": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "WB:WBPaper00042242", + "pages": [ + "reference" + ] + } + } + ], + "notes": [ + { + "note": "This is a test note.", + "references": [ + { + "publicationId": "PMID:25920550", + "crossReference": { + "id": "WB:WBPaper00042241", + "pages": [ + "reference" + ] + } + } + ] + } + ], + "crossReferences": [ + { + "id": "TEST:WBVar00252636", + "pages": [ + "homepage" + ] + } + ] + } +] + diff --git a/src/test/resources/bulk/fms/10_variant/MR_03_no_sequence_of_reference_accession_number.json b/src/test/resources/bulk/fms/10_variant/MR_03_no_sequence_of_reference_accession_number.json new file mode 100644 index 000000000..5daf65491 --- /dev/null +++ b/src/test/resources/bulk/fms/10_variant/MR_03_no_sequence_of_reference_accession_number.json @@ -0,0 +1,47 @@ +[ + { + "alleleId": "WB:AlleleWithVar1", + "start": 1, + "end": 1000, + "genomicReferenceSequence": "A", + "genomicVariantSequence": "T", + "type": "SO:1000002", + "consequence": "SO:0001587", + "references": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "WB:WBPaper00042242", + "pages": [ + "reference" + ] + } + } + ], + "notes": [ + { + "note": "This is a test note.", + "references": [ + { + "publicationId": "PMID:25920550", + "crossReference": { + "id": "WB:WBPaper00042241", + "pages": [ + "reference" + ] + } + } + ] + } + ], + "crossReferences": [ + { + "id": "TEST:WBVar00252636", + "pages": [ + "homepage" + ] + } + ] + } +] + diff --git a/src/test/resources/bulk/fms/10_variant/MR_04_no_type.json b/src/test/resources/bulk/fms/10_variant/MR_04_no_type.json new file mode 100644 index 000000000..1c218b86b --- /dev/null +++ b/src/test/resources/bulk/fms/10_variant/MR_04_no_type.json @@ -0,0 +1,47 @@ +[ + { + "alleleId": "WB:AlleleWithVar1", + "sequenceOfReferenceAccessionNumber": "RefSeq:NC_003279.8", + "start": 1, + "end": 1000, + "genomicReferenceSequence": "A", + "genomicVariantSequence": "T", + "consequence": "SO:0001587", + "references": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "WB:WBPaper00042242", + "pages": [ + "reference" + ] + } + } + ], + "notes": [ + { + "note": "This is a test note.", + "references": [ + { + "publicationId": "PMID:25920550", + "crossReference": { + "id": "WB:WBPaper00042241", + "pages": [ + "reference" + ] + } + } + ] + } + ], + "crossReferences": [ + { + "id": "TEST:WBVar00252636", + "pages": [ + "homepage" + ] + } + ] + } +] + diff --git a/src/test/resources/bulk/fms/10_variant/MR_05_no_genomic_reference_sequence.json b/src/test/resources/bulk/fms/10_variant/MR_05_no_genomic_reference_sequence.json new file mode 100644 index 000000000..090755af6 --- /dev/null +++ b/src/test/resources/bulk/fms/10_variant/MR_05_no_genomic_reference_sequence.json @@ -0,0 +1,47 @@ +[ + { + "alleleId": "WB:AlleleWithVar1", + "sequenceOfReferenceAccessionNumber": "RefSeq:NC_003279.8", + "start": 1, + "end": 1000, + "genomicVariantSequence": "T", + "type": "SO:1000002", + "consequence": "SO:0001587", + "references": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "WB:WBPaper00042242", + "pages": [ + "reference" + ] + } + } + ], + "notes": [ + { + "note": "This is a test note.", + "references": [ + { + "publicationId": "PMID:25920550", + "crossReference": { + "id": "WB:WBPaper00042241", + "pages": [ + "reference" + ] + } + } + ] + } + ], + "crossReferences": [ + { + "id": "TEST:WBVar00252636", + "pages": [ + "homepage" + ] + } + ] + } +] + diff --git a/src/test/resources/bulk/fms/10_variant/MR_06_no_genomic_variant_sequence.json b/src/test/resources/bulk/fms/10_variant/MR_06_no_genomic_variant_sequence.json new file mode 100644 index 000000000..45e9c273f --- /dev/null +++ b/src/test/resources/bulk/fms/10_variant/MR_06_no_genomic_variant_sequence.json @@ -0,0 +1,47 @@ +[ + { + "alleleId": "WB:AlleleWithVar1", + "sequenceOfReferenceAccessionNumber": "RefSeq:NC_003279.8", + "start": 1, + "end": 1000, + "genomicReferenceSequence": "A", + "type": "SO:1000002", + "consequence": "SO:0001587", + "references": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "WB:WBPaper00042242", + "pages": [ + "reference" + ] + } + } + ], + "notes": [ + { + "note": "This is a test note.", + "references": [ + { + "publicationId": "PMID:25920550", + "crossReference": { + "id": "WB:WBPaper00042241", + "pages": [ + "reference" + ] + } + } + ] + } + ], + "crossReferences": [ + { + "id": "TEST:WBVar00252636", + "pages": [ + "homepage" + ] + } + ] + } +] + diff --git a/src/test/resources/bulk/fms/10_variant/MR_07_no_allele_id.json b/src/test/resources/bulk/fms/10_variant/MR_07_no_allele_id.json new file mode 100644 index 000000000..10758b229 --- /dev/null +++ b/src/test/resources/bulk/fms/10_variant/MR_07_no_allele_id.json @@ -0,0 +1,47 @@ +[ + { + "sequenceOfReferenceAccessionNumber": "RefSeq:NC_003279.8", + "start": 1, + "end": 1000, + "genomicReferenceSequence": "A", + "genomicVariantSequence": "T", + "type": "SO:1000002", + "consequence": "SO:0001587", + "references": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "WB:WBPaper00042242", + "pages": [ + "reference" + ] + } + } + ], + "notes": [ + { + "note": "This is a test note.", + "references": [ + { + "publicationId": "PMID:25920550", + "crossReference": { + "id": "WB:WBPaper00042241", + "pages": [ + "reference" + ] + } + } + ] + } + ], + "crossReferences": [ + { + "id": "TEST:WBVar00252636", + "pages": [ + "homepage" + ] + } + ] + } +] + diff --git a/src/test/resources/bulk/fms/10_variant/UD_01_update_variant.json b/src/test/resources/bulk/fms/10_variant/UD_01_update_variant.json new file mode 100644 index 000000000..0ce4614fc --- /dev/null +++ b/src/test/resources/bulk/fms/10_variant/UD_01_update_variant.json @@ -0,0 +1,48 @@ +[ + { + "alleleId": "WB:AlleleWithVar2", + "sequenceOfReferenceAccessionNumber": "RefSeq:NC_003279.8", + "start": 1, + "end": 1000, + "genomicReferenceSequence": "A", + "genomicVariantSequence": "T", + "type": "SO:1000008", + "consequence": "SO:0001578", + "references": [ + { + "publicationId": "PMID:25920554", + "crossReference": { + "id": "WB:WBPaper00042242", + "pages": [ + "reference" + ] + } + } + ], + "notes": [ + { + "note": "This is an updated test note.", + "references": [ + { + "publicationId": "PMID:25920551", + "crossReference": { + "id": "WB:WBPaper00042241", + "pages": [ + "reference" + ] + } + } + ] + } + ], + "crossReferences": [ + { + "id": "TEST:WBVar00252637", + "pages": [ + "homepage" + ] + } + ] + } +] +