Skip to content

Commit

Permalink
ZFIN-9258 synchronize abbrev and name for transcripts (ZFIN#1121)
Browse files Browse the repository at this point in the history
* ZFIN-9258 synchronize abbrev and name for transcripts

* fix accessor for HTPDataset change

* Update db.changelog.master.xml

---------

Co-authored-by: Ryan Taylor <[email protected]>
  • Loading branch information
cmpich and rtaylorzfin authored Aug 16, 2024
1 parent 4bd56bc commit 2560c08
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 16 deletions.
90 changes: 90 additions & 0 deletions source/org/zfin/db/postGmakePostloaddb/1160/ZFIN-9258.sql
Original file line number Diff line number Diff line change
@@ -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;

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">


<include file="source/org/zfin/db/postGmakePostloaddb/1160/ZFIN-9318.sql" />

<include file="source/org/zfin/db/postGmakePostloaddb/1160/ZFIN-9244.sql" />
<include file="source/org/zfin/db/postGmakePostloaddb/1160/ZFIN-9258.sql" />


</databaseChangeLog>
49 changes: 39 additions & 10 deletions source/org/zfin/marker/MarkerHistory.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -105,6 +110,33 @@ public static Reason getReason(String reasonValue) {
return null;
}

static List<Reason> 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<Reason> 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<Reason> getTranscriptReasons() {
return transcriptReasons;
}

public static List<Reason> getMarkerReasons() {
return markerReasons;
}

public String toString() {
return value;
}
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion source/org/zfin/marker/agr/BasicRNASeqMetaDatasetInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public AllRNASeqMetaDatasetDTO getAllDatasetInfo() {
datasetId.setPreferredCrossReference(preferredCrossReference);

}
datasetId.setSecondaryId(htpSecondaryIds);
datasetId.setAlternateIds(htpSecondaryIds);
}
dto.setDatasetId(datasetId);

Expand Down
2 changes: 1 addition & 1 deletion source/org/zfin/marker/agr/HtpIDDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class HtpIDDTO {

private String primaryId;
private List<String> secondaryId;
private List<String> alternateIds;
private List<CrossReferenceDTO> crossReferences;
private CrossReferenceDTO preferredCrossReference;

Expand Down
11 changes: 7 additions & 4 deletions source/org/zfin/marker/presentation/MarkerEditController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
Expand Down

0 comments on commit 2560c08

Please sign in to comment.