From 2560c08d95b6427b203cd8a2cc255d3d3b2f9e13 Mon Sep 17 00:00:00 2001 From: Christian Pich Date: Fri, 16 Aug 2024 07:38:39 +0200 Subject: [PATCH] ZFIN-9258 synchronize abbrev and name for transcripts (#1121) * ZFIN-9258 synchronize abbrev and name for transcripts * fix accessor for HTPDataset change * Update db.changelog.master.xml --------- Co-authored-by: Ryan Taylor <90803397+rtaylorzfin@users.noreply.github.com> --- .../db/postGmakePostloaddb/1160/ZFIN-9258.sql | 90 +++++++++++++++++++ .../1160/db.changelog.master.xml | 5 ++ source/org/zfin/marker/MarkerHistory.java | 49 +++++++--- .../agr/BasicRNASeqMetaDatasetInfo.java | 2 +- source/org/zfin/marker/agr/HtpIDDTO.java | 2 +- .../presentation/MarkerEditController.java | 11 ++- 6 files changed, 143 insertions(+), 16 deletions(-) create mode 100644 source/org/zfin/db/postGmakePostloaddb/1160/ZFIN-9258.sql diff --git a/source/org/zfin/db/postGmakePostloaddb/1160/ZFIN-9258.sql b/source/org/zfin/db/postGmakePostloaddb/1160/ZFIN-9258.sql new file mode 100644 index 0000000000..af94675e57 --- /dev/null +++ b/source/org/zfin/db/postGmakePostloaddb/1160/ZFIN-9258.sql @@ -0,0 +1,90 @@ +--liquibase formatted sql +--changeset cmpich:ZFIN-9258.sql + +insert into marker_history_reason +VALUES ('Renamed to conform with Ensembl transcript nomenclature'); +insert into marker_history_reason +VALUES ('Same transcript'); + + +select count(*) +from marker +where exists(select * from transcript where mrkr_zdb_id = tscript_mrkr_zdb_id and mrkr_abbrev != mrkr_name); + +CREATE TEMP TABLE marker_name_temp as +select mrkr_zdb_id, mrkr_name, mrkr_abbrev +from marker +where exists(select * from transcript where mrkr_zdb_id = tscript_mrkr_zdb_id and mrkr_abbrev != mrkr_name); + +-- still problem transcript as they have a conflict when setting abbrev = name +select * +from marker as m +where exists( + select * from marker_name_temp as mnt where mnt.mrkr_zdb_id = m.mrkr_zdb_id + ) + and exists(select * from marker as m2 where m2.mrkr_abbrev = m.mrkr_name); + +-- remove conflicting records +delete from marker_name_temp where + mrkr_zdb_id in ('ZDB-TSCRIPT-090929-18263', 'ZDB-TSCRIPT-090929-18262', 'ZDB-TSCRIPT-090929-3084', 'ZDB-TSCRIPT-090929-5042', + 'ZDB-TSCRIPT-090929-14197', 'ZDB-TSCRIPT-110325-1463'); + +update marker as m +set mrkr_abbrev = lower(mrkr_name), + mrkr_name = lower(mrkr_name) +where exists( + select * from marker_name_temp as mnt where mnt.mrkr_zdb_id = m.mrkr_zdb_id + ); + +create temp table data_alias_temp as +select * from data_alias where exists ( + select * from marker_name_temp where mrkr_zdb_id = dalias_data_zdb_id and dalias_alias = mrkr_abbrev + ); + + +create temp table marker_alias_temp as +select get_id('DALIAS') as id, mrkr_abbrev, mrkr_zdb_id +from marker_name_temp; + +delete from marker_alias_temp as mat where + exists ( + select * from data_alias where exists ( + select * from marker_name_temp as mn where mn.mrkr_zdb_id = dalias_data_zdb_id and dalias_alias = mrkr_abbrev + and mat.mrkr_zdb_id = mn.mrkr_zdb_id + ) + ); + +insert into zdb_active_data +select id from marker_alias_temp; + +insert into data_alias (dalias_zdb_id, dalias_data_zdb_id, dalias_alias, dalias_alias_lower, dalias_group_id) +select id, mrkr_zdb_id, mrkr_abbrev, lower(mrkr_abbrev), 1 +from marker_alias_temp; + +insert into marker_alias_temp + select dalias_zdb_id, dalias_alias, dalias_data_zdb_id from data_alias_temp; + +create temp table id_temp as + select get_id('NOMEN') as id, + mrkr_zdb_id + from marker_name_temp; + +insert into zdb_active_data +select id from id_temp; + + +insert into marker_history (mhist_zdb_id, mhist_mrkr_zdb_id, mhist_event, mhist_reason, mhist_date, + mhist_mrkr_prev_name, mhist_mrkr_abbrev_on_mhist_date, mhist_mrkr_name_on_mhist_date, mhist_dalias_zdb_id) +select it.id, + mn.mrkr_zdb_id, + 'reassigned', + 'Renamed to conform with Ensembl transcript nomenclature', + now(), + mn.mrkr_abbrev, + mn.mrkr_name, + mn.mrkr_name, + mat.id +from marker_name_temp as mn, id_temp as it, marker_alias_temp as mat +where mn.mrkr_zdb_id = it.mrkr_zdb_id +and mn.mrkr_zdb_id = mat.mrkr_zdb_id; + diff --git a/source/org/zfin/db/postGmakePostloaddb/1160/db.changelog.master.xml b/source/org/zfin/db/postGmakePostloaddb/1160/db.changelog.master.xml index 9ee65757b7..47adb8df7b 100644 --- a/source/org/zfin/db/postGmakePostloaddb/1160/db.changelog.master.xml +++ b/source/org/zfin/db/postGmakePostloaddb/1160/db.changelog.master.xml @@ -5,6 +5,11 @@ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd"> + + + + + diff --git a/source/org/zfin/marker/MarkerHistory.java b/source/org/zfin/marker/MarkerHistory.java index 8130372309..03c129548b 100644 --- a/source/org/zfin/marker/MarkerHistory.java +++ b/source/org/zfin/marker/MarkerHistory.java @@ -5,7 +5,9 @@ import org.zfin.infrastructure.PublicationAttribution; import javax.persistence.*; +import java.util.ArrayList; import java.util.Date; +import java.util.List; import java.util.Set; @Entity @@ -88,7 +90,10 @@ public enum Reason { RENAMED_TO_CONFORM_WITH_HUMAN_NOMENCLATURE("renamed to conform with human nomenclature"), RENAMED_TO_CONFORM_WITH_MOUSE_NOMENCLATURE("renamed to conform with mouse nomenclature"), RENAMED_TO_CONFORM_WITH_ZEBRAFISH_GUIDELINES("renamed to conform with zebrafish guidelines"), - SAME_MARKER("same marker"); + SAME_MARKER("same marker"), + RENAMED_TO_CONFORM_WITH_ENSEMBL_TRANSCRIPT_NOMENCLATURE("Renamed to conform with Ensembl transcript nomenclature"), + SAME_TRANSCRIPT("same transcript"); + // RENAMED_THROUGH_THE_NOMENCLATURE_PIPELINE("renamed through the nomenclature pipeline"); private String value; @@ -105,6 +110,33 @@ public static Reason getReason(String reasonValue) { return null; } + static List transcriptReasons = new ArrayList<>(); + static { + transcriptReasons.add(NOT_SPECIFIED); + transcriptReasons.add(PER_GENE_FAMILY_REVISION); + transcriptReasons.add(RENAMED_TO_CONFORM_WITH_ZEBRAFISH_GUIDELINES); + transcriptReasons.add(PER_PERSONAL_COMMUNICATION_WITH_AUTHORS); + transcriptReasons.add(RENAMED_TO_CONFORM_WITH_HUMAN_NOMENCLATURE); + transcriptReasons.add(RENAMED_TO_CONFORM_WITH_MOUSE_NOMENCLATURE); + transcriptReasons.add(SAME_MARKER); + } + + static List markerReasons = new ArrayList<>(); + static { + markerReasons.add(NOT_SPECIFIED); + markerReasons.add(RENAMED_TO_CONFORM_WITH_ENSEMBL_TRANSCRIPT_NOMENCLATURE); + markerReasons.add(RENAMED_TO_CONFORM_WITH_ZEBRAFISH_GUIDELINES); + markerReasons.add(SAME_TRANSCRIPT); + } + + public static List getTranscriptReasons() { + return transcriptReasons; + } + + public static List getMarkerReasons() { + return markerReasons; + } + public String toString() { return value; } @@ -273,15 +305,12 @@ public void setOldMarkerName(String oldMarkerName) { } public String getOldSymbol() { - switch (event) { - case REASSIGNED: - return (markerAlias == null ? "" : markerAlias.getAlias()); - case MERGED: - return (markerAlias == null ? "" : markerAlias.getAlias()); - case RENAMED: - return oldMarkerName; - } - return ""; + return switch (event) { + case REASSIGNED -> (markerAlias == null ? "" : markerAlias.getAlias()); + case MERGED -> (markerAlias == null ? "" : markerAlias.getAlias()); + case RENAMED -> oldMarkerName; + default -> ""; + }; } public String getNewValue() { diff --git a/source/org/zfin/marker/agr/BasicRNASeqMetaDatasetInfo.java b/source/org/zfin/marker/agr/BasicRNASeqMetaDatasetInfo.java index 504f93008c..11149558ad 100644 --- a/source/org/zfin/marker/agr/BasicRNASeqMetaDatasetInfo.java +++ b/source/org/zfin/marker/agr/BasicRNASeqMetaDatasetInfo.java @@ -81,7 +81,7 @@ public AllRNASeqMetaDatasetDTO getAllDatasetInfo() { datasetId.setPreferredCrossReference(preferredCrossReference); } - datasetId.setSecondaryId(htpSecondaryIds); + datasetId.setAlternateIds(htpSecondaryIds); } dto.setDatasetId(datasetId); diff --git a/source/org/zfin/marker/agr/HtpIDDTO.java b/source/org/zfin/marker/agr/HtpIDDTO.java index d8c35a4c8e..77e9d71260 100644 --- a/source/org/zfin/marker/agr/HtpIDDTO.java +++ b/source/org/zfin/marker/agr/HtpIDDTO.java @@ -15,7 +15,7 @@ public class HtpIDDTO { private String primaryId; - private List secondaryId; + private List alternateIds; private List crossReferences; private CrossReferenceDTO preferredCrossReference; diff --git a/source/org/zfin/marker/presentation/MarkerEditController.java b/source/org/zfin/marker/presentation/MarkerEditController.java index 622ffe7f4a..d138deadb4 100644 --- a/source/org/zfin/marker/presentation/MarkerEditController.java +++ b/source/org/zfin/marker/presentation/MarkerEditController.java @@ -23,7 +23,10 @@ import org.zfin.nomenclature.presentation.Nomenclature; import org.zfin.publication.Publication; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Objects; import static org.zfin.repository.RepositoryFactory.getInfrastructureRepository; import static org.zfin.repository.RepositoryFactory.getPublicationRepository; @@ -60,11 +63,11 @@ private Nomenclature getNomenclatureForMarker(Marker marker) { nomenclature.setReason(""); nomenclature.setComments(""); if (marker.getMarkerType().getType().equals(Marker.Type.TSCRIPT)) { - nomenclature.putMeta("reasons", Arrays.stream(MarkerHistory.TranscriptReason.values()) - .map(MarkerHistory.TranscriptReason::toString) + nomenclature.putMeta("reasons", MarkerHistory.Reason.getTranscriptReasons().stream() + .map(MarkerHistory.Reason::toString) .toArray()); } else { - nomenclature.putMeta("reasons", Arrays.stream(MarkerHistory.Reason.values()) + nomenclature.putMeta("reasons", MarkerHistory.Reason.getMarkerReasons().stream() .map(MarkerHistory.Reason::toString) .toArray()); }