Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CNA long format (RFC 65) #9847

Merged
merged 3 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions core/src/main/java/org/mskcc/cbio/portal/dao/DaoCnaEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ public static void addCaseCnaEvent(CnaEvent cnaEvent, boolean newCnaEvent) throw
||
(cnaEvent.getDriverTiersFilter() != null
&& !cnaEvent.getDriverTiersFilter().isEmpty()
&& !cnaEvent.getDriverTiersFilter().toLowerCase().equals("na"))) {
MySQLbulkLoader.getMySQLbulkLoader("alteration_driver_annotation").insertRecord(
&& !cnaEvent.getDriverTiersFilter().toLowerCase().equals("na"))
) {
MySQLbulkLoader
.getMySQLbulkLoader("alteration_driver_annotation")
.insertRecord(
Long.toString(eventId),
Integer.toString(cnaEvent.getCnaProfileId()),
Integer.toString(cnaEvent.getSampleId()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,34 @@ public static boolean updateNameAndDescription (int geneticProfileId, String nam
JdbcUtil.closeAll(DaoGeneticProfile.class, con, pstmt, rs);
}

reCache();
return ret;
}

/**
* Updates a Genetic Profile datatype
*/
public static boolean updateDatatype(
int geneticProfileId,
String datatype
) throws DaoException {
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
boolean ret;
try {
con = JdbcUtil.getDbConnection(DaoGeneticProfile.class);
pstmt = con.prepareStatement("UPDATE genetic_profile SET DATATYPE=? " +
"WHERE GENETIC_PROFILE_ID=?");
pstmt.setString(1, datatype);
pstmt.setInt(2, geneticProfileId);
ret = pstmt.executeUpdate() > 0;
} catch (SQLException e) {
throw new DaoException(e);
} finally {
JdbcUtil.closeAll(DaoGeneticProfile.class, con, pstmt, rs);
}

reCache();
return ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private DaoGeneticProfileSamples() {}
* @return number of rows added.
* @throws DaoException Data Access Exception.
*/
public static int addGeneticProfileSamples(int geneticProfileId, ArrayList<Integer> orderedSampleList)
public static int addGeneticProfileSamples(int geneticProfileId, List<Integer> orderedSampleList)
BasLee marked this conversation as resolved.
Show resolved Hide resolved
throws DaoException {
Connection con = null;
PreparedStatement pstmt = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@

package org.mskcc.cbio.portal.model;

import org.mskcc.cbio.portal.dao.DaoException;

import java.util.*;
import java.io.Serializable;

Expand Down
6 changes: 5 additions & 1 deletion core/src/main/java/org/mskcc/cbio/portal/model/CnaEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void setGene(CanonicalGene gene) {
public void setEntrezGeneId(long entrezGeneId) {
setGene(DaoGeneOptimized.getInstance().getGene(entrezGeneId));
if (gene == null) {
throw new IllegalArgumentException("Could not find entrez gene id: "+entrezGeneId);
throw new IllegalArgumentException("Could not find entrez gene id: " + entrezGeneId);
}
}

Expand All @@ -99,6 +99,10 @@ public int hashCode() {
return hash;
}

/**
* Compare by gene and alteration,
* but not by eventId
*/
@Override
public boolean equals(Object obj) {
if (obj == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package org.mskcc.cbio.portal.scripts;

import org.mskcc.cbio.portal.dao.DaoException;
import org.mskcc.cbio.portal.dao.DaoGeneticAlteration;
import org.mskcc.cbio.portal.model.CanonicalGene;
import org.mskcc.cbio.portal.util.ProgressMonitor;

import java.util.*;

import static java.lang.String.format;

public class GeneticAlterationImporter {

private final int geneticProfileId;
private Set<Long> importSetOfGenes = new HashSet<>();
private DaoGeneticAlteration daoGeneticAlteration;

public GeneticAlterationImporter(
int geneticProfileId,
DaoGeneticAlteration daoGeneticAlteration
) {
this.geneticProfileId = geneticProfileId;
this.daoGeneticAlteration = daoGeneticAlteration;
}

/**
* Check that we have not already imported information regarding this gene.
* This is an important check, because a GISTIC or RAE file may contain
* multiple rows for the same gene, and we only want to import the first row.
*/
public boolean store(
String[] values,
CanonicalGene gene,
String geneSymbol
) throws DaoException {
try {
if (importSetOfGenes.add(gene.getEntrezGeneId())) {
daoGeneticAlteration.addGeneticAlterations(geneticProfileId, gene.getEntrezGeneId(), values);
return true;
} else {
String geneSymbolMessage = "";
if (geneSymbol != null && !geneSymbol.equalsIgnoreCase(gene.getHugoGeneSymbolAllCaps())) {
geneSymbolMessage = " (given as alias in your file as: " + geneSymbol + ")";
}
ProgressMonitor.logWarning(format(
"Gene %s (%d)%s found to be duplicated in your file. Duplicated row will be ignored!",
gene.getHugoGeneSymbolAllCaps(),
gene.getEntrezGeneId(),
geneSymbolMessage)
);
return false;
}
} catch (Exception e) {
throw new RuntimeException("Aborted: Error found for row starting with " + geneSymbol + ": " + e.getMessage());
}
}


}
Loading