package jalview.io; import jalview.bin.Jalview; import jalview.datamodel.AlignmentI; import jalview.datamodel.ResidueCount; import jalview.datamodel.SequenceI; import jalview.gui.AlignmentPanel; import jalview.gui.Desktop; import jalview.gui.JvOptionPane; import jalview.util.MessageManager; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import javax.swing.JFileChooser; public class CountReader { public static ResidueCount getBackgroundFrequencies(AlignmentPanel ap, SequenceI seq) throws MalformedURLException, IOException { JFileChooser bkgdFreqChooser = new JFileChooser(); bkgdFreqChooser.showOpenDialog(ap); File file = bkgdFreqChooser.getSelectedFile(); if (file == null) { return null; } IdentifyFile identifier = new IdentifyFile(); FileFormatI format = null; try { format = identifier.identify(file.getPath(), DataSourceType.FILE); } catch (Exception e) { } if (format == null) { if (!Jalview.isHeadlessMode()) { JvOptionPane.showInternalMessageDialog(Desktop.getInstance(), MessageManager.getString("label.couldnt_read_data") + " in " + file + "\n" + AppletFormatAdapter.getSupportedFormats(), MessageManager.getString("label.couldnt_read_data"), JvOptionPane.WARNING_MESSAGE); } } FileParse parser = new FileParse(file.getPath(), DataSourceType.FILE); AlignmentI al = new FormatAdapter().readFromFile(parser, format); parser.close(); ResidueCount counts = new ResidueCount(al.getSequences()); return counts; } }