Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Size bp and calibrated concentration added for gDNA QC records #83

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ public List<Long> getRecordIds(List<DataRecord> records) {

/**
* Method to remove 1000 separator from CSV files. Such values in CSV files are enclosed with double quotes ("123,100")
* This method can be used to fined such values and remove comma (",") to split the lines more efficiently and
* This method can be used to find such values and remove comma (",") to split the lines more efficiently and
* extract column values.
*
* @param line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class QcReportGenerator extends DefaultGenericPlugin {
private final String QC_TYPE_FOR_RIN = "bioanalyzer rna pico, bioanalyzer rna nano, tapestation rna screentape hisense sample table, tapestation rna screentape sample table";
private final String QC_TYPE_FOR_A260280 = "nanodrop nano";
private final String QC_TYPE_FOR_A260230 = "nanodrop nano";
private final String QC_TYPE_FOR_CALBRATED_CONCENTRATION = "quant-it";
private final String QC_TYPE_FOR_AVERAGE_BP_SIZE = "TapeStation Compact Peak Table, TapeStation Compact Pico Region Table, " +
"TapeStation D1000 Compact Region Table, TapeStation D1000 HiSense Compact Region Table, Bioanalyzer DNA High Sens Region Table";
private final String TAPESTATION_QC_FOR_AVERAGE_BP_SIZE = "TapeStation Compact Peak Table, TapeStation Compact Pico Region Table, " +
Expand Down Expand Up @@ -688,6 +689,61 @@ private Double getAverageLibrarySizeValue(String sampleId, List<DataRecord> qcRe
return averageBasePairSize;
}

private Double getBpSizeValue(String sampleId, List<DataRecord> qcRecords) {
List<DataRecord> qcRecordsWithBpSizeForSample;
qcRecordsWithBpSizeForSample = getQcRecordsByQcType(sampleId, qcRecords, QC_TYPE_FOR_AVERAGE_BP_SIZE);

double basePairSize = 0.0;
try {
if (!qcRecordsWithBpSizeForSample.isEmpty()) {
for (DataRecord qcRecord : qcRecordsWithBpSizeForSample) {
if (qcRecord.getValue("sizeBp", user) != null && qcRecord.getValue("SampleId", user).equals(sampleId)) {
basePairSize = qcRecord.getDoubleVal("sizeBp", user);
}
}
}
if (qcRecordsWithBpSizeForSample.isEmpty() || basePairSize <= 0) {
clientCallback.displayWarning(String.format("BP Size value not found for '%s'.", sampleId));
logInfo(String.format("WARNING: BP Size value not found for '%s'.", sampleId));
return 0.0;
}
} catch (RemoteException e) {
logError(String.format("RemoteException while getting 'sizeBp' Value for sample with Sample ID %s:\n%s", sampleId, ExceptionUtils.getStackTrace(e)));
} catch (NotFound notFound) {
logError(String.format("NotFound -> Missing 'sizeBp' Value for sample with Sample ID %s:\n%s", sampleId, ExceptionUtils.getStackTrace(notFound)));
} catch (ServerException se) {
logError(String.format("ServerException while getting 'sizeBp' Value for sample with Sample ID %s:\n%s", sampleId, ExceptionUtils.getStackTrace(se)));
}
return basePairSize;
}

private double getCalibConc(String sampleId, List<DataRecord> qcRecords) {
List<DataRecord> qcRecordsWithCalibConceForSample = getQcRecordsByQcType(sampleId, qcRecords, QC_TYPE_FOR_CALBRATED_CONCENTRATION);

double calibratedConcentration = 0.0;
try {
if (!qcRecordsWithCalibConceForSample.isEmpty()) {
for (DataRecord qcRecord : qcRecordsWithCalibConceForSample) {
if (qcRecord.getValue("calibratedConcentration", user) != null && qcRecord.getValue("SampleId", user).equals(sampleId)) {
calibratedConcentration = qcRecord.getDoubleVal("calibratedConcentration", user);
}
}
}
if (qcRecordsWithCalibConceForSample.isEmpty() || calibratedConcentration <= 0) {
clientCallback.displayWarning(String.format("Calibrated concentration value not found for '%s'.", sampleId));
logInfo(String.format("WARNING: Calibrated concentration value not found for '%s'.", sampleId));
return 0.0;
}
} catch (RemoteException e) {
logError(String.format("RemoteException while getting 'calibrated concentration' Value for sample with Sample ID %s:\n%s", sampleId, ExceptionUtils.getStackTrace(e)));
} catch (NotFound notFound) {
logError(String.format("NotFound -> Missing 'calibrated concentration' Value for sample with Sample ID %s:\n%s", sampleId, ExceptionUtils.getStackTrace(notFound)));
} catch (ServerException se) {
logError(String.format("ServerException while getting 'calibrated concentration' Value for sample with Sample ID %s:\n%s", sampleId, ExceptionUtils.getStackTrace(se)));
}
return calibratedConcentration;
}

/**
* Create DNA QC REPORT DataRecords for Samples.
*
Expand Down Expand Up @@ -725,6 +781,8 @@ private List<DataRecord> generateDnaQcReportFieldValuesMap(List<DataRecord> samp
Double dinValue = getDinValueFromQcRecord(sampleId, qcDataRecords);
Double A260280 = getA260280FromQcRecord(sampleId, qcDataRecords);
Double A260230 = getA260230FromQcRecord(sampleId, qcDataRecords);
Double sizeBp = getBpSizeValue(sampleId, qcDataRecords);
Double calibratedConcentration = getCalibConc(sampleId, qcDataRecords);
String igoRecommendation = getIgoRecommendationValue(sampleId, qcProtocolRecords);
String comments = getQcCommentsValue(sampleId, qcProtocolRecords);
if (dinValue > 0) {
Expand All @@ -738,6 +796,12 @@ private List<DataRecord> generateDnaQcReportFieldValuesMap(List<DataRecord> samp
qcRecord.put("A260280", A260280);
logInfo("A260280 is assigned to " + A260280);
}
if (sizeBp > 0) {
qcRecord.put("sizeBp", sizeBp);
}
if (calibratedConcentration > 0) {
qcRecord.put("calibratedConcentration", calibratedConcentration);
}
if (!StringUtils.isBlank(igoRecommendation)) {
qcRecord.put("IgoQcRecommendation", igoRecommendation);
}
Expand Down