Package org.bioinfo.ngs.qc.qualimap.process

Examples of org.bioinfo.ngs.qc.qualimap.process.ComputeCountsTask


                assertTrue("Path to result is empty",false);
                return;

            }

            ComputeCountsTask computeCountsTask = new ComputeCountsTask(pathToBamFile, pathToRegionFile);

            String libraryType = test.getSpecificAttribute("strand");
            if (libraryType != null) {
                assertTrue(ComputeCountsTask.supportedLibraryProtocol(libraryType));
                computeCountsTask.setProtocol(LibraryProtocol.getProtocolByName(libraryType));
            }

            String pairedAnalysis = test.getSpecificAttribute("paired");
            if (pairedAnalysis != null) {
                if (pairedAnalysis.equalsIgnoreCase("yes")) {
                    computeCountsTask.setPairedEndAnalysis();
                }
            }

            String sortingReauried = test.getSpecificAttribute("sorting");
            if (sortingReauried != null) {
                if (sortingReauried.equalsIgnoreCase("yes")) {
                    computeCountsTask.setSortingRequired();
                }
            }


            try {
                computeCountsTask.run();
                Map<String,Double> readCounts = computeCountsTask.getReadCounts();

                /*List<String> geneNames = asSortedList(readCounts.keySet());

                for (String key : geneNames) {
                    System.out.println(key + ":" + readCounts.get(key));
                }*/

                System.out.println("No feature: " + computeCountsTask.getNoFeatureNumber());
                System.out.println("Not unique alignment: " + computeCountsTask.getAlignmentNotUniqueNumber());
                System.out.println("Not aligned: " + computeCountsTask.getNotAlignedNumber());
                System.out.println("Ambiguous: " + computeCountsTask.getAmbiguousNumber());


                loadExpectedResults(pathToExpectedResults) ;

                assertTrue("Number of \"ambiguous\" reads is wrong!",
                        ambigExpected == computeCountsTask.getAmbiguousNumber());

                assertTrue("Number of \"no feature\" reads is wrong!",
                        noFeatureExpected == computeCountsTask.getNoFeatureNumber());



                for (Map.Entry<String,Double> entry: readCounts.entrySet()) {

View Full Code Here


        settingsDlg.setUiEnabled(false);

        String bamPath = settingsDlg.getBamFilePath();
        String gffPath = settingsDlg.getGtfFilePath();

        ComputeCountsTask computeCountsTask = new ComputeCountsTask(bamPath, gffPath);
        LibraryProtocol p = LibraryProtocol.getProtocolByName(settingsDlg.getProtocol());
        computeCountsTask.setProtocol(p);
        computeCountsTask.setCountingAlgorithm(settingsDlg.getCountingAlgorithm());
        computeCountsTask.addSupportedFeatureType(ComputeCountsTask.EXON_TYPE_ATTR);
        computeCountsTask.setAttrName(ComputeCountsTask.GENE_ID_ATTR);

        final JTextArea logArea = settingsDlg.getLogArea();
        logArea.setText("");

        computeCountsTask.setLogger( new LoggerThread() {
            @Override
            public void logLine(String msg) {
                logArea.append(msg + "\n");
                logArea.setCaretPosition(logArea.getText().length());
            }
View Full Code Here

    }

    @Override
    protected void execute() throws Exception {

        ComputeCountsTask computeCountsTask = new ComputeCountsTask(bamFile, gffFile);
        computeCountsTask.setProtocol(protocol);
        computeCountsTask.setCountingAlgorithm(alg);
        computeCountsTask.setAttrName(attrName);
        computeCountsTask.addSupportedFeatureType(featureType);
        if (pairedAnalysis) {
            computeCountsTask.setPairedEndAnalysis();
            if (sortingRequired) {
                computeCountsTask.setSortingRequired();
            }
        }

        PrintWriter outWriter = outFile.isEmpty() ?
                new PrintWriter(new OutputStreamWriter(System.out)) :
                new PrintWriter(new FileWriter(outFile));


        try {
            computeCountsTask.run();

            Map<String,Double> counts = computeCountsTask.getReadCounts();
            for (Map.Entry<String,Double> entry: counts.entrySet()) {
                long roundedValue = entry.getValue().longValue();
                String str = entry.getKey() + "\t" + roundedValue;
                outWriter.println(str);
            }


            outWriter.flush();

        } catch (Exception e) {
            System.err.println("Error while calculating counts! " + e.getMessage());
            e.printStackTrace();
            return;
        }

        StringBuilder message = new StringBuilder();
        message.append("Calculation successful!\n");
        message.append( computeCountsTask.getOutputStatsMessage() );


        if (!outFile.isEmpty()) {
            message.append("Result is saved to file ").append(outFile);
        }
View Full Code Here

    @Override
    protected void execute() throws Exception {

        initOutputDir();

        ComputeCountsTask computeCountsTask = new ComputeCountsTask(bamFile, gffFile);
        computeCountsTask.setProtocol(LibraryProtocol.getProtocolByName(protocol));
        computeCountsTask.setCountingAlgorithm(alg);
        computeCountsTask.setCollectRnaSeqStats(true);

        AnalysisResultManager resultManager = new AnalysisResultManager(AnalysisType.RNA_SEQ_QC);

        RNASeqQCAnalysis rnaSeqQCAnalysis = new RNASeqQCAnalysis(resultManager, computeCountsTask);
        if (countsFile.length() > 0) {
View Full Code Here

                    frame.setUiEnabled(false);
                    logArea.setText("");
                    String bamPath = bamPathEdit.getText();
                    String gffPath = gffPathEdit.getText();
                    String featureType = featureTypeField.getText();
                    ComputeCountsTask computeCountsTask = new ComputeCountsTask(bamPath, gffPath);
                    String pName = strandTypeCombo.getSelectedItem().toString();
                    computeCountsTask.setProtocol(LibraryProtocol.getProtocolByName(pName));
                    computeCountsTask.setCountingAlgorithm(countingAlgoCombo.getSelectedItem().toString());
                    computeCountsTask.addSupportedFeatureType(featureType);
                    computeCountsTask.setAttrName(featureNameField.getText());
                    if (pairedAnalysisBox.isSelected()) {
                        computeCountsTask.setPairedEndAnalysis();
                        if (!alreadySortedBox.isSelected()) {
                            computeCountsTask.setSortingRequired();
                        }
                    }

                    final JTextArea loggerDestArea = logArea;

                    computeCountsTask.setLogger( new LoggerThread() {
                        @Override
                        public void logLine(String msg) {
                            loggerDestArea.append(msg + "\n");
                            loggerDestArea.setCaretPosition(loggerDestArea.getText().length());
                        }
                    });


                    try {
                        computeCountsTask.run();

                        PrintWriter outWriter = new PrintWriter(new FileWriter(outputPathField.getText()));

                        Map<String,Double> counts = computeCountsTask.getReadCounts();
                        for (Map.Entry<String,Double> entry: counts.entrySet()) {
                            String str = entry.getKey() + "\t" + entry.getValue().longValue();
                            outWriter.println(str);
                        }
                        outWriter.flush();

                        if (saveStatsBox.isSelected()) {
                            PrintWriter statsWriter = new PrintWriter(new FileWriter(outputPathField.getText() + ".stats"));

                            String statsMessage = computeCountsTask.getOutputStatsMessage().toString();
                            statsWriter.println(statsMessage);

                            statsWriter.flush();
                        }

                    } catch (Exception e) {
                        JOptionPane.showMessageDialog(frame, e.getMessage(),
                                getTitle(), JOptionPane.ERROR_MESSAGE);
                        e.printStackTrace();
                        frame.setUiEnabled(true);
                        return;
                    }

                    StringBuilder message = new StringBuilder();
                    message.append("Counts generated!\n\n");
                    message.append(computeCountsTask.getOutputStatsMessage());
                    message.append("\nResult is saved to ").append(outputPathField.getText());

                    JOptionPane.showMessageDialog(frame, message.toString(),
                            getTitle(), JOptionPane.INFORMATION_MESSAGE);
                    logArea.append(message.toString());
View Full Code Here

TOP

Related Classes of org.bioinfo.ngs.qc.qualimap.process.ComputeCountsTask

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.