|
20 | 20 | import org.labkey.api.reader.Readers; |
21 | 21 | import org.labkey.api.sequenceanalysis.SequenceAnalysisService; |
22 | 22 | import org.labkey.api.sequenceanalysis.model.AnalysisModel; |
| 23 | +import org.labkey.api.sequenceanalysis.model.ReadData; |
23 | 24 | import org.labkey.api.sequenceanalysis.model.Readset; |
24 | 25 | import org.labkey.api.sequenceanalysis.pipeline.AbstractAnalysisStepProvider; |
25 | 26 | import org.labkey.api.sequenceanalysis.pipeline.AbstractPipelineStep; |
|
33 | 34 | import org.labkey.api.sequenceanalysis.pipeline.ToolParameterDescriptor; |
34 | 35 | import org.labkey.api.sequenceanalysis.run.AbstractDiscvrSeqWrapper; |
35 | 36 | import org.labkey.api.util.PageFlowUtil; |
| 37 | +import org.labkey.sequenceanalysis.util.SequenceUtil; |
36 | 38 |
|
37 | 39 | import java.io.File; |
38 | 40 | import java.io.IOException; |
@@ -134,15 +136,46 @@ public Output performAnalysisPerSampleRemote(Readset rs, File inputBam, Referenc |
134 | 136 | Map<String, String> metricMap = parseMetricFile(metrics); |
135 | 137 |
|
136 | 138 | NumberFormat pf = NumberFormat.getPercentInstance(); |
137 | | - pf.setMaximumFractionDigits(6); |
| 139 | + pf.setMaximumFractionDigits(4); |
| 140 | + |
| 141 | + Double hitRate = null; |
| 142 | + if (rs.getReadData() != null) |
| 143 | + { |
| 144 | + getPipelineCtx().getLogger().info("Counting total input reads"); |
| 145 | + |
| 146 | + int totalReads = 0; |
| 147 | + for (ReadData rd : rs.getReadData()) |
| 148 | + { |
| 149 | + File forward = rd.getFile1(); |
| 150 | + if (forward != null && forward.exists()) |
| 151 | + { |
| 152 | + totalReads += SequenceUtil.getLineCount(forward) / 4; |
| 153 | + } |
| 154 | + } |
| 155 | + |
| 156 | + getPipelineCtx().getLogger().info("initial reads: " + totalReads); |
| 157 | + |
| 158 | + if (totalReads > 0) |
| 159 | + { |
| 160 | + hitRate = Integer.parseInt(metricMap.get("NumReadsSpanningJunction")) / (double) totalReads; |
| 161 | + } |
| 162 | + } |
| 163 | + else |
| 164 | + { |
| 165 | + getPipelineCtx().getLogger().error("Readset did not have information on input files"); |
| 166 | + } |
138 | 167 |
|
139 | 168 | output.addSequenceOutput(siteTable, |
140 | 169 | "Putative Integration Sites: " + rs.getName(), |
141 | 170 | "Tag-PCR Integration Sites", rs.getReadsetId(), |
142 | 171 | null, |
143 | 172 | referenceGenome.getGenomeId(), |
144 | | - "Records: " + Integer.parseInt(metricMap.get("NumReadsSpanningJunction")) + "\nJunction hit rate: " + |
145 | | - pf.format(Double.parseDouble(metricMap.get("PctReadsSpanningJunction")) |
| 173 | + "Reads: " + metricMap.get("NumReadsSpanningJunction") + |
| 174 | + "\nJunction hit rate (of alignments): " + pf.format(Double.parseDouble(metricMap.get("PctReadsSpanningJunction")) + |
| 175 | + (hitRate == null ? "" : "\nJunction hit rate (of total reads): ") + pf.format(hitRate) + |
| 176 | + "\nIntegration Sites: " + metricMap.get("TotalIntegrationSitesOutput") + |
| 177 | + "\nAlignments Matching Insert: " + metricMap.get("FractionPrimaryAlignmentsMatchingInsert") |
| 178 | + |
146 | 179 | ) |
147 | 180 | ); |
148 | 181 |
|
|
0 commit comments