diff --git a/business/pom.xml b/business/pom.xml index f9e8a7936ff..efe733900f1 100644 --- a/business/pom.xml +++ b/business/pom.xml @@ -4,7 +4,7 @@ master org.mskcc.cbio - 1.5.2 + 1.6.0 4.0.0 business diff --git a/core/pom.xml b/core/pom.xml index 109e16e8fcb..a690df1db82 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -4,7 +4,7 @@ master org.mskcc.cbio - 1.5.2 + 1.6.0 4.0.0 core diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCancerStudy.java b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCancerStudy.java index 7ef19c6f0b3..aadc23d1539 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCancerStudy.java +++ b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoCancerStudy.java @@ -519,6 +519,7 @@ public static void deleteCancerStudy(int internalCancerStudyId) throws DaoExcept "DELETE FROM sample_profile WHERE GENETIC_PROFILE_ID IN (SELECT GENETIC_PROFILE_ID FROM genetic_profile WHERE CANCER_STUDY_ID=?)", "DELETE FROM mutation WHERE GENETIC_PROFILE_ID IN (SELECT GENETIC_PROFILE_ID FROM genetic_profile WHERE CANCER_STUDY_ID=?)", "DELETE FROM mutation_count WHERE GENETIC_PROFILE_ID IN (SELECT GENETIC_PROFILE_ID FROM genetic_profile WHERE CANCER_STUDY_ID=?)", + "DELETE FROM mutation_count_by_keyword WHERE GENETIC_PROFILE_ID IN (SELECT GENETIC_PROFILE_ID FROM genetic_profile WHERE CANCER_STUDY_ID=?)", "DELETE FROM clinical_attribute_meta WHERE CANCER_STUDY_ID=?", "DELETE FROM clinical_event_data WHERE CLINICAL_EVENT_ID IN (SELECT CLINICAL_EVENT_ID FROM clinical_event WHERE PATIENT_ID IN (SELECT INTERNAL_ID FROM patient WHERE CANCER_STUDY_ID=?))", "DELETE FROM clinical_event WHERE PATIENT_ID IN (SELECT INTERNAL_ID FROM patient WHERE CANCER_STUDY_ID=?)", diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoMutation.java b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoMutation.java index 4db718e6161..2a948718425 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/dao/DaoMutation.java +++ b/core/src/main/java/org/mskcc/cbio/portal/dao/DaoMutation.java @@ -145,6 +145,34 @@ public static int calculateMutationCount (int profileId) throws DaoException { JdbcUtil.closeAll(DaoMutation.class, con, pstmt, rs); } } + + public static int calculateMutationCountByKeyword(int profileId) throws DaoException { + Connection con = null; + PreparedStatement pstmt = null; + ResultSet rs = null; + try { + con = JdbcUtil.getDbConnection(DaoMutation.class); + pstmt = con.prepareStatement( + "INSERT INTO mutation_count_by_keyword " + + "SELECT g2.`GENETIC_PROFILE_ID`, mutation_event.`KEYWORD`, m2.`ENTREZ_GENE_ID`, " + + "IF(mutation_event.`KEYWORD` IS NULL, 0, COUNT(*)) AS KEYWORD_COUNT, (SELECT COUNT(*) " + + "FROM `mutation` AS m1 , `genetic_profile` AS g1 " + + "WHERE m1.`GENETIC_PROFILE_ID` = g1.`GENETIC_PROFILE_ID` " + + "AND g1.`GENETIC_PROFILE_ID`= g2.`GENETIC_PROFILE_ID` AND m1.`ENTREZ_GENE_ID` = m2.`ENTREZ_GENE_ID` " + + "GROUP BY g1.`GENETIC_PROFILE_ID` , m1.`ENTREZ_GENE_ID`) AS GENE_COUNT " + + "FROM `mutation` AS m2 , `genetic_profile` AS g2 , `mutation_event` " + + "WHERE m2.`GENETIC_PROFILE_ID` = g2.`GENETIC_PROFILE_ID` " + + "AND m2.`MUTATION_EVENT_ID` = mutation_event.`MUTATION_EVENT_ID` " + + "AND g2.`GENETIC_PROFILE_ID`=? " + + "GROUP BY g2.`GENETIC_PROFILE_ID` , mutation_event.`KEYWORD` , m2.`ENTREZ_GENE_ID`;"); + pstmt.setInt(1, profileId); + return pstmt.executeUpdate(); + } catch (SQLException e) { + throw new DaoException(e); + } finally { + JdbcUtil.closeAll(DaoMutation.class, con, pstmt, rs); + } + } /** * @deprecated We believe that this method is no longer called by any part of the codebase, and it will soon be deleted. diff --git a/core/src/main/java/org/mskcc/cbio/portal/dao/JdbcUtil.java b/core/src/main/java/org/mskcc/cbio/portal/dao/JdbcUtil.java index e985ea5769f..847e342b57e 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/dao/JdbcUtil.java +++ b/core/src/main/java/org/mskcc/cbio/portal/dao/JdbcUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Memorial Sloan-Kettering Cancer Center. + * Copyright (c) 2015 - 2017 Memorial Sloan-Kettering Cancer Center. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS @@ -32,14 +32,12 @@ package org.mskcc.cbio.portal.dao; -import org.mskcc.cbio.portal.util.*; - -import org.apache.commons.logging.*; - import java.sql.*; import java.util.*; import javax.sql.DataSource; import org.apache.commons.dbcp.BasicDataSource; +import org.apache.commons.logging.*; +import org.mskcc.cbio.portal.util.*; /** * Connection Utility for JDBC. @@ -48,57 +46,54 @@ * @author Ersin Ciftci */ public class JdbcUtil { - private static DataSource ds; + private static DataSource dataSource; private static Map activeConnectionCount = new HashMap(); // keep track of the number of active connection per class/requester private static final Log LOG = LogFactory.getLog(JdbcUtil.class); - + /** * Gets the data source * @return the data source */ public static DataSource getDataSource() { - if (ds==null) ds = initDataSource(); - return ds; + if (dataSource == null) { + dataSource = initDataSource(); + } + return dataSource; } - + /** * Sets the data source * @param value the data source */ public static void setDataSource(DataSource value) { - ds = value; + dataSource = value; } - + private static DataSource initDataSource() { DatabaseProperties dbProperties = DatabaseProperties.getInstance(); String host = dbProperties.getDbHost(); String userName = dbProperties.getDbUser(); String password = dbProperties.getDbPassword(); String database = dbProperties.getDbName(); - String url ="jdbc:mysql://" + host + "/" + database + "?user=" + userName + "&password=" + password + "&zeroDateTimeBehavior=convertToNull"; - // Set up poolable data source - BasicDataSource ds = new BasicDataSource(); - ds.setDriverClassName("com.mysql.jdbc.Driver"); - ds.setUsername(userName); - ds.setPassword(password); - ds.setUrl(url); - + BasicDataSource dataSource = new BasicDataSource(); + dataSource.setDriverClassName("com.mysql.jdbc.Driver"); + dataSource.setUsername(userName); + dataSource.setPassword(password); + dataSource.setUrl(url); // By pooling/reusing PreparedStatements, we get a major performance gain - ds.setPoolPreparedStatements(true); - ds.setMaxActive(100); - + dataSource.setPoolPreparedStatements(true); + dataSource.setMaxActive(100); activeConnectionCount = new HashMap(); - - return ds; + return dataSource; } /** * Gets Connection to the Database. - * + * * @param clazz class * @return Live Connection to Database. * @throws java.sql.SQLException Error Connecting to Database. @@ -106,10 +101,10 @@ private static DataSource initDataSource() { public static Connection getDbConnection(Class clazz) throws SQLException { return getDbConnection(clazz.getName()); } - + /** * Gets Connection to the Database. - * + * * @param requester name * @return Live Connection to Database. * @throws java.sql.SQLException Error Connecting to Database. @@ -117,21 +112,17 @@ public static Connection getDbConnection(Class clazz) throws SQLException { private static Connection getDbConnection(String requester) throws SQLException { // this method should be syncronized // but may slow the speed? - Connection con; try { con = getDataSource().getConnection(); - } - catch (Exception e) { + } catch (Exception e) { logMessage(e.getMessage()); throw new SQLException(e); } - - if (requester!=null) { + if (requester != null) { Integer count = activeConnectionCount.get(requester); - activeConnectionCount.put(requester, count==null ? 1 : (count+1)); + activeConnectionCount.put(requester, count == null ? 1 : (count + 1)); } - return con; } @@ -143,19 +134,17 @@ private static Connection getDbConnection(String requester) throws SQLException public static void closeConnection(Class clazz, Connection con) { closeConnection(clazz.getName(), con); } - + private static void closeConnection(String requester, Connection con) { try { if (con != null && !con.isClosed()) { con.close(); - if (requester!=null) { - int count = activeConnectionCount.get(requester)-1; - if (count<0) { + int count = activeConnectionCount.get(requester) - 1; + if (count < 0) { // since adding connection is not synchronized, the count may not be the real one count = 0; } - activeConnectionCount.put(requester, count); } } @@ -171,8 +160,8 @@ private static void closeConnection(String requester, Connection con) { * @param rs ResultSet Object. */ public static void closeAll(ResultSet rs) { - JdbcUtil.closeAll((String)null, null, null, rs); - } + JdbcUtil.closeAll((String)null, null, null, rs); + } /** * Frees Database Connection. @@ -181,8 +170,7 @@ public static void closeAll(ResultSet rs) { * @param ps Prepared Statement Object. * @param rs ResultSet Object. */ - public static void closeAll(Class clazz, Connection con, PreparedStatement ps, - ResultSet rs) { + public static void closeAll(Class clazz, Connection con, PreparedStatement ps, ResultSet rs) { closeAll(clazz.getName(), con, ps, rs); } @@ -192,23 +180,26 @@ public static void closeAll(Class clazz, Connection con, PreparedStatement ps, * @param con Connection Object. * @param rs ResultSet Object. */ - private static void closeAll(String requester, Connection con, PreparedStatement ps, - ResultSet rs) { + private static void closeAll(String requester, Connection con, PreparedStatement ps, ResultSet rs) { if (rs != null) { try { - rs.close(); + if (!rs.isClosed()) { + rs.close(); + } } catch (SQLException e) { e.printStackTrace(); } } if (ps != null) { try { - ps.close(); + if (!ps.isClosed()) { + ps.close(); + } } catch (SQLException e) { e.printStackTrace(); } } - closeConnection(requester, con); + closeConnection(requester, con); } /** @@ -223,7 +214,9 @@ public static void closeAll(Class clazz, Connection con, ResultSet rs) { closeConnection(requester, con); if (rs != null) { try { - rs.close(); + if (!rs.isClosed()) { + rs.close(); + } } catch (SQLException e) { e.printStackTrace(); } @@ -236,18 +229,18 @@ private static void logMessage(String message) { } System.err.println(message); } - + // is it good to put the two methods below here? static Integer readIntegerFromResultSet(ResultSet rs, String column) throws SQLException { int i = rs.getInt(column); return rs.wasNull() ? null : i; } - + static Long readLongFromResultSet(ResultSet rs, String column) throws SQLException { long l = rs.getInt(column); return rs.wasNull() ? null : l; } - + static Double readDoubleFromResultSet(ResultSet rs, String column) throws SQLException { double d = rs.getDouble(column); return rs.wasNull() ? null : d; @@ -261,7 +254,6 @@ static Double readDoubleFromResultSet(ResultSet rs, String column) throws SQLExc * @throws SQLException */ public static void disableForeignKeyCheck(Connection con) throws SQLException { - Statement stmt = con.createStatement(); stmt.execute("SET FOREIGN_KEY_CHECKS=0"); stmt.close(); @@ -273,7 +265,6 @@ public static void disableForeignKeyCheck(Connection con) throws SQLException { * @throws SQLException */ public static void enableForeignKeyCheck(Connection con) throws SQLException { - Statement stmt = con.createStatement(); stmt.execute("SET FOREIGN_KEY_CHECKS=1"); stmt.close(); diff --git a/core/src/main/java/org/mskcc/cbio/portal/scripts/ImportExtendedMutationData.java b/core/src/main/java/org/mskcc/cbio/portal/scripts/ImportExtendedMutationData.java index a200d8fb441..f38da4bd378 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/scripts/ImportExtendedMutationData.java +++ b/core/src/main/java/org/mskcc/cbio/portal/scripts/ImportExtendedMutationData.java @@ -453,6 +453,7 @@ public void importData() throws IOException, DaoException { // calculate mutation count for every sample DaoMutation.calculateMutationCount(geneticProfileId); + DaoMutation.calculateMutationCountByKeyword(geneticProfileId); if (entriesSkipped > 0) { ProgressMonitor.setCurrentMessage(" --> total number of data entries skipped (see table below): " + entriesSkipped); diff --git a/core/src/main/java/org/mskcc/cbio/portal/util/CheckDarwinAccessMain.java b/core/src/main/java/org/mskcc/cbio/portal/servlet/CheckDarwinAccessServlet.java similarity index 72% rename from core/src/main/java/org/mskcc/cbio/portal/util/CheckDarwinAccessMain.java rename to core/src/main/java/org/mskcc/cbio/portal/servlet/CheckDarwinAccessServlet.java index 6d0da203a8f..36a5af2a7cf 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/util/CheckDarwinAccessMain.java +++ b/core/src/main/java/org/mskcc/cbio/portal/servlet/CheckDarwinAccessServlet.java @@ -30,23 +30,30 @@ * along with this program. If not, see . */ -package org.mskcc.cbio.portal.util; +package org.mskcc.cbio.portal.servlet; -import org.mskcc.cbio.portal.servlet.PatientView; +import org.mskcc.cbio.portal.util.SpringUtil; +import org.mskcc.cbio.portal.util.GlobalProperties; +import org.apache.log4j.Logger; import org.springframework.http.*; import org.springframework.web.client.RestTemplate; import org.springframework.util.LinkedMultiValueMap; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.context.support.SpringBeanAutowiringSupport; import org.apache.commons.cli.*; import org.apache.commons.lang.builder.ToStringBuilder; +import java.io.*; import java.util.*; import javax.annotation.Generated; import com.fasterxml.jackson.annotation.*; import java.util.regex.Pattern; -import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.*; +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; /** * @@ -59,7 +66,15 @@ "p_userName", "p_dmp_pid" }) -public class CheckDarwinAccessMain { +public class CheckDarwinAccessServlet extends HttpServlet { + private static Logger logger = Logger.getLogger(CheckDarwinAccessServlet.class); + + @Override + public void init(ServletConfig config) throws ServletException { + super.init(config); + SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this, + config.getServletContext()); + } public static class CheckDarwinAccess { private static String darwinAuthUrl = GlobalProperties.getDarwinAuthCheckUrl(); @@ -70,18 +85,18 @@ public static class CheckDarwinAccess { public static String checkAccess(HttpServletRequest request) { if (!existsDarwinProperties()) return ""; // if sample id does not match regex or username matches cis username then return empty string - String userName = GlobalProperties.getAuthenticatedUserName().split("@")[0]; - String darwinResponse = ""; + String userName = GlobalProperties.getAuthenticatedUserName().split("@")[0]; + String darwinResponse = ""; try { - List sampleIds = (List)request.getAttribute(PatientView.SAMPLE_ID); - if (sampleIdRegex.matcher(sampleIds.get(0)).find() && !cisUser.equals(userName)) { - String patientId = (String)request.getAttribute(PatientView.PATIENT_ID); + String[] sampleIds = request.getParameter(PatientView.SAMPLE_ID).split(","); + if (sampleIdRegex.matcher(sampleIds[0]).find() && !cisUser.equals(userName)) { + String patientId = request.getParameter(PatientView.PATIENT_ID); darwinResponse = getResponse(userName, patientId); } } catch (NullPointerException ex) {} - return darwinResponse; + return darwinResponse; } public static String getResponse(String userName, String patientId){ @@ -101,7 +116,7 @@ private static HttpEntity> getRequestEntity( return new HttpEntity>(map, headers); } - private static boolean existsDarwinProperties() { + public static boolean existsDarwinProperties() { return (!darwinAuthUrl.isEmpty() && !darwinResponseUrl.isEmpty() && !cisUser.isEmpty() && !GlobalProperties.getDarwinRegex().isEmpty()); } } @@ -253,25 +268,60 @@ private static void help(Options gnuOptions, int exitStatus) { System.exit(exitStatus); } - public static void main(String[] args) throws Exception { - Options gnuOptions = CheckDarwinAccessMain.getOptions(args); - CommandLineParser parser = new DefaultParser(); - CommandLine commandLine = parser.parse(gnuOptions, args); - if (commandLine.hasOption("h") || - !commandLine.hasOption("user_name") || - !commandLine.hasOption("patient_id") || - !commandLine.hasOption("sample_id")) { - help(gnuOptions, 0); - } - if (!CheckDarwinAccess.sampleIdRegex.matcher(commandLine.getOptionValue("sample_id")).find()) { - System.out.println("Sample ID doesn't match pattern"); - } - else { - System.out.println("Sample ID valid - checking if user has access"); - String darwinAccessUrl = CheckDarwinAccess.getResponse( - commandLine.getOptionValue("user_name").split("@")[0], - commandLine.getOptionValue("patient_id")); - System.out.println(!darwinAccessUrl.isEmpty()?darwinAccessUrl:"Invalid request!"); - } + /** + * Processes requests for both HTTP GET and POST methods. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + String darwinResponse = CheckDarwinAccess.checkAccess(request); + + response.setContentType("text/plain"); + PrintWriter out = response.getWriter(); + try { + out.write(darwinResponse); + } finally { + out.close(); + } + } + + // + /** + * Handles the HTTP GET method. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); } -} \ No newline at end of file + + /** + * Handles the HTTP POST method. + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + processRequest(request, response); + } + + /** + * Returns a short description of the servlet. + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// +} diff --git a/core/src/main/java/org/mskcc/cbio/portal/servlet/PatientView.java b/core/src/main/java/org/mskcc/cbio/portal/servlet/PatientView.java index 4e6d6752acf..35bf68ccf1a 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/servlet/PatientView.java +++ b/core/src/main/java/org/mskcc/cbio/portal/servlet/PatientView.java @@ -33,44 +33,17 @@ package org.mskcc.cbio.portal.servlet; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.httpclient.methods.GetMethod; -import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; -import org.mskcc.cbio.portal.repository.MutationRepositoryLegacy; -import org.mskcc.cbio.portal.dao.*; -import org.mskcc.cbio.portal.model.*; -import org.mskcc.cbio.portal.util.AccessControl; -import org.mskcc.cbio.portal.web_api.ConnectionManager; -import org.mskcc.cbio.portal.web_api.ProtocolException; import org.mskcc.cbio.portal.util.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.userdetails.UserDetails; import org.springframework.web.context.support.SpringBeanAutowiringSupport; -import java.net.URL; -import java.util.*; import javax.servlet.*; /** @@ -78,43 +51,18 @@ * @author jj */ public class PatientView extends HttpServlet { - private static Logger logger = Logger.getLogger(PatientView.class); - public static final String ERROR = "user_error_message"; - public static final String VIEW_TYPE = "view_type"; public static final String SAMPLE_ID = "sample_id"; public static final String PATIENT_ID = "case_id"; - public static final String PATIENT_ID_ATTR_NAME = "PATIENT_ID"; - public static final String PATIENT_CASE_OBJ = "case_obj"; - public static final String CANCER_STUDY = "cancer_study"; - public static final String HAS_SEGMENT_DATA = "has_segment_data"; public static final String HAS_ALLELE_FREQUENCY_DATA = "has_allele_frequency_data"; public static final String MUTATION_PROFILE = "mutation_profile"; - public static final String CANCER_STUDY_META_DATA_KEY_STRING = "cancer_study_meta_data"; public static final String CNA_PROFILE = "cna_profile"; public static final String MRNA_PROFILE = "mrna_profile"; - public static final String NUM_CASES_IN_SAME_STUDY = "num_cases"; - public static final String NUM_CASES_IN_SAME_MUTATION_PROFILE = "num_cases_mut"; - public static final String NUM_CASES_IN_SAME_CNA_PROFILE = "num_cases_cna"; - public static final String NUM_CASES_IN_SAME_MRNA_PROFILE = "num_cases_mrna"; - public static final String PATIENT_INFO = "patient_info"; - public static final String DISEASE_INFO = "disease_info"; - public static final String PATIENT_STATUS = "patient_status"; - public static final String CLINICAL_DATA = "clinical_data"; - public static final String CLINICAL_ATTRIBUTES = "clinical_attributes"; - public static final String TISSUE_IMAGES = "tissue_images"; - public static final String PATH_REPORT_URL = "path_report_url"; - public static final String CLINICAL_ATTRIBUTE_OTHER_PAPTEINT_ID = "OTHER_PATIENT_ID"; - public static final String CLINICAL_ATTRIBUTE_OTHER_SAMPLE_ID = "OTHER_SAMPLE_ID"; - + public static final String DRUG_TYPE = "drug_type"; public static final String DRUG_TYPE_CANCER_DRUG = "cancer_drug"; public static final String DRUG_TYPE_FDA_ONLY = "fda_approved"; - - // class which process access control to cancer studies - private AccessControl accessControl; - @Autowired - private MutationRepositoryLegacy mutationRepositoryLegacy; + private static Logger logger = Logger.getLogger(PatientView.class); @Override public void init(ServletConfig config) throws ServletException { @@ -122,17 +70,6 @@ public void init(ServletConfig config) throws ServletException { SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this, config.getServletContext()); } - - /** - * Initializes the servlet. - * - * @throws ServletException Serlvet Init Error. - */ - @Override - public void init() throws ServletException { - super.init(); - accessControl = SpringUtil.getAccessControl(); - } /** * Processes requests for both HTTP GET and POST methods. @@ -145,444 +82,25 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re throws ServletException, IOException { XDebug xdebug = new XDebug( request ); request.setAttribute(QueryBuilder.XDEBUG_OBJECT, xdebug); - - String cancerStudyId = request.getParameter(QueryBuilder.CANCER_STUDY_ID); - request.setAttribute(QueryBuilder.CANCER_STUDY_ID, cancerStudyId); - - try { - if (validate(request)) { - setGeneticProfiles(request); - setClinicalInfo(request); - setNumCases(request); - setCancerStudyMetaData(request); - } - - if (request.getAttribute(ERROR)!=null) { - String msg = (String)request.getAttribute(ERROR); - xdebug.logMsg(this, msg); - forwardToErrorPage(request, response, msg, xdebug); - } else { - RequestDispatcher dispatcher = - getServletContext().getRequestDispatcher("/WEB-INF/jsp/patient_view/patient_view.jsp"); - dispatcher.forward(request, response); - } - - } catch (DaoException e) { - e.printStackTrace(); - xdebug.logMsg(this, "Got Database Exception: " + e.getMessage()); - forwardToErrorPage(request, response, - "An error occurred while trying to connect to the database.", xdebug); - } catch (ProtocolException e) { - e.printStackTrace(); - xdebug.logMsg(this, "Got Protocol Exception " + e.getMessage()); - forwardToErrorPage(request, response, - "An error occurred while trying to authenticate.", xdebug); - } - } - - /** - * - * Tests whether there is allele frequency data for a patient in a cancer study. - * It gets all the mutations and then checks the values for allele frequency. - * - * If mutationProfile is null then returns false - * - * @return Boolean - * - * @author Gideon Dresdner - */ - public boolean hasAlleleFrequencyData(int sampleId, GeneticProfile mutationProfile) throws DaoException { - - if (mutationProfile == null) { - // fail quietly - return false; - } - - return mutationRepositoryLegacy.hasAlleleFrequencyData(mutationProfile.getGeneticProfileId(), sampleId); - } - - private boolean validate(HttpServletRequest request) throws DaoException { - - // by default; in case return false; - request.setAttribute(HAS_SEGMENT_DATA, Boolean.FALSE); - request.setAttribute(HAS_ALLELE_FREQUENCY_DATA, Boolean.FALSE); - - String sampleIdsStr = request.getParameter(SAMPLE_ID); - String patientIdsStr = request.getParameter(PATIENT_ID); - if ((sampleIdsStr == null || sampleIdsStr.isEmpty()) - && (patientIdsStr == null || patientIdsStr.isEmpty())) { - request.setAttribute(ERROR, "Please specify at least one case ID or patient ID. "); - return false; - } - - String cancerStudyId = (String) request.getAttribute(QueryBuilder.CANCER_STUDY_ID); - if (cancerStudyId==null) { - request.setAttribute(ERROR, "Please specify cancer study ID. "); - return false; - } - - CancerStudy cancerStudy = DaoCancerStudy.getCancerStudyByStableId(cancerStudyId); - if (cancerStudy==null) { - request.setAttribute(ERROR, "We have no information about cancer study "+cancerStudyId); - return false; - } - - Set samples = new HashSet(); - Set sampleIdSet = new HashSet(); - if (sampleIdsStr!=null) { - for (String sampleId : sampleIdsStr.split(" +")) { - Sample _sample = DaoSample.getSampleByCancerStudyAndSampleId(cancerStudy.getInternalId(), sampleId); - if (_sample == null) { - List ss = DaoClinicalData.getSamplesByAttribute(cancerStudy.getInternalId(), CLINICAL_ATTRIBUTE_OTHER_SAMPLE_ID, sampleId); - if (!ss.isEmpty()) { //TODO: what if there are more than 1 samples with the same other id - _sample = ss.get(0); - } - } - if (_sample != null) { - samples.add(_sample); - sampleIdSet.add(_sample.getStableId()); - } - } - } - - request.setAttribute(VIEW_TYPE, "sample"); - if (patientIdsStr!=null) { - request.setAttribute(VIEW_TYPE, "patient"); - for (String patientId : patientIdsStr.split(" +")) { - Patient patient = DaoPatient.getPatientByCancerStudyAndPatientId(cancerStudy.getInternalId(), patientId); - if (patient == null) { - List ps = DaoClinicalData.getPatientsByAttribute(cancerStudy.getInternalId(), CLINICAL_ATTRIBUTE_OTHER_PAPTEINT_ID, patientId); - if (!ps.isEmpty()) { //TODO: what if there are more than 1 patients with the same other id - patient = ps.get(0); - } - } - if (patient != null) { - for (Sample sample : DaoSample.getSamplesByPatientId(patient.getInternalId())) { - if (sample != null) { - samples.add(sample); - sampleIdSet.add(sample.getStableId()); - } - } - } - } - } - - if (samples.isEmpty()) { - request.setAttribute(ERROR, "We have no information about the patient."); - return false; - } - - - int patientId = samples.iterator().next().getInternalPatientId(); - - List sampleIds = new ArrayList(sampleIdSet); - sortSampleIds(cancerStudy.getInternalId(), patientId, sampleIds); - - request.setAttribute(SAMPLE_ID, sampleIds); - - request.setAttribute(QueryBuilder.HTML_TITLE, "Patient: "+StringUtils.join(sampleIds,",")); + request.setAttribute(QueryBuilder.HTML_TITLE, "Patient"); - String cancerStudyIdentifier = cancerStudy.getCancerStudyStableId(); - - if (accessControl.isAccessibleCancerStudy(cancerStudyIdentifier).size() != 1) { - request.setAttribute(ERROR, - "You are not authorized to view the cancer study with id: '" + - cancerStudyIdentifier + "'. "); - return false; - } - else { - UserDetails ud = accessControl.getUserDetails(); - if (ud != null) { - logger.info("PatientView.validate: Query initiated by user: " + ud.getUsername()); - } - } - - request.setAttribute(PATIENT_CASE_OBJ, samples); - request.setAttribute(CANCER_STUDY, cancerStudy); - - request.setAttribute(HAS_SEGMENT_DATA, DaoCopyNumberSegment - .segmentDataExistForCancerStudy(cancerStudy.getInternalId())); - String firstSampleId = sampleIds.get(0); - Sample firstSample = DaoSample.getSampleByCancerStudyAndSampleId(cancerStudy.getInternalId(), firstSampleId); - request.setAttribute(HAS_ALLELE_FREQUENCY_DATA, - hasAlleleFrequencyData(firstSample.getInternalId(), cancerStudy.getMutationProfile(firstSampleId))); - - return true; - } - - private void sortSampleIds(int cancerStudyId, int patientId, List sampleIds) { - if (sampleIds.size()==1) { - return; - } - try { - Collections.sort(sampleIds, new NaturalOrderComparator()); - - if (DaoClinicalEvent.timeEventsExistForPatient(patientId)) { - List events = DaoClinicalEvent.getClinicalEvent(patientId, "SPECIMEN"); - if (events!=null) { - final Map sampleTimes = new HashMap(); - // TODO: event data should only use SAMPLE_ID, this allows - // all variations currently in the db while transitioning - String[] sampleIdsInEventData = {"SpecimenReferenceNumber", - "SPECIMEN_REFERENCE_NUMBER", - "SAMPLE_ID"}; - for (ClinicalEvent event : events) { - String specRefNum = null; - for (String s: sampleIdsInEventData) { - specRefNum = event.getEventData().get(s); - if (specRefNum != null) { - break; - } - } - sampleTimes.put(specRefNum, event.getStartDate()); - } - - Collections.sort(sampleIds, new Comparator() { - @Override - public int compare(String s1, String s2) { - Long l1 = sampleTimes.get(s1); - if (l1==null) l1 = Long.MAX_VALUE; - Long l2 = sampleTimes.get(s2); - if (l2==null) l2 = Long.MAX_VALUE; - - return l1.compareTo(l2); - } - }); - } - } - - ClinicalAttribute attr = DaoClinicalAttributeMeta.getDatum("SAMPLE_TYPE", cancerStudyId); - if (attr!=null) { - - List data = DaoClinicalData.getSampleData(cancerStudyId, sampleIds, attr); - if (!data.isEmpty()) { - final Map sampleTypes = new HashMap(); - for (ClinicalData datum : data) { - sampleTypes.put(datum.getStableId(), datum.getAttrVal().toLowerCase()); - } - Collections.sort(sampleIds, new Comparator() { - @Override - public int compare(String s1, String s2) { - int t1 = getOrderOfType(sampleTypes.get(s1)); - int t2 = getOrderOfType(sampleTypes.get(s2)); - return t1 - t2; - } - }); - } - } - - } catch (Exception e) { - e.printStackTrace(); - } - } - - private int getOrderOfType(String sampleType) { - switch (sampleType) { - case "primary": return 1; - case "progressed": return 3; - case "metastasis": return 4; - default: return 2; // null is primary - } - } - - private void setGeneticProfiles(HttpServletRequest request) throws DaoException { - CancerStudy cancerStudy = (CancerStudy)request.getAttribute(CANCER_STUDY); - GeneticProfile mutProfile = cancerStudy.getMutationProfile(); - if (mutProfile!=null) { - request.setAttribute(MUTATION_PROFILE, mutProfile); - request.setAttribute(NUM_CASES_IN_SAME_MUTATION_PROFILE, - DaoSampleProfile.countSamplesInProfile(mutProfile.getGeneticProfileId())); - } - - GeneticProfile cnaProfile = cancerStudy.getCopyNumberAlterationProfile(true); - if (cnaProfile!=null) { - request.setAttribute(CNA_PROFILE, cnaProfile); - request.setAttribute(NUM_CASES_IN_SAME_CNA_PROFILE, - DaoSampleProfile.countSamplesInProfile(cnaProfile.getGeneticProfileId())); - } - - GeneticProfile mrnaProfile = cancerStudy.getMRnaZscoresProfile(); - if (mrnaProfile!=null) { - request.setAttribute(MRNA_PROFILE, mrnaProfile); - request.setAttribute(NUM_CASES_IN_SAME_MRNA_PROFILE, - DaoSampleProfile.countSamplesInProfile(mrnaProfile.getGeneticProfileId())); - } + RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/WEB-INF/jsp/patient_view/patient_view.jsp"); + dispatcher.forward(request, response); } - private void setCancerStudyMetaData(HttpServletRequest request) throws DaoException, ProtocolException { - request.setAttribute(CANCER_STUDY_META_DATA_KEY_STRING, DaoSampleProfile.metaData(accessControl.getCancerStudies())); - } - - private void setNumCases(HttpServletRequest request) throws DaoException { - CancerStudy cancerStudy = (CancerStudy)request.getAttribute(CANCER_STUDY); - request.setAttribute(NUM_CASES_IN_SAME_STUDY,DaoPatient.getPatientsByCancerStudyId(cancerStudy.getInternalId()).size()); - } + private static String getFullURL(HttpServletRequest request) { + StringBuffer requestURL = request.getRequestURL(); + String queryString = request.getQueryString(); - private void setClinicalInfo(HttpServletRequest request) throws DaoException { - List samples = (List)request.getAttribute(SAMPLE_ID); - boolean isPatientView = request.getAttribute(VIEW_TYPE) == "patient"; - - CancerStudy cancerStudy = (CancerStudy)request.getAttribute(CANCER_STUDY); - int cancerStudyId = cancerStudy.getInternalId(); - List cds = DaoClinicalData.getSampleData(cancerStudyId, samples); - Map> clinicalData = new LinkedHashMap>(); - for (ClinicalData cd : cds) { - String caseId = cd.getStableId(); - String attrId = cd.getAttrId(); - String attrValue = cd.getAttrVal(); - Map attrMap = clinicalData.get(caseId); - if (attrMap==null) { - attrMap = new HashMap(); - clinicalData.put(caseId, attrMap); - } - attrMap.put(attrId, attrValue); - } - request.setAttribute(CLINICAL_DATA, clinicalData); - - // Add attribute name to display name mapping - List cas = DaoClinicalAttributeMeta.getDataByStudy(cancerStudyId); - - String sampleId = samples.get(0); - Map> clinicalAttributes = new LinkedHashMap>(); - for (ClinicalAttribute ca : cas) { - String attrId = ca.getAttrId(); - String displayName = ca.getDisplayName(); - String description = ca.getDescription(); - Map attrMap = new HashMap(); - clinicalAttributes.put(attrId, attrMap); - attrMap.put("displayName", displayName); - attrMap.put("description", description); - } - request.setAttribute(CLINICAL_ATTRIBUTES, clinicalAttributes); - - request.setAttribute("num_tumors", 1); - - // other cases with the same patient id - Patient patient = DaoPatient.getPatientById(DaoSample.getSampleByCancerStudyAndSampleId(cancerStudyId, sampleId).getInternalPatientId()); - String patientId = patient.getStableId(); - - // Add patient info to request - List patientData = DaoClinicalData.getDataByPatientId(cancerStudyId, patientId); - Map patientMap = new HashMap(); - for (ClinicalData cd: patientData) { - patientMap.put(cd.getAttrId(), cd.getAttrVal()); - } - request.setAttribute(PATIENT_INFO, patientMap); - - int numOfSamplesInPatient = DaoSample.getSamplesByPatientId(patient.getInternalId()).size(); - request.setAttribute("num_tumors", numOfSamplesInPatient); - - if (numOfSamplesInPatient>1) { - request.setAttribute(PATIENT_ID_ATTR_NAME, patientId); - } - - request.setAttribute("has_timeline_data", Boolean.FALSE); - if (patientId!=null) { - request.setAttribute("has_timeline_data", DaoClinicalEvent.timeEventsExistForPatient(patient.getInternalId())); - } - - request.setAttribute(PATIENT_ID, patientId); - - // images - String tisImageUrl = getTissueImageIframeUrl(cancerStudy.getCancerStudyStableId(), samples.size()>1?patientId:sampleId); - if (tisImageUrl!=null) { - request.setAttribute(TISSUE_IMAGES, tisImageUrl); - } - - // path report - String typeOfCancer = cancerStudy.getTypeOfCancerId(); - if (patientId!=null && patientId.startsWith("TCGA-")) { - String pathReport = getTCGAPathReport(patientId); - if (pathReport!=null) { - request.setAttribute(PATH_REPORT_URL, pathReport); - } + if (queryString == null) { + return requestURL.toString(); + } else { + return requestURL.append('?').append(queryString).toString(); } } - - private String getTissueImageIframeUrl(String cancerStudyId, String caseId) { - if (!caseId.toUpperCase().startsWith("TCGA-")) { - return null; - } - - // test if images exist for the case - String metaUrl = GlobalProperties.getDigitalSlideArchiveMetaUrl(caseId); - - HttpClient client = ConnectionManager.getHttpClient(5000); - GetMethod method = new GetMethod(metaUrl); - Pattern p = Pattern.compile(""); - try { - int statusCode = client.executeMethod(method); - if (statusCode == HttpStatus.SC_OK) { - BufferedReader bufReader = new BufferedReader( - new InputStreamReader(method.getResponseBodyAsStream())); - for (String line=bufReader.readLine(); line!=null; line=bufReader.readLine()) { - Matcher m = p.matcher(line); - if (m.find()) { - int count = Integer.parseInt(m.group(1)); - return count>0 ? GlobalProperties.getDigitalSlideArchiveIframeUrl(caseId) : null; - } - } - - } else { - // Otherwise, throw HTTP Exception Object - logger.error(statusCode + ": " + HttpStatus.getStatusText(statusCode) - + " Base URL: " + metaUrl); - } - } catch (Exception ex) { - logger.error(ex.getMessage()); - } finally { - // Must release connection back to Apache Commons Connection Pool - method.releaseConnection(); - } - - return null; - } - - // Map>> - private static Map pathologyReports = new HashMap(); - - private synchronized String getTCGAPathReport(String caseId) { - String pathologyReportUrl = pathologyReports.get(caseId); - if (pathologyReportUrl==null) { - - String pathReportUrl = GlobalProperties.getTCGAPathReportUrl(); - - if (pathReportUrl != null) { - //Strip the last item to replace it with the actual pathology report - String baseUrl = pathReportUrl.substring(0, pathReportUrl.lastIndexOf("/") + 1); - try { - URL url = new URL(pathReportUrl); - Scanner s = new Scanner(url.openStream()); - - // skip the first line (header) - s.nextLine(); - for (String line=s.nextLine(); line!=null; line=s.nextLine()) { - String patientId = line.split("\t")[0]; - String filename = line.split("\t")[1]; - pathologyReports.put(patientId, baseUrl + filename); - } - } catch (Exception ex) { - logger.error(ex.getMessage()); - } - } - } - - return pathologyReports.get(caseId); - } - - private void forwardToErrorPage(HttpServletRequest request, HttpServletResponse response, - String userMessage, XDebug xdebug) - throws ServletException, IOException { - request.setAttribute("xdebug_object", xdebug); - request.setAttribute(QueryBuilder.USER_ERROR_MESSAGE, userMessage); - RequestDispatcher dispatcher = - getServletContext().getRequestDispatcher("/WEB-INF/jsp/error.jsp"); - dispatcher.forward(request, response); - } - // /** * Handles the HTTP GET method. diff --git a/core/src/main/java/org/mskcc/cbio/portal/util/GlobalProperties.java b/core/src/main/java/org/mskcc/cbio/portal/util/GlobalProperties.java index c3bde7577cb..664748ab029 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/util/GlobalProperties.java +++ b/core/src/main/java/org/mskcc/cbio/portal/util/GlobalProperties.java @@ -124,7 +124,6 @@ public class GlobalProperties { public static final double[] DEFAULT_GENOMIC_OVERVIEW_CNA_CUTOFF = new double[]{0.2,1.5}; public static final String PATIENT_VIEW_DIGITAL_SLIDE_IFRAME_URL = "digitalslidearchive.iframe.url"; public static final String PATIENT_VIEW_DIGITAL_SLIDE_META_URL = "digitalslidearchive.meta.url"; - public static final String PATIENT_VIEW_TCGA_PATH_REPORT_URL = "tcga_path_report.url"; public static final String PATIENT_VIEW_MDACC_HEATMAP_META_URL = "mdacc.heatmap.meta.url"; public static final String PATIENT_VIEW_MDACC_HEATMAP_URL = "mdacc.heatmap.patient.url"; @@ -639,15 +638,14 @@ public static String getGenomicBuild(){ public static String getLinkToPatientView(String caseId, String cancerStudyId) { - return "case.do?" + QueryBuilder.CANCER_STUDY_ID + "=" + cancerStudyId - //+ "&"+ org.mskcc.cbio.portal.servlet.PatientView.PATIENT_ID + "=" + caseId; - + "&"+ org.mskcc.cbio.portal.servlet.PatientView.SAMPLE_ID + "=" + caseId; + return "case.do#/patient?caseId=" + caseId + + "&studyId=" + cancerStudyId; } public static String getLinkToSampleView(String caseId, String cancerStudyId) { - return "case.do?" + QueryBuilder.CANCER_STUDY_ID + "=" + cancerStudyId - + "&"+ org.mskcc.cbio.portal.servlet.PatientView.SAMPLE_ID + "=" + caseId; + return "case.do#/patient?sampleId=" + caseId + + "&studyId=" + cancerStudyId; } public static String getLinkToCancerStudyView(String cancerStudyId) @@ -705,16 +703,6 @@ public static String getPatientHeatmapViewerUrl(String caseId) return url + caseId; } - public static String getTCGAPathReportUrl() - { - String url = GlobalProperties.getProperty(PATIENT_VIEW_TCGA_PATH_REPORT_URL); - if (url == null) { - return null; - } - - return url; - } - // function for getting the custom tabs for the header public static String[] getCustomHeaderTabs(){ String customPagesString = GlobalProperties.getProperty(SKIN_CUSTOM_HEADER_TABS); diff --git a/core/src/main/java/org/mskcc/cbio/portal/util/MutationDataUtils.java b/core/src/main/java/org/mskcc/cbio/portal/util/MutationDataUtils.java index bab033ec7fc..69666b40624 100644 --- a/core/src/main/java/org/mskcc/cbio/portal/util/MutationDataUtils.java +++ b/core/src/main/java/org/mskcc/cbio/portal/util/MutationDataUtils.java @@ -227,7 +227,7 @@ protected HashMap getMutationDataMap( String typeOfCancer = DaoTypeOfCancer.getTypeOfCancerById(cancerStudy.getTypeOfCancerId()).getName(); String cancerStudyStableId = cancerStudy.getCancerStudyStableId(); Sample sample = DaoSample.getSampleById(mutation.getSampleId()); - String linkToPatientView = GlobalProperties.getLinkToPatientView(sample.getStableId(), cancerStudyStableId); + String linkToPatientView = GlobalProperties.getLinkToSampleView(sample.getStableId(), cancerStudyStableId); List mcgLinks; Boolean isHotspot; if (mutation.getMutationType().equalsIgnoreCase("Fusion")) { diff --git a/db-scripts/pom.xml b/db-scripts/pom.xml index f779455bb52..dfa2a8a32b7 100644 --- a/db-scripts/pom.xml +++ b/db-scripts/pom.xml @@ -5,7 +5,7 @@ master org.mskcc.cbio - 1.5.2 + 1.6.0 4.0.0 diff --git a/db-scripts/src/main/resources/cgds.sql b/db-scripts/src/main/resources/cgds.sql index 2cfa82f9e38..3c893330eca 100644 --- a/db-scripts/src/main/resources/cgds.sql +++ b/db-scripts/src/main/resources/cgds.sql @@ -69,6 +69,7 @@ DROP TABLE IF EXISTS `clinical_attribute_meta`; DROP TABLE IF EXISTS `clinical_sample`; DROP TABLE IF EXISTS `clinical_patient`; DROP TABLE IF EXISTS `mutation_count`; +DROP TABLE IF EXISTS `mutation_count_by_keyword`; DROP TABLE IF EXISTS `mutation`; DROP TABLE IF EXISTS `mutation_event`; DROP TABLE IF EXISTS `structural_variant`; @@ -406,6 +407,18 @@ CREATE TABLE `mutation_count` ( FOREIGN KEY (`SAMPLE_ID`) REFERENCES `sample` (`INTERNAL_ID`) ON DELETE CASCADE ); +-- -------------------------------------------------------- +CREATE TABLE `mutation_count_by_keyword` ( + `GENETIC_PROFILE_ID` int(11) NOT NULL, + `KEYWORD` varchar(50) DEFAULT NULL, + `ENTREZ_GENE_ID` int(11) NOT NULL, + `KEYWORD_COUNT` int NOT NULL, + `GENE_COUNT` int NOT NULL, + KEY (`GENETIC_PROFILE_ID`,`KEYWORD`), + FOREIGN KEY (`GENETIC_PROFILE_ID`) REFERENCES `genetic_profile` (`GENETIC_PROFILE_ID`) ON DELETE CASCADE, + FOREIGN KEY (`ENTREZ_GENE_ID`) REFERENCES `gene` (`ENTREZ_GENE_ID`) ON DELETE CASCADE +); + -- -------------------------------------------------------- CREATE TABLE `clinical_patient` ( `INTERNAL_ID` int(11) NOT NULL, @@ -705,4 +718,4 @@ CREATE TABLE `info` ( `DB_SCHEMA_VERSION` varchar(24) ); -- THIS MUST BE KEPT IN SYNC WITH db.version PROPERTY IN pom.xml -INSERT INTO info VALUES ('2.1.0'); +INSERT INTO info VALUES ('2.2.0'); diff --git a/db-scripts/src/main/resources/migration.sql b/db-scripts/src/main/resources/migration.sql index 55f02de445a..fa1d5fcc4d2 100644 --- a/db-scripts/src/main/resources/migration.sql +++ b/db-scripts/src/main/resources/migration.sql @@ -267,3 +267,29 @@ UPDATE info SET DB_SCHEMA_VERSION="2.0.1"; ALTER TABLE `cancer_study` MODIFY COLUMN `TYPE_OF_CANCER_ID` varchar(63) NOT NULL; ALTER TABLE `sample` MODIFY COLUMN `TYPE_OF_CANCER_ID` varchar(63) NOT NULL; UPDATE info SET DB_SCHEMA_VERSION="2.1.0"; + +##version: 2.2.0 +CREATE TABLE `mutation_count_by_keyword` ( + `GENETIC_PROFILE_ID` int(11) NOT NULL, + `KEYWORD` varchar(50) DEFAULT NULL, + `ENTREZ_GENE_ID` int(11) NOT NULL, + `KEYWORD_COUNT` int NOT NULL, + `GENE_COUNT` int NOT NULL, + KEY (`GENETIC_PROFILE_ID`,`KEYWORD`), + FOREIGN KEY (`GENETIC_PROFILE_ID`) REFERENCES `genetic_profile` (`GENETIC_PROFILE_ID`) ON DELETE CASCADE, + FOREIGN KEY (`ENTREZ_GENE_ID`) REFERENCES `gene` (`ENTREZ_GENE_ID`) ON DELETE CASCADE +); + +INSERT INTO mutation_count_by_keyword + SELECT g2.`GENETIC_PROFILE_ID`, mutation_event.`KEYWORD`, m2.`ENTREZ_GENE_ID`, + IF(mutation_event.`KEYWORD` IS NULL, 0, COUNT(*)) AS KEYWORD_COUNT, + (SELECT COUNT(*) FROM `mutation` AS m1 , `genetic_profile` AS g1 + WHERE m1.`GENETIC_PROFILE_ID` = g1.`GENETIC_PROFILE_ID` + AND g1.`GENETIC_PROFILE_ID`= g2.`GENETIC_PROFILE_ID` AND m1.`ENTREZ_GENE_ID` = m2.`ENTREZ_GENE_ID` + GROUP BY g1.`GENETIC_PROFILE_ID` , m1.`ENTREZ_GENE_ID`) AS GENE_COUNT + FROM `mutation` AS m2 , `genetic_profile` AS g2 , `mutation_event` + WHERE m2.`GENETIC_PROFILE_ID` = g2.`GENETIC_PROFILE_ID` + AND m2.`MUTATION_EVENT_ID` = mutation_event.`MUTATION_EVENT_ID` + AND g2.`GENETIC_ALTERATION_TYPE` = 'MUTATION_EXTENDED' + GROUP BY g2.`GENETIC_PROFILE_ID` , mutation_event.`KEYWORD` , m2.`ENTREZ_GENE_ID`; +UPDATE info SET DB_SCHEMA_VERSION="2.2.0"; \ No newline at end of file diff --git a/docs/Customizing-your-instance-of-cBioPortal.md b/docs/Customizing-your-instance-of-cBioPortal.md index 69f705e31e4..1daf13eb6eb 100644 --- a/docs/Customizing-your-instance-of-cBioPortal.md +++ b/docs/Customizing-your-instance-of-cBioPortal.md @@ -259,6 +259,6 @@ If your documentation contains a relative link, cBioPortal will assume it uses t Please be aware that the links may be case-sensitive! E.g. https://github.com/cBioPortal/cbioportal/wiki/News.md is not the same as https://github.com/cBioPortal/cbioportal/wiki/news.md # Custom styling of the patient view's clinical data -The [Patient View](http://www.cbioportal.org/case.do?cancer_study_id=lgg_ucsf_2014&case_id=P04) shows several [clinical attributes](File-Formats.md#clinical-data) at the top of the page, e.g. `AGE`, `SEX`: +The [Patient View](http://www.cbioportal.org/case.do#/patient?studyId=lgg_ucsf_2014&caseId=P04) shows several [clinical attributes](File-Formats.md#clinical-data) at the top of the page, e.g. `AGE`, `SEX`: ![test](../test/end-to-end/screenshots/firefox/patient_view_lgg_ucsf_2014_case_id_P04.png) The order, styling and visibility of those [attributes](File-Formats.md#clinical-data) at the top can be changed by editing the [patient view's clinical attributes CSS file](../portal/src/main/webapp/css/patient-view/clinical-attributes.css). diff --git a/docs/File-Formats.md b/docs/File-Formats.md index 34604e277a3..8ad7cff9be6 100644 --- a/docs/File-Formats.md +++ b/docs/File-Formats.md @@ -145,7 +145,7 @@ Following the metadata rows comes a tab delimited list of clinical attributes (c The file containing the patient attributes has one **required** column: - **PATIENT_ID (required)**: a unique patient ID. -The following columns are used by the study view as well as the patient view. In the [study view](http://www.cbioportal.org/study?id=brca_tcga) they are used to create the survival plots. In the patient view they are used to add information to the [header](http://www.cbioportal.org/case.do?cancer_study_id=lgg_ucsf_2014&case_id=P05). +The following columns are used by the study view as well as the patient view. In the [study view](http://www.cbioportal.org/study?id=brca_tcga) they are used to create the survival plots. In the patient view they are used to add information to the [header](http://www.cbioportal.org/case.do#/patient?studyId=lgg_ucsf_2014&caseId=P05). - **OS_STATUS**: Overall patient survival status - Possible values: DECEASED, LIVING - In the patient view, LIVING creates a green label, DECEASED a red label. @@ -181,7 +181,7 @@ The file containing the sample attributes has two **required** columns: - **PATIENT_ID (required)**: A patient ID. - **SAMPLE_ID (required)**: A sample ID. -By adding `PATIENT_ID` here, cBioPortal will map the given sample to this patient. This enables one to associate multiple samples to one patient. For example, a single patient may have had multiple biopsies, each of which has been genomically profiled. See [this example for a patient with multiple samples](http://www.cbioportal.org/case.do?cancer_study_id=lgg_ucsf_2014&case_id=P04). +By adding `PATIENT_ID` here, cBioPortal will map the given sample to this patient. This enables one to associate multiple samples to one patient. For example, a single patient may have had multiple biopsies, each of which has been genomically profiled. See [this example for a patient with multiple samples](http://www.cbioportal.org/case.do#/patient?studyId=lgg_ucsf_2014&caseId=P04). The following columns are required if you want the [pan-cancer summary statistics tab in a pan-cancer study](http://www.cbioportal.org/index.do?cancer_study_list=cellline_ccle_broad&cancer_study_id=cellline_ccle_broad&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=cellline_ccle_broad_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=cellline_ccle_broad_CNA&Z_SCORE_THRESHOLD=2.0&data_priority=0&case_set_id=cellline_ccle_broad_cnaseq&case_ids=&patient_case_select=sample&gene_set_choice=prostate-cancer%3A-ar-signaling-%2810-genes%29&gene_list=SOX9+RAN+TNK2+EP300+PXN+NCOA2+AR+NRIP1+NCOR1+NCOR2&clinical_param_selection=null&tab_index=tab_visualize&Action=Submit#pancancer_study_summary): - **CANCER_TYPE**: Cancer Type @@ -325,7 +325,7 @@ The log2 copy number data file follows the same format as expression data files. ## Segmented Data -A SEG file (segmented data; .seg or .cbs) is a tab-delimited text file that lists loci and associated numeric values. The segmented data file format is the output of the Circular Binary Segmentation algorithm (Olshen et al., 2004). **Segment data for import into the cBioPortal should be based on build 37 (hg19)**. This Segment data enables the 'CNA' lane in the Genomic overview of the Patient view (as [can be seen in this example](http://www.cbioportal.org/case.do?sample_id=TCGA-BH-A0E6-01&cancer_study_id=brca_tcga)). +A SEG file (segmented data; .seg or .cbs) is a tab-delimited text file that lists loci and associated numeric values. The segmented data file format is the output of the Circular Binary Segmentation algorithm (Olshen et al., 2004). **Segment data for import into the cBioPortal should be based on build 37 (hg19)**. This Segment data enables the 'CNA' lane in the Genomic overview of the Patient view (as [can be seen in this example](http://www.cbioportal.org/case.do#/patient?sampleId=TCGA-BH-A0E6-01&studyId=brca_tcga)). #### Meta file The segmented metadata file should contain the following fields: diff --git a/docs/News.md b/docs/News.md index 24fd50c3816..4f4663fc96c 100644 --- a/docs/News.md +++ b/docs/News.md @@ -91,7 +91,7 @@ # January 12, 2016 * **New features**: * Visualization of multiple samples in a patient - * Visualization of timeline data of a patient ([example](http://www.cbioportal.org/case.do?cancer_study_id=lgg_ucsf_2014&case_id=P04))
+ * Visualization of timeline data of a patient ([example](http://www.cbioportal.org/case.do#/patient?studyId=lgg_ucsf_2014&caseId=P04))
![timeline-example](https://cloud.githubusercontent.com/assets/840895/12055606/cca26160-aefc-11e5-93f9-2ecfe7e95caf.png) * All **TCGA data** updated to the latest Firehose run of August 21, 2015 * **New TCGA studies**: @@ -321,7 +321,7 @@ * Multi-gene correlation plots. * Variant allele frequency distribution plots for individual tumor samples. -* Tissue images for TCGA samples in the patient view, via [Digital Slide Archive](http://cancer.digitalslidearchive.net/). [Example](http://www.cbioportal.org/case.do?cancer_study_id=ucec_tcga&case_id=TCGA-BK-A0CC#tab_images). +* Tissue images for TCGA samples in the patient view, via [Digital Slide Archive](http://cancer.digitalslidearchive.net/). [Example](http://www.cbioportal.org/case.do#/patient?studyId=ucec_tcga&caseId=TCGA-BK-A0CC&tab=tissueImageTab). # July 16, 2013 diff --git a/model/pom.xml b/model/pom.xml index 5f2c7f80cdd..0b18ddaed79 100644 --- a/model/pom.xml +++ b/model/pom.xml @@ -5,7 +5,7 @@ master org.mskcc.cbio - 1.5.2 + 1.6.0 4.0.0 diff --git a/model/src/main/java/org/cbioportal/model/ClinicalAttribute.java b/model/src/main/java/org/cbioportal/model/ClinicalAttribute.java index ca5622c5e15..e1be7cba0c4 100644 --- a/model/src/main/java/org/cbioportal/model/ClinicalAttribute.java +++ b/model/src/main/java/org/cbioportal/model/ClinicalAttribute.java @@ -11,7 +11,7 @@ public class ClinicalAttribute implements Serializable { private Boolean patientAttribute; private String priority; private Integer cancerStudyId; - private CancerStudy cancerStudy; + private String cancerStudyIdentifier; public String getAttrId() { return attrId; @@ -69,11 +69,11 @@ public void setCancerStudyId(Integer cancerStudyId) { this.cancerStudyId = cancerStudyId; } - public CancerStudy getCancerStudy() { - return cancerStudy; + public String getCancerStudyIdentifier() { + return cancerStudyIdentifier; } - public void setCancerStudy(CancerStudy cancerStudy) { - this.cancerStudy = cancerStudy; + public void setCancerStudyIdentifier(String cancerStudyIdentifier) { + this.cancerStudyIdentifier = cancerStudyIdentifier; } } diff --git a/model/src/main/java/org/cbioportal/model/MutationCount.java b/model/src/main/java/org/cbioportal/model/MutationCount.java new file mode 100644 index 00000000000..f25b74a4bbd --- /dev/null +++ b/model/src/main/java/org/cbioportal/model/MutationCount.java @@ -0,0 +1,34 @@ +package org.cbioportal.model; + +import java.io.Serializable; + +public class MutationCount implements Serializable { + + private String geneticProfileId; + private String sampleId; + private Integer mutationCount; + + public String getGeneticProfileId() { + return geneticProfileId; + } + + public void setGeneticProfileId(String geneticProfileId) { + this.geneticProfileId = geneticProfileId; + } + + public String getSampleId() { + return sampleId; + } + + public void setSampleId(String sampleId) { + this.sampleId = sampleId; + } + + public Integer getMutationCount() { + return mutationCount; + } + + public void setMutationCount(Integer mutationCount) { + this.mutationCount = mutationCount; + } +} diff --git a/persistence/persistence-api/pom.xml b/persistence/persistence-api/pom.xml index 933053da9bc..30716c69e18 100644 --- a/persistence/persistence-api/pom.xml +++ b/persistence/persistence-api/pom.xml @@ -5,7 +5,7 @@ persistence org.mskcc.cbio - 1.5.2 + 1.6.0 4.0.0 diff --git a/persistence/persistence-api/src/main/java/org/cbioportal/persistence/ClinicalAttributeRepository.java b/persistence/persistence-api/src/main/java/org/cbioportal/persistence/ClinicalAttributeRepository.java new file mode 100644 index 00000000000..dc7194c59e0 --- /dev/null +++ b/persistence/persistence-api/src/main/java/org/cbioportal/persistence/ClinicalAttributeRepository.java @@ -0,0 +1,21 @@ +package org.cbioportal.persistence; + +import org.cbioportal.model.ClinicalAttribute; +import org.cbioportal.model.meta.BaseMeta; + +import java.util.List; + +public interface ClinicalAttributeRepository { + + List getAllClinicalAttributes(String projection, Integer pageSize, Integer pageNumber, + String sortBy, String direction); + + BaseMeta getMetaClinicalAttributes(); + + ClinicalAttribute getClinicalAttribute(String studyId, String clinicalAttributeId); + + List getAllClinicalAttributesInStudy(String studyId, String projection, Integer pageSize, + Integer pageNumber, String sortBy, String direction); + + BaseMeta getMetaClinicalAttributesInStudy(String studyId); +} diff --git a/persistence/persistence-api/src/main/java/org/cbioportal/persistence/DiscreteCopyNumberRepository.java b/persistence/persistence-api/src/main/java/org/cbioportal/persistence/DiscreteCopyNumberRepository.java index ebd25215c89..5a36b0b836b 100644 --- a/persistence/persistence-api/src/main/java/org/cbioportal/persistence/DiscreteCopyNumberRepository.java +++ b/persistence/persistence-api/src/main/java/org/cbioportal/persistence/DiscreteCopyNumberRepository.java @@ -8,12 +8,14 @@ public interface DiscreteCopyNumberRepository { - List getDiscreteCopyNumbersInGeneticProfile(String geneticProfileId, String sampleId, - List alterations, String projection); + List getDiscreteCopyNumbersInGeneticProfileBySampleListId(String geneticProfileId, + String sampleListId, + List alterations, + String projection); - BaseMeta getMetaDiscreteCopyNumbersInGeneticProfile(String geneticProfileId, String sampleId, - List alterations); + BaseMeta getMetaDiscreteCopyNumbersInGeneticProfileBySampleListId(String geneticProfileId, String sampleListId, + List alterations); List fetchDiscreteCopyNumbersInGeneticProfile(String geneticProfileId, List sampleIds, diff --git a/persistence/persistence-api/src/main/java/org/cbioportal/persistence/MutationRepository.java b/persistence/persistence-api/src/main/java/org/cbioportal/persistence/MutationRepository.java index 72535d142f0..b92ccda4dc7 100644 --- a/persistence/persistence-api/src/main/java/org/cbioportal/persistence/MutationRepository.java +++ b/persistence/persistence-api/src/main/java/org/cbioportal/persistence/MutationRepository.java @@ -1,6 +1,7 @@ package org.cbioportal.persistence; import org.cbioportal.model.Mutation; +import org.cbioportal.model.MutationCount; import org.cbioportal.model.MutationSampleCountByGene; import org.cbioportal.model.MutationSampleCountByKeyword; import org.cbioportal.model.meta.BaseMeta; @@ -10,19 +11,27 @@ public interface MutationRepository { - List getMutationsInGeneticProfile(String geneticProfileId, String sampleId, String projection, - Integer pageSize, Integer pageNumber, String sortBy, String direction); + List getMutationsInGeneticProfileBySampleListId(String geneticProfileId, String sampleListId, + List entrezGeneIds, String projection, + Integer pageSize, Integer pageNumber, String sortBy, + String direction); - MutationMeta getMetaMutationsInGeneticProfile(String geneticProfileId, String sampleId); + MutationMeta getMetaMutationsInGeneticProfileBySampleListId(String geneticProfileId, String sampleListId, + List entrezGeneIds); - List fetchMutationsInGeneticProfile(String geneticProfileId, List sampleIds, - String projection, Integer pageSize, Integer pageNumber, - String sortBy, String direction); + List fetchMutationsInGeneticProfile(String geneticProfileId, List sampleIds, + List entrezGeneIds, String projection, Integer pageSize, + Integer pageNumber, String sortBy, String direction); - MutationMeta fetchMetaMutationsInGeneticProfile(String geneticProfileId, List sampleIds); + MutationMeta fetchMetaMutationsInGeneticProfile(String geneticProfileId, List sampleIds, + List entrezGeneIds); List getSampleCountByEntrezGeneIds(String geneticProfileId, List entrezGeneIds); List getSampleCountByKeywords(String geneticProfileId, List keywords); + + List getMutationCountsInGeneticProfileBySampleListId(String geneticProfileId, String sampleListId); + + List fetchMutationCountsInGeneticProfile(String geneticProfileId, List sampleIds); } diff --git a/persistence/persistence-mybatis/pom.xml b/persistence/persistence-mybatis/pom.xml index 4bd0944900d..db98c2294d7 100644 --- a/persistence/persistence-mybatis/pom.xml +++ b/persistence/persistence-mybatis/pom.xml @@ -5,7 +5,7 @@ persistence org.mskcc.cbio - 1.5.2 + 1.6.0 4.0.0 diff --git a/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/ClinicalAttributeMapper.java b/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/ClinicalAttributeMapper.java index 050b4de07ba..2892b56c465 100644 --- a/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/ClinicalAttributeMapper.java +++ b/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/ClinicalAttributeMapper.java @@ -1,4 +1,16 @@ package org.cbioportal.persistence.mybatis; +import org.cbioportal.model.ClinicalAttribute; +import org.cbioportal.model.meta.BaseMeta; + +import java.util.List; + public interface ClinicalAttributeMapper { + + List getAllClinicalAttributes(String studyId, String projection, Integer limit, Integer offset, + String sortBy, String direction); + + BaseMeta getMetaClinicalAttributes(String studyId); + + ClinicalAttribute getClinicalAttribute(String studyId, String clinicalAttributeId, String projection); } diff --git a/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/ClinicalAttributeMyBatisRepository.java b/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/ClinicalAttributeMyBatisRepository.java new file mode 100644 index 00000000000..dba66b858d2 --- /dev/null +++ b/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/ClinicalAttributeMyBatisRepository.java @@ -0,0 +1,57 @@ +package org.cbioportal.persistence.mybatis; + +import org.cbioportal.model.ClinicalAttribute; +import org.cbioportal.model.meta.BaseMeta; +import org.cbioportal.persistence.ClinicalAttributeRepository; +import org.cbioportal.persistence.PersistenceConstants; +import org.cbioportal.persistence.mybatis.util.OffsetCalculator; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public class ClinicalAttributeMyBatisRepository implements ClinicalAttributeRepository { + + @Autowired + private ClinicalAttributeMapper clinicalAttributeMapper; + @Autowired + private OffsetCalculator offsetCalculator; + + + @Override + public List getAllClinicalAttributes(String projection, Integer pageSize, Integer pageNumber, + String sortBy, String direction) { + + return clinicalAttributeMapper.getAllClinicalAttributes(null, projection, pageSize, + offsetCalculator.calculate(pageSize, pageNumber), sortBy, direction); + } + + @Override + public BaseMeta getMetaClinicalAttributes() { + + return clinicalAttributeMapper.getMetaClinicalAttributes(null); + } + + @Override + public ClinicalAttribute getClinicalAttribute(String studyId, String clinicalAttributeId) { + + return clinicalAttributeMapper.getClinicalAttribute(studyId, clinicalAttributeId, + PersistenceConstants.DETAILED_PROJECTION); + } + + @Override + public List getAllClinicalAttributesInStudy(String studyId, String projection, Integer pageSize, + Integer pageNumber, String sortBy, + String direction) { + + return clinicalAttributeMapper.getAllClinicalAttributes(studyId, projection, pageSize, + offsetCalculator.calculate(pageSize, pageNumber), sortBy, direction); + } + + @Override + public BaseMeta getMetaClinicalAttributesInStudy(String studyId) { + + return clinicalAttributeMapper.getMetaClinicalAttributes(studyId); + } +} diff --git a/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMapper.java b/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMapper.java index 4ce4da819c6..af0ed7f909b 100644 --- a/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMapper.java +++ b/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMapper.java @@ -7,13 +7,20 @@ import java.util.List; public interface DiscreteCopyNumberMapper { + + List getDiscreteCopyNumbersBySampleListId(String geneticProfileId, String sampleListId, + List entrezGeneIds, + List alterations, String projection); + + BaseMeta getMetaDiscreteCopyNumbersBySampleListId(String geneticProfileId, String sampleListId, + List entrezGeneIds, List alterations); - List getDiscreteCopyNumbers(String geneticProfileId, List sampleIds, - List entrezGeneIds, List alterations, - String projection); + List getDiscreteCopyNumbersBySampleIds(String geneticProfileId, List sampleIds, + List entrezGeneIds, + List alterations, String projection); - BaseMeta getMetaDiscreteCopyNumbers(String geneticProfileId, List sampleIds, List entrezGeneIds, - List alterations); + BaseMeta getMetaDiscreteCopyNumbersBySampleIds(String geneticProfileId, List sampleIds, + List entrezGeneIds, List alterations); List getSampleCountByGeneAndAlteration(String geneticProfileId, List entrezGeneIds, diff --git a/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMyBatisRepository.java b/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMyBatisRepository.java index bfc2670f847..aa534a6f3b6 100644 --- a/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMyBatisRepository.java +++ b/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMyBatisRepository.java @@ -17,20 +17,22 @@ public class DiscreteCopyNumberMyBatisRepository implements DiscreteCopyNumberRe private DiscreteCopyNumberMapper discreteCopyNumberMapper; @Override - public List getDiscreteCopyNumbersInGeneticProfile(String geneticProfileId, String sampleId, - List alterations, - String projection) { + public List getDiscreteCopyNumbersInGeneticProfileBySampleListId(String geneticProfileId, + String sampleListId, + List alterations, + String projection) { - return discreteCopyNumberMapper.getDiscreteCopyNumbers(geneticProfileId, - sampleId == null ? null : Arrays.asList(sampleId), null, alterations, projection); + return discreteCopyNumberMapper.getDiscreteCopyNumbersBySampleListId(geneticProfileId, sampleListId, null, + alterations, projection); } @Override - public BaseMeta getMetaDiscreteCopyNumbersInGeneticProfile(String geneticProfileId, String sampleId, - List alterations) { + public BaseMeta getMetaDiscreteCopyNumbersInGeneticProfileBySampleListId(String geneticProfileId, + String sampleListId, + List alterations) { - return discreteCopyNumberMapper.getMetaDiscreteCopyNumbers(geneticProfileId, - sampleId == null ? null : Arrays.asList(sampleId), null, alterations); + return discreteCopyNumberMapper.getMetaDiscreteCopyNumbersBySampleListId(geneticProfileId, sampleListId, null, + alterations); } @Override @@ -40,8 +42,8 @@ public List fetchDiscreteCopyNumbersInGeneticProfile(Str List alterations, String projection) { - return discreteCopyNumberMapper.getDiscreteCopyNumbers(geneticProfileId, sampleIds, entrezGeneIds, alterations, - projection); + return discreteCopyNumberMapper.getDiscreteCopyNumbersBySampleIds(geneticProfileId, sampleIds, entrezGeneIds, + alterations, projection); } @Override @@ -49,8 +51,8 @@ public BaseMeta fetchMetaDiscreteCopyNumbersInGeneticProfile(String geneticProfi List entrezGeneIds, List alterations) { - return discreteCopyNumberMapper.getMetaDiscreteCopyNumbers(geneticProfileId, sampleIds, entrezGeneIds, - alterations); + return discreteCopyNumberMapper.getMetaDiscreteCopyNumbersBySampleIds(geneticProfileId, sampleIds, + entrezGeneIds, alterations); } @Override diff --git a/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/MutationMapper.java b/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/MutationMapper.java index ae134648b4f..0265aa026ae 100644 --- a/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/MutationMapper.java +++ b/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/MutationMapper.java @@ -1,6 +1,7 @@ package org.cbioportal.persistence.mybatis; import org.cbioportal.model.Mutation; +import org.cbioportal.model.MutationCount; import org.cbioportal.model.MutationSampleCountByGene; import org.cbioportal.model.MutationSampleCountByKeyword; import org.cbioportal.model.meta.BaseMeta; @@ -10,12 +11,25 @@ public interface MutationMapper { - List getMutations(String geneticProfileId, List sampleIds, String projection, Integer limit, - Integer offset, String sortBy, String direction); + List getMutationsBySampleListId(String geneticProfileId, String sampleListId, List entrezGeneIds, + String projection, Integer limit, Integer offset, String sortBy, + String direction); - MutationMeta getMetaMutations(String geneticProfileId, List sampleIds); + MutationMeta getMetaMutationsBySampleListId(String geneticProfileId, String sampleListId, + List entrezGeneIds); + + List getMutationsBySampleIds(String geneticProfileId, List sampleIds, List entrezGeneIds, + String projection, Integer limit, Integer offset, String sortBy, + String direction); + + MutationMeta getMetaMutationsBySampleIds(String geneticProfileId, List sampleIds, + List entrezGeneIds); List getSampleCountByEntrezGeneIds(String geneticProfileId, List entrezGeneIds); List getSampleCountByKeywords(String geneticProfileId, List keywords); + + List getMutationCountsBySampleListId(String geneticProfileId, String sampleListId); + + List getMutationCountsBySampleIds(String geneticProfileId, List sampleIds); } diff --git a/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/MutationMyBatisRepository.java b/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/MutationMyBatisRepository.java index 4691b2063a7..f30c5041b73 100644 --- a/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/MutationMyBatisRepository.java +++ b/persistence/persistence-mybatis/src/main/java/org/cbioportal/persistence/mybatis/MutationMyBatisRepository.java @@ -1,16 +1,15 @@ package org.cbioportal.persistence.mybatis; import org.cbioportal.model.Mutation; +import org.cbioportal.model.MutationCount; import org.cbioportal.model.MutationSampleCountByGene; import org.cbioportal.model.MutationSampleCountByKeyword; -import org.cbioportal.model.meta.BaseMeta; import org.cbioportal.model.meta.MutationMeta; import org.cbioportal.persistence.MutationRepository; import org.cbioportal.persistence.mybatis.util.OffsetCalculator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; -import java.util.Arrays; import java.util.List; @Repository @@ -22,33 +21,37 @@ public class MutationMyBatisRepository implements MutationRepository { private OffsetCalculator offsetCalculator; @Override - public List getMutationsInGeneticProfile(String geneticProfileId, String sampleId, String projection, - Integer pageSize, Integer pageNumber, String sortBy, - String direction) { + public List getMutationsInGeneticProfileBySampleListId(String geneticProfileId, String sampleListId, + List entrezGeneIds, String projection, + Integer pageSize, Integer pageNumber, + String sortBy, String direction) { - return mutationMapper.getMutations(geneticProfileId, sampleId == null ? null : Arrays.asList(sampleId), - projection, pageSize, offsetCalculator.calculate(pageSize, pageNumber), sortBy, direction); + return mutationMapper.getMutationsBySampleListId(geneticProfileId, sampleListId, entrezGeneIds, projection, + pageSize, offsetCalculator.calculate(pageSize, pageNumber), sortBy, direction); } @Override - public MutationMeta getMetaMutationsInGeneticProfile(String geneticProfileId, String sampleId) { + public MutationMeta getMetaMutationsInGeneticProfileBySampleListId(String geneticProfileId, String sampleListId, + List entrezGeneIds) { - return mutationMapper.getMetaMutations(geneticProfileId, sampleId == null ? null : Arrays.asList(sampleId)); + return mutationMapper.getMetaMutationsBySampleListId(geneticProfileId, sampleListId, entrezGeneIds); } @Override - public List fetchMutationsInGeneticProfile(String geneticProfileId, List sampleIds, - String projection, Integer pageSize, Integer pageNumber, - String sortBy, String direction) { + public List fetchMutationsInGeneticProfile(String geneticProfileId, List sampleIds, + List entrezGeneIds, String projection, + Integer pageSize, Integer pageNumber, String sortBy, + String direction) { - return mutationMapper.getMutations(geneticProfileId, sampleIds, projection, pageSize, + return mutationMapper.getMutationsBySampleIds(geneticProfileId, sampleIds, entrezGeneIds, projection, pageSize, offsetCalculator.calculate(pageSize, pageNumber), sortBy, direction); } @Override - public MutationMeta fetchMetaMutationsInGeneticProfile(String geneticProfileId, List sampleIds) { + public MutationMeta fetchMetaMutationsInGeneticProfile(String geneticProfileId, List sampleIds, + List entrezGeneIds) { - return mutationMapper.getMetaMutations(geneticProfileId, sampleIds); + return mutationMapper.getMetaMutationsBySampleIds(geneticProfileId, sampleIds, entrezGeneIds); } @Override @@ -63,4 +66,17 @@ public List getSampleCountByKeywords(String geneti return mutationMapper.getSampleCountByKeywords(geneticProfileId, keywords); } + + @Override + public List getMutationCountsInGeneticProfileBySampleListId(String geneticProfileId, + String sampleListId) { + + return mutationMapper.getMutationCountsBySampleListId(geneticProfileId, sampleListId); + } + + @Override + public List fetchMutationCountsInGeneticProfile(String geneticProfileId, List sampleIds) { + + return mutationMapper.getMutationCountsBySampleIds(geneticProfileId, sampleIds); + } } diff --git a/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalAttributeMapper.xml b/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalAttributeMapper.xml index 5f1c611d3f0..5f5c5a39625 100644 --- a/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalAttributeMapper.xml +++ b/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/ClinicalAttributeMapper.xml @@ -5,7 +5,8 @@ - clinical_attribute_meta.ATTR_ID AS "${prefix}attrId" + clinical_attribute_meta.ATTR_ID AS "${prefix}attrId", + cancer_study.CANCER_STUDY_IDENTIFIER AS "${prefix}cancerStudyIdentifier" , clinical_attribute_meta.DISPLAY_NAME AS "${prefix}displayName", @@ -16,4 +17,47 @@ clinical_attribute_meta.CANCER_STUDY_ID AS "${prefix}cancerStudyId" + + + + + + + \ No newline at end of file diff --git a/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMapper.xml b/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMapper.xml index 5cb7270fb39..f98fb0e4e5f 100644 --- a/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMapper.xml +++ b/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMapper.xml @@ -48,7 +48,48 @@ - + SELECT + + + + INNER JOIN gene ON cna_event.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + + + + + + + - SELECT COUNT(*) AS totalCount diff --git a/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/MutationMapper.xml b/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/MutationMapper.xml index db7a5245fb1..f33508387ae 100644 --- a/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/MutationMapper.xml +++ b/persistence/persistence-mybatis/src/main/resources/org/cbioportal/persistence/mybatis/MutationMapper.xml @@ -61,10 +61,64 @@ #{item} + + AND mutation.ENTREZ_GENE_ID IN + + #{item} + + + + + + + + genetic_profile.STABLE_ID = #{geneticProfileId} + AND mutation.SAMPLE_ID IN + ( + SELECT sample_list_list.SAMPLE_ID FROM sample_list_list + INNER JOIN sample_list ON sample_list_list.LIST_ID = sample_list.LIST_ID + WHERE sample_list.STABLE_ID = #{sampleListId} + ) + + AND mutation.ENTREZ_GENE_ID IN + + #{item} + + - + SELECT + + + + INNER JOIN mutation_event ON mutation.MUTATION_EVENT_ID = mutation_event.MUTATION_EVENT_ID + + + INNER JOIN gene ON mutation.ENTREZ_GENE_ID = gene.ENTREZ_GENE_ID + + + + ORDER BY ${sortBy} ${direction} + + + ORDER BY genetic_profile.STABLE_ID ASC, sample.STABLE_ID ASC, mutation.ENTREZ_GENE_ID ASC + + + LIMIT #{limit} OFFSET #{offset} + + + + + + - SELECT COUNT(*) AS totalCount, COUNT(DISTINCT(mutation.SAMPLE_ID)) AS sampleCount @@ -126,4 +180,38 @@ GROUP BY mutation_event.KEYWORD + + + + \ No newline at end of file diff --git a/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/ClinicalAttributeMyBatisRepositoryTest.java b/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/ClinicalAttributeMyBatisRepositoryTest.java new file mode 100644 index 00000000000..9a95aae2f59 --- /dev/null +++ b/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/ClinicalAttributeMyBatisRepositoryTest.java @@ -0,0 +1,157 @@ +package org.cbioportal.persistence.mybatis; + +import org.cbioportal.model.ClinicalAttribute; +import org.cbioportal.model.meta.BaseMeta; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Configurable; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration("/testContextDatabase.xml") +@Configurable +public class ClinicalAttributeMyBatisRepositoryTest { + + @Autowired + private ClinicalAttributeMyBatisRepository clinicalAttributeMyBatisRepository; + + @Test + public void getAllClinicalAttributesIdProjection() throws Exception { + + List result = clinicalAttributeMyBatisRepository.getAllClinicalAttributes("ID", null, null, + null, null); + + Assert.assertEquals(28, result.size()); + ClinicalAttribute clinicalAttribute = result.get(0); + Assert.assertEquals("DAYS_TO_COLLECTION", clinicalAttribute.getAttrId()); + Assert.assertEquals("study_tcga_pub", clinicalAttribute.getCancerStudyIdentifier()); + } + + @Test + public void getAllClinicalAttributesSummaryProjection() throws Exception { + + List result = clinicalAttributeMyBatisRepository.getAllClinicalAttributes("SUMMARY", null, + null, null, null); + + Assert.assertEquals(28, result.size()); + ClinicalAttribute clinicalAttribute = result.get(0); + Assert.assertEquals("RETROSPECTIVE_COLLECTION", clinicalAttribute.getAttrId()); + Assert.assertEquals("study_tcga_pub", clinicalAttribute.getCancerStudyIdentifier()); + Assert.assertEquals((Integer) 1, clinicalAttribute.getCancerStudyId()); + Assert.assertEquals("STRING", clinicalAttribute.getDatatype()); + Assert.assertEquals("Text indicator for the time frame of tissue procurement,indicating that the tissue was " + + "obtained and stored prior to the initiation of the project.", clinicalAttribute.getDescription()); + Assert.assertEquals("Tissue Retrospective Collection Indicator", clinicalAttribute.getDisplayName()); + Assert.assertEquals("1", clinicalAttribute.getPriority()); + Assert.assertEquals(true, clinicalAttribute.getPatientAttribute()); + } + + @Test + public void getAllClinicalAttributesDetailedProjection() throws Exception { + + List result = clinicalAttributeMyBatisRepository.getAllClinicalAttributes("DETAILED", null, + null, null, null); + + Assert.assertEquals(28, result.size()); + ClinicalAttribute clinicalAttribute = result.get(0); + Assert.assertEquals("RETROSPECTIVE_COLLECTION", clinicalAttribute.getAttrId()); + Assert.assertEquals("study_tcga_pub", clinicalAttribute.getCancerStudyIdentifier()); + Assert.assertEquals((Integer) 1, clinicalAttribute.getCancerStudyId()); + Assert.assertEquals("STRING", clinicalAttribute.getDatatype()); + Assert.assertEquals("Text indicator for the time frame of tissue procurement,indicating that the tissue was " + + "obtained and stored prior to the initiation of the project.", clinicalAttribute.getDescription()); + Assert.assertEquals("Tissue Retrospective Collection Indicator", clinicalAttribute.getDisplayName()); + Assert.assertEquals("1", clinicalAttribute.getPriority()); + Assert.assertEquals(true, clinicalAttribute.getPatientAttribute()); + } + + @Test + public void getAllClinicalAttributesSummaryProjection1PageSize() throws Exception { + + List result = clinicalAttributeMyBatisRepository.getAllClinicalAttributes("SUMMARY", 1, 0, + null, null); + + Assert.assertEquals(1, result.size()); + } + + @Test + public void getAllClinicalAttributesSummaryProjectionDisplayNameSort() throws Exception { + + List result = clinicalAttributeMyBatisRepository.getAllClinicalAttributes("SUMMARY", null, + null, "displayName", "ASC"); + + Assert.assertEquals(28, result.size()); + Assert.assertEquals("Days to Sample Collection.", result.get(0).getDisplayName()); + Assert.assertEquals("Days to Sample Collection.", result.get(1).getDisplayName()); + Assert.assertEquals("Disease Free (Months)", result.get(2).getDisplayName()); + Assert.assertEquals("Disease Free (Months)", result.get(3).getDisplayName()); + Assert.assertEquals("Disease Free Status", result.get(4).getDisplayName()); + Assert.assertEquals("Disease Free Status", result.get(5).getDisplayName()); + } + + @Test + public void getMetaClinicalAttributes() throws Exception { + + BaseMeta result = clinicalAttributeMyBatisRepository.getMetaClinicalAttributes(); + + Assert.assertEquals((Integer) 28, result.getTotalCount()); + } + + @Test + public void getClinicalAttributeNullResult() throws Exception { + + ClinicalAttribute result = clinicalAttributeMyBatisRepository.getClinicalAttribute("study_tcga_pub", + "invalid_clinical_attribute"); + + Assert.assertNull(result); + } + + @Test + public void getClinicalAttribute() throws Exception { + + ClinicalAttribute result = clinicalAttributeMyBatisRepository.getClinicalAttribute("study_tcga_pub", + "RETROSPECTIVE_COLLECTION"); + + Assert.assertEquals("RETROSPECTIVE_COLLECTION", result.getAttrId()); + Assert.assertEquals("study_tcga_pub", result.getCancerStudyIdentifier()); + Assert.assertEquals((Integer) 1, result.getCancerStudyId()); + Assert.assertEquals("STRING", result.getDatatype()); + Assert.assertEquals("Text indicator for the time frame of tissue procurement,indicating that the tissue was " + + "obtained and stored prior to the initiation of the project.", result.getDescription()); + Assert.assertEquals("Tissue Retrospective Collection Indicator", result.getDisplayName()); + Assert.assertEquals("1", result.getPriority()); + Assert.assertEquals(true, result.getPatientAttribute()); + } + + @Test + public void getAllClinicalAttributesInStudySummaryProjection() throws Exception { + + List result = clinicalAttributeMyBatisRepository.getAllClinicalAttributesInStudy( + "study_tcga_pub", "SUMMARY", null, null, null, null); + + Assert.assertEquals(14, result.size()); + ClinicalAttribute clinicalAttribute = result.get(0); + Assert.assertEquals("RETROSPECTIVE_COLLECTION", clinicalAttribute.getAttrId()); + Assert.assertEquals("study_tcga_pub", clinicalAttribute.getCancerStudyIdentifier()); + Assert.assertEquals((Integer) 1, clinicalAttribute.getCancerStudyId()); + Assert.assertEquals("STRING", clinicalAttribute.getDatatype()); + Assert.assertEquals("Text indicator for the time frame of tissue procurement,indicating that the tissue was " + + "obtained and stored prior to the initiation of the project.", clinicalAttribute.getDescription()); + Assert.assertEquals("Tissue Retrospective Collection Indicator", clinicalAttribute.getDisplayName()); + Assert.assertEquals("1", clinicalAttribute.getPriority()); + Assert.assertEquals(true, clinicalAttribute.getPatientAttribute()); + } + + @Test + public void getMetaClinicalAttributesInStudy() throws Exception { + + BaseMeta result = clinicalAttributeMyBatisRepository.getMetaClinicalAttributesInStudy("study_tcga_pub"); + + Assert.assertEquals((Integer) 14, result.getTotalCount()); + } +} \ No newline at end of file diff --git a/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMyBatisRepositoryTest.java b/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMyBatisRepositoryTest.java index f0bd4ae08b2..27b281563bf 100644 --- a/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMyBatisRepositoryTest.java +++ b/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/DiscreteCopyNumberMyBatisRepositoryTest.java @@ -25,16 +25,17 @@ public class DiscreteCopyNumberMyBatisRepositoryTest { private DiscreteCopyNumberMyBatisRepository discreteCopyNumberMyBatisRepository; @Test - public void getDiscreteCopyNumbersInGeneticProfileSummaryProjection() throws Exception { + public void getDiscreteCopyNumbersInGeneticProfileBySampleListIdSummaryProjection() throws Exception { List alterations = new ArrayList<>(); alterations.add(-2); alterations.add(2); List result = discreteCopyNumberMyBatisRepository - .getDiscreteCopyNumbersInGeneticProfile("study_tcga_pub_gistic", "TCGA-A1-A0SB-01", alterations, "SUMMARY"); + .getDiscreteCopyNumbersInGeneticProfileBySampleListId("study_tcga_pub_gistic", "study_tcga_pub_all", + alterations, "SUMMARY"); - Assert.assertEquals(2, result.size()); + Assert.assertEquals(3, result.size()); DiscreteCopyNumberData discreteCopyNumberData = result.get(0); Assert.assertEquals("study_tcga_pub_gistic", discreteCopyNumberData.getGeneticProfileId()); Assert.assertEquals("TCGA-A1-A0SB-01", discreteCopyNumberData.getSampleId()); @@ -44,17 +45,17 @@ public void getDiscreteCopyNumbersInGeneticProfileSummaryProjection() throws Exc } @Test - public void getDiscreteCopyNumbersInGeneticProfileDetailedProjection() throws Exception { + public void getDiscreteCopyNumbersInGeneticProfileBySampleListIdDetailedProjection() throws Exception { List alterations = new ArrayList<>(); alterations.add(-2); alterations.add(2); List result = discreteCopyNumberMyBatisRepository - .getDiscreteCopyNumbersInGeneticProfile("study_tcga_pub_gistic", "TCGA-A1-A0SB-01", alterations, - "DETAILED"); + .getDiscreteCopyNumbersInGeneticProfileBySampleListId("study_tcga_pub_gistic", "study_tcga_pub_all", + alterations, "DETAILED"); - Assert.assertEquals(2, result.size()); + Assert.assertEquals(3, result.size()); DiscreteCopyNumberData discreteCopyNumberData = result.get(0); Assert.assertEquals("study_tcga_pub_gistic", discreteCopyNumberData.getGeneticProfileId()); Assert.assertEquals("TCGA-A1-A0SB-01", discreteCopyNumberData.getSampleId()); @@ -69,16 +70,16 @@ public void getDiscreteCopyNumbersInGeneticProfileDetailedProjection() throws Ex } @Test - public void getMetaDiscreteCopyNumbersInGeneticProfile() throws Exception { + public void getMetaDiscreteCopyNumbersInGeneticProfileBySampleListId() throws Exception { List alterations = new ArrayList<>(); alterations.add(-2); alterations.add(2); - BaseMeta result = discreteCopyNumberMyBatisRepository.getMetaDiscreteCopyNumbersInGeneticProfile( - "study_tcga_pub_gistic", "TCGA-A1-A0SB-01", alterations); + BaseMeta result = discreteCopyNumberMyBatisRepository.getMetaDiscreteCopyNumbersInGeneticProfileBySampleListId( + "study_tcga_pub_gistic", "study_tcga_pub_all", alterations); - Assert.assertEquals((Integer) 2, result.getTotalCount()); + Assert.assertEquals((Integer) 3, result.getTotalCount()); } @Test diff --git a/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/MutationMyBatisRepositoryTest.java b/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/MutationMyBatisRepositoryTest.java index d15fa50bae6..44dd006afd3 100644 --- a/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/MutationMyBatisRepositoryTest.java +++ b/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/MutationMyBatisRepositoryTest.java @@ -1,9 +1,6 @@ package org.cbioportal.persistence.mybatis; -import org.cbioportal.model.Gene; -import org.cbioportal.model.Mutation; -import org.cbioportal.model.MutationSampleCountByGene; -import org.cbioportal.model.MutationSampleCountByKeyword; +import org.cbioportal.model.*; import org.cbioportal.model.meta.MutationMeta; import org.junit.Assert; import org.junit.Test; @@ -26,29 +23,29 @@ public class MutationMyBatisRepositoryTest { private MutationMyBatisRepository mutationMyBatisRepository; @Test - public void getMutationsInGeneticProfileIdProjection() throws Exception { + public void getMutationsInGeneticProfileBySampleListIdIdProjection() throws Exception { - List result = mutationMyBatisRepository.getMutationsInGeneticProfile("study_tcga_pub_mutations", - "TCGA-A1-A0SH-01", "ID", null, null, null, null); + List result = mutationMyBatisRepository.getMutationsInGeneticProfileBySampleListId( + "study_tcga_pub_mutations", "study_tcga_pub_all", null, "ID", null, null, null, null); - Assert.assertEquals(2, result.size()); + Assert.assertEquals(8, result.size()); Mutation mutation = result.get(0); Assert.assertEquals("study_tcga_pub_mutations", mutation.getGeneticProfileStableId()); - Assert.assertEquals("TCGA-A1-A0SH-01", mutation.getSampleStableId()); - Assert.assertEquals((Integer) 672, mutation.getEntrezGeneId()); + Assert.assertEquals("TCGA-A1-A0SB-01", mutation.getSampleStableId()); + Assert.assertEquals((Integer) 207, mutation.getEntrezGeneId()); } @Test - public void getMutationsInGeneticProfileSummaryProjection() throws Exception { + public void getMutationsInGeneticProfileBySampleListIdSummaryProjection() throws Exception { - List result = mutationMyBatisRepository.getMutationsInGeneticProfile("study_tcga_pub_mutations", - "TCGA-A1-A0SH-01", "SUMMARY", null, null, null, null); + List result = mutationMyBatisRepository.getMutationsInGeneticProfileBySampleListId( + "study_tcga_pub_mutations", "study_tcga_pub_all", null, "SUMMARY", null, null, null, null); - Assert.assertEquals(2, result.size()); + Assert.assertEquals(8, result.size()); Mutation mutation = result.get(0); Assert.assertEquals("study_tcga_pub_mutations", mutation.getGeneticProfileStableId()); - Assert.assertEquals("TCGA-A1-A0SH-01", mutation.getSampleStableId()); - Assert.assertEquals((Integer) 672, mutation.getEntrezGeneId()); + Assert.assertEquals("TCGA-A1-A0SB-01", mutation.getSampleStableId()); + Assert.assertEquals((Integer) 207, mutation.getEntrezGeneId()); Assert.assertEquals("cyclases/Protein", mutation.getAminoAcidChange()); Assert.assertEquals("genome.wustl.edu", mutation.getCenter()); Assert.assertEquals((Long) 41244748L, mutation.getEndPosition()); @@ -64,24 +61,61 @@ public void getMutationsInGeneticProfileSummaryProjection() throws Exception { Assert.assertEquals("Q934*", mutation.getProteinChange()); Assert.assertEquals("G", mutation.getReferenceAllele()); Assert.assertEquals((Long) 41244748L, mutation.getStartPosition()); - Assert.assertEquals((Integer) 1, mutation.getTumorAltCount()); - Assert.assertEquals((Integer) 0, mutation.getTumorRefCount()); + Assert.assertEquals((Integer) (-1), mutation.getTumorAltCount()); + Assert.assertEquals((Integer) (-1), mutation.getTumorRefCount()); Assert.assertEquals("A", mutation.getTumorSeqAllele()); Assert.assertEquals("Unknown", mutation.getValidationStatus()); Assert.assertEquals("SNP", mutation.getVariantType()); } @Test - public void getMutationsInGeneticProfileDetailedProjection() throws Exception { + public void getMutationsInGeneticProfileBySampleListIdAndEntrezGeneIdsSummaryProjection() throws Exception { - List result = mutationMyBatisRepository.getMutationsInGeneticProfile("study_tcga_pub_mutations", - "TCGA-A1-A0SH-01", "DETAILED", null, null, null, null); + List entrezGeneIds = new ArrayList<>(); + entrezGeneIds.add(207); + entrezGeneIds.add(208); + + List result = mutationMyBatisRepository.getMutationsInGeneticProfileBySampleListId( + "study_tcga_pub_mutations", "study_tcga_pub_all", entrezGeneIds, "SUMMARY", null, null, null, null); - Assert.assertEquals(2, result.size()); + Assert.assertEquals(3, result.size()); Mutation mutation = result.get(0); Assert.assertEquals("study_tcga_pub_mutations", mutation.getGeneticProfileStableId()); - Assert.assertEquals("TCGA-A1-A0SH-01", mutation.getSampleStableId()); - Assert.assertEquals((Integer) 672, mutation.getEntrezGeneId()); + Assert.assertEquals("TCGA-A1-A0SB-01", mutation.getSampleStableId()); + Assert.assertEquals((Integer) 207, mutation.getEntrezGeneId()); + Assert.assertEquals("cyclases/Protein", mutation.getAminoAcidChange()); + Assert.assertEquals("genome.wustl.edu", mutation.getCenter()); + Assert.assertEquals((Long) 41244748L, mutation.getEndPosition()); + Assert.assertEquals("BRCA1 truncating", mutation.getKeyword()); + Assert.assertEquals("Germline", mutation.getMutationStatus()); + Assert.assertEquals("Nonsense_Mutation", mutation.getMutationType()); + Assert.assertEquals("37", mutation.getNcbiBuild()); + Assert.assertEquals((Integer) (-1), mutation.getNormalAltCount()); + Assert.assertEquals((Integer) (-1), mutation.getNormalRefCount()); + Assert.assertEquals((Integer) 934, mutation.getOncotatorProteinPosEnd()); + Assert.assertEquals((Integer) 934, mutation.getOncotatorProteinPosStart()); + Assert.assertEquals("NM_007294", mutation.getOncotatorRefseqMrnaId()); + Assert.assertEquals("Q934*", mutation.getProteinChange()); + Assert.assertEquals("G", mutation.getReferenceAllele()); + Assert.assertEquals((Long) 41244748L, mutation.getStartPosition()); + Assert.assertEquals((Integer) (-1), mutation.getTumorAltCount()); + Assert.assertEquals((Integer) (-1), mutation.getTumorRefCount()); + Assert.assertEquals("A", mutation.getTumorSeqAllele()); + Assert.assertEquals("Unknown", mutation.getValidationStatus()); + Assert.assertEquals("SNP", mutation.getVariantType()); + } + + @Test + public void getMutationsInGeneticProfileBySampleListIdDetailedProjection() throws Exception { + + List result = mutationMyBatisRepository.getMutationsInGeneticProfileBySampleListId( + "study_tcga_pub_mutations", "study_tcga_pub_all", null, "DETAILED", null, null, null, null); + + Assert.assertEquals(8, result.size()); + Mutation mutation = result.get(0); + Assert.assertEquals("study_tcga_pub_mutations", mutation.getGeneticProfileStableId()); + Assert.assertEquals("TCGA-A1-A0SB-01", mutation.getSampleStableId()); + Assert.assertEquals((Integer) 207, mutation.getEntrezGeneId()); Assert.assertEquals("cyclases/Protein", mutation.getAminoAcidChange()); Assert.assertEquals("genome.wustl.edu", mutation.getCenter()); Assert.assertEquals((Long) 41244748L, mutation.getEndPosition()); @@ -102,47 +136,63 @@ public void getMutationsInGeneticProfileDetailedProjection() throws Exception { Assert.assertEquals("Q934*", mutation.getProteinChange()); Assert.assertEquals("G", mutation.getReferenceAllele()); Assert.assertEquals((Long) 41244748L, mutation.getStartPosition()); - Assert.assertEquals((Integer) 1, mutation.getTumorAltCount()); - Assert.assertEquals((Integer) 0, mutation.getTumorRefCount()); + Assert.assertEquals((Integer) (-1), mutation.getTumorAltCount()); + Assert.assertEquals((Integer) (-1), mutation.getTumorRefCount()); Assert.assertEquals("A", mutation.getTumorSeqAllele()); Assert.assertEquals("Unknown", mutation.getValidationStatus()); Assert.assertEquals("SNP", mutation.getVariantType()); Gene gene = mutation.getGene(); - Assert.assertEquals((Integer) 672, gene.getEntrezGeneId()); - Assert.assertEquals("BRCA1", gene.getHugoGeneSymbol()); + Assert.assertEquals((Integer) 207, gene.getEntrezGeneId()); + Assert.assertEquals("AKT1", gene.getHugoGeneSymbol()); Assert.assertEquals("protein-coding", gene.getType()); - Assert.assertEquals("17q21", gene.getCytoband()); - Assert.assertEquals((Integer) 8426, gene.getLength()); + Assert.assertEquals("14q32.32", gene.getCytoband()); + Assert.assertEquals((Integer) 10838, gene.getLength()); } @Test - public void getMutationsInGeneticProfileSummaryProjection1PageSize() throws Exception { + public void getMutationsInGeneticProfileBySampleListIdSummaryProjection1PageSize() throws Exception { - List result = mutationMyBatisRepository.getMutationsInGeneticProfile("study_tcga_pub_mutations", - "TCGA-A1-A0SH-01", "SUMMARY", 1, 0, null, null); + List result = mutationMyBatisRepository.getMutationsInGeneticProfileBySampleListId( + "study_tcga_pub_mutations", "study_tcga_pub_all", null, "SUMMARY", 1, 0, null, null); Assert.assertEquals(1, result.size()); } @Test - public void getMutationsInGeneticProfileSummaryProjectionProteinChangeSort() throws Exception { + public void getMutationsInGeneticProfileBySampleListIdSummaryProjectionProteinChangeSort() throws Exception { - List result = mutationMyBatisRepository.getMutationsInGeneticProfile("study_tcga_pub_mutations", - "TCGA-A1-A0SH-01", "SUMMARY", null, null, "proteinChange", "ASC"); + List result = mutationMyBatisRepository.getMutationsInGeneticProfileBySampleListId( + "study_tcga_pub_mutations", "study_tcga_pub_all", null, "SUMMARY", null, null, "proteinChange", "ASC"); - Assert.assertEquals(2, result.size()); - Assert.assertEquals("C61G", result.get(0).getProteinChange()); - Assert.assertEquals("Q934*", result.get(1).getProteinChange()); + Assert.assertEquals(8, result.size()); + Assert.assertEquals("C27_splice", result.get(0).getProteinChange()); + Assert.assertEquals("C27_splice", result.get(1).getProteinChange()); + Assert.assertEquals("C27_splice", result.get(2).getProteinChange()); + Assert.assertEquals("C61G", result.get(3).getProteinChange()); + } + + @Test + public void getMetaMutationsInGeneticProfileBySampleListId() throws Exception { + + MutationMeta result = mutationMyBatisRepository.getMetaMutationsInGeneticProfileBySampleListId( + "study_tcga_pub_mutations", "study_tcga_pub_all", null); + + Assert.assertEquals((Integer) 8, result.getTotalCount()); + Assert.assertEquals((Integer) 7, result.getSampleCount()); } @Test - public void getMetaMutationsInGeneticProfile() throws Exception { + public void getMetaMutationsInGeneticProfileBySampleListIdAndEntrezGeneIds() throws Exception { - MutationMeta result = mutationMyBatisRepository.getMetaMutationsInGeneticProfile("study_tcga_pub_mutations", - "TCGA-A1-A0SH-01"); + List entrezGeneIds = new ArrayList<>(); + entrezGeneIds.add(207); + entrezGeneIds.add(208); + + MutationMeta result = mutationMyBatisRepository.getMetaMutationsInGeneticProfileBySampleListId( + "study_tcga_pub_mutations", "study_tcga_pub_all", entrezGeneIds); - Assert.assertEquals((Integer) 2, result.getTotalCount()); - Assert.assertEquals((Integer) 1, result.getSampleCount()); + Assert.assertEquals((Integer) 3, result.getTotalCount()); + Assert.assertEquals((Integer) 3, result.getSampleCount()); } @Test @@ -153,7 +203,7 @@ public void fetchMutationsInGeneticProfile() throws Exception { sampleIds.add("TCGA-A1-A0SO-01"); List result = mutationMyBatisRepository.fetchMutationsInGeneticProfile("study_tcga_pub_mutations", - sampleIds, "SUMMARY", null, null, null, null); + sampleIds, null, "SUMMARY", null, null, null, null); Assert.assertEquals(3, result.size()); Assert.assertEquals("study_tcga_pub_mutations", result.get(0).getGeneticProfileStableId()); @@ -172,7 +222,7 @@ public void fetchMetaMutationsInGeneticProfile() throws Exception { sampleIds.add("TCGA-A1-A0SO-01"); MutationMeta result = mutationMyBatisRepository.fetchMetaMutationsInGeneticProfile("study_tcga_pub_mutations", - sampleIds); + sampleIds, null); Assert.assertEquals((Integer) 3, result.getTotalCount()); Assert.assertEquals((Integer) 2, result.getSampleCount()); @@ -203,4 +253,34 @@ public void getSampleCountByKeywords() throws Exception { Assert.assertEquals(1, result.size()); Assert.assertEquals((Integer) 2, result.get(0).getSampleCount()); } + + @Test + public void getMutationCountsInGeneticProfileBySampleListId() throws Exception { + + List result = mutationMyBatisRepository.getMutationCountsInGeneticProfileBySampleListId( + "study_tcga_pub_mutations", "study_tcga_pub_all"); + + Assert.assertEquals(7, result.size()); + MutationCount mutationCount = result.get(0); + Assert.assertEquals("study_tcga_pub_mutations", mutationCount.getGeneticProfileId()); + Assert.assertEquals("TCGA-A1-A0SB-01", mutationCount.getSampleId()); + Assert.assertEquals((Integer) 1, mutationCount.getMutationCount()); + } + + @Test + public void fetchMutationCountsInGeneticProfile() throws Exception { + + List sampleIds = new ArrayList<>(); + sampleIds.add("TCGA-A1-A0SH-01"); + sampleIds.add("TCGA-A1-A0SO-01"); + + List result = mutationMyBatisRepository.fetchMutationCountsInGeneticProfile( + "study_tcga_pub_mutations", sampleIds); + + Assert.assertEquals(2, result.size()); + MutationCount mutationCount = result.get(0); + Assert.assertEquals("study_tcga_pub_mutations", mutationCount.getGeneticProfileId()); + Assert.assertEquals("TCGA-A1-A0SH-01", mutationCount.getSampleId()); + Assert.assertEquals((Integer) 2, mutationCount.getMutationCount()); + } } \ No newline at end of file diff --git a/persistence/persistence-mybatis-test/src/test/java/org/cbioportal/persistence/mybatis/MutationalSignatureMyBatisRepositoryTest.java b/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/MutationalSignatureMyBatisRepositoryTest.java similarity index 91% rename from persistence/persistence-mybatis-test/src/test/java/org/cbioportal/persistence/mybatis/MutationalSignatureMyBatisRepositoryTest.java rename to persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/MutationalSignatureMyBatisRepositoryTest.java index 342363af29d..34cff958466 100644 --- a/persistence/persistence-mybatis-test/src/test/java/org/cbioportal/persistence/mybatis/MutationalSignatureMyBatisRepositoryTest.java +++ b/persistence/persistence-mybatis/src/test/java/org/cbioportal/persistence/mybatis/MutationalSignatureMyBatisRepositoryTest.java @@ -1,16 +1,10 @@ package org.cbioportal.persistence.mybatis; -import java.util.ArrayList; import java.util.LinkedList; import java.util.List; -import org.cbioportal.model.Mutation; -import org.cbioportal.model.MutationCount; import org.cbioportal.model.SNPCount; -import org.cbioportal.persistence.dto.AltCount; -import org.cbioportal.persistence.dto.KeywordSampleCount; -import org.cbioportal.persistence.dto.MutatedGeneSampleCount; -import org.cbioportal.persistence.dto.SignificantlyMutatedGene; + import org.junit.Test; import org.junit.Assert; import org.junit.runner.RunWith; @@ -57,7 +51,7 @@ public void getSNPCountsForSpecificSamplesAllPresent() { Assert.assertTrue(snpCounts.get(0).getSampleId().equals("TCGA-A1-A0SI-01")); Assert.assertTrue(snpCounts.get(0).getReferenceAllele().equals("G")); Assert.assertTrue(snpCounts.get(0).getTumorAllele().equals("A")); - Assert.assertTrue(snpCounts.get(0).getCount() == 2); + Assert.assertTrue(snpCounts.get(0).getCount() == 1); List sampleIds4 = new LinkedList<>(); sampleIds4.add("TCGA-A1-A0SP-01"); diff --git a/persistence/pom.xml b/persistence/pom.xml index c7a9412061a..7dbc00ead7c 100644 --- a/persistence/pom.xml +++ b/persistence/pom.xml @@ -5,7 +5,7 @@ master org.mskcc.cbio - 1.5.2 + 1.6.0 4.0.0 diff --git a/pom.xml b/pom.xml index a6af11e4e99..9252dc2d0ca 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ master pom Portal Master - 1.5.2 + 1.6.0 master maven module @@ -179,7 +179,7 @@ provided - 2.1.0 + 2.2.0 diff --git a/portal/pom.xml b/portal/pom.xml index 8d774a2848c..e9e17e240e4 100644 --- a/portal/pom.xml +++ b/portal/pom.xml @@ -4,7 +4,7 @@ master org.mskcc.cbio - 1.5.2 + 1.6.0 4.0.0 cbioportal @@ -119,7 +119,7 @@ com.github.cbioportal cbioportal-frontend - v0.4.6 + cbff44ea7dd11a48d970bd26f21f0303c280864e jar . *index* diff --git a/portal/src/main/resources/content/examples.markdown b/portal/src/main/resources/content/examples.markdown index e36ee0ee57a..82ab231ebe4 100644 --- a/portal/src/main/resources/content/examples.markdown +++ b/portal/src/main/resources/content/examples.markdown @@ -11,5 +11,5 @@

BRAF V600E mutations across cancer types

-Patient view of an endometrial cancer case -

\ No newline at end of file +Patient view of an endometrial cancer case +

diff --git a/portal/src/main/resources/content/examples_prostate.markdown b/portal/src/main/resources/content/examples_prostate.markdown index 996e45604c9..8980d451f0e 100644 --- a/portal/src/main/resources/content/examples_prostate.markdown +++ b/portal/src/main/resources/content/examples_prostate.markdown @@ -3,5 +3,5 @@

SPOP mutations in primary prostate cancer

-A TCGA Prostate Adenocarcinoma Case -

\ No newline at end of file +A TCGA Prostate Adenocarcinoma Case +

diff --git a/portal/src/main/resources/content/examples_tcga.markdown b/portal/src/main/resources/content/examples_tcga.markdown index 354886ef121..99fea8bb8a2 100644 --- a/portal/src/main/resources/content/examples_tcga.markdown +++ b/portal/src/main/resources/content/examples_tcga.markdown @@ -13,7 +13,7 @@

BRAF V600E mutations across cancer types

-Patient view of an endometrial cancer case +Patient view of an endometrial cancer case

diff --git a/portal/src/main/resources/content/news.markdown b/portal/src/main/resources/content/news.markdown index 53db3653742..5cf2b397ea3 100644 --- a/portal/src/main/resources/content/news.markdown +++ b/portal/src/main/resources/content/news.markdown @@ -172,7 +172,7 @@ * Multi-gene correlation plots. * Variant allele frequency distribution plots for individual tumor samples. -* Tissue images for TCGA samples in the patient view, via [Digital Slide Archive](http://cancer.digitalslidearchive.net/). [Example](case.do?cancer_study_id=ucec_tcga&case_id=TCGA-BK-A0CC#images). +* Tissue images for TCGA samples in the patient view, via [Digital Slide Archive](http://cancer.digitalslidearchive.net/). [Example](case.do#/patient?studyId=ucec_tcga&caseId=TCGA-BK-A0CC&tab=tissueImageTab). # July 16, 2013 @@ -344,4 +344,4 @@ only view amplifications of EGFR, and ignore deletions. * Official release of our [Web Interface](web_api.jsp), enabling programmatic access to all data. * Official release of our [R Package](cgds_r.jsp), enabling programmatic access to all data from the R platform for statistical computing. -
![OncoPrints](images/previews/gbm_oncoprint.png)
\ No newline at end of file +
![OncoPrints](images/previews/gbm_oncoprint.png)
diff --git a/portal/src/main/resources/content/news_prostate.markdown b/portal/src/main/resources/content/news_prostate.markdown index 5aa176e1714..17f1fc4909a 100644 --- a/portal/src/main/resources/content/news_prostate.markdown +++ b/portal/src/main/resources/content/news_prostate.markdown @@ -42,8 +42,8 @@ * Multi-gene correlation plots. * Variant allele frequency distribution plots for individual tumor samples. -* Tissue images for TCGA samples in the patient view, via [Digital Slide Archive](http://cancer.digitalslidearchive.net/). [Example](case.do?cancer_study_id=prad_tcga&case_id=TCGA-CH-5788#images). -* Support for multiple tumor samples for a single patient. [Example](case.do?cancer_study_id=prad_mich&case_id=WA43). +* Tissue images for TCGA samples in the patient view, via [Digital Slide Archive](http://cancer.digitalslidearchive.net/). [Example](case.do#/patient?studyId=prad_tcga&caseId=TCGA-CH-5788&tab=tissueImageTab). +* Support for multiple tumor samples for a single patient. [Example](case.do#/patient?studyId=prad_mich&caseId=WA43). # July 16, 2013 @@ -70,4 +70,4 @@ - Barbieri et al. (Broad/Cornell) - 112 primary tumors - Grasso et al. (Michigan) - 61 metastatic and 11 primary tumors - Taylor et al. (MSKCC) - 181 primary and 37 metastatic tumors - - SU2C prostate study - 1 case. \ No newline at end of file + - SU2C prostate study - 1 case. diff --git a/portal/src/main/resources/content/news_tcga.markdown b/portal/src/main/resources/content/news_tcga.markdown index 3af85432a59..90e736a5377 100644 --- a/portal/src/main/resources/content/news_tcga.markdown +++ b/portal/src/main/resources/content/news_tcga.markdown @@ -82,7 +82,7 @@ * Multi-gene correlation plots. * Variant allele frequency distribution plots for individual tumor samples. -* Tissue images for TCGA samples in the patient view, via [Digital Slide Archive](http://cancer.digitalslidearchive.net/). [Example](case.do?cancer_study_id=ucec_tcga&case_id=TCGA-BK-A0CC#images). +* Tissue images for TCGA samples in the patient view, via [Digital Slide Archive](http://cancer.digitalslidearchive.net/). [Example](case.do#/patient?studyId=ucec_tcga&caseId=TCGA-BK-A0CC&tab=tissueImageTab). # July 16, 2013 diff --git a/portal/src/main/webapp/WEB-INF/jsp/global/css_include.jsp b/portal/src/main/webapp/WEB-INF/jsp/global/css_include.jsp index 24ed12a32ef..27da28d4afe 100644 --- a/portal/src/main/webapp/WEB-INF/jsp/global/css_include.jsp +++ b/portal/src/main/webapp/WEB-INF/jsp/global/css_include.jsp @@ -52,7 +52,7 @@ - + <% String authenticationMethod = GlobalProperties.authenticationMethod(); String global_style = GlobalProperties.getProperty("global_css"); diff --git a/portal/src/main/webapp/WEB-INF/jsp/global/css_include_standard.jsp b/portal/src/main/webapp/WEB-INF/jsp/global/css_include_standard.jsp index 1a3f1a1c367..cc86b290a33 100644 --- a/portal/src/main/webapp/WEB-INF/jsp/global/css_include_standard.jsp +++ b/portal/src/main/webapp/WEB-INF/jsp/global/css_include_standard.jsp @@ -45,7 +45,7 @@ - + <% String global_style = GlobalProperties.getProperty("global_css"); String special_style = GlobalProperties.getProperty("special_css"); diff --git a/portal/src/main/webapp/WEB-INF/jsp/global/header.jsp b/portal/src/main/webapp/WEB-INF/jsp/global/header.jsp index 5e382180d23..f9f1d14ffbe 100644 --- a/portal/src/main/webapp/WEB-INF/jsp/global/header.jsp +++ b/portal/src/main/webapp/WEB-INF/jsp/global/header.jsp @@ -37,7 +37,7 @@ <%@ page import="org.mskcc.cbio.portal.util.GlobalProperties" %> - + @@ -70,13 +70,17 @@ <%= request.getAttribute(QueryBuilder.HTML_TITLE)%> - -
+ +
+
+
+ +
diff --git a/portal/src/main/webapp/WEB-INF/jsp/global/header_bar.jsp b/portal/src/main/webapp/WEB-INF/jsp/global/header_bar.jsp index 6dc388fe3d9..bd3b7e862c3 100644 --- a/portal/src/main/webapp/WEB-INF/jsp/global/header_bar.jsp +++ b/portal/src/main/webapp/WEB-INF/jsp/global/header_bar.jsp @@ -53,9 +53,10 @@
- - - -
- - - -
- +
- -
-
- +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> + - - - - - - -<%@ include file="../oncokb/oncokb-card-template.html" %> -<%@ include file="../civic/civic-qtip-template.html" %> - - - - - - - - function previousCaseId() { - return hasPrevious() ? navCaseIds[currPosition-1] : null; - } + + + + + + - function nextCaseId() { - return hasNext ? navCaseIds[currPosition+1] : null; - } + - return { - currPosition: function() {return currPosition;}, - numOfNavCases: function() {return navCaseIds.length;}, - hasNavCaseIds : hasNavCaseIds, - hasPrevious : hasPrevious, - hasNext : hasNext, - first: function() { - return getUrlTo(navCaseIds[0]); - }, - previous: function() { - return getUrlTo(previousCaseId()); - }, - next: function() { - return getUrlTo(nextCaseId()); - }, - last: function() { - return getUrlTo(navCaseIds[navCaseIds.length-1]); - }, - navToFirst: function() { - navTo(navCaseIds[0]); - }, - navToPrevious : function() { - navTo(previousCaseId()); - }, - navToNext : function() { - navTo(nextCaseId()); - }, - navToLast: function() { - navTo(navCaseIds[navCaseIds.length-1]); - } - }; -})(isPatientView?patientId:caseIds[0]); + -window["<%=PatientView.CANCER_STUDY_META_DATA_KEY_STRING%>"] - = <%=jsonMapper.writeValueAsString(request.getAttribute(PatientView.CANCER_STUDY_META_DATA_KEY_STRING))%>; - - - diff --git a/portal/src/main/webapp/WEB-INF/web.xml b/portal/src/main/webapp/WEB-INF/web.xml index cb2dd8a9b48..7ee18a8d3d1 100755 --- a/portal/src/main/webapp/WEB-INF/web.xml +++ b/portal/src/main/webapp/WEB-INF/web.xml @@ -448,6 +448,15 @@ /crosscancermutation.json + + CheckDarwinAccessServlet + org.mskcc.cbio.portal.servlet.CheckDarwinAccessServlet + + + CheckDarwinAccessServlet + /checkDarwinAccess.do + + MutationsJSON org.mskcc.cbio.portal.servlet.MutationsJSON @@ -456,16 +465,16 @@ MutationsJSON /mutations.json - + - CnaJSON + CnaJSON org.mskcc.cbio.portal.servlet.CnaJSON CnaJSON /cna.json - + SVGtoPDFConverter org.mskcc.cbio.portal.servlet.SvgConverter diff --git a/portal/src/main/webapp/content/examples.html b/portal/src/main/webapp/content/examples.html index c2312aa9de4..581b5b57b2b 100644 --- a/portal/src/main/webapp/content/examples.html +++ b/portal/src/main/webapp/content/examples.html @@ -18,6 +18,6 @@ BRAF V600E mutations across cancer types
  • - Patient view of an endometrial cancer case + Patient view of an endometrial cancer case
  • - \ No newline at end of file + diff --git a/portal/src/main/webapp/content/examples_genie.html b/portal/src/main/webapp/content/examples_genie.html index 68d0cd9533a..8356de8f6c4 100644 --- a/portal/src/main/webapp/content/examples_genie.html +++ b/portal/src/main/webapp/content/examples_genie.html @@ -5,5 +5,5 @@

    BRAF V600 mutations across cancer types

    -Lung cancer case with post-treatment T790M EGFR mutation -

    \ No newline at end of file +Lung cancer case with post-treatment T790M EGFR mutation +

    diff --git a/portal/src/main/webapp/content/examples_prostate.html b/portal/src/main/webapp/content/examples_prostate.html index 996e45604c9..8980d451f0e 100644 --- a/portal/src/main/webapp/content/examples_prostate.html +++ b/portal/src/main/webapp/content/examples_prostate.html @@ -3,5 +3,5 @@

    SPOP mutations in primary prostate cancer

    -A TCGA Prostate Adenocarcinoma Case -

    \ No newline at end of file +A TCGA Prostate Adenocarcinoma Case +

    diff --git a/portal/src/main/webapp/content/examples_tcga.html b/portal/src/main/webapp/content/examples_tcga.html index c203a09c6e7..680640384c1 100644 --- a/portal/src/main/webapp/content/examples_tcga.html +++ b/portal/src/main/webapp/content/examples_tcga.html @@ -13,5 +13,5 @@

    BRAF V600E mutations across cancer types

    -Patient view of an endometrial cancer case -

    \ No newline at end of file +Patient view of an endometrial cancer case +

    diff --git a/portal/src/main/webapp/content/news.html b/portal/src/main/webapp/content/news.html index b5bcbfbb4bf..b50e586eb71 100644 --- a/portal/src/main/webapp/content/news.html +++ b/portal/src/main/webapp/content/news.html @@ -221,7 +221,7 @@

    July 25, 2013

    • Multi-gene correlation plots.
    • Variant allele frequency distribution plots for individual tumor samples.
    • -
    • Tissue images for TCGA samples in the patient view, via Digital Slide Archive. Example.
    • +
    • Tissue images for TCGA samples in the patient view, via Digital Slide Archive. Example.

    July 16, 2013

      @@ -397,4 +397,4 @@

      November 4, 2010

    • Official release of our Web Interface, enabling programmatic access to all data.
    • Official release of our R Package, enabling programmatic access to all data from the R platform for statistical computing.
    -

    OncoPrints

    \ No newline at end of file +

    OncoPrints

    diff --git a/portal/src/main/webapp/content/news_prostate.html b/portal/src/main/webapp/content/news_prostate.html index 521ca58c9d9..af63df89446 100644 --- a/portal/src/main/webapp/content/news_prostate.html +++ b/portal/src/main/webapp/content/news_prostate.html @@ -52,8 +52,8 @@

    July 25, 2013

    • Multi-gene correlation plots.
    • Variant allele frequency distribution plots for individual tumor samples.
    • -
    • Tissue images for TCGA samples in the patient view, via Digital Slide Archive. Example.
    • -
    • Support for multiple tumor samples for a single patient. Example.
    • +
    • Tissue images for TCGA samples in the patient view, via Digital Slide Archive. Example.
    • +
    • Support for multiple tumor samples for a single patient. Example.

    July 16, 2013

      @@ -83,4 +83,4 @@

      January 25, 2013

    • SU2C prostate study - 1 case.
    - \ No newline at end of file + diff --git a/portal/src/main/webapp/content/news_tcga.html b/portal/src/main/webapp/content/news_tcga.html index 83bd993228a..9fe21decb39 100644 --- a/portal/src/main/webapp/content/news_tcga.html +++ b/portal/src/main/webapp/content/news_tcga.html @@ -105,7 +105,7 @@

    July 23, 2013

    • Multi-gene correlation plots.
    • Variant allele frequency distribution plots for individual tumor samples.
    • -
    • Tissue images for TCGA samples in the patient view, via Digital Slide Archive. Example.
    • +
    • Tissue images for TCGA samples in the patient view, via Digital Slide Archive. Example.

    July 16, 2013

      @@ -245,4 +245,4 @@

      September 12, 2011

    April 26, 2011

    This is the initial release of the cBio TCGA Cancer Genomics Portal. The portal contains data from all completed and ongoing TCGA projects. All data is automatically imported from the output of the Broad Firehose.

    -

    This release includes data on 2531 samples from 11 tumor types.

    \ No newline at end of file +

    This release includes data on 2531 samples from 11 tumor types.

    diff --git a/portal/src/main/webapp/css/global_portal.css b/portal/src/main/webapp/css/global_portal.css index 3412977b682..d48998964a6 100644 --- a/portal/src/main/webapp/css/global_portal.css +++ b/portal/src/main/webapp/css/global_portal.css @@ -1,7 +1,7 @@ /* CSS THAT APPLIES TO ALLLLLL PORTALS */ body { - background-color: #f5f5f5; + background-color: #f5f5f5; font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; table-layout: fixed; text-align: center; @@ -124,6 +124,10 @@ fieldset#patient-view-summary-fieldset > legend { } } +#content { + padding: 0 20px; +} + img { border: 0px; } @@ -1031,116 +1035,6 @@ html { min-height: 100%; margin-bottom: 1px; min-width: 100%; margin-right: 1px; text-align: right; } -#login_header_top { - padding:5px 0px 0px 0px; - background: white; - margin:0px; - height:70px; -} - -header { - background: linear-gradient(to bottom, rgba(252,252,252,1) 90%, rgba(249,249,249,1) 100%); - border-bottom: 1px solid #f5f5f5; - margin: 0 0 20px 0; - position: relative; - display: flex !important; - justify-content: space-between; - flex-wrap: wrap; - align-items: flex-end; -} - -#header { - display: flex; - flex-direction: column; - align-items: flex-end; - justify-content: space-around; - height: 100%; - position: absolute; - right: 0; - top: 0; -} - -#cbioportal-logo { - padding: 15px; -} - -#institute-logo { - box-sizing: content-box; - max-height: 35px; - padding: 4px 10px; - float: right; -} - -#authentication { - position: relative; - margin-top: -2px; -} - -#authentication p { - font: normal normal 400 11px/35px 'Helvetica Neue', Helvetica, Verdana, Arial, sans-serif; - display: inline-block; - padding: 0px 10px; - float: right; - margin: -1px 20px 0px 0; - background: #fff; - border-bottom-left-radius: 5px; - border-bottom-right-radius: 5px; - box-shadow: 0px 1px 1px rgba(93, 130, 158, 0.5); -} - -#authentication span { - padding: 4px 10px; - display: inline-block; -} - -#authentication span.username { - padding: 0px; - font-weight: 600; -} - -#authentication a:link, #authentication a:visited { - color: #428bca; -} - -header > div { - display: flex; - flex-direction: column; - justify-content: space-between; -} - -#main-nav { - display: flex; - flex-direction: column; - justify-content: center; - padding: 10px 0 10px 5px; -} - -#main-nav ul { - margin: 0 15px 0 0; - padding: 0; -} - -#main-nav li { - list-style-type: none; - display: inline-block; - font: normal normal 400 14px/18px 'Helvetica Neue', Helvetica, Verdana, Arial, sans-serif; - padding: 5px 7px; -} - -#main-nav li a:link, #main-nav li a:visited { - color: #777; - padding: 1px; -} - -#main-nav li a:hover { - color: #000; - text-decoration: none; -} - -#main-nav li.selected a:link, #main-nav li.selected a:visited { - color: #000; - border-bottom: 1px solid #ddd; -} .welcome { padding: 3px; diff --git a/portal/src/main/webapp/css/header.css b/portal/src/main/webapp/css/header.css new file mode 100644 index 00000000000..065bf0e4117 --- /dev/null +++ b/portal/src/main/webapp/css/header.css @@ -0,0 +1,146 @@ +#login_header_top { + padding:5px 0px 0px 0px; + background: white; + margin:0px; + height:70px; +} + +header { + background: linear-gradient(to bottom, rgba(252,252,252,1) 90%, rgba(249,249,249,1) 100%); + border-bottom: 1px solid #f5f5f5; + position: relative; + display: flex !important; + justify-content: space-between; + flex-wrap: wrap; + align-items: flex-end; + min-width:780px; +} + +.legacy header { + max-width:1270px; + margin:0 auto; + box-sizing:border-box !important; +} + +.pageTopContainer { + background:#f5f5f5; + padding-left:20px; + padding-right:20px; +} + +.pageTopContainer, #reactRoot { + +} + +#reactRoot { + min-height:600px; +} + +/* override for new layout */ +.pageTopContainer header { + background:none; + +} + +.pageTopContainer header #authentication p { + margin-right:0; +} + + +#cbioportal-logo { + padding: 15px 0; +} + +#institute-logo { + max-height: 35px; + float: right; + margin-right:5px; + margin-top:3px; + opacity:0.5; +} + +#authentication { + position: absolute; + top: 0; + right: 0; +} + +#authentication p { + font: normal normal 400 11px/35px 'Helvetica Neue', Helvetica, Verdana, Arial, sans-serif; + display: inline-block; + padding: 0px 10px; + float: right; + margin: -1px 20px 0px 0; + background: #fff; + border-bottom-left-radius: 5px; + border-bottom-right-radius: 5px; + box-shadow: 0px 1px 1px rgba(93, 130, 158, 0.5); +} + +#authentication span { + padding: 4px 10px; + display: inline-block; +} + +#authentication span.username { + padding: 0px; + font-weight: 600; +} + +#authentication a:link, #authentication a:visited { + color: #428bca; +} + +header > div { + display: flex; + flex-direction: column; + justify-content: space-between; +} + +#main-nav { + position:relative; + top:-1px; +} + +#main-nav:first-child { + top:-22px; +} + +#main-nav li { + list-style-type: none; + display: inline-block; + font: normal normal 400 14px/18px 'Helvetica Neue', Helvetica, Verdana, Arial, sans-serif; + margin-left:15px; +} + +#main-nav li a:link, #main-nav li a:visited { + color: #777; +} + +#main-nav li a:hover { + color: #000; +} + +#main-nav li.selected a:link, #main-nav li.selected a:visited { + color: #000; + border-bottom: 1px solid #ddd; +} + +.contentWidth { + +} + +#footer { + text-align:center; + padding:30px; + opacity:.5 +} + +.legacy #page_wrapper { + max-width:1320px; + margin:0 auto; +} + + + + diff --git a/portal/src/main/webapp/images/msk_logo_transparent_black.png b/portal/src/main/webapp/images/msk_logo_transparent_black.png new file mode 100644 index 00000000000..2f45c8a6339 Binary files /dev/null and b/portal/src/main/webapp/images/msk_logo_transparent_black.png differ diff --git a/portal/src/main/webapp/js/src/cbio-util.js b/portal/src/main/webapp/js/src/cbio-util.js index 454db67b39c..db86e76e4bb 100644 --- a/portal/src/main/webapp/js/src/cbio-util.js +++ b/portal/src/main/webapp/js/src/cbio-util.js @@ -422,11 +422,11 @@ cbio.util = (function() { } function getLinkToPatientView(cancerStudyId, patientId) { - return "case.do?cancer_study_id=" + cancerStudyId + "&case_id=" + patientId; + return "case.do#/patient?studyId=" + cancerStudyId + "&caseId=" + patientId; } function getLinkToSampleView(cancerStudyId, sampleId) { - return "case.do?cancer_study_id=" + cancerStudyId + "&sample_id=" + sampleId; + return "case.do#/patient?studyId=" + cancerStudyId + "&sampleId=" + sampleId; } /** diff --git a/portal/src/main/webapp/js/src/dashboard/cbio-vendor.js b/portal/src/main/webapp/js/src/dashboard/cbio-vendor.js index 895820bde53..04436f8218a 100644 --- a/portal/src/main/webapp/js/src/dashboard/cbio-vendor.js +++ b/portal/src/main/webapp/js/src/dashboard/cbio-vendor.js @@ -425,11 +425,11 @@ cbio.util = (function() { } function getLinkToPatientView(cancerStudyId, patientId) { - return "case.do?cancer_study_id=" + cancerStudyId + "&case_id=" + patientId; + return "case.do#/patient?studyId=" + cancerStudyId + "&caseId=" + patientId; } function getLinkToSampleView(cancerStudyId, sampleId) { - return "case.do?cancer_study_id=" + cancerStudyId + "&sample_id=" + sampleId; + return "case.do#/patient?studyId=" + cancerStudyId + "&sampleId=" + sampleId; } /** diff --git a/portal/src/main/webapp/js/src/dashboard/iviz.js b/portal/src/main/webapp/js/src/dashboard/iviz.js index 948f0409914..99867359fe9 100644 --- a/portal/src/main/webapp/js/src/dashboard/iviz.js +++ b/portal/src/main/webapp/js/src/dashboard/iviz.js @@ -1021,10 +1021,10 @@ var iViz = (function(_, $, cbio, QueryByGeneUtil, QueryByGeneTextArea) { }); if (possible) { var _selectedCaseIds = selectedCases_.sort(); - var _url = window.cbioURL + 'case.do?cancer_study_id=' + - studyId + '&' + (type === 'patient' ? 'case_id' : 'sample_id') + + var _url = window.cbioURL + 'case.do#/patient?studyId=' + + studyId + '&' + (type === 'patient' ? 'caseId' : 'sampleId') + '=' + _selectedCaseIds[0] + - '#nav_case_ids=' + _selectedCaseIds.join(','); + '&navCaseIds=' + _selectedCaseIds.join(','); window.open(_url); } else { new Notification().createNotification( diff --git a/portal/src/main/webapp/js/src/global-tabs.js b/portal/src/main/webapp/js/src/global-tabs.js index da011212ab5..fa83f1d8499 100644 --- a/portal/src/main/webapp/js/src/global-tabs.js +++ b/portal/src/main/webapp/js/src/global-tabs.js @@ -47,67 +47,6 @@ $(document).ready(function() { return false; }); -window.loadReactApp = function(config) { - - // Set frontend route to /patient - window.defaultRoute = `/${config.defaultRoute}`; - - - if (localStorage.getItem('localdev') === "true") { - // Use cbioportal-frontend localhost:3000 for dev - document.write(''); - document.write('