Commit a9422451 authored by Guillaume Jimenez's avatar Guillaume Jimenez
Browse files

Added more null safe checks

parent 811b60c3
......@@ -152,6 +152,17 @@ const SampleCoverage = {
<span>Close</span>
</v-tooltip>
</v-toolbar>
<v-card-text class="pb-0">
<v-layout row wrap>
<v-flex>
<v-text-field label="Max Depth"
value="thresholdDistribution" v-model="thresholdDistribution"
@input="getCoverageDistributionData()" :rules="[nbRules]">
</v-text-field>
</v-flex>
</v-layout>
</v-card-text>
<v-card-text>
<div :style="fullSizeChart">
<div :id="distributionChartId" style="height: 100%"></div>
......@@ -311,7 +322,8 @@ const SampleCoverage = {
nbRules: value => {
const pattern = /^\d+$/;
return pattern.test(value) || 'Numbers only.'
}
},
thresholdDistribution: 1000
}
},
methods: {
......@@ -495,7 +507,8 @@ const SampleCoverage = {
params: {
sampleId: this.$route.params.id,
uniqueOnly: this.uniqueOnly == "uniq",
runId: this.sampleRunItemSelected
runId: this.sampleRunItemSelected,
maxDepth: this.thresholdDistribution
}
})
.then(response => {
......
......@@ -772,7 +772,7 @@ public class ModelDAO {
@Transactional
public List<CoverageViewer> getCoverageViewerBySampleIdRunId(Integer sampleId, String runId, Boolean unique) {
Session session = sessionFactory.getCurrentSession();
String sql = "select * from coverage_viewer where sample_id = :sampleId and runId = :runId and uniq = :uniq";
String sql = "select * from coverage_viewer where sample_id = :sampleId and seq_run_id = :runId and uniq = :uniq";
List<CoverageViewer> covViewers = session.createNativeQuery(sql, CoverageViewer.class)
.setParameter("sampleId", sampleId)
.setParameter("runId", runId)
......
......@@ -82,7 +82,7 @@ public class QualityMetricsDAO {
private StringBuilder createSQLControlPPVCombined() {
StringBuilder sql = new StringBuilder();
sql.append(" select run.run_date as 'date', cs.sp as qmValue, sa.sample_lab_name as sampleName ")
sql.append(" select run.run_date as 'date', cs.ppv_combined as qmValue, sa.sample_lab_name as sampleName ")
.append(" , ifnull(run.tech_name, 'Unknown') as techName , sa.tissue_type as tissueType, sa.t_class as tClass ")
.append(" from sample sa, seq_run run, control_snsp cs ")
.append(" ,subject su ")
......@@ -514,7 +514,7 @@ public class QualityMetricsDAO {
}
private String getFullGroupBy() {
return " group by 'date', qmValue, sampleName, techName, tissueType, tClass ";
return " group by 'date', qmValue, sampleName, techName, tissueType, tClass, run_date ";
}
}
......@@ -107,6 +107,10 @@ public class PipelineDAO2 {
fetchSomaticData(response, props);
Sample sample = sampleDAO.getSampleByName(props.getSampleName());
if (sample == null) {
response.addErrorMessage("Sample " + props.getSampleName() + " could NOT be found. Check for typos or if NuCLIA is synced with Clarity.");
return;
}
BaitPool baitPool = BaitPool.getBaitPoolForSample(sample.getSampleLabName(), baitPools,
props.getBaitPool());
// found a valid directory
......@@ -156,75 +160,82 @@ public class PipelineDAO2 {
private void fetchAlignementData(APIResponse response, SampleImportProperties props, Sample sample)
throws IOException, ParseException {
File sequenceStatsFile = props.getSampleAlignment();
if (sequenceStatsFile != null && sequenceStatsFile.exists()) {
if (sample.isDna()) {
DnaAlignment dataDAlignment = DnaAlignmentParser.parseFile(sequenceStatsFile);
Alignment dataAlignment = dataDAlignment.getAlignment();
List<DnaAlignment> alignments = modelDAO.getDnaAlignmentForSample(sample);
// check if the data matches existing alignements
boolean isNew = true;
for (DnaAlignment dal : alignments) {
Alignment al = dal.getAlignment();
if (al.getAlignDate().isEqual(dataAlignment.getAlignDate()) // date
&& al.getTotalReads().equals(dataAlignment.getTotalReads()) // total reads
&& al.getPipeline() != null && al.getPipeline().getVersion() != null // should never be null
// in the database
&& al.getPipeline().getAssay() != null // should never be null in the database
&& al.getPipeline().getVersion().equals(dataAlignment.getPipelineVersion()) // version
&& (dataAlignment.getAssay() == null
|| al.getPipeline().getAssay().equals(dataAlignment.getAssay()))) { // TODO do I
// need
// more?
// this is not a new alignement
isNew = false;
break; // no need to check for other alignements
if (sequenceStatsFile != null) {
if (sequenceStatsFile.exists()) {
if (sample.isDna()) {
DnaAlignment dataDAlignment = DnaAlignmentParser.parseFile(sequenceStatsFile);
Alignment dataAlignment = dataDAlignment.getAlignment();
List<DnaAlignment> alignments = modelDAO.getDnaAlignmentForSample(sample);
// check if the data matches existing alignements
boolean isNew = true;
for (DnaAlignment dal : alignments) {
Alignment al = dal.getAlignment();
if (al.getAlignDate().isEqual(dataAlignment.getAlignDate()) // date
&& al.getTotalReads().equals(dataAlignment.getTotalReads()) // total reads
&& al.getPipeline() != null && al.getPipeline().getVersion() != null // should never be null
// in the database
&& al.getPipeline().getAssay() != null // should never be null in the database
&& al.getPipeline().getVersion().equals(dataAlignment.getPipelineVersion()) // version
&& (dataAlignment.getAssay() == null
|| al.getPipeline().getAssay().equals(dataAlignment.getAssay()))) { // TODO do I
// need
// more?
// this is not a new alignement
isNew = false;
break; // no need to check for other alignements
}
}
}
if (isNew) {
dataAlignment.setSample(sample);
Pipeline pipeline = modelDAO.getPipelineByVersionAndAssay(dataAlignment.getPipelineVersion(),
dataAlignment.getAssay());
dataAlignment.setPipeline(pipeline);
sessionFactory.getCurrentSession().saveOrUpdate(dataAlignment);
sessionFactory.getCurrentSession().saveOrUpdate(dataDAlignment);
} else {
response.addErrorMessage("Previous identical alignment data found. No alignment was added.");
}
} else {
RnaAlignment dataRAlignment = RnaAlignmentParser.parseFile(sequenceStatsFile);
Alignment dataAlignment = dataRAlignment.getAlignment();
List<RnaAlignment> alignments = modelDAO.getRnaAlignmentForSample(sample);
// check if the data matches existing alignements
boolean isNew = true;
for (RnaAlignment ral : alignments) {
Alignment al = ral.getAlignment();
if (al.getAlignDate().isEqual(dataAlignment.getAlignDate())
&& al.getTotalReads().equals(dataAlignment.getTotalReads()) && al.getPipeline() != null
&& al.getPipeline().getVersion() != null && al.getPipeline().getAssay() != null
&& al.getPipeline().getVersion().equals(dataAlignment.getPipelineVersion())
&& (dataAlignment.getAssay() == null
|| al.getPipeline().getAssay().equals(dataAlignment.getAssay()))) { // TODO do I
// need more?
// this is not a new alignement
isNew = false;
break; // no need to check for other alignements
if (isNew) {
dataAlignment.setSample(sample);
Pipeline pipeline = modelDAO.getPipelineByVersionAndAssay(dataAlignment.getPipelineVersion(),
dataAlignment.getAssay());
dataAlignment.setPipeline(pipeline);
sessionFactory.getCurrentSession().saveOrUpdate(dataAlignment);
sessionFactory.getCurrentSession().saveOrUpdate(dataDAlignment);
} else {
response.addErrorMessage("Previous identical alignment data found. No alignment was added.");
}
}
if (isNew) {
dataAlignment.setSample(sample);
Pipeline pipeline = modelDAO.getPipelineByVersionAndAssay(dataAlignment.getPipelineVersion(),
dataAlignment.getAssay());
dataAlignment.setPipeline(pipeline);
sessionFactory.getCurrentSession().saveOrUpdate(dataAlignment);
sessionFactory.getCurrentSession().saveOrUpdate(dataRAlignment);
} else {
response.addErrorMessage("Previous identical alignment data found. No alignment was added.");
RnaAlignment dataRAlignment = RnaAlignmentParser.parseFile(sequenceStatsFile);
Alignment dataAlignment = dataRAlignment.getAlignment();
List<RnaAlignment> alignments = modelDAO.getRnaAlignmentForSample(sample);
// check if the data matches existing alignements
boolean isNew = true;
for (RnaAlignment ral : alignments) {
Alignment al = ral.getAlignment();
if (al.getAlignDate().isEqual(dataAlignment.getAlignDate())
&& al.getTotalReads().equals(dataAlignment.getTotalReads()) && al.getPipeline() != null
&& al.getPipeline().getVersion() != null && al.getPipeline().getAssay() != null
&& al.getPipeline().getVersion().equals(dataAlignment.getPipelineVersion())
&& (dataAlignment.getAssay() == null
|| al.getPipeline().getAssay().equals(dataAlignment.getAssay()))) { // TODO do I
// need more?
// this is not a new alignement
isNew = false;
break; // no need to check for other alignements
}
}
if (isNew) {
dataAlignment.setSample(sample);
Pipeline pipeline = modelDAO.getPipelineByVersionAndAssay(dataAlignment.getPipelineVersion(),
dataAlignment.getAssay());
dataAlignment.setPipeline(pipeline);
sessionFactory.getCurrentSession().saveOrUpdate(dataAlignment);
sessionFactory.getCurrentSession().saveOrUpdate(dataRAlignment);
} else {
response.addErrorMessage("Previous identical alignment data found. No alignment was added.");
}
}
}
} else {
response.addErrorMessage("Sequencing file not found here: " + sequenceStatsFile.getAbsolutePath());
else {
response.addErrorMessage("Sequencing file not found here: " + sequenceStatsFile.getAbsolutePath());
}
}
else {
response.addErrorMessage("No sequencing file provided.");
}
}
@Transactional
private void fetchCoverageData(APIResponse response, SeqRun run, SampleImportProperties props, Sample sample,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment