/** * Copyright Copyright 2010-17 Simon Andrews * * This file is part of FastQC. * * FastQC is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * FastQC is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with FastQC; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ package uk.ac.babraham.FastQC.Analysis; import java.io.File; import java.io.IOException; import java.util.Vector; import java.util.concurrent.atomic.AtomicInteger; import uk.ac.babraham.FastQC.FastQCConfig; import uk.ac.babraham.FastQC.Modules.ModuleFactory; import uk.ac.babraham.FastQC.Modules.QCModule; import uk.ac.babraham.FastQC.Report.HTMLReportArchive; import uk.ac.babraham.FastQC.Sequence.SequenceFactory; import uk.ac.babraham.FastQC.Sequence.SequenceFile; import uk.ac.babraham.FastQC.Utilities.CasavaBasename; import uk.ac.babraham.FastQC.Utilities.NanoporeBasename; public class OfflineRunner implements AnalysisListener { private AtomicInteger filesRemaining; private boolean showUpdates = true; // We'll set a flag which will tell us if any of the sequences failed // so we can exit with an error state so the calling process can tell // that something went wrong. private boolean somethingFailed = false; public OfflineRunner (String [] filenames) { // See if we need to show updates showUpdates = !FastQCConfig.getInstance().quiet; Vector files = new Vector(); // We make a special case if they supply a single filename // which is stdin. In this case we'll take data piped to us // rather than trying to read the actual file. We'll also // skip the existence check. if (filenames.length == 1 && filenames[0].startsWith("stdin")) { files.add(new File(filenames[0])); } else { for (int f=0;f 0) { try { Thread.sleep(1000); } catch (InterruptedException e) {} } if (somethingFailed) { System.exit(1); } System.exit(0); } public void processFile (File [] files) throws Exception { for (int f=0;f 100) { if (showUpdates) System.err.println("Still going at "+percentComplete+"% complete for "+file.name()); } else { if (showUpdates) System.err.println("Approx "+percentComplete+"% complete for "+file.name()); } } } public void analysisExceptionReceived(SequenceFile file, Exception e) { System.err.println("Failed to process file "+file.name()); somethingFailed = true; e.printStackTrace(); filesRemaining.decrementAndGet(); } public void analysisStarted(SequenceFile file) { if (showUpdates) System.err.println("Started analysis of "+file.name()); } }