List of usage examples for java.lang Exception getStackTrace
public StackTraceElement[] getStackTrace()
From source file:base.BasePlayer.FileRead.java
void varCalc() { try {/*from w w w . j a va 2 s. co m*/ /*array = new int[Main.drawCanvas.sampleList.size()][101]; for(int i = 0; i<array.length; i++) { for(int j = 0; j<array[i].length; j++) { array[i][j] = 0; } } */ FileRead.novars = false; boolean isfreeze = VariantHandler.freeze.isSelected(); if (!VariantHandler.none.isSelected()) { SampleDialog.checkFiles(); if (affected == 0) { Main.showError( "Set at least one individual as affected. (click sample name or right click sample sidebar)", "Note"); return; } } else { VariantHandler.freeze.setSelected(true); } contexts = null; //contextQuals = null; Draw.calculateVars = false; Draw.variantcalculator = true; if (VariantHandler.writetofile.isSelected()) { lastWriteVar = FileRead.head; } clearVariantsFromGenes(); SplitClass split = Main.drawCanvas.splits.get(0); int chromcounter = 0; VariantHandler.outputStrings.clear(); if (Main.drawCanvas.clusterNodes == null) { Main.drawCanvas.clusterNodes = new ArrayList<ClusterNode>(); } else { Main.drawCanvas.clusterNodes.clear(); } Main.drawCanvas.clusterId = 1; VariantHandler.table.variants = 0; VariantHandler.stattable.variants = 0; VariantHandler.clusterTable.variants = 0; for (int i = 0; i < VariantHandler.tables.size(); i++) { VariantHandler.tables.get(i).variants = 0; } cancelvarcount = false; VariantHandler.table.genearray.clear(); VariantHandler.table.aminoarray.clear(); VariantHandler.table.controlarray = null; VariantHandler.stattable.sampleArray.clear(); for (int i = 0; i < VariantHandler.tables.size(); i++) { VariantHandler.tables.get(i).bedarray = null; VariantHandler.tables.get(i).aminoarray = null; VariantHandler.tables.get(i).vararray = null; VariantHandler.tables.get(i).controlarray = null; VariantHandler.tables.get(i).variants = 0; } VarNode vardraw = Main.drawCanvas.current; Object[] addobject; for (int i = 0; i < Main.drawCanvas.sampleList.size(); i++) { if (Main.drawCanvas.sampleList.get(i).multiVCF || (Main.drawCanvas.sampleList.get(i).getTabixFile() == null && !Main.drawCanvas.sampleList.get(i).multipart) && (FileRead.caller && Main.drawCanvas.sampleList.get(i).samFile == null) && !Main.drawCanvas.sampleList.get(i).calledvariants) { continue; } addobject = new Object[VariantHandler.stattable.headerlengths.length]; addobject[0] = Main.drawCanvas.sampleList.get(i); for (int j = 1; j < addobject.length; j++) { addobject[j] = 0; } Main.drawCanvas.sampleList.get(i).mutationTypes = new double[6]; for (int j = 0; j < 6; j++) { Main.drawCanvas.sampleList.get(i).mutationTypes[j] = 0.0; } VariantHandler.stattable.sampleArray.add(addobject); Main.drawCanvas.sampleList.get(i).heterozygotes = 0; Main.drawCanvas.sampleList.get(i).homozygotes = 0; Main.drawCanvas.sampleList.get(i).varcount = 0; Main.drawCanvas.sampleList.get(i).indels = 0; Main.drawCanvas.sampleList.get(i).snvs = 0; Main.drawCanvas.sampleList.get(i).sitioRate = 0; Main.drawCanvas.sampleList.get(i).versioRate = 0; Main.drawCanvas.sampleList.get(i).ins = 0; Main.drawCanvas.sampleList.get(i).callrates = 0.0; Main.drawCanvas.sampleList.get(i).coding = 0; Main.drawCanvas.sampleList.get(i).syn = 0; Main.drawCanvas.sampleList.get(i).nonsyn = 0; Main.drawCanvas.sampleList.get(i).missense = 0; Main.drawCanvas.sampleList.get(i).splice = 0; Main.drawCanvas.sampleList.get(i).nonsense = 0; Main.drawCanvas.sampleList.get(i).fshift = 0; Main.drawCanvas.sampleList.get(i).inframe = 0; } VariantHandler.stattable.setPreferredSize(new Dimension( VariantHandler.statsScroll.getViewport().getWidth(), (VariantHandler.stattable.sampleArray.size() + 1) * VariantHandler.stattable.rowHeight)); VariantHandler.stattable.revalidate(); VariantHandler.stattable.repaint(); for (int g = 0; g < split.getGenes().size(); g++) { split.getGenes().get(g).mutations = 0; split.getGenes().get(g).missense = 0; split.getGenes().get(g).nonsense = 0; split.getGenes().get(g).synonymous = 0; split.getGenes().get(g).intronic = 0; split.getGenes().get(g).utr = 0; split.getGenes().get(g).samples.clear(); split.getGenes().get(g).varnodes.clear(); split.getGenes().get(g).intergenic = false; split.getGenes().get(g).transcriptString = new StringBuffer(); } if (VariantHandler.allChroms.isSelected() && !VariantHandler.xLinked.isSelected()) { for (int i = 0; i < Main.bedCanvas.bedTrack.size(); i++) { if (Main.bedCanvas.bedTrack.get(i).getVarcalc().isSelected()) { Main.bedCanvas.bedTrack.get(i).intersect = true; } } if (VariantHandler.allChromsfrom.isSelected()) { chromcounter = Main.chromosomeDropdown.getSelectedIndex(); Main.nothread = true; Main.chromosomeDropdown.setSelectedIndex(Main.chromosomeDropdown.getSelectedIndex()); Main.nothread = false; vardraw = FileRead.head.getNext(); Main.drawCanvas.clusterNodes.clear(); Main.drawCanvas.calcClusters(FileRead.head.getNext()); } else if (Main.drawCanvas.splits.get(0).start != 1 || Main.chromosomeDropdown.getSelectedIndex() != 0) { Main.nothread = true; Main.chromosomeDropdown.setSelectedIndex(0); Main.nothread = false; vardraw = FileRead.head.getNext(); Main.drawCanvas.clusterNodes.clear(); Main.drawCanvas.calcClusters(FileRead.head.getNext()); } else { vardraw = FileRead.head.getNext(); Main.drawCanvas.clusterNodes.clear(); Main.drawCanvas.calcClusters(FileRead.head.getNext()); } } else { if (VariantHandler.xLinked.isSelected()) { if (Main.chromModel.getIndexOf("X") != -1) { if (Main.drawCanvas.splits.get(0).start != 1 || Main.chromosomeDropdown.getSelectedIndex() != 0) { Main.nothread = true; Main.chromosomeDropdown.setSelectedItem("X"); Main.nothread = false; vardraw = FileRead.head.getNext(); Main.drawCanvas.clusterNodes.clear(); Main.drawCanvas.calcClusters(FileRead.head.getNext()); } } else { JOptionPane.showMessageDialog(Main.drawScroll, "No chromosome X available.", "Note", JOptionPane.INFORMATION_MESSAGE); return; } } for (int i = 0; i < Main.bedCanvas.bedTrack.size(); i++) { if (Main.bedCanvas.bedTrack.get(i).getVarcalc().isSelected()) { Main.bedCanvas.bedTrack.get(i).intersect = true; if (Main.bedCanvas.bedTrack.get(i).small && !Main.bedCanvas.bedTrack.get(i).bigWig) { Main.bedCanvas.annotate(Main.bedCanvas.bedTrack.get(i).getHead(), FileRead.head.getNext()); Main.bedCanvas.intersected = true; } else { BedCanvas.Annotator annotator = Main.bedCanvas.new Annotator( Main.bedCanvas.bedTrack.get(i)); annotator.annotateVars(); Main.bedCanvas.intersected = true; } } } } if (caller && varc == null) { varc = new VariantCaller(true); varcal = varc.new VarCaller(); } Main.drawCanvas.loadbarAll = 0; Main.drawCanvas.loadBarSample = 0; if (caller && FileRead.head.getNext() == null) { varcal.callVariants(); vardraw = FileRead.head.getNext(); } while (true) { if (cancelvarcount || !Main.drawCanvas.loading) { cancelFileRead(); vardraw = null; break; } if (vardraw == null) { if (VariantHandler.writetofile.isSelected()) { for (int i = 0; i < VariantHandler.table.genearray.size(); i++) { VariantHandler.writeTranscriptToFile(VariantHandler.table.genearray.get(i), output); } FileRead.lastpos = 0; Main.drawCanvas.clusterNodes.clear(); } VariantHandler.table .setPreferredSize(new Dimension(VariantHandler.tableScroll.getViewport().getWidth(), (VariantHandler.table.getTableSize() + 1) * (VariantHandler.table.rowHeight))); if (VariantHandler.tabs.getSelectedIndex() == 0) { VariantHandler.aminoCount.setText(VariantHandler.table.variants + " variants"); } else if (VariantHandler.tabs.getSelectedIndex() == 1) { VariantHandler.aminoCount.setText(VariantHandler.stattable.variants + " variants"); } else if (VariantHandler.tabs.getSelectedIndex() == 2) { VariantHandler.aminoCount.setText(VariantHandler.clusterTable.variants + " variants"); } else { VariantHandler.aminoCount.setText( VariantHandler.tables.get(VariantHandler.tabs.getSelectedIndex() - 3).variants + " variants"); } VariantHandler.table.revalidate(); VariantHandler.table.repaint(); try { if (VariantHandler.commonSlider.getValue() > 1 && VariantHandler.clusterSize > 0) { VariantHandler.clusterTable.setPreferredSize( new Dimension(VariantHandler.tableScroll.getViewport().getWidth(), (Main.drawCanvas.clusterNodes.size() + 1) * VariantHandler.clusterTable.rowHeight)); VariantHandler.clusterTable.revalidate(); VariantHandler.clusterTable.repaint(); } for (int i = 0; i < VariantHandler.stattable.sampleArray.size(); i++) { sample = (Sample) VariantHandler.stattable.sampleArray.get(i)[0]; VariantHandler.stattable.sampleArray.get(i)[1] = sample.varcount; VariantHandler.stattable.sampleArray.get(i)[2] = sample.snvs; VariantHandler.stattable.sampleArray.get(i)[3] = sample.indels; VariantHandler.stattable.sampleArray.get(i)[4] = sample.ins; VariantHandler.stattable.sampleArray.get(i)[5] = sample.coding; VariantHandler.stattable.sampleArray.get(i)[6] = MethodLibrary .round(sample.heterozygotes / (double) sample.homozygotes, 2); VariantHandler.stattable.sampleArray.get(i)[7] = MethodLibrary .round((int) sample.sitioRate / (double) sample.versioRate, 2); for (int j = 0; j < 6; j++) { VariantHandler.stattable.sampleArray.get(i)[8 + j] = MethodLibrary .round(sample.mutationTypes[j] / (double) sample.snvs, 2); } VariantHandler.stattable.sampleArray.get(i)[14] = MethodLibrary .round(sample.callrates / (double) sample.varcount, 2); VariantHandler.stattable.repaint(); } } catch (Exception e) { e.printStackTrace(); } if (VariantHandler.allChroms.isSelected() && !VariantHandler.xLinked.isSelected()) { for (int i = 0; i < Main.bedCanvas.bedTrack.size(); i++) { removeNonListBeds(Main.bedCanvas.bedTrack.get(i).getHead(), Main.drawCanvas.splits.get(0).chromEnd); } if (VariantHandler.writetofile.isSelected()) { FileRead.head.putNext(null); nullifyVarNodes(); clearVariantsFromGenes(); } if (cancelvarcount || !Main.drawCanvas.loading) { cancelFileRead(); break; } FileRead.lastpos = 0; if (chromcounter < Main.chromosomeDropdown.getItemCount()) { chromcounter++; if (chromcounter == Main.chromosomeDropdown.getItemCount()) {// || Main.chromosomeDropdown.getItemAt(chromcounter).toString().contains("X")) { break; } if (VariantHandler.onlyAutosomes.isSelected()) { if (Main.chromosomeDropdown.getItemAt(chromcounter).toString().equals("X") || Main.chromosomeDropdown.getItemAt(chromcounter).toString().equals("Y")) { break; } } Main.nothread = true; Main.chromosomeDropdown.setSelectedIndex(chromcounter); Main.nothread = false; if (nobeds) { continue; } for (int g = 0; g < split.getGenes().size(); g++) { split.getGenes().get(g).mutations = 0; split.getGenes().get(g).missense = 0; split.getGenes().get(g).nonsense = 0; split.getGenes().get(g).synonymous = 0; split.getGenes().get(g).intronic = 0; split.getGenes().get(g).utr = 0; split.getGenes().get(g).samples.clear(); split.getGenes().get(g).varnodes.clear(); split.getGenes().get(g).intergenic = false; split.getGenes().get(g).transcriptString = new StringBuffer(); } if (caller) { varcal.callVariants(); } Main.drawCanvas.calcClusters(FileRead.head.getNext()); vardraw = FileRead.head.getNext(); FileRead.head.putNext(null); if (vardraw == null) { continue; } if (lastVar == null) { lastVar = FileRead.head; } if (lastWriteVar == null) { lastWriteVar = FileRead.head; } vardraw.putPrev(lastVar); lastVar.putNext(vardraw); } else { Main.drawCanvas.ready("all"); break; } } else { break; } } try { if (!VariantHandler.allChroms.isSelected()) { if (vardraw != null && vardraw.getPosition() < Main.drawCanvas.splits.get(0).start) { vardraw = vardraw.getNext(); continue; } if (vardraw == null || vardraw.getPosition() > Main.drawCanvas.splits.get(0).end) { vardraw = null; continue; } } //STATS vardraw = annotateVariant(vardraw); } catch (Exception ex) { ErrorLog.addError(ex.getStackTrace()); ex.printStackTrace(); } } nullifyVarNodes(); vardraw = null; Draw.calculateVars = true; Draw.updatevars = true; VariantHandler.table.revalidate(); VariantHandler.table.repaint(); for (int i = 0; i < VariantHandler.tables.size(); i++) { VariantHandler.tables.get(i) .setPreferredSize(new Dimension(VariantHandler.tableScroll.getViewport().getWidth(), (VariantHandler.tables.get(i).getTableSize() + 1) * (VariantHandler.tables.get(i).rowHeight))); VariantHandler.tables.get(i).revalidate(); VariantHandler.tables.get(i).repaint(); } VariantHandler.clusterTable.setPreferredSize(new Dimension( VariantHandler.tableScroll.getViewport().getWidth(), (VariantHandler.clusterTable.getTableSize() + 1) * (VariantHandler.clusterTable.rowHeight))); VariantHandler.clusterTable.revalidate(); VariantHandler.clusterTable.repaint(); VariantHandler.clusterTable.repaint(); VariantHandler.table.setPreferredSize(new Dimension(VariantHandler.tableScroll.getViewport().getWidth(), (VariantHandler.table.getTableSize() + 1) * (VariantHandler.table.rowHeight))); if (VariantHandler.tabs.getSelectedIndex() == 0) { VariantHandler.aminoCount.setText(VariantHandler.table.variants + " variants"); } else if (VariantHandler.tabs.getSelectedIndex() == 1) { VariantHandler.aminoCount.setText(VariantHandler.stattable.variants + " variants"); } else if (VariantHandler.tabs.getSelectedIndex() == 2) { VariantHandler.aminoCount.setText(VariantHandler.clusterTable.variants + " variants"); } else { VariantHandler.aminoCount .setText(VariantHandler.tables.get(VariantHandler.tabs.getSelectedIndex() - 3).variants + " variants"); } try { if (output != null) { if (VariantHandler.onlyStats.isSelected() && VariantHandler.outputContexts.isSelected()) { for (int i = 0; i < VariantHandler.stattable.sampleArray.size(); i++) { sample = (Sample) VariantHandler.stattable.sampleArray.get(i)[0]; output.write(sample.getName()); for (int j = 1; j < VariantHandler.stattable.headerlengths.length; j++) { output.write("\t" + VariantHandler.stattable.sampleArray.get(i)[j]); } output.write("\t" + sample.syn + "\t" + sample.nonsyn + "\t" + sample.missense + "\t" + sample.splice + "\t" + sample.nonsense + "\t" + sample.fshift + "\t" + sample.inframe); output.write(Main.lineseparator); } if (contexts != null) { /*Iterator<Entry<String, Float[]>> iterQuals = contextQuals.entrySet().iterator(); while(iterQuals.hasNext()) { Entry<String, Float[]> entry = iterQuals.next(); Float[] values = entry.getValue(); } */ Iterator<Entry<String, Integer[]>> iter = contexts.entrySet().iterator(); sigOutput.write("#mutType"); for (int i = 0; i < Main.drawCanvas.sampleList.size(); i++) { if (!Main.drawCanvas.sampleList.get(i).multiVCF && !Main.drawCanvas.sampleList.get(i).removed) { sigOutput.write("\t" + Main.drawCanvas.sampleList.get(i).getName()); } } sigOutput.write("\n"); //Main.lineseparator);Main.lineseparator); while (iter.hasNext()) { Entry<String, Integer[]> entry = iter.next(); Integer[] samples = entry.getValue(); sigOutput.write(entry.getKey().substring(1) + ">" + entry.getKey().charAt(1) + entry.getKey().charAt(0) + entry.getKey().charAt(3)); for (int i = 0; i < Main.drawCanvas.sampleList.size(); i++) { if (!Main.drawCanvas.sampleList.get(i).multiVCF && !Main.drawCanvas.sampleList.get(i).removed) { if (samples[i] == null) { sigOutput.write("\t0"); } else { sigOutput.write("\t" + samples[i]); } } } sigOutput.write("\n"); //Main.lineseparator); } sigOutput.close(); } } output.close(); } if (outputgz != null) { for (int i = 0; i < VariantHandler.outputStrings.size(); i++) { outputgz.write(VariantHandler.outputStrings.get(i).getBytes()); Feature vcf = VariantHandler.vcfCodec.decode(VariantHandler.outputStrings.get(i)); FileRead.indexCreator.addFeature(vcf, FileRead.filepointer); FileRead.filepointer = outputgz.getFilePointer(); } VariantHandler.outputStrings.clear(); outputgz.flush(); Index index = indexCreator.finalizeIndex(outputgz.getFilePointer()); index.writeBasedOnFeatureFile(outFile); outputgz.close(); } } catch (Exception e) { e.printStackTrace(); } split = null; if (!isfreeze) { VariantHandler.freeze.setSelected(false); } Main.drawCanvas.ready("all"); if (!Main.drawCanvas.loading) { Draw.calculateVars = true; } Draw.variantcalculator = false; Main.drawCanvas.loadbarAll = 0; Main.drawCanvas.loadBarSample = 0; if (VariantHandler.allChroms.isSelected()) { Main.showError("Variant annotation ready!", "Note"); } } catch (Exception e) { e.printStackTrace(); } /*if(contexts != null) { Iterator<Entry<String, Integer[]>> iter = contexts.entrySet().iterator(); System.out.print("#mutType"); for(int i = 0 ; i<Main.samples; i++) { if(!Main.drawCanvas.sampleList.get(i).multiVCF) { System.out.print("\t" +Main.drawCanvas.sampleList.get(i).getName()); } } System.out.println(); while(iter.hasNext()) { Entry<String, Integer[]> entry = iter.next(); Integer[] samples = entry.getValue(); System.out.print(entry.getKey().substring(1)+">" +entry.getKey().charAt(1) +entry.getKey().charAt(0) +entry.getKey().charAt(3)); for(int i = 0; i<samples.length; i++) { if(!Main.drawCanvas.sampleList.get(i).multiVCF) { if(samples[i] == null) { System.out.print("\t0"); } else { System.out.print("\t" +samples[i]); } } } System.out.println(); } }*/ //boolean found = false; /* StringBuffer copy = new StringBuffer(""); Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); String type = ""; for(int i = 0 ; i<VariantHandler.table.genearray.size(); i++) { if(VariantHandler.table.genearray.get(i).getName().equals(Main.searchField.getText().trim().toUpperCase())) { for(int j = 0; j<Main.drawCanvas.sampleList.size(); j++) { if(Main.drawCanvas.sampleList.get(j).multiVCF) { continue; } found = false; for(int s = 0; s < VariantHandler.table.genearray.get(i).samples.size(); s++) { if(VariantHandler.table.genearray.get(i).samples.get(s).getName().equals(Main.drawCanvas.sampleList.get(j).getName())) { found = true; break; } } if(found) { if(Main.drawCanvas.sampleList.get(j).fshift > 0) { type = "frameshift"; } else if(Main.drawCanvas.sampleList.get(j).nonsense > 0) { type = "nonsense"; } else if(Main.drawCanvas.sampleList.get(j).inframe > 0) { type = "inframe"; } else if(Main.drawCanvas.sampleList.get(j).splice > 0) { type = "splice"; } else if(Main.drawCanvas.sampleList.get(j).missense > 0) { type = "missense"; } else if(Main.drawCanvas.sampleList.get(j).syn > 0) { type = "synonymous"; } else { System.out.println(Main.drawCanvas.sampleList.get(j).getName() +" " +VariantHandler.table.genearray.get(i).getName()); } copy.append(Main.drawCanvas.sampleList.get(j).getName() +"\t" +type +"\n" ); } else { copy.append(Main.drawCanvas.sampleList.get(j).getName() +"\t0\n" ); } } break; } } StringSelection stringSelection= new StringSelection(copy.toString()); clpbrd.setContents(stringSelection, null);*/ }
From source file:it.eng.spagobi.engines.chart.bo.ChartImpl.java
/** * configureChart reads the content of the template and sets the chart parameters. * /*from w ww. ja v a 2s . c o m*/ * @param content the content */ public void configureChart(SourceBean content) { logger.debug("IN"); // common part for all charts //setting the title with parameter values if is necessary if (content.getAttribute(NAME) != null) { String titleChart = (String) content.getAttribute(NAME); String tmpTitle = titleChart; while (!tmpTitle.equals("")) { if (tmpTitle.indexOf("$P{") >= 0) { String parName = tmpTitle.substring(tmpTitle.indexOf("$P{") + 3, tmpTitle.indexOf("}")); String parValue = (parametersObject.get(parName) == null) ? "" : (String) parametersObject.get(parName); parValue = parValue.replaceAll("\'", ""); if (parValue.equals("%")) parValue = ""; int pos = tmpTitle.indexOf("$P{" + parName + "}") + (parName.length() + 4); titleChart = titleChart.replace("$P{" + parName + "}", parValue); tmpTitle = tmpTitle.substring(pos); } else tmpTitle = ""; } setName(titleChart); } else setName(""); SourceBean styleTitleSB = (SourceBean) content.getAttribute(STYLE_TITLE); if (styleTitleSB != null) { String fontS = (String) styleTitleSB.getAttribute(FONT_STYLE); String sizeS = (String) styleTitleSB.getAttribute(SIZE_STYLE); String colorS = (String) styleTitleSB.getAttribute(COLOR_STYLE); try { Color color = Color.decode(colorS); int size = Integer.valueOf(sizeS).intValue(); styleTitle = new StyleLabel(fontS, size, color); } catch (Exception e) { logger.error("Wrong style Title settings, use default"); } } SourceBean styleSubTitleSB = (SourceBean) content.getAttribute(STYLE_SUBTITLE); if (styleSubTitleSB != null) { String subTitle = (String) styleSubTitleSB.getAttribute(NAME_STYLE); if (subTitle != null) { String tmpSubTitle = subTitle; while (!tmpSubTitle.equals("")) { if (tmpSubTitle.indexOf("$P{") >= 0) { String parName = tmpSubTitle.substring(tmpSubTitle.indexOf("$P{") + 3, tmpSubTitle.indexOf("}")); String parValue = (parametersObject.get(parName) == null) ? "" : (String) parametersObject.get(parName); parValue = parValue.replaceAll("\'", ""); if (parValue.equals("%")) parValue = ""; int pos = tmpSubTitle.indexOf("$P{" + parName + "}") + (parName.length() + 4); subTitle = subTitle.replace("$P{" + parName + "}", parValue); tmpSubTitle = tmpSubTitle.substring(pos); } else tmpSubTitle = ""; } setSubName(subTitle); } else setSubName(""); String fontS = (String) styleSubTitleSB.getAttribute(FONT_STYLE); String sizeS = (String) styleSubTitleSB.getAttribute(SIZE_STYLE); String colorS = (String) styleSubTitleSB.getAttribute(COLOR_STYLE); try { Color color = Color.decode(colorS); int size = Integer.valueOf(sizeS).intValue(); styleSubTitle = new StyleLabel(fontS, size, color); } catch (Exception e) { logger.error("Wrong style SubTitle settings, use default"); } } SourceBean styleLabelsSB = (SourceBean) content.getAttribute(STYLE_LABELS_DEFAULT); if (styleLabelsSB != null) { String fontS = (String) styleLabelsSB.getAttribute(FONT_STYLE); if (fontS == null) { fontS = "Arial"; } String sizeS = (String) styleLabelsSB.getAttribute(SIZE_STYLE); if (sizeS == null) { sizeS = "12"; } String colorS = (String) styleLabelsSB.getAttribute(COLOR_STYLE); if (colorS == null) { colorS = "#000000"; } String orientationS = (String) styleLabelsSB.getAttribute(ORIENTATION_STYLE); if (orientationS == null) { orientationS = "horizontal"; } try { Color color = Color.decode(colorS); int size = Integer.valueOf(sizeS).intValue(); defaultLabelsStyle = new StyleLabel(fontS, size, color, orientationS); } catch (Exception e) { logger.error("Wrong style labels settings, use default"); } } else { defaultLabelsStyle = new StyleLabel("Arial", 12, Color.BLACK); } if (content.getAttribute("title_dimension") != null) { String titleD = ((String) content.getAttribute(TITLE_DIMENSION)); titleDimension = Integer.valueOf(titleD).intValue(); } else setTitleDimension(18); String colS = (String) content.getAttribute(COLORS_BACKGROUND); if (colS != null) { Color col = new Color(Integer.decode(colS).intValue()); if (col != null) { setColor(col); } else { setColor(Color.white); } } else { setColor(Color.white); } String widthS = (String) content.getAttribute(DIMENSION_WIDTH); String heightS = (String) content.getAttribute(DIMENSION_HEIGHT); if (widthS == null || heightS == null) { logger.warn("Width or height non defined, use default ones"); widthS = "400"; heightS = "300"; } width = Integer.valueOf(widthS).intValue(); height = Integer.valueOf(heightS).intValue(); // get all the data parameters try { Map dataParameters = new HashMap(); SourceBean dataSB = (SourceBean) content.getAttribute(CONF); List dataAttrsList = dataSB.getContainedSourceBeanAttributes(); Iterator dataAttrsIter = dataAttrsList.iterator(); while (dataAttrsIter.hasNext()) { SourceBeanAttribute paramSBA = (SourceBeanAttribute) dataAttrsIter.next(); SourceBean param = (SourceBean) paramSBA.getValue(); String nameParam = (String) param.getAttribute("name"); String valueParam = (String) param.getAttribute("value"); dataParameters.put(nameParam, valueParam); } if (dataParameters.get(CONF_DATASET) != null && !(((String) dataParameters.get(CONF_DATASET)).equalsIgnoreCase(""))) { confDataset = (String) dataParameters.get(CONF_DATASET); isLovConfDefined = true; } else { isLovConfDefined = false; } legend = true; if (dataParameters.get(LEGEND) != null && !(((String) dataParameters.get(LEGEND)).equalsIgnoreCase(""))) { String leg = (String) dataParameters.get(LEGEND); if (leg.equalsIgnoreCase("false")) legend = false; } legendPosition = "bottom"; if (dataParameters.get(LEGEND_POSITION) != null && !(((String) dataParameters.get(LEGEND_POSITION)).equalsIgnoreCase(""))) { String leg = (String) dataParameters.get(LEGEND_POSITION); if (leg.equalsIgnoreCase("bottom") || leg.equalsIgnoreCase("left") || leg.equalsIgnoreCase("right") || leg.equalsIgnoreCase("top")) legendPosition = leg; } filter = true; if (dataParameters.get(VIEW_FILTER) != null && !(((String) dataParameters.get(VIEW_FILTER)).equalsIgnoreCase(""))) { String fil = (String) dataParameters.get(VIEW_FILTER); if (fil.equalsIgnoreCase("false")) filter = false; } slider = true; if (dataParameters.get(VIEW_SLIDER) != null && !(((String) dataParameters.get(VIEW_SLIDER)).equalsIgnoreCase(""))) { String sli = (String) dataParameters.get(VIEW_SLIDER); if (sli.equalsIgnoreCase("false")) slider = false; } sliderStartFromEnd = false; if (dataParameters.get(SLIDER_START_FROM_END) != null && !(((String) dataParameters.get(SLIDER_START_FROM_END)).equalsIgnoreCase(""))) { String sli = (String) dataParameters.get(SLIDER_START_FROM_END); if (sli.equalsIgnoreCase("true")) sliderStartFromEnd = true; } positionSlider = "top"; if (dataParameters.get(POSITION_SLIDER) != null && !(((String) dataParameters.get(POSITION_SLIDER)).equalsIgnoreCase(""))) { positionSlider = (String) dataParameters.get(POSITION_SLIDER); } //reading series orders if present SourceBean sbSerieLabels = (SourceBean) content.getAttribute(SERIES_LABELS); // back compatibility if (sbSerieLabels == null) { sbSerieLabels = (SourceBean) content.getAttribute("CONF.SERIES_LABELS"); } if (sbSerieLabels != null) { seriesLabelsMap = new LinkedHashMap(); List atts = sbSerieLabels.getContainedAttributes(); String serieLabel = ""; for (Iterator iterator = atts.iterator(); iterator.hasNext();) { SourceBeanAttribute object = (SourceBeanAttribute) iterator.next(); String serieName = (String) object.getKey(); serieLabel = new String((String) object.getValue()); if (serieLabel != null) { seriesLabelsMap.put(serieName, serieLabel); } } } SourceBean styleLegendSB = (SourceBean) content.getAttribute(LEGEND_STYLE); if (styleLegendSB != null) { String fontS = (String) styleLegendSB.getAttribute(FONT_STYLE); String sizeS = (String) styleLegendSB.getAttribute(SIZE_STYLE); String colorS = (String) styleLegendSB.getAttribute(COLOR_STYLE); try { Color color = Color.decode(colorS); int size = Integer.valueOf(sizeS).intValue(); styleLegend = new StyleLabel(fontS, size, color); } catch (Exception e) { logger.error("Wrong style Legend settings, use default"); } } } catch (Exception e) { logger.error(e.getCause() + " " + e.getStackTrace()); logger.error("many error in reading data source parameters", e); } }
From source file:v800_trainer.JCicloTronic.java
private void ExtractCSV(byte[] Data) { int Filezeiger = 0; int AnzahlBloecke = 0; int Intervall = 0; int Block;//from w w w . j a v a 2 s .c o m int i, j; String Dummy; String DataString = new String(Data); float Stunden; float Minuten; float Sekunden; int Zeitpunkt; long RR_Zeit; int Ausgangshoehe; int Startkilometer; int Start_HF; int Akt_Hoehe; int Akt_HF; double Distanz = 0; double Rest; int Strecke; int Cadence; int Schrittlnge; float Temperatur; double Geschw; int gef_Zeit; int alt_Zeitpunkt; int alt_Hoehe; boolean speed = false; boolean cadence = false; boolean alti = false; boolean unit = false; boolean exit = false; boolean RR = false; boolean skip = false; short Daten1, Daten2, Daten3, Daten4, Daten5; File file = new File("Dummy"); DataProperty = new java.util.Properties(); Buffer = new StringBuffer(); StringBuffer BufferString; format = new java.text.DecimalFormat("0000000"); formatneg = new java.text.DecimalFormat("000000"); DataProperty.setProperty("Computer", "Polar_V/M_Serie"); Filezeiger = DataString.indexOf("VO2max") + "VO2max".length() + 2; //Start der Daten im CSV; +2 wegen \n DataProperty.setProperty("Vorname", DataString.substring(Filezeiger, DataString.indexOf(" ", Filezeiger))); Filezeiger = DataString.indexOf(" ", Filezeiger) + 1; DataProperty.setProperty("Name", DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger))); Filezeiger = DataString.indexOf(",", Filezeiger) + 1; DataProperty.setProperty("Typ", DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger))); Filezeiger = DataString.indexOf(",", Filezeiger) + 1; DataProperty.setProperty("Jahr", DataString.substring(Filezeiger + 6, Filezeiger + 10)); DataProperty.setProperty("Monat", DataString.substring(Filezeiger + 3, Filezeiger + 5)); DataProperty.setProperty("Tag", DataString.substring(Filezeiger + 0, Filezeiger + 2)); Filezeiger = DataString.indexOf(",", Filezeiger) + 1; DataProperty.setProperty("Stunde", DataString.substring(Filezeiger + 0, Filezeiger + 2)); DataProperty.setProperty("Minute", DataString.substring(Filezeiger + 3, Filezeiger + 5)); DataProperty.setProperty("Sekunde", DataString.substring(Filezeiger + 6, Filezeiger + 8)); Filezeiger = DataString.indexOf(",", Filezeiger) + 1; // Dauer berspringen Filezeiger = DataString.indexOf(",", Filezeiger) + 1; if (!DataString.substring(Filezeiger, Filezeiger + 1).equalsIgnoreCase(",")) { DataProperty.setProperty("Strecke", DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger))); } Filezeiger = DataString.indexOf(",", Filezeiger) + 1; // Filezeiger = DataString.indexOf(",", Filezeiger+1)+1; //durchschnittliche HF berspringen Filezeiger = DataString.indexOf(",", Filezeiger) + 1; //Durchschnittsgeschwindigketi berspringen Filezeiger = DataString.indexOf(",", Filezeiger) + 1; //maximale Geschwindigkeit berspringen Filezeiger = DataString.indexOf(",", Filezeiger) + 1; //maximale pace und durchschnitts pace berspringen Filezeiger = DataString.indexOf(",", Filezeiger) + 1; Filezeiger = DataString.indexOf(",", Filezeiger) + 1; if (!DataString.substring(Filezeiger, Filezeiger + 1).equalsIgnoreCase(",")) { DataProperty.setProperty("Kalorien", DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger))); } Filezeiger = DataString.indexOf(",", Filezeiger) + 1; if (!DataString.substring(Filezeiger, Filezeiger + 1).equalsIgnoreCase(",")) { DataProperty.setProperty("Fett", DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger))); } Filezeiger = DataString.indexOf(",", Filezeiger) + 1; //durchschnittliche Cadence berspringen Filezeiger = DataString.indexOf(",", Filezeiger) + 1; //durchschnittliche Schrittlnge berspringen Filezeiger = DataString.indexOf(",", Filezeiger) + 1; if (!DataString.substring(Filezeiger, Filezeiger + 1).equalsIgnoreCase(",")) { DataProperty.setProperty("Running-Index", DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger))); } Filezeiger = DataString.indexOf(",", Filezeiger) + 1; if (!DataString.substring(Filezeiger, Filezeiger + 1).equalsIgnoreCase(",")) { DataProperty.setProperty("Belastung", DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger))); } Filezeiger = DataString.indexOf(",", Filezeiger) + 1; //Anstieg berspringen Filezeiger = DataString.indexOf(",", Filezeiger) + 1; //Abstieg berspringen Filezeiger = DataString.indexOf(",", Filezeiger) + 1; //Notiz berspringen Filezeiger = DataString.indexOf(",", Filezeiger) + 1; if (!DataString.substring(Filezeiger, Filezeiger + 1).equalsIgnoreCase(",")) { DataProperty.setProperty("Gre", DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger))); } Filezeiger = DataString.indexOf(",", Filezeiger) + 1; if (!DataString.substring(Filezeiger, Filezeiger + 1).equalsIgnoreCase(",")) { DataProperty.setProperty("Gewicht", DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger))); } Filezeiger = DataString.indexOf(",", Filezeiger) + 1; if (!DataString.substring(Filezeiger, Filezeiger + 1).equalsIgnoreCase(",")) { DataProperty.setProperty("obere Hf", DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger))); } Filezeiger = DataString.indexOf(",", Filezeiger) + 1; if (!DataString.substring(Filezeiger, Filezeiger + 1).equalsIgnoreCase(",")) { DataProperty.setProperty("untere Hf", DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger))); } Filezeiger = DataString.indexOf(",", Filezeiger) + 1; if (!DataString.substring(Filezeiger, Filezeiger + 1).equalsIgnoreCase(",")) { DataProperty.setProperty("vo2max", DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger))); } Filezeiger = DataString.indexOf(",", Filezeiger) + 1; for (i = 0; i < 11; i++) { Filezeiger = DataString.indexOf(",", Filezeiger) + 1; } Filezeiger++; //\n berspringen // String d = DataString.substring(Filezeiger, // DataString.indexOf(",", Filezeiger)); Intervall = Integer.parseInt(DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger))); Filezeiger = DataString.indexOf(",", Filezeiger) + 1; // Handling LapDaten offen AnzahlBloecke = 0; Zeitpunkt = 0; Strecke = 0; Rest = 0; Akt_Hoehe = 0; Cadence = 0; Akt_HF = 0; Geschw = 0; Schrittlnge = 0; Temperatur = 0; BufferString = new StringBuffer(); try { while (Filezeiger != -1 && Filezeiger < Data.length) { AnzahlBloecke++; exit = false; //Zeitpunkt berspringen Filezeiger++; //erstes Komma berspringen //Zeitpunkt berspringen Filezeiger = DataString.indexOf(",", Filezeiger) + 1; if (!DataString.substring(Filezeiger, Filezeiger + 1).equalsIgnoreCase(",")) { Akt_HF = Integer .parseInt(DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger))); } Filezeiger = DataString.indexOf(",", Filezeiger) + 1; if (!DataString.substring(Filezeiger, Filezeiger + 1).equalsIgnoreCase(",")) { Geschw = Double .parseDouble(DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger))); } Filezeiger = DataString.indexOf(",", Filezeiger) + 1; //pace berspringen Filezeiger = DataString.indexOf(",", Filezeiger) + 1; if (!DataString.substring(Filezeiger, Filezeiger + 1).equalsIgnoreCase(",")) { Cadence = Integer .parseInt(DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger))); } Filezeiger = DataString.indexOf(",", Filezeiger) + 1; if (!DataString.substring(Filezeiger, Filezeiger + 1).equalsIgnoreCase(",")) { Akt_Hoehe = Integer .parseInt(DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger))); } Filezeiger = DataString.indexOf(",", Filezeiger) + 1; if (!DataString.substring(Filezeiger, Filezeiger + 1).equalsIgnoreCase(",")) { Schrittlnge = Integer .parseInt(DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger))); } Filezeiger = DataString.indexOf(",", Filezeiger) + 1; if (!DataString.substring(Filezeiger, Filezeiger + 1).equalsIgnoreCase(",")) { Strecke = (int) (Float .parseFloat(DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger)))); } Filezeiger = DataString.indexOf(",", Filezeiger) + 1; if (!DataString.substring(Filezeiger, Filezeiger + 1).equalsIgnoreCase(",")) { Temperatur = Float .parseFloat(DataString.substring(Filezeiger, DataString.indexOf(",", Filezeiger))); } Filezeiger = DataString.indexOf(",", Filezeiger) + 1; //Power berspringen Filezeiger = DataString.indexOf(",", Filezeiger) + 1; Filezeiger++; //\n berspringen BufferString = BufferString.append(format.format(Zeitpunkt)).append('\t') .append(format.format(Strecke)).append('\t'); if (Akt_Hoehe < 0) { BufferString = BufferString.append(formatneg.format(Akt_Hoehe * 10)).append('\t'); } else { BufferString = BufferString.append(format.format(Akt_Hoehe * 10)).append('\t'); } if (Akt_HF < 0) { BufferString = BufferString.append(formatneg.format(Akt_HF)).append('\t'); } else { BufferString = BufferString.append(format.format(Akt_HF)).append('\t'); } BufferString = BufferString.append(format.format(Cadence)).append('\t'); BufferString = BufferString.append(format.format(Schrittlnge)).append('\t'); BufferString = BufferString.append(format.format(Geschw * 100)).append('\t'); if (Temperatur >= 0) { BufferString = BufferString.append(format.format(Temperatur * 10)).append('\n'); } else { BufferString = BufferString.append(formatneg.format(Temperatur * 10)).append('\n'); } Zeitpunkt += Intervall; } } catch (Exception e) { JOptionPane.showMessageDialog(null, "Fehler im CSV File", "Achtung!", JOptionPane.ERROR_MESSAGE); } if (BufferString.length() == 0) { JOptionPane.showMessageDialog(null, "Keine Daten im CSV File gefunden", "Achtung!", JOptionPane.ERROR_MESSAGE); return; } file = new File(Properties.getProperty("data.dir", Properties.getProperty("working.dir")) + SystemProperties.getProperty("file.separator") + DataProperty.getProperty("Jahr") + DataProperty.getProperty("Monat") + DataProperty.getProperty("Tag") + DataProperty.getProperty("Stunde") + DataProperty.getProperty("Minute") + "_Tour.txt"); file2 = new File(Properties.getProperty("data.dir", Properties.getProperty("working.dir")) + SystemProperties.getProperty("file.separator") + DataProperty.getProperty("Jahr") + DataProperty.getProperty("Monat") + DataProperty.getProperty("Tag") + DataProperty.getProperty("Stunde") + DataProperty.getProperty("Minute") + "_Tour.cfg"); try { if (file2.exists() == true && Integer.parseInt(Properties.getProperty("Daten ueberschreiben")) == 1 || file2.exists() == false) { Ausgabedatei = new FileOutputStream(file); Ausgabedatei.write(BufferString.toString().getBytes()); Ausgabedatei.close(); } } catch (IOException e) { JOptionPane.showMessageDialog(null, "IO-Fehler bei Speicherung der Tour Datei", "Achtung!", JOptionPane.ERROR_MESSAGE); } try { DataProperty.setProperty("Anzahl Datenpunkte", Integer.toString(AnzahlBloecke)); formatb = new java.text.DecimalFormat("0.00"); DataProperty.setProperty("Strecke", formatb.format(Strecke / (float) 1000.0)); DataProperty.setProperty("Dauer", Integer.toString(Zeitpunkt - Intervall)); boolean neu = false; if ((file2.exists() == true && Properties.getProperty("Daten ueberschreiben", "0").equalsIgnoreCase("1")) || file2.exists() == false) { neu = true; Ausgabedatei = new FileOutputStream(file2); DataProperty.store(Ausgabedatei, "Tour Eigenschaften: " + DataProperty.getProperty("Jahr") + DataProperty.getProperty("Monat") + DataProperty.getProperty("Tag") + DataProperty.getProperty("Stunde") + DataProperty.getProperty("Minute")); Ausgabedatei.close(); // Ermitteln und Abspeichern des Trainingstyps sowie Hhenmeter JTourData Dummydata = new JTourData(file.getPath().substring(0, file.getPath().lastIndexOf('.')), this); DataProperty.setProperty("Hoehenmeter", "" + Dummydata.ges_Hoehep); // if (Dummydata.max_Geschw > 25) { // DataProperty.setProperty("Typ", "Bike"); // } // if (Dummydata.max_Geschw <= 25 && Dummydata.max_Geschw > 1) { // DataProperty.setProperty("Typ", "Jogging"); // } // if (Dummydata.max_Geschw <= 1) { // DataProperty.setProperty("Typ", "Studio"); // } if (neu) { Ausgabedatei = new FileOutputStream(file2); DataProperty.store(Ausgabedatei, "Tour Eigenschaften: " + DataProperty.getProperty("Jahr") + DataProperty.getProperty("Monat") + DataProperty.getProperty("Tag") + DataProperty.getProperty("Stunde") + DataProperty.getProperty("Minute")); Ausgabedatei.close(); } } } catch (Exception e) { JOptionPane.showMessageDialog(null, "IO-Fehler bei Speicherung der cfg Datei \n " + e.getStackTrace(), "Achtung!", JOptionPane.ERROR_MESSAGE); } }
From source file:base.BasePlayer.FileRead.java
public ArrayList<Gene> getExons(String chrom) { ArrayList<Gene> transcriptsTemp = new ArrayList<Gene>(); try {//from w w w . ja v a 2 s . c om if (Main.genomehash.size() == 0 || Main.genomehash.get(Main.defaultGenome).size() == 0) { return new ArrayList<Gene>(); } if (ChromDraw.exonReader != null) { ChromDraw.exonReader.close(); } ChromDraw.exonReader = new TabixReader( Main.genomehash.get(Main.defaultGenome).get(Main.annotation).getCanonicalPath()); if (chrom == null) { return null; } TabixReader.Iterator exonIterator = null; try { if (!ChromDraw.exonReader.getChromosomes().contains(chrom)) { String[] gene = { Main.chromosomeDropdown.getSelectedItem().toString(), "1", "" + Main.drawCanvas.splits.get(0).chromEnd, Main.chromosomeDropdown.getSelectedItem().toString(), "1", "+", "-", "-", "-", "-", "-", "1", "1", "1", "" + Main.drawCanvas.splits.get(0).chromEnd, "-1,", "-" }; Gene addGene = new Gene(gene); Transcript addtrans = null; try { addtrans = new Transcript(gene); } catch (Exception e) { e.printStackTrace(); } addGene.addTranscript(addtrans); addGene.setLongest(addtrans); addtrans.setGene(addGene); transcriptsTemp.add(addGene); return transcriptsTemp; //return new ArrayList<Gene>(); } else { exonIterator = ChromDraw.exonReader.query(chrom); } } catch (Exception e) { try { if (chrom.matches("\\w+")) { exonIterator = ChromDraw.exonReader.query("M"); } } catch (Exception ex) { System.out.println(chrom); e.printStackTrace(); } } String s; String[] exonSplit; Transcript addtrans = null; Hashtable<String, Gene> genes = new Hashtable<String, Gene>(); Gene setGene; while (exonIterator != null && (s = exonIterator.next()) != null) { exonSplit = s.split("\t"); if (exonSplit[0].equals("23")) { exonSplit[0] = "X"; } else if (exonSplit[0].equals("24")) { exonSplit[0] = "Y"; } else if (exonSplit[0].equals("25")) { exonSplit[0] = "MT"; } addtrans = new Transcript(exonSplit); if (!genes.containsKey(exonSplit[6])) { Gene addgene = new Gene(exonSplit); genes.put(exonSplit[6], addgene); addgene.addTranscript(addtrans); addgene.setLongest(addtrans); addtrans.setGene(addgene); transcriptsTemp.add(addgene); } else { setGene = genes.get(exonSplit[6]); setGene.addTranscript(addtrans); addtrans.setGene(setGene); if (addtrans.getLength() > setGene.getLongest().getLength()) { setGene.setLongest(addtrans); } } } genes.clear(); ChromDraw.exonReader.close(); } catch (Exception e) { ErrorLog.addError(e.getStackTrace()); e.printStackTrace(); } return transcriptsTemp; }
From source file:base.BasePlayer.FileRead.java
public ArrayList<ReadNode> getReads(String chrom, int startpos, int endpos, Reads readClass, SplitClass split) { if (endpos - startpos > Settings.coverageDrawDistance || endpos - startpos < 100) { return null; }/*from w w w . j a v a 2 s .c om*/ try { double[][] coverageArray = null; if (Main.drawCanvas.drawVariables.sampleHeight > 100) { bamIterator = getBamIterator(readClass, chrom, startpos, endpos); if (viewLength > Settings.readDrawDistance) { double[][] coverages = new double[(int) Main.frame.getWidth()][8]; readClass.setCoverages(coverages); readClass.setMaxcoverage(1); readClass.setCoverageStart(startpos); oldstart = endpos; readClass.setCoverageEnd(endpos); firstCov = false; coverageArray = readClass.getCoverages(); } boolean firstRead = true; int firststart = 0, laststart = 0; while (bamIterator != null && bamIterator.hasNext()) { try { if (cancelreadread || !Main.drawCanvas.loading || readClass.sample.getIndex() < Main.drawCanvas.drawVariables.visiblestart || readClass.sample.getIndex() > Main.drawCanvas.drawVariables.visiblestart + Main.drawCanvas.drawVariables.visiblesamples) { return null; } try { samRecord = bamIterator.next(); } catch (htsjdk.samtools.SAMFormatException ex) { ex.printStackTrace(); } if (samRecord.getReadUnmappedFlag()) { continue; } if (Draw.variantcalculator) { if (readClass.getHeadAndTail().size() > Settings.readDepthLimit) { break; } } if (samRecord.getUnclippedStart() > endpos) { Main.drawCanvas.loadBarSample = 0; Main.drawCanvas.loadbarAll = 0; break; } if (readClass.getReadStart() != Integer.MAX_VALUE && readClass.searchstart != Integer.MAX_VALUE) { if (readClass.searchstart > startpos && samRecord.getUnclippedEnd() >= readClass.searchstart && samRecord.getUnclippedStart() < readClass.searchend) { continue; } if (readClass.searchstart < startpos && samRecord.getUnclippedStart() < readClass.searchend) { continue; } /* if( readClass.getReadEnd() < split.end) { if(samRecord.getUnclippedStart() >= readClass.getReadStart() && samRecord.getUnclippedStart() <= readClass.getReadEnd()) { continue; } }*/ } if (samRecord.getUnclippedEnd() < startpos) { continue; } if (readClass.sample.getComplete() == null) { if (samRecord.getReadName().startsWith("GS")) { readClass.sample.setcomplete(true); } else { readClass.sample.setcomplete(false); } } if (viewLength < Settings.readDrawDistance) { if (firstRead || readClass.sample.longestRead < samRecord.getCigar().getReferenceLength()) { readClass.sample.longestRead = samRecord.getCigar().getReferenceLength(); } /* if(samRecord.getUnclippedEnd() > splitIndex.end + readClass.sample.longestRead) { endpos = samRecord.getUnclippedEnd(); } else { endpos = (int)splitIndex.end + readClass.sample.longestRead; }*/ if (firstRead) { if (readClass.getReadStart() > samRecord.getUnclippedStart()) { firststart = samRecord.getUnclippedStart(); } if (readClass.getCoverageStart() == Integer.MAX_VALUE) { setReadArrays(readClass, firststart, endpos + readClass.sample.longestRead); } coverageArray = readClass.getCoverages(); firstRead = false; // break; } if (readClass.getReadEnd() < samRecord.getUnclippedStart()) { laststart = samRecord.getUnclippedStart(); } /*if(samRecord.getUnclippedEnd() > readClass.getCoverageEnd()-1) { double[][] coverages = new double[(int)(readClass.getCoverages().length +(samRecord.getUnclippedEnd()-samRecord.getUnclippedStart() + (int)splitIndex.viewLength))][8]; //pointer = coverages.length-1; for(int i =0; i<readClass.getCoverages().length; i++) { coverages[i][0] = readClass.getCoverages()[i][0]; coverages[i][1] = readClass.getCoverages()[i][1]; coverages[i][2] = readClass.getCoverages()[i][2]; coverages[i][3] = readClass.getCoverages()[i][3]; coverages[i][4] = readClass.getCoverages()[i][4]; coverages[i][5] = readClass.getCoverages()[i][5]; coverages[i][6] = readClass.getCoverages()[i][6]; coverages[i][7] = readClass.getCoverages()[i][7]; // pointer--; } readClass.setCoverageEnd(readClass.getCoverageStart()+coverages.length); readClass.setCoverages(coverages); coverageArray = readClass.getCoverages(); }*/ } else { if (Main.drawCanvas.loadBarSample != (int) (((samRecord.getUnclippedStart() - startpos) / (double) (oldstart - startpos)) * 100)) { Main.drawCanvas.loadBarSample = (int) (((samRecord.getUnclippedStart() - startpos) / (double) (oldstart - startpos)) * 100); Main.drawCanvas.loadbarAll = (int) (((samRecord.getUnclippedStart() - startpos) / (double) (oldstart - startpos)) * 100); } for (int i = 0; i < (int) (samRecord.getReadLength() * splitIndex.pixel + 1); i++) { if ((samRecord.getUnclippedStart() - start) * splitIndex.pixel + i < 0) { continue; } if ((samRecord.getUnclippedStart() - start) * splitIndex.pixel + i > coverageArray.length - 1) { break; } if (samRecord.getReadLength() * splitIndex.pixel >= 1) { coverageArray[(int) ((samRecord.getUnclippedStart() - start) * splitIndex.pixel + i)][0] += (1 / splitIndex.pixel); } else { coverageArray[(int) ((samRecord.getUnclippedStart() - start) * splitIndex.pixel + i)][0] += samRecord.getReadLength(); } if (coverageArray[(int) ((samRecord.getUnclippedStart() - start) * splitIndex.pixel + i)][0]/*pixel*/ > readClass.getMaxcoverage()) { readClass.setMaxcoverage( (coverageArray[(int) ((samRecord.getUnclippedStart() - start) * splitIndex.pixel + i)][0]/*pixel*/)); } } continue; } java.util.ArrayList<java.util.Map.Entry<Integer, Byte>> mismatches = null; if (Main.drawCanvas.loadBarSample != (int) (((samRecord.getUnclippedStart() - startpos) / (double) (endpos - startpos)) * 100)) { Main.drawCanvas.loadBarSample = (int) (((samRecord.getUnclippedStart() - startpos) / (double) (endpos - startpos)) * 100); Main.drawCanvas.loadbarAll = (int) (((samRecord.getUnclippedStart() - startpos) / (double) (endpos - startpos)) * 100); } /*if(right && readClass.getLastRead() != null && (samRecord.getUnclippedStart() <= startpos)) { continue; }*/ /*if(right && samRecord.getUnclippedStart() > endpos) { right = false; }*/ try { if (coverageArray == null) { return null; } if (readClass.getCoverageEnd() < endpos) { coverageArray = coverageArrayAdd((int) ((endpos - readClass.getCoverageEnd() + (int) readClass.sample.longestRead)), coverageArray, readClass); } if (samRecord.getAlignmentEnd() >= readClass.getCoverageEnd()) { coverageArray = coverageArrayAdd( (int) (((samRecord.getAlignmentEnd() - samRecord.getUnclippedStart()) + (int) readClass.sample.longestRead)), coverageArray, readClass); } if (samRecord.getUnclippedStart() < readClass.getCoverageStart()) { coverageArray = coverageArrayAddStart(samRecord.getUnclippedStart(), readClass.getCoverageEnd(), coverageArray, readClass); } if (coverageArray == null) { setReadArrays(readClass, firststart, endpos + readClass.sample.longestRead); coverageArray = readClass.getCoverages(); } mismatches = getMismatches(samRecord, readClass, coverageArray, split); } catch (Exception e) { e.printStackTrace(); } /* if(left) { if(readClass.getFirstRead().getPosition() > samRecord.getUnclippedStart()) { ReadNode addNode = new ReadNode(samRecord, readClass.sample.getComplete(), chrom, readClass.sample, splitIndex,readClass, mismatches); readClass.setFirstRead(addNode); startY = (int)(((readClass.sample.getIndex()+1)*Main.drawCanvas.drawVariables.sampleHeight-Main.drawCanvas.bottom-(readClass.readHeight+2))); addNode.setPrev(null); addNode.setNext(readClass.getHeadAndTail().get(0)[headnode]); readClass.getHeadAndTail().get(0)[headnode].setPrev(addNode); lastAdded = addNode; } else { ReadNode addNode = new ReadNode(samRecord, readClass.sample.getComplete(), chrom, readClass.sample, splitIndex,readClass, mismatches); startY = (int)(((readClass.sample.getIndex()+1)*Main.drawCanvas.drawVariables.sampleHeight-Main.drawCanvas.bottom-(readClass.readHeight+2))); addNode.setPrev(lastAdded); addNode.setNext(lastAdded.getNext()); lastAdded.setNext(addNode); lastAdded = addNode; readClass.getHeadAndTail().get(0)[headnode].setPrev(addNode); addNode.setNext(readClass.getHeadAndTail().get(0)[headnode]); } } else { */ try { if (readClass.getReads().isEmpty() || samRecord.getUnclippedStart() > readClass.getReadEnd()) { readSam(chrom, readClass, samRecord, mismatches, 0); } else { readSamLeft(chrom, readClass, samRecord, mismatches); } } catch (Exception e) { System.out.println(samRecord + " " + currentread); e.printStackTrace(); break; } // } // } // } /* else { continue; }*/ } catch (Exception e) { ErrorLog.addError(e.getStackTrace()); e.printStackTrace(); break; } } if (viewLength < Settings.readDrawDistance) { if (readClass.searchstart > startpos) { readClass.searchstart = startpos; //splitIndex.setMinReadStart(startpos); } if (readClass.searchend < endpos) { readClass.searchend = endpos; } if (firststart > 0 && readClass.getReadStart() > firststart) { readClass.setReadStart(firststart); } if (readClass.getReadEnd() < laststart) { readClass.setReadEnd(laststart); } } /*if(left) { Main.drawCanvas.loadBarSample = 0; Main.drawCanvas.loadbarAll =0; setLevels(lastAdded, readClass.sample, readClass); lastAdded = null; }*/ } } catch (Exception ex) { ErrorLog.addError(ex.getStackTrace()); ex.printStackTrace(); return null; } return null; }
From source file:base.BasePlayer.FileRead.java
Iterator<SAMRecord> getBamIterator(Reads readClass, String chrom, int startpos, int endpos) { try {//from w w w. j a va2 s . com if (samFileReader != null) { samFileReader.close(); } if (CRAMReader != null) { CRAMReader.close(); } if (readClass.sample.CRAM) { CRAMReader = new CRAMFileReader(readClass.sample.samFile, new File(readClass.sample.samFile.getCanonicalFile() + ".crai"), new ReferenceSource(Main.ref), /*Main.referenceFile, */ValidationStringency.SILENT); if (CRAMReader != null && !CRAMReader.hasIndex()) { Main.showError("Index file is missing (.crai) for " + readClass.sample.samFile.getName(), "Note"); return null; } } else { try { samFileReader = SamReaderFactory.make().open(readClass.sample.samFile); //samFileReader = new SAMFileReader(readClass.sample.samFile); if (samFileReader != null && !samFileReader.hasIndex()) { Main.showError("Index file is missing (.bai) for " + readClass.sample.samFile.getName(), "Note"); return null; } } catch (Exception e) { Main.showError(e.getMessage(), "Note"); e.printStackTrace(); } } } catch (Exception e) { if (readClass.sample.CRAM) { if (CRAMReader != null && !CRAMReader.hasIndex()) { Main.showError("Index file is missing (.crai) for " + readClass.sample.samFile.getName(), "Note"); return null; } } else { if (samFileReader != null && !samFileReader.hasIndex()) { Main.showError("Index file is missing (.bai) for " + readClass.sample.samFile.getName(), "Note"); return null; } } e.printStackTrace(); } try { if (readClass.sample.CRAM) { if (!readClass.sample.chrSet) { if (CRAMReader.getFileHeader().getSequence(0).getSAMString().contains("chr")) { readClass.sample.chr = "chr"; } readClass.sample.chrSet = true; } QueryInterval[] interval = { new QueryInterval( CRAMReader.getFileHeader().getSequence(readClass.sample.chr + chrom).getSequenceIndex(), startpos, endpos) }; Iterator<SAMRecord> value = CRAMReader.query(interval, false); return value; } else { Iterator<SAMRecord> value = null; // SAMReadGroupRecord record = new SAMReadGroupRecord("fixed_My6090N_sorted"); // samFileReader.getFileHeader().addReadGroup(record); try { //SAMFileReader.setDefaultValidationStringency(ValidationStringency.SILENT); if (!readClass.sample.chrSet) { if (samFileReader.getFileHeader().getSequence(0).getSAMString().contains("chr")) { readClass.sample.chr = "chr"; } readClass.sample.chrSet = true; } value = samFileReader.queryOverlapping(readClass.sample.chr + chrom, startpos, endpos); } catch (htsjdk.samtools.SAMFormatException e) { e.printStackTrace(); } return value; } } catch (Exception e) { try { if (readClass.sample.CRAM) { e.printStackTrace(); /*if(CRAMReader.getFileHeader().getSequence(readClass.sample.chr + "M") != null) { QueryInterval[] interval = { new QueryInterval(CRAMReader.getFileHeader().getSequence(readClass.sample.chr + "M").getSequenceIndex(), startpos, endpos) }; } Iterator<SAMRecord> value = CRAMReader.query(interval, false); if(!readClass.sample.chrSet) { if(!value.hasNext()) { QueryInterval[] interval2 = { new QueryInterval(CRAMReader.getFileHeader().getSequence("chrM").getSequenceIndex(), startpos, endpos) }; value = CRAMReader.query(interval2, false); if(value.hasNext()) { readClass.sample.chr = "chr"; readClass.sample.chrSet = true; } } else { readClass.sample.chrSet = true; } }*/ return null; //return value; } else { return null; /* Iterator<SAMRecord> value = samFileReader.queryOverlapping(readClass.sample.chr+"M", startpos, endpos); if(!readClass.sample.chrSet) { if(!value.hasNext()) { value = samFileReader.queryOverlapping("chrM", startpos, endpos); if(value.hasNext()) { readClass.sample.chr = "chr"; readClass.sample.chrSet = true; } } else { readClass.sample.chrSet = true; } }*/ //return value; } } catch (Exception ex) { ex.printStackTrace(); ErrorLog.addError(e.getStackTrace()); return null; } } }
From source file:base.BasePlayer.FileRead.java
java.util.ArrayList<java.util.Map.Entry<Integer, Byte>> getMismatches(SAMRecord samRecord, Reads readClass, double[][] coverageArray, SplitClass split) { if (readClass == null) { sample.resetreadHash();// w w w .j ava 2s . co m } java.util.ArrayList<java.util.Map.Entry<Integer, Byte>> mismatches = null; String MD = samRecord.getStringAttribute("MD"); String SA = samRecord.getStringAttribute("SA"); if (samRecord.getReadBases().length == 0) { return null; } try { if (MD == null) { if (readClass.sample.MD) { readClass.sample.MD = false; } } if ((readClass.sample.MD || MD != null) && (samRecord.getCigarString().contains("S") && Settings.softClips == 0)/* && ((!samRecord.getCigarString().contains("S") && SA == null) || SA !=null)*/) { if (!readClass.sample.MD) { readClass.sample.MD = true; } java.util.ArrayList<java.util.Map.Entry<Integer, Integer>> insertions = null; int softstart = 0; if (samRecord.getCigarLength() > 1) { readstart = samRecord.getUnclippedStart(); if (readClass.getCoverageStart() > readstart) { return null; } readpos = 0; for (int i = 0; i < samRecord.getCigarLength(); i++) { element = samRecord.getCigar().getCigarElement(i); if (element.getOperator().compareTo(CigarOperator.MATCH_OR_MISMATCH) == 0) { for (int r = readpos; r < readpos + element.getLength(); r++) { try { coverageArray[((readstart + r) - readClass.getCoverageStart())][0]++; } catch (Exception e) { //TODO } try { if (coverageArray[((readstart + r) - readClass.getCoverageStart())][0] > readClass.getMaxcoverage()) { readClass.setMaxcoverage( coverageArray[((readstart + r) - readClass.getCoverageStart())][0]); } } catch (Exception e) { //TODO } mispos++; } readpos += element.getLength(); } else if (element.getOperator().compareTo(CigarOperator.DELETION) == 0) { for (int d = 0; d < element.getLength(); d++) { readClass.getCoverages()[(readstart + readpos + d) - readClass.getCoverageStart()][Main.baseMap.get((byte) 'D')]++; } readpos += element.getLength(); } else if (element.getOperator().compareTo(CigarOperator.INSERTION) == 0) { if (insertions == null) { insertions = new java.util.ArrayList<java.util.Map.Entry<Integer, Integer>>(); } java.util.Map.Entry<Integer, Integer> ins = new java.util.AbstractMap.SimpleEntry<>( readpos, element.getLength()); insertions.add(ins); readClass.getCoverages()[(readstart + readpos) - readClass.getCoverageStart()][Main.baseMap.get((byte) 'I')]++; mispos += element.getLength(); } else if (element.getOperator().compareTo(CigarOperator.SOFT_CLIP) == 0) { if (i == 0 && SA == null) { softstart = element.getLength(); } if (Settings.softClips == 1) { for (int r = readpos; r < readpos + element.getLength(); r++) { if (SA == null) { coverageArray[((readstart + r) - readClass.getCoverageStart())][0]++; } mispos++; } readpos += element.getLength(); } else { if (i == 0) { readstart = samRecord.getAlignmentStart(); mispos += element.getLength(); } } } else if (element.getOperator().compareTo(CigarOperator.HARD_CLIP) == 0) { if (i == 0) { readstart = samRecord.getAlignmentStart(); } } else if (element.getOperator().compareTo(CigarOperator.SKIPPED_REGION) == 0) { readpos += element.getLength(); } } } else { readstart = samRecord.getUnclippedStart(); for (int i = 0; i < samRecord.getReadLength(); i++) { try { if (readClass.getCoverageStart() > readstart) { break; } coverageArray[(readstart + i) - readClass.getCoverageStart()][0]++; if (coverageArray[(samRecord.getUnclippedStart() - readClass.getCoverageStart()) + i][0] > readClass.getMaxcoverage()) { readClass.setMaxcoverage( coverageArray[(samRecord.getUnclippedStart() - readClass.getCoverageStart()) + i][0]); } } catch (Exception e) { ErrorLog.addError(e.getStackTrace()); e.printStackTrace(); FileRead.cancelreadread = true; break; } } } if (MD != null) { try { Integer.parseInt(MD); return null; } catch (Exception ex) { readstart = samRecord.getAlignmentStart() - softstart; char[] chars = MD.toCharArray(); String bases = samRecord.getReadString(); String qualities = samRecord.getBaseQualityString(); if (SA == null) { softstart = 0; } int readpos = softstart; int mispos = softstart; int add = 0; int digitpointer = 0, insertionpointer = 0; boolean first = true; for (int i = 0; i < chars.length; i++) { try { if (insertions != null) { if (insertionpointer < insertions.size() && insertions.get(insertionpointer).getKey() <= readpos) { while (insertionpointer < insertions.size() && insertions.get(insertionpointer).getKey() <= readpos) { mispos += insertions.get(insertionpointer).getValue(); insertionpointer++; } } } if (Character.isDigit(chars[i])) { digitpointer = i + 1; while (digitpointer < chars.length && Character.isDigit(chars[digitpointer])) { digitpointer++; } if (digitpointer == chars.length) { if ((mispos + Integer.parseInt(MD.substring(i, digitpointer))) > samRecord .getReadLength()) { if (!first) { break; } first = false; readpos = 0; mispos = 0; i = -1; digitpointer = 0; insertionpointer = 0; mismatches.clear(); continue; } break; } else { add = Integer.parseInt(MD.substring(i, digitpointer)); readpos += add; mispos += add; } i = digitpointer - 1; } else if (chars[i] != '^') { if (mismatches == null) { mismatches = new java.util.ArrayList<java.util.Map.Entry<Integer, Byte>>(); } readClass.getCoverages()[(readstart + readpos) - readClass.getCoverageStart()][Main.baseMap .get((byte) bases.charAt(mispos))]++; if (samRecord.getBaseQualityString().length() != 1 && (int) qualities.charAt(mispos) - readClass.sample.phred < Settings.baseQ) { java.util.Map.Entry<Integer, Byte> mismatch = new java.util.AbstractMap.SimpleEntry<>( readpos, (byte) Character.toLowerCase(bases.charAt(mispos))); mismatches.add(mismatch); } else { java.util.Map.Entry<Integer, Byte> mismatch = new java.util.AbstractMap.SimpleEntry<>( readpos, (byte) bases.charAt(mispos)); mismatches.add(mismatch); } mispos++; readpos++; } else { digitpointer = i + 1; while (!Character.isDigit(chars[digitpointer])) { digitpointer++; readpos++; } i = digitpointer - 1; } } catch (Exception exc) { if (!first) { break; } first = false; readpos = 0; mispos = 0; i = -1; digitpointer = 0; insertionpointer = 0; mismatches.clear(); } } } } } else { /*if(split.getReference() == null) { readClass.setReference(new ReferenceSeq(splitIndex.chrom,start-500, end+500, Main.referenceFile)); }*/ //timecounter = 0; /*while(splitIndex.getReadReference() == null) { Thread.sleep(100); timecounter++; if(timecounter > 20) { break; } } Thread.sleep(0); */ // if(splitIndex.getReadReference() == null) { //splitIndex.setReference(new ReferenceSeq(splitIndex.chrom,startpos-searchwindow-1, endpos+searchwindow +200, Main.referenceFile)); // return null; //} if (samRecord.getCigarLength() > 1) { readstart = samRecord.getUnclippedStart(); readpos = 0; mispos = 0; /*if(readClass.getCoverageStart()>readstart) { return null; }*/ if (mismatches == null) { mismatches = new java.util.ArrayList<java.util.Map.Entry<Integer, Byte>>(); } for (int i = 0; i < samRecord.getCigarLength(); i++) { element = samRecord.getCigar().getCigarElement(i); if (element.getOperator().compareTo(CigarOperator.MATCH_OR_MISMATCH) == 0) { for (int r = readpos; r < readpos + element.getLength(); r++) { if (((readstart + r) - split.getReadReference().getStartPos() - 1) > split.getReadReference().getSeq().length - 1) { split.getReadReference().append(samRecord.getUnclippedEnd() + 1000); } if (((readstart + r) - split.getReadReference().getStartPos() - 1) < 0) { split.getReadReference().appendToStart(samRecord.getUnclippedStart() - 1000); } try { if (samRecord.getReadBases()[mispos] != split.getReadReference() .getSeq()[((readstart + r) - split.getReadReference().getStartPos() - 1)]) { readClass.getCoverages()[(readstart + r) - readClass.getCoverageStart()][Main.baseMap .get((byte) samRecord.getReadBases()[mispos])]++; if (samRecord.getBaseQualityString().length() != 1 && (int) samRecord.getBaseQualityString().charAt(mispos) - readClass.sample.phred < Settings.baseQ) { java.util.Map.Entry<Integer, Byte> mismatch = new java.util.AbstractMap.SimpleEntry<>( r, (byte) Character .toLowerCase((char) samRecord.getReadBases()[mispos])); mismatches.add(mismatch); } else { java.util.Map.Entry<Integer, Byte> mismatch = new java.util.AbstractMap.SimpleEntry<>( r, samRecord.getReadBases()[mispos]); mismatches.add(mismatch); } } } catch (Exception e) { System.out.println(samRecord.getReadBases().length); e.printStackTrace(); } try { coverageArray[((readstart + r) - readClass.getCoverageStart())][0]++; if (coverageArray[((readstart + r) - readClass.getCoverageStart())][0] > readClass.getMaxcoverage()) { readClass.setMaxcoverage( coverageArray[((readstart + r) - readClass.getCoverageStart())][0]); } } catch (Exception e) { //TODO } mispos++; } readpos += element.getLength(); } else if (element.getOperator().compareTo(CigarOperator.DELETION) == 0) { // readWidth+=element.getLength(); for (int d = 0; d < element.getLength(); d++) { readClass.getCoverages()[(readstart + readpos + d) - readClass.getCoverageStart()][Main.baseMap.get((byte) 'D')]++; } readpos += element.getLength(); } else if (element.getOperator().compareTo(CigarOperator.INSERTION) == 0) { readClass.getCoverages()[(readstart + readpos) - readClass.getCoverageStart()][Main.baseMap.get((byte) 'I')]++; mispos += element.getLength(); } else if (element.getOperator().compareTo(CigarOperator.SOFT_CLIP) == 0) { if (Settings.softClips == 1) { for (int r = readpos; r < readpos + element.getLength(); r++) { if (((readstart + r) - split.getReadReference().getStartPos() - 1) > split.getReadReference().getSeq().length - 1) { split.getReadReference().append(samRecord.getUnclippedEnd() + 1000); } if (((readstart + r) - splitIndex.getReadReference().getStartPos() - 1) < 0) { split.getReadReference() .appendToStart(samRecord.getUnclippedStart() - 1000); } /* if(((readstart+r)-readClass.reference.getStartPos()-1) < 0) { continue; }*/ if (samRecord.getReadBases()[mispos] != split.getReadReference() .getSeq()[((readstart + r) - split.getReadReference().getStartPos() - 1)]) { if (SA == null) { readClass.getCoverages()[(readstart + r) - readClass.getCoverageStart()][Main.baseMap .get(samRecord.getReadBases()[mispos])]++; } if (mismatches == null) { mismatches = new java.util.ArrayList<java.util.Map.Entry<Integer, Byte>>(); } java.util.Map.Entry<Integer, Byte> mismatch = new java.util.AbstractMap.SimpleEntry<>( r, samRecord.getReadBases()[mispos]); mismatches.add(mismatch); } if (SA == null) { coverageArray[((readstart + r) - readClass.getCoverageStart())][0]++; } mispos++; } readpos += element.getLength(); } else { if (i == 0) { readpos += element.getLength(); mispos += element.getLength(); } } } else if (element.getOperator().compareTo(CigarOperator.HARD_CLIP) == 0) { if (i == 0) { readstart = samRecord.getAlignmentStart(); } } else if (element.getOperator().compareTo(CigarOperator.SKIPPED_REGION) == 0) { readpos += element.getLength(); // this.readWidth+=element.getLength(); } } } else { readstart = samRecord.getUnclippedStart(); /*if(readClass.getCoverageStart()>readstart) { return null; }*/ if ((samRecord.getUnclippedEnd() - split.getReadReference().getStartPos() - 1) > split.getReadReference().getSeq().length - 1) { split.getReadReference().append(samRecord.getUnclippedEnd() + 100); } if ((samRecord.getUnclippedStart() - split.getReadReference().getStartPos() - 1) < 0) { split.getReadReference().appendToStart(samRecord.getUnclippedStart() - 100); } for (int r = 0; r < samRecord.getReadLength(); r++) { try { if (samRecord.getReadBases()[r] != split.getReadReference() .getSeq()[((readstart + r) - split.getReadReference().getStartPos() - 1)]) { if ((readstart + r) - readClass.getCoverageStart() < readClass.getCoverages().length - 1) { readClass.getCoverages()[(readstart + r) - readClass.getCoverageStart()][Main.baseMap .get(samRecord.getReadBases()[r])]++; if (mismatches == null) { mismatches = new java.util.ArrayList<java.util.Map.Entry<Integer, Byte>>(); } java.util.Map.Entry<Integer, Byte> mismatch = new java.util.AbstractMap.SimpleEntry<>( r, samRecord.getReadBases()[r]); mismatches.add(mismatch); } } try { coverageArray[(readstart + r) - readClass.getCoverageStart()][0]++; } catch (Exception e) { //TODO //e.printStackTrace(); continue; } if (coverageArray[(samRecord.getUnclippedStart() - readClass.getCoverageStart()) + r][0] > readClass.getMaxcoverage()) { readClass.setMaxcoverage( coverageArray[(samRecord.getUnclippedStart() - readClass.getCoverageStart()) + r][0]); } } catch (Exception e) { ErrorLog.addError(e.getStackTrace()); e.printStackTrace(); return mismatches; } } } } } catch (Exception e) { e.printStackTrace(); return null; } return mismatches; }
From source file:base.BasePlayer.FileRead.java
public void readLine(String[] split, Sample sample) { try {/*w ww . jav a 2 s . c o m*/ if (split.length < 3) { return; } if (split[0].startsWith("#") || split[4].equals("*")) { return; } pos = Integer.parseInt(split[1]) - 1; if (pos < Main.drawCanvas.variantsStart) { return; } else if (pos >= Main.drawCanvas.variantsEnd) { stop = true; return; } if (linecounter == 0 || pos - linecounter > (Main.drawCanvas.variantsEnd - Main.drawCanvas.variantsStart) / 100) { Main.drawCanvas.loadBarSample = (int) (((pos - Main.drawCanvas.variantsStart) / (double) (Main.drawCanvas.variantsEnd - Main.drawCanvas.variantsStart)) * 100); // Draw.updatevars = true; linecounter = pos; if (search) { if (!Main.drawCanvas.loading) { Draw.calculateVars = true; } } } /* if(first) { info = split[split.length-1].split(":"); if(info[0].length() == 1 || info[0].charAt(0) == '0' && info[0].charAt(2) =='0') { info = split[split.length-2].split(":"); sample.infolocation = (short)(split.length-2); } else { sample.infolocation = (short)(split.length-1); } } else { */ //} if (sample.somaticColumn != null) { if (sample.somaticColumn > split.length - 1) { sample.somaticColumn = null; info = split[split.length - 1].split(":"); } else { info = split[sample.somaticColumn].split(":"); } } else { info = split[split.length - 1].split(":"); } noref = false; multi = false; HashMap<String, Integer> infofield = new HashMap<String, Integer>(); if (split.length > 8) { String[] infos = split[8].split(":"); for (int i = 0; i < infos.length; i++) { infofield.put(infos[i], i); } } if (infofield.containsKey("GT")) { gtindex = infofield.get("GT"); if (info[gtindex].contains(".")) { return; } try { if (info[gtindex].contains("|")) { firstallele = Short.parseShort("" + info[gtindex].split("|")[0]); secondallele = Short.parseShort("" + info[gtindex].split("|")[2]); } else { firstallele = Short.parseShort("" + info[gtindex].split("/")[0]); secondallele = Short.parseShort("" + info[gtindex].split("/")[1]); } } catch (Exception e) { return; } genotype = firstallele == secondallele; if (genotype && firstallele == 0) { return; } if (infofield.containsKey("AD")) { if (infofield.containsKey("RD")) { calls1 = Integer.parseInt(info[infofield.get("RD")]); try { if (info[infofield.get("AD")].contains(",")) { calls2 = Integer.parseInt(info[infofield.get("AD")].split(",")[1]); } else { calls2 = Integer.parseInt(info[infofield.get("AD")]); } } catch (Exception e) { System.out.println(info[infofield.get("AD")]); e.printStackTrace(); } } else { coverages = info[infofield.get("AD")].split(","); if (genotype) { calls1 = Integer.parseInt(coverages[0]); } else { try { calls1 = Integer.parseInt(coverages[firstallele]); } catch (Exception ex) { calls1 = Integer.parseInt(coverages[coverages.length - 1]); } } try { calls2 = Integer.parseInt(coverages[secondallele]); } catch (Exception ex) { calls2 = Integer.parseInt(coverages[coverages.length - 1]); } } if (!genotype) { if (firstallele == 0) { refallele = firstallele; refcalls = calls1; altallele = secondallele; altcalls = calls2; } else if (secondallele == 0) { refallele = secondallele; refcalls = calls2; altallele = firstallele; altcalls = calls1; } else { noref = true; refallele = firstallele; refcalls = calls1; altallele = secondallele; altcalls = calls2; } } else { try { refcalls = calls1; // Short.parseShort(info[split[8].indexOf("AD")/3].split(",")[0]); altallele = secondallele; altcalls = calls2; } catch (Exception e) { for (int i = 0; i < split.length; i++) { System.out.print(split[i] + "\t"); } System.out.println(); e.printStackTrace(); } } } else if (infofield.containsKey("DP")) { refcalls = Integer.parseInt(info[infofield.get("DP")]); altcalls = refcalls; } else if (split[7].contains("DP4")) { coverages = split[7].substring(split[7].indexOf("DP4") + 4).split(";")[0].split(","); refallele = firstallele; altallele = secondallele; refcalls = Integer.parseInt(coverages[0]) + Integer.parseInt(coverages[1]); altcalls = Integer.parseInt(coverages[2]) + Integer.parseInt(coverages[3]); } else { if (firstallele == 0) { refallele = firstallele; altallele = secondallele; } else if (secondallele == 0) { refallele = secondallele; altallele = firstallele; } else { refallele = firstallele; altallele = secondallele; } refcalls = 20; altcalls = 20; } } else if (split[7].contains("t_alt_count")) { try { altcalls = Integer .parseInt(split[7].substring(split[7].indexOf("t_alt_count") + 12).split(";")[0]); refcalls = Integer .parseInt(split[7].substring(split[7].indexOf("t_ref_count") + 12).split(";")[0]); } catch (Exception e) { System.out.println("alt: " + split[7].substring(split[7].indexOf("t_alt_count") + 12)); System.out.println("ref: " + split[7].substring(split[7].indexOf("t_ref_count") + 12)); } if (sample.annoTrack) { sample.annoTrack = false; } } else { refcalls = 20; altcalls = 20; } if (!split[4].contains(",")) { altbase = getVariant(split[3], split[4]); } else if (!noref) { if (altallele > 0) { altbase = getVariant(split[3], split[4].split(",")[altallele - 1]); } else { altbase = getVariant(split[3], split[4].split(",")[0]); multi = true; } } else { altbase = getVariant(split[3], split[4].split(",")[altallele - 1]); altbase2 = getVariant(split[3], split[4].split(",")[refallele - 1]); } quality = null; if (split.length > 8 && split[8].contains("Q")) { if (infofield.containsKey("GQ") && !info[infofield.get("GQ")].equals(".")) { gq = (float) Double.parseDouble(info[infofield.get("GQ")]); } else if (infofield.containsKey("BQ") && !info[infofield.get("BQ")].equals(".")) { quality = (float) Double.parseDouble(info[infofield.get("BQ")]); } else if (split[7].contains("SSC")) { quality = Float.parseFloat(split[7].substring(split[7].indexOf("SSC") + 4).split(";")[0]); } } if (quality == null) { if (split.length > 5 && split[5].matches("\\d+.?.*")) { quality = (float) Double.parseDouble(split[5]); } } HashMap<String, Float> advancedQualities = null; if (VariantHandler.freeze.isSelected()) { if (!sample.annoTrack) { if (refcalls + altcalls < VariantHandler.coverageSlider.getValue()) { return; } if (quality != null && quality < VariantHandler.qualitySlider.getValue()) { return; } if (gq != null && gq < VariantHandler.gqSlider.getValue()) { return; } if (altcalls / (double) (refcalls + altcalls) < VariantHandler.callSlider.getValue() / 100.0) { return; } } if (!sample.annotation) { if (VariantHandler.hideSNVs.isSelected() && altbase.length() == 1) { return; } if (VariantHandler.hideIndels.isSelected() && altbase.length() > 1) { return; } if (VariantHandler.rscode.isSelected() && !split[2].equals(".")) { return; } } } if (!sample.annoTrack) { if (split.length > 6) { if (checkAdvFilters(split[6], altbase.length() > 1)) { return; } } if (split.length > 7) { if (checkAdvQuals(split[7], infofield, info, altbase.length() > 1) > 0) { return; } } if (refcalls + altcalls > VariantHandler.maxCoverageSlider.getMaximum()) { VariantHandler.maxCoverageSlider.setMaximum(refcalls + altcalls); VariantHandler.maxCoverageSlider.setValue(refcalls + altcalls); } } while (current != null && current.getNext() != null && current.getPosition() < pos) { current = current.getNext(); } if (current.getNext() == null && current.getPosition() < pos) { try { if (!split[2].equals(".")) { current.putNext( new VarNode(pos, (byte) split[3].charAt(0), altbase, refcalls + altcalls, altcalls, genotype, quality, gq, advancedQualities, split[2], sample, current, null)); } else { current.putNext(new VarNode(pos, (byte) split[3].charAt(0), altbase, refcalls + altcalls, altcalls, genotype, quality, gq, advancedQualities, null, sample, current, null)); } if (noref) { if (split.length > 6) { if (checkAdvFilters(split[6], altbase.length() > 1)) { return; } } if (split.length > 7) { if (checkAdvQuals(split[7], infofield, info, altbase.length() > 1) > 0) ; return; } current.getNext().addSample(altbase2, refcalls + altcalls, refcalls, genotype, quality, gq, advancedQualities, sample); } if (multi) { String[] altsplit = split[4].split(","); for (int i = 1; i < altsplit.length; i++) { altbase = getVariant(split[3], altsplit[i]); if (split.length > 6) { if (checkAdvFilters(split[6], altbase.length() > 1)) { continue; } } if (split.length > 7) { if (checkAdvQuals(split[7], infofield, info, altbase.length() > 1) > 0) ; return; } current.getNext().addSample(altbase, refcalls + altcalls, refcalls, genotype, quality, gq, advancedQualities, sample); } } } catch (Exception e) { ErrorLog.addError(e.getStackTrace()); e.printStackTrace(); //Main.drawCanvas.ready("all"); } } else if (current.getPosition() == pos) { current.addSample(altbase, refcalls + altcalls, altcalls, genotype, quality, gq, advancedQualities, sample); if (noref) { if (split.length > 6) { if (checkAdvFilters(split[6], altbase2.length() > 1)) { return; } } if (split.length > 7) { if (checkAdvQuals(split[7], infofield, info, altbase.length() > 1) > 0) ; return; } current.addSample(altbase2, refcalls + altcalls, refcalls, genotype, quality, gq, advancedQualities, sample); } if (current.isRscode() == null && !split[2].equals(".")) { current.setRscode(split[2]); } if (multi) { String[] altsplit = split[4].split(","); for (int i = 1; i < altsplit.length; i++) { altbase = getVariant(split[3], altsplit[i]); if (split.length > 6) { if (checkAdvFilters(split[6], altbase.length() > 1)) { continue; } } if (split.length > 7) { if (checkAdvQuals(split[7], infofield, info, altbase.length() > 1) > 0) ; continue; } try { current.getNext().addSample(altbase, refcalls + altcalls, refcalls, genotype, quality, gq, advancedQualities, sample); } catch (Exception e) { System.out.println(current.getChrom() + ":" + current.getPosition()); } } } } else if (current.getPosition() > pos) { if (!split[2].equals(".")) { current.getPrev() .putNext(new VarNode(pos, (byte) split[3].charAt(0), altbase, refcalls + altcalls, altcalls, genotype, quality, gq, advancedQualities, split[2], sample, current.getPrev(), current)); } else { if (current.getPrev() == null) { System.out.println(current.getPosition()); Main.cancel(); } current.getPrev() .putNext(new VarNode(pos, (byte) split[3].charAt(0), altbase, refcalls + altcalls, altcalls, genotype, quality, gq, advancedQualities, null, sample, current.getPrev(), current)); } current.putPrev(current.getPrev().getNext()); current = current.getPrev(); if (noref) { if (split.length > 6) { if (checkAdvFilters(split[6], altbase2.length() > 1)) { return; } } if (split.length > 7) { if (checkAdvQuals(split[7], infofield, info, altbase.length() > 1) > 0) ; return; } current.addSample(altbase2, refcalls + altcalls, refcalls, genotype, quality, gq, advancedQualities, sample); } if (multi) { String[] altsplit = split[4].split(","); for (int i = 1; i < altsplit.length; i++) { altbase = getVariant(split[3], altsplit[i]); if (split.length > 6) { if (checkAdvFilters(split[6], altbase.length() > 1)) { continue; } } if (split.length > 7) { if (checkAdvQuals(split[7], infofield, info, altbase.length() > 1) > 0) ; continue; } current.addSample(altbase, refcalls + altcalls, refcalls, genotype, quality, gq, advancedQualities, sample); } } } } catch (Exception ex) { //System.out.println(split[8] +" " +split[10] +" " +split[3] +" " +split[4]); ErrorLog.addError(ex.getStackTrace()); ex.printStackTrace(); } }
From source file:base.BasePlayer.FileRead.java
public VariantCall[][] variantCaller(String chrom, int startpos, int endpos, Reads readClass, int minBaseQuality, int minReadQuality, ReferenceSeq reference) { VariantCall[][] coverages = new VariantCall[endpos - startpos + 300][8]; Iterator<SAMRecord> bamIterator = getBamIterator(readClass, chrom, startpos, endpos); String run;//from w ww . j a v a 2 s . co m // int scanner = 0, scannerEnd = 0, scanWindow = 10; Boolean strand, scanFail = false; HashMap<String, String> runs = new HashMap<String, String>(); try { readClass.setCoverageStart(startpos); readClass.startpos = startpos; readClass.endpos = endpos; readClass.setReadStart(startpos); readClass.setReadEnd(endpos); readClass.setCoverageEnd(startpos + coverages.length); while (bamIterator != null && bamIterator.hasNext()) { if (!Main.drawCanvas.loading) { Main.drawCanvas.ready("all"); break; } try { try { samRecord = bamIterator.next(); } catch (htsjdk.samtools.SAMFormatException ex) { ex.printStackTrace(); } if (samRecord.getMappingQuality() < minReadQuality) { continue; } if (samRecord.getReadUnmappedFlag()) { continue; } if (samRecord.getReadLength() == 0) { continue; } //TODO jos on pienempi ku vika unclipped start if (samRecord.getUnclippedEnd() < startpos) { //this.readSeqStart+1) { continue; } if (samRecord.getUnclippedStart() >= endpos) { break; } /*if(readClass.sample.longestRead <samRecord.getCigar().getReferenceLength()) { readClass.sample.longestRead = samRecord.getCigar().getReferenceLength(); }*/ /*if(readClass.sample.getComplete() == null) { if(samRecord.getReadName().startsWith("GS")) { readClass.sample.setcomplete(true); } else { readClass.sample.setcomplete(false); } }*/ if (MethodLibrary.isDiscordant(samRecord, false)) { continue; } if (samRecord.getReadName().contains(":")) { run = samRecord.getReadName().split(":")[1]; } else { run = samRecord.getReadName(); } if (!runs.containsKey(run)) { runs.put(run, ""); } if (samRecord.getAlignmentEnd() >= readClass.getCoverageEnd()) { coverages = coverageArrayAdd(readClass.sample.longestRead * 2, coverages, readClass); reference.append(reference.getEndPos() + readClass.sample.longestRead * 2); } strand = samRecord.getReadNegativeStrandFlag(); if (samRecord.getCigarLength() > 1) { /*if(samRecord.getCigarString().contains("S")) { continue; }*/ readstart = samRecord.getUnclippedStart(); readpos = 0; mispos = 0; for (int i = 0; i < samRecord.getCigarLength(); i++) { scanFail = false; element = samRecord.getCigar().getCigarElement(i); if (element.getOperator().compareTo(CigarOperator.MATCH_OR_MISMATCH) == 0) { for (int r = readpos; r < readpos + element.getLength(); r++) { if (((readstart + r) - readClass.getCoverageStart()) < 0) { continue; } try { if (samRecord.getReadBases()[mispos] != reference .getSeq()[((readstart + r) - reference.getStartPos() - 1)]) { if ((readstart + r) - readClass.getCoverageStart() < coverages.length - 1 && (readstart + r) - readClass.getCoverageStart() > -1) { readClass.sample.basequalsum += (int) samRecord .getBaseQualityString().charAt(mispos) - readClass.sample.phred; readClass.sample.basequals++; if ((int) samRecord.getBaseQualityString().charAt(mispos) - readClass.sample.phred >= minBaseQuality) { if (mispos > 5 && mispos < samRecord.getReadLength() - 5) { /* if(r < scanWindow) { scanner = 0; } else { scanner = r-scanWindow; } if(r > samRecord.getReadLength()-scanWindow) { scannerEnd = samRecord.getReadLength(); } else { scannerEnd = r+scanWindow; } for(int s = scanner ; s<scannerEnd;s++) { if(s == r) { continue; } if(samRecord.getReadBases()[s] != reference.getSeq()[((readstart+s)-reference.getStartPos()-1)]) { scanFail = true; break; } } */ if (!scanFail) { if (coverages[(readstart + r) - readClass.getCoverageStart()][Main.baseMap .get((byte) samRecord .getReadBases()[mispos])] == null) { coverages[(readstart + r) - readClass.getCoverageStart()][Main.baseMap .get((byte) samRecord .getReadBases()[mispos])] = new VariantCall(); } coverages[(readstart + r) - readClass.getCoverageStart()][Main.baseMap .get((byte) samRecord .getReadBases()[mispos])].calls++; coverages[(readstart + r) - readClass.getCoverageStart()][Main.baseMap .get((byte) samRecord .getReadBases()[mispos])].qualities += (int) samRecord .getBaseQualityString() .charAt(mispos) - readClass.sample.phred; //if(readstart+mispos == 73789324) { // System.out.println(coverages[(readstart+r)- readClass.getCoverageStart()][Main.baseMap.get((byte)samRecord.getReadBases()[mispos])].calls); //} if (!coverages[(readstart + r) - readClass.getCoverageStart()][Main.baseMap .get((byte) samRecord .getReadBases()[mispos])].runs .contains(run)) { coverages[(readstart + r) - readClass.getCoverageStart()][Main.baseMap .get((byte) samRecord .getReadBases()[mispos])].runs .add(run); } if (!coverages[(readstart + r) - readClass.getCoverageStart()][Main.baseMap .get((byte) samRecord .getReadBases()[mispos])].strands .contains(strand)) { coverages[(readstart + r) - readClass.getCoverageStart()][Main.baseMap .get((byte) samRecord .getReadBases()[mispos])].strands .add(strand); } } } else { scanFail = true; } } else { scanFail = true; } } else { scanFail = true; } } } catch (Exception e) { System.out.println(samRecord.getSAMString()); System.out.println(samRecord.getReadLength() + " " + samRecord.getReadString().length()); e.printStackTrace(); return null; } if (!scanFail) { if (coverages[((readstart + r) - readClass.getCoverageStart())][0] == null) { coverages[((readstart + r) - readClass.getCoverageStart())][0] = new VariantCall(); } coverages[((readstart + r) - readClass.getCoverageStart())][0].calls++; ; if (coverages[((readstart + r) - readClass.getCoverageStart())][0].calls > readClass .getMaxcoverage()) { readClass.setMaxcoverage(coverages[((readstart + r) - readClass.getCoverageStart())][0].calls); } } mispos++; } readpos += element.getLength(); } else if (element.getOperator().compareTo(CigarOperator.DELETION) == 0) { scanFail = true; readpos += element.getLength(); } else if (element.getOperator().compareTo(CigarOperator.INSERTION) == 0) { // coverages[(readstart+readpos)- readClass.getCoverageStart()][Main.baseMap.get((byte)'I')]++; mispos += element.getLength(); scanFail = true; } else if (element.getOperator().compareTo(CigarOperator.SOFT_CLIP) == 0) { scanFail = true; if (i == 0) { /*if(element.getLength() > 1000) { System.out.println(samRecord.getReadLength() +" " +samRecord.getReadString().length() +"\n" +samRecord.getSAMString()); }*/ readstart = samRecord.getAlignmentStart(); mispos += element.getLength(); } //} } else if (element.getOperator().compareTo(CigarOperator.HARD_CLIP) == 0) { scanFail = true; if (i == 0) { readstart = samRecord.getAlignmentStart(); } } else if (element.getOperator().compareTo(CigarOperator.SKIPPED_REGION) == 0) { scanFail = true; readpos += element.getLength(); } } } else { readstart = samRecord.getUnclippedStart(); for (int r = 0; r < samRecord.getReadLength(); r++) { try { scanFail = false; if (samRecord.getReadBases()[r] != reference .getSeq()[((readstart + r) - reference.getStartPos() - 1)]) { if ((readstart + r) - readClass.getCoverageStart() < coverages.length - 1 && (readstart + r) - readClass.getCoverageStart() > -1) { readClass.sample.basequalsum += (int) samRecord.getBaseQualityString() .charAt(r) - readClass.sample.phred; readClass.sample.basequals++; if ((int) samRecord.getBaseQualityString().charAt(r) - readClass.sample.phred >= minBaseQuality) { if (r > 5 && r < samRecord.getReadLength() - 5) { /*if(samRecord.getReadString().charAt(r) == 'C' && samRecord.getReadString().charAt(r-1) == 'C' && samRecord.getReadString().charAt(r+1) == 'C') { if(samRecord.getReadString().charAt(r-2) != 'C' && samRecord.getReadString().charAt(r+2) != 'C') { VariantCaller.qualities += (int)samRecord.getBaseQualityString().charAt(r)-readClass.sample.phred; VariantCaller.amount++; } }*/ /* if(r < scanWindow) { scanner = 0; } else { scanner = r-scanWindow; } if(r > samRecord.getReadLength()-scanWindow) { scannerEnd = samRecord.getReadLength(); } else { scannerEnd = r+scanWindow; } for(int i = scanner ; i<scannerEnd;i++) { if(i == r) { continue; } if(samRecord.getReadBases()[i] != reference.getSeq()[((readstart+i)-reference.getStartPos()-1)]) { scanFail = true; break; } }*/ if (!scanFail) { if (coverages[(readstart + r) - readClass.getCoverageStart()][Main.baseMap.get( (byte) samRecord.getReadBases()[r])] == null) { coverages[(readstart + r) - readClass.getCoverageStart()][Main.baseMap .get((byte) samRecord .getReadBases()[r])] = new VariantCall(); } coverages[(readstart + r) - readClass.getCoverageStart()][Main.baseMap.get( (byte) samRecord.getReadBases()[r])].calls++; coverages[(readstart + r) - readClass.getCoverageStart()][Main.baseMap .get((byte) samRecord .getReadBases()[r])].qualities += (int) samRecord .getBaseQualityString() .charAt(r) - readClass.sample.phred; if (!coverages[(readstart + r) - readClass.getCoverageStart()][Main.baseMap .get((byte) samRecord.getReadBases()[r])].runs .contains(run)) { coverages[(readstart + r) - readClass.getCoverageStart()][Main.baseMap.get( (byte) samRecord.getReadBases()[r])].runs .add(run); } if (!coverages[(readstart + r) - readClass.getCoverageStart()][Main.baseMap.get( (byte) samRecord.getReadBases()[r])].strands .contains(strand)) { coverages[(readstart + r) - readClass.getCoverageStart()][Main.baseMap.get( (byte) samRecord.getReadBases()[r])].strands .add(strand); } } } else { scanFail = true; } } else { scanFail = true; } } else { scanFail = true; } } if (!scanFail) { if ((readstart + r) - readClass.getCoverageStart() < 0) { continue; } if (coverages[((readstart + r) - readClass.getCoverageStart())][0] == null) { coverages[((readstart + r) - readClass.getCoverageStart())][0] = new VariantCall(); } coverages[(readstart + r) - readClass.getCoverageStart()][0].calls++; } } catch (Exception e) { ErrorLog.addError(e.getStackTrace()); e.printStackTrace(); break; } } } } catch (Exception e) { e.printStackTrace(); break; } } } catch (Exception ex) { ex.printStackTrace(); return null; } // readClass.setRuns(runs.size()); return coverages; }