Skip to content

Commit

Permalink
Q-value QC Plot changes
Browse files Browse the repository at this point in the history
  • Loading branch information
danjasuw committed Nov 5, 2015
1 parent a0d3605 commit 434ff0b
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 28 deletions.
40 changes: 16 additions & 24 deletions WebRoot/js/qcChartQValueCounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,21 +673,15 @@ QCChartQValueCounts.prototype.createChartResponse = function(requestData, respon

var lineColors = [];

var maxPSMCount = 0;

var updateMaxPSMCountForType = function( chartDataForType ) {

var bucketsFor_chartDataForType = chartDataForType.chartBuckets;

var lastBucket = bucketsFor_chartDataForType[ dataArraySize - 1 ];

var lastBucket_totalCount = lastBucket.totalCount;

if ( maxPSMCount < lastBucket_totalCount ) {

maxPSMCount = lastBucket_totalCount;
}
};
// var maxPSMCount = 0;
//
// var updateMaxPSMCountForType = function( chartDataForType ) {
//
// if ( maxPSMCount < chartDataForType.totalCountForType ) {
//
// maxPSMCount = chartDataForType.totalCountForType;
// }
// };


// red: #A55353
Expand All @@ -705,7 +699,7 @@ QCChartQValueCounts.prototype.createChartResponse = function(requestData, respon

lineColors.push( '#a5a5a5' ); // combined: #a5a5a5 (gray)

updateMaxPSMCountForType( alllinkChartData );
// updateMaxPSMCountForType( alllinkChartData );
}

if ( crosslinkChartData ) {
Expand All @@ -715,7 +709,7 @@ QCChartQValueCounts.prototype.createChartResponse = function(requestData, respon

lineColors.push( '#A55353' ); // red: #A55353

updateMaxPSMCountForType( crosslinkChartData );
// updateMaxPSMCountForType( crosslinkChartData );
}

if ( looplinkChartData ) {
Expand All @@ -725,7 +719,7 @@ QCChartQValueCounts.prototype.createChartResponse = function(requestData, respon

lineColors.push( '#53a553' ); // green: #53a553

updateMaxPSMCountForType( looplinkChartData );
// updateMaxPSMCountForType( looplinkChartData );
}

if ( unlinkedChartData ) {
Expand All @@ -735,7 +729,7 @@ QCChartQValueCounts.prototype.createChartResponse = function(requestData, respon

lineColors.push( '#5353a5' ); // blue: #5353a5

updateMaxPSMCountForType( unlinkedChartData );
// updateMaxPSMCountForType( unlinkedChartData );
}


Expand All @@ -754,23 +748,21 @@ QCChartQValueCounts.prototype.createChartResponse = function(requestData, respon
var linkTypeLabel = params.linkTypeLabel;

if ( dataForType ) {

var lastBucket = dataForType.chartBuckets[ dataArraySize - 1 ];

var lastBucket_totalCount = lastBucket.totalCount;

var bucket = dataForType.chartBuckets[ index ];

if ( chartDataEntry.length === 0 ) {

// Add position to chartDataEntry array if chartDataEntry is empty

chartDataEntry.push( bucket.binEnd );
}

var chartDataValue = bucket.totalCount;

if ( displayAsPercentage ) {

chartDataValue = chartDataValue / lastBucket_totalCount * 100;
chartDataValue = chartDataValue / dataForType.totalCountForType * 100;
}

chartDataEntry.push( chartDataValue );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ public PsmCountPerQValueQCPlotDataJSONRoot create( Set<String> selectedLinkTypes

List<Double> qValuesForPSMsthatMeetCriteriaList =
QValuesFromPsmTblSearcher.getInstance().getQValues( selectedDBLinkTypes, searchId, psmQValueCutoff );

int totalCountForType = qValuesForPSMsthatMeetCriteriaList.size();

if ( psmQValueCutoff != null ) {

totalCountForType = QValuesFromPsmTblSearcher.getInstance().getQValuesCount( selectedDBLinkTypes, searchId );
}

PsmCountPerQValueQCPlotDataJSONPerType linkData = null;

Expand All @@ -132,10 +139,9 @@ public PsmCountPerQValueQCPlotDataJSONRoot create( Set<String> selectedLinkTypes

unlinkedData = new PsmCountPerQValueQCPlotDataJSONPerType();
linkData = unlinkedData;

}


int qvalueZeroCount = 0;

int[] qvalueCounts = new int[ BIN_COUNT ];
Expand Down Expand Up @@ -215,6 +221,10 @@ public PsmCountPerQValueQCPlotDataJSONRoot create( Set<String> selectedLinkTypes
linkData.setChartBuckets( chartBuckets );

dataArraySize = chartBuckets.size();


linkData.setTotalCountForType( totalCountForType );

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@
public class PsmCountPerQValueQCPlotDataJSONPerType {

private List<PsmCountPerQValueQCPlotDataJSONChartBucket> chartBuckets;
// private int zeroQvalueCount = 0;

private int totalCountForType;

public int getTotalCountForType() {
return totalCountForType;
}
public void setTotalCountForType(int totalCountForType) {
this.totalCountForType = totalCountForType;
}
public List<PsmCountPerQValueQCPlotDataJSONChartBucket> getChartBuckets() {
return chartBuckets;
}
Expand Down
100 changes: 100 additions & 0 deletions src/org/yeastrc/xlink/www/searcher/QValuesFromPsmTblSearcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,106 @@ private QValuesFromPsmTblSearcher() { }
private static final QValuesFromPsmTblSearcher _INSTANCE = new QValuesFromPsmTblSearcher();
public static QValuesFromPsmTblSearcher getInstance() { return _INSTANCE; }



/**
* @param selectedDBLinkTypes - NULL for all
* @param searchId
* @return
* @throws Exception
*/
public int getQValuesCount(
List<String> selectedDBLinkTypes,
int searchId
) throws Exception {


int getQValuesCount = 0;

Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;


StringBuilder sqlSB = new StringBuilder( 10000 );

sqlSB.append( "SELECT COUNT(*) AS count FROM psm WHERE search_id = ? " );

if ( selectedDBLinkTypes != null && ! selectedDBLinkTypes.isEmpty() ) {

sqlSB.append( " AND psm.type IN ( " );

boolean firstWebLinkType = true;

for ( String selectedDBLinkType : selectedDBLinkTypes ) {

if ( firstWebLinkType ) {

firstWebLinkType = false;
} else {

sqlSB.append( " , " );
}
sqlSB.append( " '" );
sqlSB.append( selectedDBLinkType );
sqlSB.append( "' " );
}

sqlSB.append( " ) " );

}

String sql = sqlSB.toString();


try {

conn = DBConnectionFactory.getConnection( DBConnectionFactory.CROSSLINKS );


pstmt = conn.prepareStatement( sql );

int paramCounter = 0;

paramCounter++;
pstmt.setInt( paramCounter, searchId );

rs = pstmt.executeQuery();

if( rs.next() ) {
getQValuesCount = rs.getInt( "count" );
}

} catch ( Exception e ) {

String msg = "getQValuesCount(), sql: " + sql;

log.error( msg, e );

throw e;

} finally {

// be sure database handles are closed
if( rs != null ) {
try { rs.close(); } catch( Throwable t ) { ; }
rs = null;
}

if( pstmt != null ) {
try { pstmt.close(); } catch( Throwable t ) { ; }
pstmt = null;
}

if( conn != null ) {
try { conn.close(); } catch( Throwable t ) { ; }
conn = null;
}
}

return getQValuesCount;
}


/**
* @param selectedDBLinkTypes - NULL for all
Expand Down

0 comments on commit 434ff0b

Please sign in to comment.