}
}
public JSONObject getSummaryStatsForRun(Run run) throws RunStatsException {
JSONObject report = new JSONObject();
ReportTable rt;
Map<RunProperty, String> map = new HashMap<RunProperty, String>();
map.put(RunProperty.run, run.getAlias());
try {
rt = reports.getAverageValues(map);
if (rt == null) {
return null;
}
report.put("runSummary", JSONArray.fromObject(rt.toJSON()));
}
catch (SQLException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
if (!((RunImpl) run).getSequencerPartitionContainers().isEmpty()) {
JSONObject containers = new JSONObject();
for (SequencerPartitionContainer<SequencerPoolPartition> container : ((RunImpl) run).getSequencerPartitionContainers()) {
JSONObject f = new JSONObject();
f.put("idBarcode", container.getIdentificationBarcode());
JSONArray partitions = new JSONArray();
for (SequencerPoolPartition part : container.getPartitions()) {
JSONObject partition = new JSONObject();
map.put(RunProperty.lane, Integer.toString(part.getPartitionNumber()));
try {
rt = reports.getAverageValues(map);
if (rt != null) {
partition.put("partitionSummary", JSONArray.fromObject(rt.toJSON()));
}
}
catch (SQLException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
//clear any previous barcode query
map.remove(RunProperty.barcode);
if (part.getPool() != null) {
Pool<? extends Poolable> pool = part.getPool();
for (Dilution d : pool.getDilutions()) {
Library l = d.getLibrary();
if (!l.getTagBarcodes().isEmpty()) {
for (TagBarcode tb : l.getTagBarcodes().values()) {
map.remove(RunProperty.barcode);
try {
map.put(RunProperty.barcode, tb.getSequence());
rt = reports.getAverageValues(map);
if (rt != null) {
partition.put(tb.getSequence(), JSONArray.fromObject(rt.toJSON()));
}
}
catch (SQLException e) {
e.printStackTrace();
}