/** * 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; import java.awt.BorderLayout; import java.io.File; import java.io.IOException; import java.util.Vector; import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTabbedPane; import javax.swing.UIManager; import javax.swing.filechooser.FileFilter; import uk.ac.babraham.FastQC.Analysis.AnalysisRunner; import uk.ac.babraham.FastQC.Analysis.OfflineRunner; import uk.ac.babraham.FastQC.Dialogs.WelcomePanel; import uk.ac.babraham.FastQC.FileFilters.BAMFileFilter; import uk.ac.babraham.FastQC.FileFilters.CasavaFastQFileFilter; import uk.ac.babraham.FastQC.FileFilters.FastQFileFilter; import uk.ac.babraham.FastQC.FileFilters.MappedBAMFileFilter; import uk.ac.babraham.FastQC.FileFilters.SequenceFileFilter; 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.Results.ResultsPanel; import uk.ac.babraham.FastQC.Sequence.SequenceFactory; import uk.ac.babraham.FastQC.Sequence.SequenceFile; import uk.ac.babraham.FastQC.Sequence.SequenceFormatException; import uk.ac.babraham.FastQC.Utilities.CasavaBasename; import uk.ac.babraham.FastQC.Utilities.NanoporeBasename; public class FastQCApplication extends JFrame { public static final String VERSION = "0.12.1"; private JTabbedPane fileTabs; private WelcomePanel welcomePanel; private File lastUsedDir = null; public FastQCApplication () { setTitle("FastQC"); setIconImage(new ImageIcon(ClassLoader.getSystemResource("uk/ac/babraham/FastQC/Resources/fastqc_icon.png")).getImage()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // setSize(1280, 720); setSize(800,600); setLocationRelativeTo(null); welcomePanel = new WelcomePanel(); fileTabs = new JTabbedPane(JTabbedPane.TOP); setContentPane(welcomePanel); setJMenuBar(new FastQCMenuBar(this)); } public void close () { if (fileTabs.getSelectedIndex() >=0) { fileTabs.remove(fileTabs.getSelectedIndex()); } if (fileTabs.getTabCount() == 0) { setContentPane(welcomePanel); validate(); repaint(); } } public void closeAll () { fileTabs.removeAll(); setContentPane(welcomePanel); validate(); repaint(); } public void openFile () { JFileChooser chooser; if (lastUsedDir == null) { chooser = new JFileChooser(); } else { chooser = new JFileChooser(lastUsedDir); } chooser.setMultiSelectionEnabled(true); SequenceFileFilter sff = new SequenceFileFilter(); chooser.addChoosableFileFilter(sff); chooser.addChoosableFileFilter(new FastQFileFilter()); chooser.addChoosableFileFilter(new CasavaFastQFileFilter()); chooser.addChoosableFileFilter(new BAMFileFilter()); chooser.addChoosableFileFilter(new MappedBAMFileFilter()); chooser.setFileFilter(sff); int result = chooser.showOpenDialog(this); if (result == JFileChooser.CANCEL_OPTION) return; // See if they forced a file format FileFilter chosenFilter = chooser.getFileFilter(); if (chosenFilter instanceof FastQFileFilter) { FastQCConfig.getInstance().setSequenceFormat("fastq"); } if (chosenFilter instanceof CasavaFastQFileFilter) { FastQCConfig.getInstance().setSequenceFormat("fastq"); FastQCConfig.getInstance().setCasavaMode(true); } else if (chosenFilter instanceof BAMFileFilter) { FastQCConfig.getInstance().setSequenceFormat("bam"); } else if (chosenFilter instanceof MappedBAMFileFilter) { FastQCConfig.getInstance().setSequenceFormat("bam_mapped"); System.setProperty("fastqc.sequence_format", "bam_mapped"); } // If we're still showing the welcome panel switch this out for // the file tabs panel if (fileTabs.getTabCount() == 0) { setContentPane(fileTabs); validate(); repaint(); } File [] files = chooser.getSelectedFiles(); if (FastQCConfig.getInstance().nano) { // Some of the files we've been passed might be directories and we would need to // list the fast5 files within those directories. Vector keptFiles = new Vector(); for (int f=0;f 0) { // Set headless to true so we don't get problems // with people working without an X display. System.setProperty("java.awt.headless", "true"); // We used to default to unzipping the zip file in // non-interactive runs. As we now save an HTML // report at the top level we no longer do this // so unzip is false unless explicitly set to be true. if (FastQCConfig.getInstance().do_unzip == null) { FastQCConfig.getInstance().do_unzip = false; } new OfflineRunner(args); System.exit(0); } else { // Recent java themes for linux are just horribly broken with missing // bits of UI. We're therefore not going to set a native look if // we're on linux. See seqmonk bug #95 for details. try { if (! System.getProperty("os.name").toLowerCase().contains("linux")) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } } catch (Exception e) {} // The interactive default is to not uncompress the // reports after they have been generated if (FastQCConfig.getInstance().do_unzip == null) { FastQCConfig.getInstance().do_unzip = false; } FastQCApplication app = new FastQCApplication(); app.setVisible(true); } } }