import jalview.appletgui.SequenceRenderer;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
+import jalview.io.DataSourceType;
import jalview.io.StructureFile;
import jalview.structure.AtomSpec;
import jalview.structure.StructureListener;
StructureSelectionManager ssm;
public AppletPDBCanvas(PDBEntry pdbentry, SequenceI[] seq,
- String[] chains, AlignmentPanel ap, String protocol)
+ String[] chains, AlignmentPanel ap, DataSourceType protocol)
{
this.ap = ap;
{
pdb = ssm.setMapping(seq, chains, pdbentry.getFile(), protocol);
- if (protocol.equals(jalview.io.AppletFormatAdapter.PASTE))
+ if (protocol == DataSourceType.PASTE)
{
pdbentry.setFile("INLINE" + pdb.getId());
}
import jalview.appletgui.EmbmenuFrame;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
+import jalview.io.DataSourceType;
import jalview.schemes.BuriedColourScheme;
import jalview.schemes.HelixColourScheme;
import jalview.schemes.HydrophobicColourScheme;
AppletPDBCanvas pdbcanvas;
public AppletPDBViewer(PDBEntry pdbentry, SequenceI[] seq,
- String[] chains, AlignmentPanel ap, String protocol)
+ String[] chains, AlignmentPanel ap, DataSourceType protocol)
{
try
{
}
+ @Override
public void actionPerformed(ActionEvent evt)
{
if (evt.getSource() == mapping)
}
+ @Override
public void itemStateChanged(ItemEvent evt)
{
if (evt.getSource() == allchains)
{
pdb = ssm.setMapping(seq, chains, pdbentry.getFile(), protocol);
- if (protocol.equals(jalview.io.AppletFormatAdapter.PASTE))
+ if (protocol.equals(jalview.io.DataSourceType.PASTE))
{
pdbentry.setFile("INLINE" + pdb.getId());
}
import jalview.gui.Desktop;
import jalview.gui.OOMWarning;
import jalview.gui.UserDefinedColours;
+import jalview.io.DataSourceType;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
import jalview.schemes.BuriedColourScheme;
{
tmpPDBFile = pdbentry.getFile();
PDBfile pdbfile = new PDBfile(false, false, false, tmpPDBFile,
- jalview.io.AppletFormatAdapter.FILE);
+ DataSourceType.FILE);
pdbcanvas.init(pdbentry, seq, chains, ap, protocol);
import jalview.datamodel.DBRefSource;
import jalview.datamodel.SequenceI;
import jalview.io.FileParse;
+import jalview.io.DataSourceType;
import jalview.io.StructureFile;
import jalview.structure.StructureImportSettings;
import jalview.util.MessageManager;
}
public PDBfile(boolean addAlignmentAnnotations, boolean predictSecStr,
- boolean externalSecStr, String dataObject, String protocol)
+ boolean externalSecStr, String dataObject,
+ DataSourceType sourceType)
throws IOException
{
- super(false, dataObject, protocol);
+ super(false, dataObject, sourceType);
addSettings(addAlignmentAnnotations, predictSecStr, externalSecStr);
doParse();
}
*/
package jalview.api;
+import jalview.io.DataSourceType;
+
import java.util.List;
/**
* add a features file of some kind to the current view
*
* @param file
- * @param protocol
+ * @param sourceType
* @param relaxedIdMatching
* if true, try harder to match up IDs with local sequence data
* @return true if parsing resulted in something being imported to the view or
* dataset
*/
- public boolean parseFeaturesFile(String file, String protocol,
+ public boolean parseFeaturesFile(String file, DataSourceType sourceType,
boolean relaxedIdMatching);
}
import jalview.datamodel.SequenceI;
import jalview.io.AnnotationFile;
import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
import jalview.io.FeaturesFile;
+import jalview.io.FileFormat;
import jalview.io.TCoffeeScoreFile;
import jalview.schemes.Blosum62ColourScheme;
import jalview.schemes.BuriedColourScheme;
* is protocol for accessing data referred to by file
*/
- public boolean parseFeaturesFile(String file, String type)
+ public boolean parseFeaturesFile(String file, DataSourceType type)
{
return parseFeaturesFile(file, type, true);
}
*
* @param file
* file URL, content, or other resolvable path
- * @param type
+ * @param paste
* is protocol for accessing data referred to by file
* @param autoenabledisplay
* when true, display features flag will be automatically enabled if
* features are loaded
* @return true if data parsed as a features file
*/
- public boolean parseFeaturesFile(String file, String type,
+ public boolean parseFeaturesFile(String file, DataSourceType paste,
boolean autoenabledisplay)
{
boolean featuresFile = false;
.getFeatureRenderer().getFeatureColours();
boolean relaxedIdMatching = viewport.applet.getDefaultParameter(
"relaxedidmatch", false);
- featuresFile = new FeaturesFile(file, type).parse(
+ featuresFile = new FeaturesFile(file, paste).parse(
viewport.getAlignment(), colours, true, relaxedIdMatching);
} catch (Exception ex)
{
}
// resolve data source
// TODO: this code should be a refactored to an io package
- String protocol = AppletFormatAdapter.resolveProtocol(pdbFile, "PDB");
+ DataSourceType protocol = AppletFormatAdapter.resolveProtocol(
+ pdbFile, FileFormat.PDB);
if (protocol == null)
{
return false;
// make a note of the access mode and add
if (pdbentry.getProperty() == null)
{
- pdbentry.setProperty(new Hashtable());
+ pdbentry.setProperty(new Hashtable<String, String>());
}
- pdbentry.getProperty().put("protocol", protocol);
+ pdbentry.getProperty().put("protocol", protocol.toString());
toaddpdb.addPDBId(pdbentry);
alignPanel.getStructureSelectionManager()
.registerPDBEntry(pdbentry);
}
public void newStructureView(JalviewLite applet, PDBEntry pdb,
- SequenceI[] seqs, String[] chains, String protocol)
+ SequenceI[] seqs, String[] chains, DataSourceType protocol)
{
// Scrub any null sequences from the array
Object[] sqch = cleanSeqChainArrays(seqs, chains);
System.err
.println("JalviewLite.AlignFrame:newStructureView: No sequence to bind structure to.");
}
- if (protocol == null || protocol.trim().length() == 0
- || protocol.equals("null"))
+ if (protocol == null)
{
- protocol = (String) pdb.getProperty().get("protocol");
+ String sourceType = pdb.getProperty().get("protocol");
+ try
+ {
+ protocol = DataSourceType.valueOf(sourceType);
+ } catch (IllegalArgumentException e)
+ {
+ // ignore
+ }
if (protocol == null)
{
System.err.println("Couldn't work out protocol to open structure: "
{
// can only do alignments with Jmol
// find the last jmol window assigned to this alignment
- jalview.appletgui.AppletJmol ajm = null, tajm;
- Vector jmols = applet
- .getAppletWindow(jalview.appletgui.AppletJmol.class);
+ AppletJmol ajm = null, tajm;
+ Vector jmols = applet.getAppletWindow(AppletJmol.class);
for (int i = 0, iSize = jmols.size(); i < iSize; i++)
{
- tajm = (jalview.appletgui.AppletJmol) jmols.elementAt(i);
+ tajm = (AppletJmol) jmols.elementAt(i);
if (tajm.ap.alignFrame == this)
{
ajm = tajm;
// otherwise, create a new window
if (applet.jmolAvailable)
{
- new jalview.appletgui.AppletJmol(pdb, seqs, chains, alignPanel,
+ new AppletJmol(pdb, seqs, chains, alignPanel,
protocol);
applet.lastFrameX += 40;
applet.lastFrameY += 40;
*/
package jalview.appletgui;
+import jalview.bin.JalviewLite;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
-import jalview.io.AppletFormatAdapter;
import jalview.io.FileParse;
+import jalview.io.DataSourceType;
import jalview.io.StructureFile;
import jalview.schemes.BuriedColourScheme;
import jalview.schemes.HelixColourScheme;
}
public AppletJmol(PDBEntry pdbentry, SequenceI[] seq, String[] chains,
- AlignmentPanel ap, String protocol)
+ AlignmentPanel ap, DataSourceType protocol)
{
this.ap = ap;
jmb = new AppletJmolBinding(this, ap.getStructureSelectionManager(),
jmb.setColourBySequence(true);
if (pdbentry.getId() == null || pdbentry.getId().length() < 1)
{
- if (protocol.equals(AppletFormatAdapter.PASTE))
+ if (protocol == DataSourceType.PASTE)
{
pdbentry.setId("PASTED PDB"
+ (chains == null ? "_" : chains.toString()));
}
}
- if (jalview.bin.JalviewLite.debug)
+ if (JalviewLite.debug)
{
System.err
.println("AppletJmol: PDB ID is '" + pdbentry.getId() + "'");
});
if (pdbentry.getProperty() == null)
{
- pdbentry.setProperty(new Hashtable());
- pdbentry.getProperty().put("protocol", protocol);
+ pdbentry.setProperty(new Hashtable<String, String>());
+ pdbentry.getProperty().put("protocol", protocol.toString());
}
if (pdbentry.getFile() != null)
{
// import structure data from pdbentry.getFile based on given protocol
- if (protocol.equals(AppletFormatAdapter.PASTE))
+ if (protocol == DataSourceType.PASTE)
{
// TODO: JAL-623 : correctly record file contents for matching up later
// pdbentry.getProperty().put("pdbfilehash",""+pdbentry.getFile().hashCode());
loadInline(pdbentry.getFile());
}
- else if (protocol.equals(AppletFormatAdapter.FILE)
- || protocol.equals(AppletFormatAdapter.URL))
+ else if (protocol == DataSourceType.FILE
+ || protocol == DataSourceType.URL)
{
jmb.viewer.openFile(pdbentry.getFile());
}
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.ext.jmol.JalviewJmolBinding;
+import jalview.io.DataSourceType;
import jalview.structure.StructureSelectionManager;
import java.awt.Container;
public AppletJmolBinding(AppletJmol appletJmol,
StructureSelectionManager sSm, PDBEntry[] pdbentry,
- SequenceI[][] seq, String[][] chains, String protocol)
+ SequenceI[][] seq, String[][] chains, DataSourceType protocol)
{
super(sSm, pdbentry, seq, chains, protocol);
appletJmolBinding = appletJmol;
appletJmolBinding.updateTitleAndMenus();
}
+ @Override
public void updateColours(Object source)
{
AlignmentPanel ap = (AlignmentPanel) source;
colourBySequence(ap);
}
+ @Override
public void showUrl(String url)
{
try
// do nothing.
}
+ @Override
public void selectionChanged(BS arg0)
{
// TODO Auto-generated method stub
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
+import jalview.io.AlignmentFileI;
import jalview.io.AnnotationFile;
import jalview.io.AppletFormatAdapter;
-import jalview.io.FileParse;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormatI;
import jalview.io.IdentifyFile;
import jalview.io.NewickFile;
import jalview.io.TCoffeeScoreFile;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
+import java.io.IOException;
public class CutAndPasteTransfer extends Panel implements ActionListener,
MouseListener
AlignFrame alignFrame;
- FileParse source = null;
+ AlignmentFileI source = null;
public CutAndPasteTransfer(boolean forImport, AlignFrame alignFrame)
{
{
try
{
- NewickFile fin = new NewickFile(textarea.getText(), "Paste");
+ NewickFile fin = new NewickFile(textarea.getText(),
+ DataSourceType.PASTE);
fin.parse();
if (fin.getTree() != null)
{
AlignmentI al = null;
- String format = new IdentifyFile().identify(text,
- AppletFormatAdapter.PASTE);
- AppletFormatAdapter afa = new AppletFormatAdapter(alignFrame.alignPanel);
try
{
- al = afa.readFile(text, AppletFormatAdapter.PASTE, format);
+ FileFormatI format = new IdentifyFile().identify(text,
+ DataSourceType.PASTE);
+ AppletFormatAdapter afa = new AppletFormatAdapter(
+ alignFrame.alignPanel);
+ al = afa.readFile(text, DataSourceType.PASTE, format);
source = afa.getAlignFile();
- } catch (java.io.IOException ex)
- {
- ex.printStackTrace();
- }
if (al != null)
{
.getString("label.successfully_pasted_alignment_file"));
}
}
+ } catch (IOException ex)
+ {
+ ex.printStackTrace();
+ }
}
/**
* @param al
* @return
*/
- protected boolean openSplitFrame(AlignmentI al, String format)
+ protected boolean openSplitFrame(AlignmentI al, FileFormatI format)
{
final AlignmentI thisAlignment = this.alignFrame.getAlignViewport()
.getAlignment();
try
{
tcf = new TCoffeeScoreFile(textarea.getText(),
- jalview.io.AppletFormatAdapter.PASTE);
+ jalview.io.DataSourceType.PASTE);
if (tcf.isValid())
{
if (tcf.annotateAlignment(alignFrame.viewport.getAlignment(), true))
if (tcf == null)
{
if (new AnnotationFile().annotateAlignmentView(alignFrame.viewport,
- textarea.getText(), jalview.io.AppletFormatAdapter.PASTE))
+ textarea.getText(), jalview.io.DataSourceType.PASTE))
{
alignFrame.alignPanel.fontChanged();
alignFrame.alignPanel.setScrollValues(0, 0);
else
{
if (!alignFrame.parseFeaturesFile(textarea.getText(),
- jalview.io.AppletFormatAdapter.PASTE))
+ jalview.io.DataSourceType.PASTE))
{
alignFrame.statusBar
.setText(MessageManager
if (alignFrame.alignPanel.av.applet.jmolAvailable)
{
new jalview.appletgui.AppletJmol(pdb, new SequenceI[] { seq }, null,
- alignFrame.alignPanel, AppletFormatAdapter.PASTE);
+ alignFrame.alignPanel, DataSourceType.PASTE);
}
else
{
new MCview.AppletPDBViewer(pdb, new SequenceI[] { seq }, null,
- alignFrame.alignPanel, AppletFormatAdapter.PASTE);
+ alignFrame.alignPanel, DataSourceType.PASTE);
}
}
import jalview.gui.PromptUserConfig;
import jalview.io.AppletFormatAdapter;
import jalview.io.BioJsHTMLOutput;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FileFormatException;
+import jalview.io.FileFormatI;
import jalview.io.FileLoader;
-import jalview.io.FormatAdapter;
import jalview.io.HtmlSvgOutput;
import jalview.io.IdentifyFile;
import jalview.io.NewickFile;
BioJsHTMLOutput.updateBioJS();
}
- String file = null, protocol = null, format = null, data = null;
+ String file = null, data = null;
+ FileFormatI format = null;
+ DataSourceType protocol = null;
FileLoader fileLoader = new FileLoader(!headless);
Vector<String> getFeatures = null; // vector of das source nicknames to
// fetch
{
try
{
- String viprotocol = AppletFormatAdapter
+ DataSourceType viprotocol = AppletFormatAdapter
.checkProtocol(vamsasImport);
- if (viprotocol == jalview.io.FormatAdapter.FILE)
+ if (viprotocol == DataSourceType.FILE)
{
inSession = desktop.vamsasImport(new File(vamsasImport));
}
- else if (viprotocol == FormatAdapter.URL)
+ else if (viprotocol == DataSourceType.URL)
{
inSession = desktop.vamsasImport(new URL(vamsasImport));
}
protocol = AppletFormatAdapter.checkProtocol(file);
- format = new IdentifyFile().identify(file, protocol);
+ try
+ {
+ format = new IdentifyFile().identify(file, protocol);
+ } catch (FileFormatException e1)
+ {
+ // TODO ?
+ }
AlignFrame af = fileLoader.LoadFileWaitTillLoaded(file, protocol,
format);
String imageName = "unnamed.png";
while (aparser.getSize() > 1)
{
- format = aparser.nextValue();
+ String outputFormat = aparser.nextValue();
file = aparser.nextValue();
- if (format.equalsIgnoreCase("png"))
+ if (outputFormat.equalsIgnoreCase("png"))
{
af.createPNG(new File(file));
imageName = (new File(file)).getName();
System.out.println("Creating PNG image: " + file);
continue;
}
- else if (format.equalsIgnoreCase("svg"))
+ else if (outputFormat.equalsIgnoreCase("svg"))
{
File imageFile = new File(file);
imageName = imageFile.getName();
System.out.println("Creating SVG image: " + file);
continue;
}
- else if (format.equalsIgnoreCase("html"))
+ else if (outputFormat.equalsIgnoreCase("html"))
{
File imageFile = new File(file);
imageName = imageFile.getName();
System.out.println("Creating HTML image: " + file);
continue;
}
- else if (format.equalsIgnoreCase("imgMap"))
+ else if (outputFormat.equalsIgnoreCase("imgMap"))
{
af.createImageMap(new File(file), imageName);
System.out.println("Creating image map: " + file);
continue;
}
- else if (format.equalsIgnoreCase("eps"))
+ else if (outputFormat.equalsIgnoreCase("eps"))
{
File outputFile = new File(file);
System.out.println("Creating EPS file: "
jalview.bin.Cache.removeProperty("STARTUP_FILE");
}
- protocol = "File";
+ protocol = DataSourceType.FILE;
if (file.indexOf("http:") > -1)
{
- protocol = "URL";
+ protocol = DataSourceType.URL;
}
if (file.endsWith(".jar"))
{
- format = "Jalview";
+ format = FileFormat.Jalview;
}
else
{
- format = new IdentifyFile().identify(file, protocol);
+ try
+ {
+ format = new IdentifyFile().identify(file, protocol);
+ } catch (FileFormatException e)
+ {
+ // TODO what?
+ }
}
startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol,
import jalview.datamodel.SequenceI;
import jalview.io.AnnotationFile;
import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormatI;
import jalview.io.FileParse;
import jalview.io.IdentifyFile;
import jalview.io.JPredFile;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedReader;
+import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
public void loadAnnotationFrom(AlignFrame alf, String annotation)
{
if (new AnnotationFile().annotateAlignmentView(alf.getAlignViewport(),
- annotation, AppletFormatAdapter.PASTE))
+ annotation, DataSourceType.PASTE))
{
alf.alignPanel.fontChanged();
alf.alignPanel.setScrollValues(0, 0);
}
else
{
- alf.parseFeaturesFile(annotation, AppletFormatAdapter.PASTE);
+ alf.parseFeaturesFile(annotation, DataSourceType.PASTE);
}
}
public boolean loadFeaturesFrom(AlignFrame alf, String features,
boolean autoenabledisplay)
{
- return alf.parseFeaturesFile(features, AppletFormatAdapter.PASTE,
+ return alf.parseFeaturesFile(features, DataSourceType.PASTE,
autoenabledisplay);
}
{
AlignmentI al = null;
- String format = new IdentifyFile().identify(text,
- AppletFormatAdapter.PASTE);
try
{
- al = new AppletFormatAdapter().readFile(text,
- AppletFormatAdapter.PASTE, format);
+ FileFormatI format = new IdentifyFile().identify(text,
+ DataSourceType.PASTE);
+ al = new AppletFormatAdapter().readFile(text, DataSourceType.PASTE,
+ format);
if (al.getHeight() > 0)
{
return new AlignFrame(al, this, title, false);
}
- } catch (java.io.IOException ex)
+ } catch (IOException ex)
{
ex.printStackTrace();
}
/**
* State variable: protocol for access to file source
*/
- String protocol;
+ DataSourceType protocol;
String _file; // alignment file or URL spec
*/
if (path.startsWith("PASTE"))
{
- protocol = AppletFormatAdapter.PASTE;
+ protocol = DataSourceType.PASTE;
return path.substring(5);
}
*/
if (path.indexOf("://") != -1)
{
- protocol = AppletFormatAdapter.URL;
+ protocol = DataSourceType.URL;
return path;
}
System.err.println("Prepended document base '" + documentBase
+ "' to make: '" + withDocBase + "'");
}
- protocol = AppletFormatAdapter.URL;
+ protocol = DataSourceType.URL;
return withDocBase;
}
if (!withCodeBase.equals(withDocBase)
&& HttpUtils.isValidUrl(withCodeBase))
{
- protocol = AppletFormatAdapter.URL;
+ protocol = DataSourceType.URL;
if (debug)
{
System.err.println("Prepended codebase '" + codeBase
*/
if (inArchive(path))
{
- protocol = AppletFormatAdapter.CLASSLOADER;
+ protocol = DataSourceType.CLASSLOADER;
}
return path;
}
return null;
}
String resolvedFile = resolveFileProtocol(fileParam);
- String format = new IdentifyFile().identify(resolvedFile, protocol);
- dbgMsg("File identified as '" + format + "'");
AlignmentI al = null;
try
{
+ FileFormatI format = new IdentifyFile().identify(resolvedFile,
+ protocol);
+ dbgMsg("File identified as '" + format + "'");
al = new AppletFormatAdapter().readFile(resolvedFile, protocol,
format);
if ((al != null) && (al.getHeight() > 0))
// update the focus.
currentAlignFrame = newAlignFrame;
- if (protocol == AppletFormatAdapter.PASTE)
+ if (protocol == DataSourceType.PASTE)
{
newAlignFrame.setTitle(MessageManager.formatMessage(
"label.sequences_from", new Object[] { applet
}
else
{
- pdbs.addElement(new Object[] { pdb, seqs, chains,
- new String(protocol) });
+ pdbs.addElement(new Object[] { pdb, seqs, chains, protocol });
}
}
}
import jalview.datamodel.AlignmentI;
import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FileFormatI;
import jalview.io.FileParse;
+import jalview.io.IdentifyFile;
import java.applet.Applet;
import java.io.InputStream;
*
* @return void
*/
+ @Override
public void init()
{
this.setSize(300, 200);
.println("Specify a resource to read on the file parameter");
return;
}
- String protocol = null;
+ DataSourceType protocol = null;
try
{
System.out.println("Loading thread started with:\n>>file\n" + file
+ (rtn ? "" : "not") + " located by classloader.");
if (rtn)
{
- protocol = AppletFormatAdapter.CLASSLOADER;
+ protocol = DataSourceType.CLASSLOADER;
}
} catch (Exception ex)
}
if (file.indexOf("://") > -1)
{
- protocol = AppletFormatAdapter.URL;
+ protocol = DataSourceType.URL;
}
else
{
// skipping codebase prepend check.
- protocol = AppletFormatAdapter.FILE;
+ protocol = DataSourceType.FILE;
}
System.out.println("Trying to get contents of resource:");
+ " cannot be read with protocol==" + protocol);
return;
}
- String format = getParameter("format");
- if (format == null || format.length() == 0)
+ FileFormatI format = FileFormat.valueOf(getParameter("format"));
+ if (format == null)
{
- format = new jalview.io.IdentifyFile().identify(file, protocol);
+ format = new IdentifyFile().identify(file, protocol);
System.out.println("Format is " + format);
}
else
if (al != null)
{
System.out.println(new AppletFormatAdapter().formatSequences(
- "FASTA", al, false));
+ FileFormat.Fasta, al, false));
}
} catch (Exception e)
{
PDB, MMCIF, FILE
}
- Hashtable properties;
+ Hashtable<String, String> properties;
/*
* (non-Javadoc)
this.properties = property;
}
- public Hashtable getProperty()
+ public Hashtable<String, String> getProperty()
{
return properties;
}
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
import jalview.io.StructureFile;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ResidueProperties;
public JalviewJmolBinding(StructureSelectionManager ssm,
PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
- String protocol)
+ DataSourceType protocol)
{
super(ssm, pdbentry, sequenceIs, chains, protocol);
/*
// see JAL-623 - need method of matching pasted data up
{
pdb = getSsm().setMapping(getSequence()[pe], getChains()[pe],
- pdbfile, AppletFormatAdapter.PASTE);
+ pdbfile, DataSourceType.PASTE);
getPdbEntry(modelnum).setFile("INLINE" + pdb.getId());
matches = true;
foundEntry = true;
// needs
// to be tested. See mantis bug
// https://mantis.lifesci.dundee.ac.uk/view.php?id=36605
- String protocol = AppletFormatAdapter.URL;
+ DataSourceType protocol = DataSourceType.URL;
try
{
if (fl.exists())
{
- protocol = AppletFormatAdapter.FILE;
+ protocol = DataSourceType.FILE;
}
} catch (Exception e)
{
import jalview.datamodel.DBRefSource;
import jalview.datamodel.SequenceI;
import jalview.io.FileParse;
+import jalview.io.DataSourceType;
import jalview.io.StructureFile;
import jalview.schemes.ResidueProperties;
import jalview.structure.StructureImportSettings;
Viewer viewer = null;
public JmolParser(boolean addAlignmentAnnotations, boolean predictSecStr,
- boolean externalSecStr, String inFile, String type)
+ boolean externalSecStr, String inFile, DataSourceType sourceType)
throws IOException
{
- super(inFile, type);
+ super(inFile, sourceType);
}
public JmolParser(boolean addAlignmentAnnotations, boolean predictSecStr,
import jalview.api.AlignExportSettingI;
import jalview.bin.Jalview;
+import jalview.io.FileFormatI;
import jalview.jbgui.GAlignExportSettings;
import jalview.util.MessageManager;
JDialog dialog;
public AlignExportSettings(boolean hasHiddenSeq, boolean hasHiddenCols,
- String alignFileFormat)
+ FileFormatI format)
{
- super(hasHiddenSeq, hasHiddenCols, alignFileFormat);
+ super(hasHiddenSeq, hasHiddenCols, format);
if (!Jalview.isHeadlessMode() && isShowDialog())
{
MessageManager.getString("label.export_settings"));
dialog.addWindowListener(new WindowAdapter()
{
+ @Override
public void windowClosing(WindowEvent e)
{
cancelled = true;
}
}
+ @Override
public void ok_actionPerformed(ActionEvent e)
{
cancelled = false;
dialog.dispose();
}
+ @Override
public void cancel_actionPerformed(ActionEvent e)
{
cancelled = true;
return chkExportGrps.isSelected();
}
+ @Override
public boolean isCancelled()
{
return cancelled;
import jalview.io.AlignmentProperties;
import jalview.io.AnnotationFile;
import jalview.io.BioJsHTMLOutput;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FileFormatI;
import jalview.io.FileLoader;
import jalview.io.FormatAdapter;
import jalview.io.HtmlSvgOutput;
import jalview.io.IdentifyFile;
+import jalview.io.JPredFile;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
import jalview.io.JnetAnnotationMaker;
/**
* Last format used to load or save alignments in this window
*/
- String currentFileFormat = null;
+ FileFormatI currentFileFormat = null;
/**
* Current filename for this alignment
* @param format
* format of file
*/
- public void setFileName(String file, String format)
+ public void setFileName(String file, FileFormatI format)
{
fileName = file;
setFileFormat(format);
fileName = chooser.getSelectedFile().getPath();
- jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT",
- currentFileFormat);
+ Cache.setProperty("DEFAULT_FILE_FORMAT",
+ currentFileFormat.toString());
- jalview.bin.Cache.setProperty("LAST_DIRECTORY", fileName);
+ Cache.setProperty("LAST_DIRECTORY", fileName);
if (currentFileFormat.indexOf(" ") > -1)
{
currentFileFormat = currentFileFormat.substring(0,
}
}
- public boolean saveAlignment(String file, String format)
+ public boolean saveAlignment(String file, FileFormatI format)
{
boolean success = true;
- if (format.equalsIgnoreCase("Jalview"))
+ if (format == FileFormat.Jalview)
{
String shortName = title;
cap.setForInput(null);
try
{
+ FileFormatI format = FileFormat.valueOf(e.getActionCommand());
cap.setText(new FormatAdapter(alignPanel, exportData.getSettings())
- .formatSequences(e.getActionCommand(),
+ .formatSequences(format,
exportData.getAlignment(),
exportData.getOmitHidden(),
exportData.getStartEndPostions(),
}
public static AlignmentExportData getAlignmentForExport(
- String exportFormat, AlignViewportI viewport,
+ FileFormatI format, AlignViewportI viewport,
AlignExportSettingI exportSettings)
{
AlignmentI alignmentToExport = null;
if (settings == null)
{
settings = new AlignExportSettings(hasHiddenSeqs,
- viewport.hasHiddenColumns(), exportFormat);
+ viewport.hasHiddenColumns(), format);
}
// settings.isExportAnnotations();
jalview.io.NewickFile fin = null;
try
{
- fin = new jalview.io.NewickFile(choice, "File");
+ fin = new NewickFile(choice, DataSourceType.FILE);
viewport.setCurrentTree(ShowNewickTree(fin, choice).getTree());
} catch (Exception ex)
{
/**
* Set the file format
*
- * @param fileFormat
+ * @param format
*/
- public void setFileFormat(String fileFormat)
+ public void setFileFormat(FileFormatI format)
{
- this.currentFileFormat = fileFormat;
+ this.currentFileFormat = format;
}
/**
*
* @param file
* contents or path to retrieve file
- * @param type
+ * @param sourceType
* access mode of file (see jalview.io.AlignFile)
* @return true if features file was parsed correctly.
*/
- public boolean parseFeaturesFile(String file, String type)
+ public boolean parseFeaturesFile(String file, DataSourceType sourceType)
{
- return avc.parseFeaturesFile(file, type,
- jalview.bin.Cache.getDefault("RELAXEDSEQIDMATCHING", false));
+ return avc.parseFeaturesFile(file, sourceType,
+ Cache.getDefault("RELAXEDSEQIDMATCHING", false));
}
public void drop(DropTargetDropEvent evt)
{
Transferable t = evt.getTransferable();
- java.util.List<String> files = new ArrayList<String>(), protocols = new ArrayList<String>();
+ List<String> files = new ArrayList<String>();
+ List<DataSourceType> protocols = new ArrayList<DataSourceType>();
try
{
{
String file = files.get(i).toString();
String pdbfn = "";
- String protocol = FormatAdapter.checkProtocol(file);
- if (protocol == jalview.io.FormatAdapter.FILE)
+ DataSourceType protocol = FormatAdapter.checkProtocol(file);
+ if (protocol == DataSourceType.FILE)
{
File fl = new File(file);
pdbfn = fl.getName();
}
- else if (protocol == jalview.io.FormatAdapter.URL)
+ else if (protocol == DataSourceType.URL)
{
URL url = new URL(file);
pdbfn = url.getFile();
* @param file
* either a filename or a URL string.
*/
- public void loadJalviewDataFile(String file, String protocol,
- String format, SequenceI assocSeq)
+ public void loadJalviewDataFile(String file, DataSourceType sourceType,
+ FileFormatI format, SequenceI assocSeq)
{
try
{
- if (protocol == null)
+ if (sourceType == null)
{
- protocol = FormatAdapter.checkProtocol(file);
+ sourceType = FormatAdapter.checkProtocol(file);
}
// if the file isn't identified, or not positively identified as some
// other filetype (PFAM is default unidentified alignment file type) then
// try to parse as annotation.
- boolean isAnnotation = (format == null || format
- .equalsIgnoreCase("PFAM")) ? new AnnotationFile()
- .annotateAlignmentView(viewport, file, protocol) : false;
+ boolean isAnnotation = (format == null || format == FileFormat.Pfam) ? new AnnotationFile()
+ .annotateAlignmentView(viewport, file, sourceType) : false;
if (!isAnnotation)
{
TCoffeeScoreFile tcf = null;
try
{
- tcf = new TCoffeeScoreFile(file, protocol);
+ tcf = new TCoffeeScoreFile(file, sourceType);
if (tcf.isValid())
{
if (tcf.annotateAlignment(viewport.getAlignment(), true))
// try to parse it as a features file
if (format == null)
{
- format = new IdentifyFile().identify(file, protocol);
+ format = new IdentifyFile().identify(file, sourceType);
}
- if (format.equalsIgnoreCase("JnetFile"))
+ if (format == FileFormat.Jnet)
{
- jalview.io.JPredFile predictions = new jalview.io.JPredFile(
- file, protocol);
+ JPredFile predictions = new JPredFile(
+ file, sourceType);
new JnetAnnotationMaker();
JnetAnnotationMaker.add_annotation(predictions,
viewport.getAlignment(), 0, false);
}
else if (IdentifyFile.FeaturesFile.equals(format))
{
- if (parseFeaturesFile(file, protocol))
+ if (parseFeaturesFile(file, sourceType))
{
alignPanel.paintAlignment(true);
}
}
else
{
- new FileLoader().LoadFile(viewport, file, protocol, format);
+ new FileLoader().LoadFile(viewport, file, sourceType, format);
}
}
}
}
new OOMWarning(
"loading data "
- + (protocol != null ? (protocol.equals(FormatAdapter.PASTE) ? "from clipboard."
- : "using " + protocol + " from " + file)
+ + (sourceType != null ? (sourceType == DataSourceType.PASTE ? "from clipboard."
+ : "using " + sourceType + " from " + file)
: ".")
+ (format != null ? "(parsing as '" + format
+ "' file)" : ""), oom, Desktop.desktop);
// TODO if we want this (e.g. to enable reload of the alignment from file),
// we will need to add parameters to the stack.
- // if (!protocol.equals(AppletFormatAdapter.PASTE))
+ // if (!protocol.equals(DataSourceType.PASTE))
// {
// alignFrame.setFileName(file, format);
// }
* type which are in the application scope (all, selected or unselected
* sequences).
*
- * @param type
+ * @param dataSourceType
*/
protected void changeShowHide_actionPerformed()
{
import jalview.datamodel.SequenceI;
import jalview.ext.rbvi.chimera.JalviewChimeraBinding;
import jalview.gui.StructureViewer.ViewerType;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
import jalview.schemes.BuriedColourScheme;
jmb.openFile(pe);
jmb.addSequence(pos, jmb.getSequence()[pos]);
File fl = new File(pe.getFile());
- String protocol = AppletFormatAdapter.URL;
+ DataSourceType protocol = DataSourceType.URL;
try
{
if (fl.exists())
{
- protocol = AppletFormatAdapter.FILE;
+ protocol = DataSourceType.FILE;
}
} catch (Throwable e)
{
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.SequenceI;
import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormatI;
import jalview.io.FileParse;
import jalview.io.FormatAdapter;
import jalview.io.IdentifyFile;
return;
}
- String format = new IdentifyFile().identify(text, "Paste");
- if (format == null || format.equalsIgnoreCase("EMPTY DATA FILE"))
+ FileFormatI format = new IdentifyFile().identify(text,
+ DataSourceType.PASTE);
+ if (format == null)
{
System.err.println(MessageManager
.getString("label.couldnt_read_data"));
if (!Jalview.isHeadlessMode())
{
- javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop,
+ JOptionPane.showInternalMessageDialog(Desktop.desktop,
AppletFormatAdapter.SUPPORTED_FORMATS,
MessageManager.getString("label.couldnt_read_data"),
JOptionPane.WARNING_MESSAGE);
try
{
FormatAdapter fa = new FormatAdapter(alignpanel);
- al = fa.readFile(getText(), "Paste", format);
+ al = fa.readFile(getText(), DataSourceType.PASTE, format);
source = fa.getAlignFile();
} catch (java.io.IOException ex)
import jalview.api.AlignmentViewPanel;
import jalview.bin.Cache;
import jalview.bin.Jalview;
+import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FileFormatException;
+import jalview.io.FileFormatI;
import jalview.io.FileLoader;
-import jalview.io.FormatAdapter;
import jalview.io.IdentifyFile;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
String file = (String) contents
.getTransferData(DataFlavor.stringFlavor);
- String format = new IdentifyFile().identify(file,
- FormatAdapter.PASTE);
+ FileFormatI format = new IdentifyFile().identify(file,
+ DataSourceType.PASTE);
- new FileLoader().LoadFile(file, FormatAdapter.PASTE, format);
+ new FileLoader().LoadFile(file, DataSourceType.PASTE, format);
}
} catch (Exception ex)
{
boolean success = true;
Transferable t = evt.getTransferable();
- java.util.List<String> files = new ArrayList<String>();
- java.util.List<String> protocols = new ArrayList<String>();
+ List<String> files = new ArrayList<String>();
+ List<DataSourceType> protocols = new ArrayList<DataSourceType>();
try
{
for (int i = 0; i < files.size(); i++)
{
String file = files.get(i).toString();
- String protocol = (protocols == null) ? FormatAdapter.FILE
- : (String) protocols.get(i);
- String format = null;
+ DataSourceType protocol = (protocols == null) ? DataSourceType.FILE
+ : protocols.get(i);
+ FileFormatI format = null;
if (file.endsWith(".jar"))
{
- format = "Jalview";
+ format = FileFormat.Jalview;
}
else
public void inputLocalFileMenuItem_actionPerformed(AlignViewport viewport)
{
JalviewFileChooser chooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
- jalview.io.AppletFormatAdapter.READABLE_EXTENSIONS,
- jalview.io.AppletFormatAdapter.READABLE_FNAMES,
- jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
+ Cache.getProperty("LAST_DIRECTORY"),
+ AppletFormatAdapter.READABLE_EXTENSIONS,
+ AppletFormatAdapter.READABLE_FNAMES,
+ Cache.getProperty("DEFAULT_FILE_FORMAT"));
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager
if (value == JalviewFileChooser.APPROVE_OPTION)
{
String choice = chooser.getSelectedFile().getPath();
- jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser
+ Cache.setProperty("LAST_DIRECTORY", chooser
.getSelectedFile().getParent());
- String format = null;
+ FileFormatI format = null;
if (chooser.getSelectedFormat() != null
- && chooser.getSelectedFormat().equals("Jalview"))
+ && chooser.getSelectedFormat() == FileFormat.Jalview)
{
- format = "Jalview";
+ format = FileFormat.Jalview;
}
else
{
- format = new IdentifyFile().identify(choice, FormatAdapter.FILE);
+ try
+ {
+ format = new IdentifyFile().identify(choice, DataSourceType.FILE);
+ } catch (FileFormatException e)
+ {
+ // format is null
+ }
}
if (viewport != null)
{
- new FileLoader().LoadFile(viewport, choice, FormatAdapter.FILE,
+ new FileLoader().LoadFile(viewport, choice, DataSourceType.FILE,
format);
}
else
{
- new FileLoader().LoadFile(choice, FormatAdapter.FILE, format);
+ new FileLoader().LoadFile(choice, DataSourceType.FILE, format);
}
}
}
*
* @param e
* DOCUMENT ME!
+ * @throws FileFormatException
*/
@Override
public void inputURLMenuItem_actionPerformed(AlignViewport viewport)
+ throws FileFormatException
{
// This construct allows us to have a wider textfield
// for viewing
{
if (viewport != null)
{
- new FileLoader().LoadFile(viewport, url, FormatAdapter.URL,
- "Jalview");
+ new FileLoader().LoadFile(viewport, url, DataSourceType.URL,
+ FileFormat.Jalview);
}
else
{
- new FileLoader().LoadFile(url, FormatAdapter.URL, "Jalview");
+ new FileLoader().LoadFile(url, DataSourceType.URL,
+ FileFormat.Jalview);
}
}
else
{
- String format = new IdentifyFile().identify(url, FormatAdapter.URL);
+ FileFormatI format = new IdentifyFile().identify(url,
+ DataSourceType.URL);
if (format.equals("URL NOT FOUND"))
{
if (viewport != null)
{
- new FileLoader().LoadFile(viewport, url, FormatAdapter.URL, format);
+ new FileLoader()
+ .LoadFile(viewport, url, DataSourceType.URL, format);
}
else
{
- new FileLoader().LoadFile(url, FormatAdapter.URL, format);
+ new FileLoader().LoadFile(url, DataSourceType.URL, format);
}
}
}
}
public static void transferFromDropTarget(List<String> files,
- List<String> protocols, DropTargetDropEvent evt, Transferable t)
+ List<DataSourceType> protocols, DropTargetDropEvent evt,
+ Transferable t)
throws Exception
{
.getTransferData(DataFlavor.javaFileListFlavor))
{
files.add(((File)file).toString());
- protocols.add(FormatAdapter.FILE);
+ protocols.add(DataSourceType.FILE);
}
}
else
{
Cache.log.debug("Adding missing FILE protocol for "
+ files.get(protocols.size()));
- protocols.add(FormatAdapter.FILE);
+ protocols.add(DataSourceType.FILE);
}
for (java.util.StringTokenizer st = new java.util.StringTokenizer(
data, "\r\n"); st.hasMoreTokens();)
java.net.URI uri = new java.net.URI(s);
if (uri.getScheme().toLowerCase().startsWith("http"))
{
- protocols.add(FormatAdapter.URL);
+ protocols.add(DataSourceType.URL);
files.add(uri.toString());
}
else
{
// otherwise preserve old behaviour: catch all for file objects
java.io.File file = new java.io.File(uri);
- protocols.add(FormatAdapter.FILE);
+ protocols.add(DataSourceType.FILE);
files.add(file.toString());
}
}
import jalview.datamodel.StructureViewerModel.StructureData;
import jalview.ext.varna.RnaModel;
import jalview.gui.StructureViewer.ViewerType;
+import jalview.io.DataSourceType;
import jalview.schemabinding.version2.AlcodMap;
import jalview.schemabinding.version2.AlcodonFrame;
import jalview.schemabinding.version2.Annotation;
if (entry.getProperty() != null && !entry.getProperty().isEmpty())
{
PdbentryItem item = new PdbentryItem();
- Hashtable properties = entry.getProperty();
- Enumeration en2 = properties.keys();
+ Hashtable<String, String> properties = entry.getProperty();
+ Enumeration<String> en2 = properties.keys();
while (en2.hasMoreElements())
{
Property prop = new Property();
- String key = en2.nextElement().toString();
+ String key = en2.nextElement();
prop.setName(key);
- prop.setValue(properties.get(key).toString());
+ prop.setValue(properties.get(key));
item.addProperty(prop);
}
pdb.addPdbentryItem(item);
StructureData filedat = oldFiles.get(id);
String pdbFile = filedat.getFilePath();
SequenceI[] seq = filedat.getSeqList().toArray(new SequenceI[0]);
- binding.getSsm().setMapping(seq, null, pdbFile,
- jalview.io.AppletFormatAdapter.FILE);
+ binding.getSsm().setMapping(seq, null, pdbFile, DataSourceType.FILE);
binding.addSequenceForStructFile(pdbFile, seq);
}
// and add the AlignmentPanel's reference to the view panel
public void startupFileTextfield_mouseClicked()
{
JalviewFileChooser chooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"), new String[] {
+ Cache.getProperty("LAST_DIRECTORY"), new String[] {
"fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
"jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF",
"PIR", "BLC", "Jalview" },
- jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
+ Cache.getProperty("DEFAULT_FILE_FORMAT"));
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager
.getString("label.select_startup_file"));
if (value == JalviewFileChooser.APPROVE_OPTION)
{
- jalview.bin.Cache.applicationProperties.setProperty(
- "DEFAULT_FILE_FORMAT", chooser.getSelectedFormat());
+ Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT",
+ chooser
+ .getSelectedFormat().toString());
startupFileTextfield.setText(chooser.getSelectedFile()
.getAbsolutePath());
}
}
PDBEntry fileEntry = new AssociatePdbFileWithSeq()
.associatePdbWithSeq(selectedPdbFileName,
- jalview.io.AppletFormatAdapter.FILE,
+ jalview.io.DataSourceType.FILE,
selectedSequence, true, Desktop.instance);
launchStructureViewer(ssm, new PDBEntry[] { fileEntry }, ap,
import jalview.datamodel.SequenceI;
import jalview.gui.StructureViewer.ViewerType;
import jalview.gui.ViewSelectionMenu.ViewSetProvider;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
import jalview.jbgui.GStructureViewer;
import jalview.structures.models.AAStructureBindingModel;
import jalview.util.MessageManager;
this.ap = alp;
}
+ @Override
public AlignmentPanel[] getAllAlignmentPanels()
{
AlignmentPanel[] t, list = new AlignmentPanel[0];
// queue.
new Thread(new Runnable()
{
+ @Override
public void run()
{
while (worker != null && worker.isAlive() && _started)
* create the mappings
*/
apanel.getStructureSelectionManager().setMapping(seq, chains,
- pdbFilename, AppletFormatAdapter.FILE);
+ pdbFilename, DataSourceType.FILE);
/*
* alert the FeatureRenderer to show new (PDB RESNUM) features
* @author $author$
* @version $Revision$
*/
-public abstract class AlignFile extends FileParse
+public abstract class AlignFile extends FileParse implements AlignmentFileI
{
int noSeqs = 0;
*
* @param dataObject
* Filename, URL or Pasted String to read from.
- * @param type
+ * @param sourceType
* What type of file to read from (File, URL, Pasted String)
*/
- public AlignFile(String dataObject, String type) throws IOException
+ public AlignFile(String dataObject, DataSourceType sourceType)
+ throws IOException
{
- this(true, dataObject, type);
+ this(true, dataObject, sourceType);
}
/**
* if false, need to call 'doParse()' to begin parsing data
* @param dataObject
* Filename, URL or Pasted String to read from.
- * @param type
+ * @param sourceType
* What type of file to read from (File, URL)
* @throws IOException
*/
- public AlignFile(boolean parseImmediately, String dataObject, String type)
+ public AlignFile(boolean parseImmediately, String dataObject,
+ DataSourceType sourceType)
throws IOException
{
- super(dataObject, type);
+ super(dataObject, sourceType);
initData();
if (parseImmediately)
{
/**
* Return the Sequences in the seqs Vector as an array of Sequences
*/
+ @Override
public SequenceI[] getSeqsAsArray()
{
SequenceI[] s = new SequenceI[seqs.size()];
*
* @param al
*/
+ @Override
public void addAnnotations(AlignmentI al)
{
addProperties(al);
* @param s
* DOCUMENT ME!
*/
- protected void setSeqs(SequenceI[] s)
+ @Override
+ public void setSeqs(SequenceI[] s)
{
seqs = new Vector<SequenceI>();
/**
* Print out in alignment file format the Sequences in the seqs Vector.
*/
+ @Override
public abstract String print();
+ @Override
public void addJVSuffix(boolean b)
{
jvSuffix = b;
return newickStrings == null ? 0 : newickStrings.size();
}
+ @Override
public void addGroups(AlignmentI al)
{
String refSeqId = null;
public boolean annotateAlignmentView(AlignViewportI viewport,
- String file, String protocol)
+ String file, DataSourceType protocol)
{
ColumnSelection colSel = viewport.getColumnSelection();
if (colSel == null)
}
public boolean readAnnotationFile(AlignmentI al, String file,
- String protocol)
+ DataSourceType sourceType)
{
- return readAnnotationFile(al, null, file, protocol);
+ return readAnnotationFile(al, null, file, sourceType);
}
public boolean readAnnotationFile(AlignmentI al, ColumnSelection colSel,
- String file, String protocol)
+ String file, DataSourceType sourceType)
{
BufferedReader in = null;
try
{
- if (protocol.equals(AppletFormatAdapter.FILE))
+ if (sourceType == DataSourceType.FILE)
{
in = new BufferedReader(new FileReader(file));
}
- else if (protocol.equals(AppletFormatAdapter.URL))
+ else if (sourceType == DataSourceType.URL)
{
URL url = new URL(file);
in = new BufferedReader(new InputStreamReader(url.openStream()));
}
- else if (protocol.equals(AppletFormatAdapter.PASTE))
+ else if (sourceType == DataSourceType.PASTE)
{
in = new BufferedReader(new StringReader(file));
}
- else if (protocol.equals(AppletFormatAdapter.CLASSLOADER))
+ else if (sourceType == DataSourceType.CLASSLOADER)
{
java.io.InputStream is = getClass().getResourceAsStream("/" + file);
if (is != null)
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentView;
import jalview.structure.StructureImportSettings;
-import jalview.util.MessageManager;
import java.io.File;
import java.io.IOException;
{
private AlignmentViewPanel viewpanel;
- public static String FILE = "File";
-
- public static String URL = "URL";
-
- public static String PASTE = "Paste";
-
- public static String CLASSLOADER = "ClassLoader";
-
/**
* add jalview-derived non-secondary structure annotation from PDB structure
*/
*/
boolean serviceSecondaryStruct = false;
- private AlignFile alignFile = null;
+ private AlignmentFileI alignFile = null;
String inFile;
*/
public static final String[] READABLE_FORMATS = new String[] { "BLC",
"CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "STH", "PDB",
- "JnetFile", "RNAML", PhylipFile.FILE_DESC, JSONFile.FILE_DESC,
+ "JnetFile", "RNAML", "PHYLIP", "JSON",
IdentifyFile.FeaturesFile, "HTML", "mmCIF" };
/**
*/
public static final String[] READABLE_EXTENSIONS = new String[] {
"fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa",
- "sto,stk", "xml,rnaml", PhylipFile.FILE_EXT, JSONFile.FILE_EXT,
+ "sto,stk", "xml,rnaml", "phy", "json",
".gff2,gff3", "jar,jvp", HtmlFile.FILE_EXT, "cif" };
/**
*/
public static final String[] READABLE_FNAMES = new String[] { "Fasta",
"Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "Stockholm", "RNAML",
- PhylipFile.FILE_DESC, JSONFile.FILE_DESC, IdentifyFile.FeaturesFile,
+ "PHYLIP", "JSON", IdentifyFile.FeaturesFile,
"Jalview", HtmlFile.FILE_DESC, "mmCIF" };
/**
*/
public static final String[] WRITEABLE_FORMATS = new String[] { "BLC",
"CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "AMSA", "STH",
- PhylipFile.FILE_DESC, JSONFile.FILE_DESC };
+ "PHYLIP", "JSON" };
/**
* List of extensions corresponding to file format types in WRITABLE_FNAMES
*/
public static final String[] WRITABLE_EXTENSIONS = new String[] {
"fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa",
- "sto,stk", PhylipFile.FILE_EXT, JSONFile.FILE_EXT, "jvp" };
+ "sto,stk", "phy", "json", "jvp" };
/**
* List of writable formats by the application. Order must correspond with the
*/
public static final String[] WRITABLE_FNAMES = new String[] { "Fasta",
"Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "STH",
- PhylipFile.FILE_DESC, JSONFile.FILE_DESC, "Jalview" };
+ "PHYLIP", "JSON", "Jalview" };
public static String INVALID_CHARACTERS = "Contains invalid characters";
*
* @param inFile
* data/data location
- * @param type
+ * @param sourceType
* type of datasource
- * @param format
- * File format of data provided by datasource
+ * @param fileFormat
*
- * @return DOCUMENT ME!
+ * @return
*/
- public AlignmentI readFile(String inFile, String type, String format)
- throws java.io.IOException
+ public AlignmentI readFile(String file, DataSourceType sourceType,
+ FileFormatI fileFormat) throws IOException
{
- // TODO: generalise mapping between format string and io. class instances
- // using Constructor.invoke reflection
- this.inFile = inFile;
+ this.inFile = file;
try
{
- if (format.equals("FASTA"))
- {
- alignFile = new FastaFile(inFile, type);
- }
- else if (format.equals("MSF"))
- {
- alignFile = new MSFfile(inFile, type);
- }
- else if (format.equals("PileUp"))
- {
- alignFile = new PileUpfile(inFile, type);
- }
- else if (format.equals("CLUSTAL"))
- {
- alignFile = new ClustalFile(inFile, type);
- }
- else if (format.equals("BLC"))
- {
- alignFile = new BLCFile(inFile, type);
- }
- else if (format.equals("PIR"))
- {
- alignFile = new PIRFile(inFile, type);
- }
- else if (format.equals("PFAM"))
- {
- alignFile = new PfamFile(inFile, type);
- }
- else if (format.equals("JnetFile"))
- {
- alignFile = new JPredFile(inFile, type);
- ((JPredFile) alignFile).removeNonSequences();
- }
- else if (format.equals("PDB"))
- {
- // TODO obtain config value from preference settings.
- // Set value to 'true' to test PDB processing with Jmol: JAL-1213
- boolean isParseWithJMOL = !StructureImportSettings
- .getCurrentDefaultFormat().equalsIgnoreCase("PDB");
- if (isParseWithJMOL)
- {
- StructureImportSettings.addSettings(annotFromStructure,
- localSecondaryStruct, serviceSecondaryStruct);
- alignFile = new jalview.ext.jmol.JmolParser(annotFromStructure,
- localSecondaryStruct, serviceSecondaryStruct, inFile,
- type);
- }
- else
- {
- StructureImportSettings.addSettings(annotFromStructure,
- localSecondaryStruct, serviceSecondaryStruct);
- StructureImportSettings.setShowSeqFeatures(true);
- alignFile = new MCview.PDBfile(annotFromStructure,
- localSecondaryStruct, serviceSecondaryStruct, inFile,
- type);
- }
- }
- else if (format.equals("mmCIF"))
+ if (fileFormat == FileFormat.PDB || fileFormat == FileFormat.MMCif)
{
StructureImportSettings.addSettings(annotFromStructure,
localSecondaryStruct, serviceSecondaryStruct);
- alignFile = new jalview.ext.jmol.JmolParser(annotFromStructure,
- localSecondaryStruct, serviceSecondaryStruct, inFile, type);
+ alignFile = fileFormat.getAlignmentFile(inFile, sourceType);
}
- else if (format.equals("STH"))
- {
- alignFile = new StockholmFile(inFile, type);
- }
- else if (format.equals("SimpleBLAST"))
- {
- alignFile = new SimpleBlastFile(inFile, type);
- }
- else if (format.equals(PhylipFile.FILE_DESC))
- {
- alignFile = new PhylipFile(inFile, type);
- }
- else if (format.equals(JSONFile.FILE_DESC))
- {
- alignFile = new JSONFile(inFile, type);
- }
- else if (format.equals(HtmlFile.FILE_DESC))
- {
- alignFile = new HtmlFile(inFile, type);
- }
- else if (format.equals("RNAML"))
- {
- alignFile = new RnamlFile(inFile, type);
- }
- else if (format.equals(IdentifyFile.FeaturesFile))
+ else
{
- alignFile = new FeaturesFile(true, inFile, type);
- }
- return buildAlignmentFrom(alignFile);
+ alignFile = fileFormat.getAlignmentFile(inFile, sourceType);
+ }
+ // new FastaFile(inFile, sourceType);
+ // new MSFfile(inFile, sourceType);
+ // new PileUpfile(inFile, sourceType);
+ // new ClustalFile(inFile, sourceType);
+ // new BLCFile(inFile, sourceType);
+ // new PIRFile(inFile, sourceType);
+ // new PfamFile(inFile, sourceType);
+ // alignFile = new JPredFile(inFile, sourceType);
+ // ((JPredFile) alignFile).removeNonSequences();
+ // new StockholmFile(inFile, sourceType);
+ // new SimpleBlastFile(inFile, sourceType);
+ // new PhylipFile(inFile, sourceType);
+ // new JSONFile(inFile, sourceType);
+ // new HtmlFile(inFile, sourceType);
+ // new RnamlFile(inFile, sourceType);
+// alignFile = new FeaturesFile(true, inFile, sourceType);
+ return buildAlignmentFromFile();
} catch (Exception e)
{
e.printStackTrace();
- System.err.println("Failed to read alignment using the '" + format
+ System.err.println("Failed to read alignment using the '"
+ + fileFormat
+ "' reader.\n" + e);
if (e.getMessage() != null
&& e.getMessage().startsWith(INVALID_CHARACTERS))
{
- throw new java.io.IOException(e.getMessage());
+ throw new IOException(e.getMessage());
}
// Finally test if the user has pasted just the sequence, no id
- if (type.equalsIgnoreCase("Paste"))
+ if (sourceType == DataSourceType.PASTE)
{
try
{
// Possible sequence is just residues with no label
- alignFile = new FastaFile(">UNKNOWN\n" + inFile, "Paste");
- return buildAlignmentFrom(alignFile);
+ alignFile = new FastaFile(">UNKNOWN\n" + inFile,
+ DataSourceType.PASTE);
+ return buildAlignmentFromFile();
} catch (Exception ex)
{
if (ex.toString().startsWith(INVALID_CHARACTERS))
{
- throw new java.io.IOException(e.getMessage());
+ throw new IOException(e.getMessage());
}
ex.printStackTrace();
}
}
- if (format.equalsIgnoreCase("HTML"))
+ if (fileFormat == FileFormat.Html)
{
throw new IOException(e.getMessage());
}
- // If we get to this stage, the format was not supported
- throw new java.io.IOException(SUPPORTED_FORMATS);
}
+ throw new FileFormatException(SUPPORTED_FORMATS);
}
/**
* @param format
* File format of data that will be provided by datasource
*
- * @return DOCUMENT ME!
+ * @return
*/
- public AlignmentI readFromFile(FileParse source, String format)
- throws java.io.IOException
+ public AlignmentI readFromFile(FileParse source, FileFormatI format)
+ throws IOException
{
- // TODO: generalise mapping between format string and io. class instances
- // using Constructor.invoke reflection
- // This is exactly the same as the readFile method except we substitute
- // 'inFile, type' with 'source'
this.inFile = source.getInFile();
- String type = source.type;
+ DataSourceType type = source.dataSourceType;
try
{
- if (format.equals("FASTA"))
- {
- alignFile = new FastaFile(source);
- }
- else if (format.equals("MSF"))
- {
- alignFile = new MSFfile(source);
- }
- else if (format.equals("PileUp"))
- {
- alignFile = new PileUpfile(source);
- }
- else if (format.equals("CLUSTAL"))
- {
- alignFile = new ClustalFile(source);
- }
- else if (format.equals("BLC"))
- {
- alignFile = new BLCFile(source);
- }
- else if (format.equals("PIR"))
- {
- alignFile = new PIRFile(source);
- }
- else if (format.equals("PFAM"))
- {
- alignFile = new PfamFile(source);
- }
- else if (format.equals("JnetFile"))
- {
- alignFile = new JPredFile(source);
- ((JPredFile) alignFile).removeNonSequences();
- }
- else if (format.equals("PDB"))
- {
- // TODO obtain config value from preference settings
- boolean isParseWithJMOL = false;
- if (isParseWithJMOL)
- {
- StructureImportSettings.addSettings(annotFromStructure,
- localSecondaryStruct, serviceSecondaryStruct);
- alignFile = new jalview.ext.jmol.JmolParser(annotFromStructure,
- localSecondaryStruct, serviceSecondaryStruct, source);
- }
- else
- {
- StructureImportSettings.setShowSeqFeatures(true);
- alignFile = new MCview.PDBfile(annotFromStructure,
- localSecondaryStruct, serviceSecondaryStruct, source);
- }
- }
- else if (format.equals("mmCIF"))
+ if (format == FileFormat.PDB || format == FileFormat.MMCif)
{
StructureImportSettings.addSettings(annotFromStructure,
localSecondaryStruct, serviceSecondaryStruct);
- alignFile = new jalview.ext.jmol.JmolParser(annotFromStructure,
- localSecondaryStruct, serviceSecondaryStruct, source);
- }
- else if (format.equals("STH"))
- {
- alignFile = new StockholmFile(source);
- }
- else if (format.equals("RNAML"))
- {
- alignFile = new RnamlFile(source);
+ alignFile = format.getAlignmentFile(source);
}
- else if (format.equals("SimpleBLAST"))
- {
- alignFile = new SimpleBlastFile(source);
- }
- else if (format.equals(PhylipFile.FILE_DESC))
- {
- alignFile = new PhylipFile(source);
- }
- else if (format.equals(IdentifyFile.FeaturesFile))
- {
- alignFile = new FeaturesFile(inFile, type);
- }
- else if (format.equals(JSONFile.FILE_DESC))
- {
- alignFile = new JSONFile(source);
- }
- else if (format.equals(HtmlFile.FILE_DESC))
+ else
{
- alignFile = new HtmlFile(source);
+ alignFile = format.getAlignmentFile(source);
}
- return buildAlignmentFrom(alignFile);
+ return buildAlignmentFromFile();
} catch (Exception e)
{
if (e.getMessage() != null
&& e.getMessage().startsWith(INVALID_CHARACTERS))
{
- throw new java.io.IOException(e.getMessage());
+ throw new FileFormatException(e.getMessage());
}
// Finally test if the user has pasted just the sequence, no id
- if (type.equalsIgnoreCase("Paste"))
+ if (type == DataSourceType.PASTE)
{
try
{
// Possible sequence is just residues with no label
- alignFile = new FastaFile(">UNKNOWN\n" + inFile, "Paste");
- return buildAlignmentFrom(alignFile);
+ alignFile = new FastaFile(">UNKNOWN\n" + inFile,
+ DataSourceType.PASTE);
+ return buildAlignmentFromFile();
} catch (Exception ex)
{
if (ex.toString().startsWith(INVALID_CHARACTERS))
{
- throw new java.io.IOException(e.getMessage());
+ throw new IOException(e.getMessage());
}
ex.printStackTrace();
}
// If we get to this stage, the format was not supported
- throw new java.io.IOException(SUPPORTED_FORMATS);
+ throw new FileFormatException(SUPPORTED_FORMATS);
}
}
* boilerplate method to handle data from an AlignFile and construct a new
* alignment or import to an existing alignment
*
- * @param alignFile2
* @return AlignmentI instance ready to pass to a UI constructor
*/
- private AlignmentI buildAlignmentFrom(AlignFile alignFile2)
+ private AlignmentI buildAlignmentFromFile()
{
// Standard boilerplate for creating alignment from parser
// alignFile.configureForView(viewpanel);
* @param selectedOnly
* @return flatfile in a string
*/
- public String formatSequences(String format, boolean jvsuffix,
+ public String formatSequences(FileFormatI format, boolean jvsuffix,
AlignmentViewPanel ap, boolean selectedOnly)
{
*
* @return alignment flat file contents
*/
- public String formatSequences(String format, AlignmentI alignment,
+ public String formatSequences(FileFormatI format, AlignmentI alignment,
boolean jvsuffix)
{
try
{
- AlignFile afile = null;
- if (format.equalsIgnoreCase("FASTA"))
- {
- afile = new FastaFile();
- }
- else if (format.equalsIgnoreCase("MSF"))
- {
- afile = new MSFfile();
- }
- else if (format.equalsIgnoreCase("PileUp"))
- {
- afile = new PileUpfile();
- }
- else if (format.equalsIgnoreCase("CLUSTAL"))
- {
- afile = new ClustalFile();
- }
- else if (format.equalsIgnoreCase("BLC"))
- {
- afile = new BLCFile();
- }
- else if (format.equalsIgnoreCase("PIR"))
- {
- afile = new PIRFile();
- }
- else if (format.equalsIgnoreCase("PFAM"))
- {
- afile = new PfamFile();
- }
- else if (format.equalsIgnoreCase("STH"))
- {
- afile = new StockholmFile(alignment);
- }
- else if (format.equalsIgnoreCase("AMSA"))
- {
- afile = new AMSAFile(alignment);
- }
- else if (format.equalsIgnoreCase(PhylipFile.FILE_DESC))
- {
- afile = new PhylipFile();
- }
- else if (format.equalsIgnoreCase(JSONFile.FILE_DESC))
- {
- afile = new JSONFile();
- }
- else if (format.equalsIgnoreCase("RNAML"))
- {
- afile = new RnamlFile();
- }
-
- else
- {
- throw new Exception(
- MessageManager
- .getString("error.implementation_error_unknown_file_format_string"));
- }
+ AlignmentFileI afile = format.getAlignmentFile();
afile.setNewlineString(newline);
afile.addJVSuffix(jvsuffix);
return null;
}
- public static String checkProtocol(String file)
+ public static DataSourceType checkProtocol(String file)
{
- String protocol = FILE;
+ DataSourceType protocol = DataSourceType.FILE;
String ft = file.toLowerCase().trim();
if (ft.indexOf("http:") == 0 || ft.indexOf("https:") == 0
|| ft.indexOf("file:") == 0)
{
- protocol = URL;
+ protocol = DataSourceType.URL;
}
return protocol;
}
System.gc();
long memf = -r.totalMemory() + r.freeMemory();
long t1 = -System.currentTimeMillis();
- AlignmentI al = afa.readFile(args[i], FILE,
- new IdentifyFile().identify(args[i], FILE));
+ AlignmentI al = afa
+ .readFile(args[i], DataSourceType.FILE,
+ new IdentifyFile().identify(args[i],
+ DataSourceType.FILE));
t1 += System.currentTimeMillis();
System.gc();
memf += r.totalMemory() - r.freeMemory();
try
{
System.out.println(new AppletFormatAdapter().formatSequences(
- "FASTA", al, true));
+ FileFormat.Fasta, al, true));
} catch (Exception e)
{
System.err
* @param format
* @return protocol that yields the data parsable as the given type
*/
- public static String resolveProtocol(String file, String format)
+ public static DataSourceType resolveProtocol(String file,
+ FileFormatI format)
{
return resolveProtocol(file, format, false);
}
- public static String resolveProtocol(String file, String format,
- boolean debug)
+ public static DataSourceType resolveProtocol(String file,
+ FileFormatI format, boolean debug)
{
// TODO: test thoroughly!
- String protocol = null;
+ DataSourceType protocol = null;
if (debug)
{
System.out.println("resolving datasource started with:\n>>file\n"
System.err.println("Resource '" + file + "' was "
+ (rtn ? "" : "not") + " located by classloader.");
}
- ;
if (rtn)
{
- protocol = AppletFormatAdapter.CLASSLOADER;
+ protocol = DataSourceType.CLASSLOADER;
}
} catch (Exception ex)
if (file.indexOf("://") > -1)
{
- protocol = AppletFormatAdapter.URL;
+ protocol = DataSourceType.URL;
}
else
{
// skipping codebase prepend check.
- protocol = AppletFormatAdapter.FILE;
+ protocol = DataSourceType.FILE;
}
FileParse fp = null;
try
{
System.out.println("Accessing as paste.");
}
- protocol = AppletFormatAdapter.PASTE;
+ protocol = DataSourceType.PASTE;
fp = null;
try
{
{
return null;
}
- if (format == null || format.length() == 0)
+ if (format == null)
{
return protocol;
}
{
try
{
- String idformat = new jalview.io.IdentifyFile().identify(file,
+ FileFormatI idformat = new IdentifyFile().identify(file,
protocol);
if (idformat == null)
{
System.err.println("File deemed not accessible via " + protocol);
e.printStackTrace();
}
- ;
-
}
}
return null;
}
- public AlignFile getAlignFile()
+ public AlignmentFileI getAlignFile()
{
return alignFile;
}
-
- public void setAlignFile(AlignFile alignFile)
- {
- this.alignFile = alignFile;
- }
}
*
* @param inFile
* DOCUMENT ME!
- * @param type
+ * @param sourceType
* DOCUMENT ME!
*
* @throws IOException
* DOCUMENT ME!
*/
- public BLCFile(String inFile, String type) throws IOException
+ public BLCFile(String inFile, DataSourceType sourceType)
+ throws IOException
{
- super(inFile, type);
+ super(inFile, sourceType);
}
public BLCFile(FileParse source) throws IOException
/**
* DOCUMENT ME!
*/
+ @Override
public void initData()
{
super.initData();
/**
* DOCUMENT ME!
*/
+ @Override
public void parse() throws IOException
{
StringBuffer headerLines = new StringBuffer();
*
* @return DOCUMENT ME!
*/
+ @Override
public String print()
{
return print(getSeqsAsArray());
import jalview.api.AlignmentViewPanel;
import jalview.datamodel.AlignmentExportData;
import jalview.exceptions.NoFileSelectedException;
+import jalview.gui.AlignFrame;
import jalview.gui.IProgressIndicator;
import jalview.gui.OOMWarning;
import jalview.json.binding.biojs.BioJSReleasePojo;
}
};
- AlignmentExportData exportData = jalview.gui.AlignFrame
- .getAlignmentForExport(JSONFile.FILE_DESC,
+ AlignmentExportData exportData = AlignFrame
+ .getAlignmentForExport(FileFormat.Json,
ap.getAlignViewport(), exportSettings);
String bioJSON = new FormatAdapter(ap, exportData.getSettings())
- .formatSequences(JSONFile.FILE_DESC, exportData
+ .formatSequences(FileFormat.Json, exportData
.getAlignment(), exportData.getOmitHidden(),
exportData.getStartEndPostions(), ap
.getAlignViewport().getColumnSelection());
{
}
- public ClustalFile(String inFile, String type) throws IOException
+ public ClustalFile(String inFile, DataSourceType sourceType)
+ throws IOException
{
- super(inFile, type);
+ super(inFile, sourceType);
}
public ClustalFile(FileParse source) throws IOException
*
* @param inFile
* DOCUMENT ME!
- * @param type
+ * @param sourceType
* DOCUMENT ME!
*
* @throws IOException
* DOCUMENT ME!
*/
- public FastaFile(String inFile, String type) throws IOException
+ public FastaFile(String inFile, DataSourceType sourceType)
+ throws IOException
{
- super(inFile, type);
+ super(inFile, sourceType);
}
public FastaFile(FileParse source) throws IOException
* Constructor which does not parse the file immediately
*
* @param inFile
- * @param type
+ * @param paste
* @throws IOException
*/
- public FeaturesFile(String inFile, String type) throws IOException
+ public FeaturesFile(String inFile, DataSourceType paste)
+ throws IOException
{
- super(false, inFile, type);
+ super(false, inFile, paste);
}
/**
* @param type
* @throws IOException
*/
- public FeaturesFile(boolean parseImmediately, String inFile, String type)
+ public FeaturesFile(boolean parseImmediately, String inFile,
+ DataSourceType type)
throws IOException
{
super(parseImmediately, inFile, type);
import jalview.api.FeatureSettingsModelI;
import jalview.api.FeaturesDisplayedI;
import jalview.api.FeaturesSourceI;
+import jalview.bin.Cache;
import jalview.bin.Jalview;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
{
String file;
- String protocol;
+ DataSourceType protocol;
- String format;
+ FileFormatI format;
- FileParse source = null; // alternative specification of where data comes
+ AlignmentFileI source = null; // alternative specification of where data comes
// from
}
public void LoadFile(AlignViewport viewport, String file,
- String protocol, String format)
+ DataSourceType protocol, FileFormatI format)
{
this.viewport = viewport;
LoadFile(file, protocol, format);
}
- public void LoadFile(String file, String protocol, String format)
+ public void LoadFile(String file, DataSourceType protocol,
+ FileFormatI format)
{
this.file = file;
this.protocol = protocol;
* @param file
* @param protocol
*/
- public void LoadFile(String file, String protocol)
+ public void LoadFile(String file, DataSourceType protocol)
{
LoadFile(file, protocol, null);
}
* Load alignment from (file, protocol) and wait till loaded
*
* @param file
- * @param protocol
+ * @param sourceType
* @return alignFrame constructed from file contents
*/
- public AlignFrame LoadFileWaitTillLoaded(String file, String protocol)
+ public AlignFrame LoadFileWaitTillLoaded(String file,
+ DataSourceType sourceType)
{
- return LoadFileWaitTillLoaded(file, protocol, null);
+ return LoadFileWaitTillLoaded(file, sourceType, null);
}
/**
* Load alignment from (file, protocol) of type format and wait till loaded
*
* @param file
- * @param protocol
+ * @param sourceType
* @param format
* @return alignFrame constructed from file contents
*/
- public AlignFrame LoadFileWaitTillLoaded(String file, String protocol,
- String format)
+ public AlignFrame LoadFileWaitTillLoaded(String file,
+ DataSourceType sourceType, FileFormatI format)
{
this.file = file;
- this.protocol = protocol;
+ this.protocol = sourceType;
this.format = format;
return _LoadFileWaitTillLoaded();
}
* @param format
* @return alignFrame constructed from file contents
*/
- public AlignFrame LoadFileWaitTillLoaded(FileParse source, String format)
+ public AlignFrame LoadFileWaitTillLoaded(AlignmentFileI source,
+ FileFormatI format)
{
this.source = source;
file = source.getInFile();
- protocol = source.type;
+ protocol = source.getDataSourceType();
this.format = format;
return _LoadFileWaitTillLoaded();
}
public void updateRecentlyOpened()
{
Vector recent = new Vector();
- if (protocol.equals(FormatAdapter.PASTE))
+ if (protocol == DataSourceType.PASTE)
{
// do nothing if the file was pasted in as text... there is no filename to
// refer to it as.
return;
}
- String type = protocol.equals(FormatAdapter.FILE) ? "RECENT_FILE"
+ String type = protocol == DataSourceType.FILE ? "RECENT_FILE"
: "RECENT_URL";
String historyItems = jalview.bin.Cache.getProperty(type);
newHistory.append(recent.elementAt(i));
}
- jalview.bin.Cache.setProperty(type, newHistory.toString());
+ Cache.setProperty(type, newHistory.toString());
- if (protocol.equals(FormatAdapter.FILE))
+ if (protocol == DataSourceType.FILE)
{
- jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT", format);
+ Cache.setProperty("DEFAULT_FILE_FORMAT", format.toString());
}
}
@Override
public void run()
{
- String title = protocol.equals(AppletFormatAdapter.PASTE) ? "Copied From Clipboard"
+ String title = protocol == DataSourceType.PASTE ? "Copied From Clipboard"
: file;
Runtime rt = Runtime.getRuntime();
try
}
- if (format == null || format.equalsIgnoreCase("EMPTY DATA FILE"))
+ if (format == null)
{
Desktop.instance.stopLoading();
System.err.println("The input file \"" + file
loadtime = -System.currentTimeMillis();
AlignmentI al = null;
- if (format.equalsIgnoreCase("Jalview"))
+ if (format == FileFormat.Jalview)
{
if (source != null)
{
else
{
String error = AppletFormatAdapter.SUPPORTED_FORMATS;
- if (FormatAdapter.isValidFormat(format))
- {
try
{
if (source != null)
{
error = ex.getMessage();
}
- }
- else
- {
- if (format != null && format.length() > 7)
- {
- // ad hoc message in format.
- error = format + "\n" + error;
- }
- }
if ((al != null) && (al.getHeight() > 0) && al.hasValidSequence())
{
}
}
// add metadata and update ui
- if (!protocol.equals(AppletFormatAdapter.PASTE))
+ if (!(protocol == DataSourceType.PASTE))
{
alignFrame.setFileName(file, format);
}
*/
protected String suffix = null;
- protected String type = null;
+ protected DataSourceType dataSourceType = null;
protected BufferedReader dataIn = null;
suffix = from.suffix;
errormessage = from.errormessage; // inherit potential error messages
error = false; // reset any error condition.
- type = from.type;
+ dataSourceType = from.dataSourceType;
dataIn = from.dataIn;
if (dataIn != null)
{
* configurable values for the origin and the type of the source
*/
public FileParse(BufferedReader source, String originString,
- String typeString)
+ DataSourceType sourceType)
{
- type = typeString;
+ dataSourceType = sourceType;
error = false;
inFile = null;
dataName = originString;
*
* @param fileStr
* - datasource locator/content
- * @param type
+ * @param sourceType
* - protocol of source
* @throws MalformedURLException
* @throws IOException
*/
- public FileParse(String fileStr, String type)
+ public FileParse(String fileStr, DataSourceType sourceType)
throws MalformedURLException, IOException
{
- this.type = type;
+ this.dataSourceType = sourceType;
error = false;
- if (type.equals(AppletFormatAdapter.FILE))
+ if (sourceType == DataSourceType.FILE)
{
if (checkFileSource(fileStr))
{
}
}
}
- else if (type.equals(AppletFormatAdapter.URL))
+ else if (sourceType == DataSourceType.URL)
{
try
{
error = true;
}
}
- else if (type.equals(AppletFormatAdapter.PASTE))
+ else if (sourceType == DataSourceType.PASTE)
{
errormessage = "PASTE INACCESSIBLE!";
dataIn = new BufferedReader(new StringReader(fileStr));
dataName = "Paste";
}
- else if (type.equals(AppletFormatAdapter.CLASSLOADER))
+ else if (sourceType == DataSourceType.CLASSLOADER)
{
errormessage = "RESOURCE CANNOT BE LOCATED";
java.io.InputStream is = getClass()
else
{
errormessage = "PROBABLE IMPLEMENTATION ERROR : Datasource Type given as '"
- + (type != null ? type : "null") + "'";
+ + (sourceType != null ? sourceType : "null") + "'";
error = true;
}
if (dataIn == null || error)
{
return null;
}
+
+ public DataSourceType getDataSourceType()
+ {
+ return dataSourceType;
+ }
}
import jalview.api.AlignExportSettingI;
import jalview.api.AlignmentViewPanel;
+import jalview.bin.Cache;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import java.io.IOException;
+
/**
* Additional formatting methods used by the application in a number of places.
*
return null;
}
- public boolean getCacheSuffixDefault(String format)
+ public boolean getCacheSuffixDefault(FileFormatI format)
{
if (isValidFormat(format))
{
- return jalview.bin.Cache.getDefault(format.toUpperCase()
+ return Cache.getDefault(format.toUpperCase()
+ "_JVSUFFIX", true);
}
return false;
}
- public String formatSequences(String format, AlignmentI alignment,
+ public String formatSequences(FileFormatI format, AlignmentI alignment,
String[] omitHidden, int[] exportRange, ColumnSelection colSel)
{
return formatSequences(format, alignment, omitHidden, exportRange,
getCacheSuffixDefault(format), colSel, null);
}
- public String formatSequences(String format, AlignmentI alignment,
+ public String formatSequences(FileFormatI format, AlignmentI alignment,
String[] omitHidden, int[] exportRange, ColumnSelection colSel,
SequenceGroup sgp)
{
* defines hidden columns that are edited out of annotation
* @return string representation of the alignment formatted as format
*/
- public String formatSequences(String format, AlignmentI alignment,
+ public String formatSequences(FileFormatI format, AlignmentI alignment,
String[] omitHidden, int[] exportRange, boolean suffix,
ColumnSelection colSel)
{
suffix, colSel, null);
}
- public String formatSequences(String format, AlignmentI alignment,
+ public String formatSequences(FileFormatI format, AlignmentI alignment,
String[] omitHidden, int[] exportRange, boolean suffix,
- ColumnSelection colSel, jalview.datamodel.SequenceGroup selgp)
+ ColumnSelection colSel, SequenceGroup selgp)
{
if (omitHidden != null)
{
return this.formatSequences(format, alignment, suffix);
}
- public AlignmentI readFile(String inFile, String type, String format)
- throws java.io.IOException
+ @Override
+ public AlignmentI readFile(String file, DataSourceType sourceType,
+ FileFormatI fileFormat) throws IOException
{
- AlignmentI al = super.readFile(inFile, type, format);
+ AlignmentI al = super.readFile(file, sourceType, fileFormat);
return al;
}
- public AlignmentI readFromFile(FileParse source, String format)
- throws java.io.IOException
+ @Override
+ public AlignmentI readFromFile(FileParse source, FileFormatI format)
+ throws IOException
{
AlignmentI al = super.readFromFile(source, format);
return al;
* alignment panel originating the view
* @return String containing flat file
*/
- public String formatSequences(String format, AlignmentViewPanel ap,
+ public String formatSequences(FileFormatI format, AlignmentViewPanel ap,
boolean selectedOnly)
{
return formatSequences(format, getCacheSuffixDefault(format), ap,
super(source);
}
- public HtmlFile(String inFile, String type) throws IOException
+ public HtmlFile(String inFile, DataSourceType sourceType)
+ throws IOException
{
- super(inFile, type);
+ super(inFile, sourceType);
}
@Override
try
{
setProgressMessage(null);
- setProgressMessage(MessageManager
-.formatMessage(
+ setProgressMessage(MessageManager.formatMessage(
"status.exporting_alignment_as_x_file", "HTML"));
AlignmentDimension aDimension = ap.getAlignmentDimension();
SVGGraphics2D g1 = new SVGGraphics2D(aDimension.getWidth(),
};
AlignmentExportData exportData = jalview.gui.AlignFrame
- .getAlignmentForExport(JSONFile.FILE_DESC, av,
+ .getAlignmentForExport(FileFormat.Json, av,
exportSettings);
jsonData = new FormatAdapter(ap, exportData.getSettings())
- .formatSequences(JSONFile.FILE_DESC,
+ .formatSequences(FileFormat.Json,
exportData.getAlignment(),
exportData.getOmitHidden(),
exportData.getStartEndPostions(),
* instead.
*
* @param file
- * DOCUMENT ME!
- * @param protocol
- * DOCUMENT ME!
- * @return ID String
+ * @param sourceType
+ * @return
+ * @throws FileFormatException
*/
- public String identify(String file, String protocol)
+ public FileFormatI identify(String file, DataSourceType sourceType)
+ throws FileFormatException
{
String emessage = "UNIDENTIFIED FILE PARSING ERROR";
FileParse parser = null;
try
{
- parser = new FileParse(file, protocol);
+ parser = new FileParse(file, sourceType);
if (parser.isValid())
{
return identify(parser);
}
if (parser != null)
{
- return parser.errormessage;
+ throw new FileFormatException(parser.errormessage);
}
- return emessage;
+ throw new FileFormatException(emessage);
}
- public String identify(FileParse source)
+ public FileFormatI identify(FileParse source) throws FileFormatException
{
- return identify(source, true); // preserves original behaviour prior to
- // version 2.3
+ return identify(source, true);
+ // preserves original behaviour prior to version 2.3
}
/**
*
* @param source
* @param closeSource
- * @return filetype string
+ * @return (best guess at) file format
+ * @throws FileFormatException
*/
- public String identify(FileParse source, boolean closeSource)
+ public FileFormatI identify(FileParse source, boolean closeSource)
+ throws FileFormatException
{
- String reply = "PFAM";
+ FileFormatI reply = FileFormat.Pfam;
String data;
int bytesRead = 0;
int trimmedLength = 0;
if (fileStr.lastIndexOf(".jar") > -1
|| fileStr.lastIndexOf(".zip") > -1)
{
- reply = "Jalview";
+ reply = FileFormat.Jalview;
}
}
if (!lineswereskipped && data.startsWith("PK"))
{
- reply = "Jalview"; // archive.
+ reply = FileFormat.Jalview; // archive.
break;
}
}
if (data.startsWith("##GFF-VERSION"))
{
// GFF - possibly embedded in a Jalview features file!
- reply = FeaturesFile;
+ reply = FileFormat.Features;
break;
}
if (looksLikeFeatureData(data))
{
- reply = FeaturesFile;
+ reply = FileFormat.Features;
break;
}
if (data.indexOf("# STOCKHOLM") > -1)
{
- reply = "STH";
+ reply = FileFormat.Stockholm;
break;
}
if (data.indexOf("_ENTRY.ID") > -1
|| data.indexOf("_AUDIT_AUTHOR.NAME") > -1
|| data.indexOf("_ATOM_SITE.") > -1)
{
- reply = "mmCIF";
+ reply = FileFormat.MMCif;
break;
}
// if (data.indexOf(">") > -1)
{
// watch for PIR file attributes
checkPIR = true;
- reply = "PIR";
+ reply = FileFormat.PIR;
}
// could also be BLC file, read next line to confirm
data = source.nextLine();
if (data.indexOf(">") > -1)
{
- reply = "BLC";
+ reply = FileFormat.BLC;
}
else
{
{
if (c1 == 0 && c1 == data2.indexOf("*"))
{
- reply = "BLC";
+ reply = FileFormat.BLC;
}
else
{
- reply = "FASTA"; // possibly a bad choice - may be recognised as
+ reply = FileFormat.Fasta; // possibly a bad choice - may be
+ // recognised as
// PIR
}
// otherwise can still possibly be a PIR file
}
else
{
- reply = "FASTA";
+ reply = FileFormat.Fasta;
// TODO : AMSA File is indicated if there is annotation in the
// FASTA file - but FASTA will automatically generate this at the
// mo.
}
if (starterm)
{
- reply = "PIR";
+ reply = FileFormat.PIR;
break;
}
else
{
- reply = "FASTA"; // probably a bad choice!
+ reply = FileFormat.Fasta; // probably a bad choice!
}
}
// read as a FASTA (probably)
String upper = data.toUpperCase();
if (upper.substring(lessThan).startsWith("<HTML"))
{
- reply = HtmlFile.FILE_DESC;
+ reply = FileFormat.Html;
break;
}
if (upper.substring(lessThan).startsWith("<RNAML"))
{
- reply = "RNAML";
+ reply = FileFormat.Rnaml;
break;
}
}
if (data.indexOf("{\"") > -1)
{
- reply = JSONFile.FILE_DESC;
+ reply = FileFormat.Json;
break;
}
if ((data.length() < 1) || (data.indexOf("#") == 0))
if (data.indexOf("PILEUP") > -1)
{
- reply = "PileUp";
+ reply = FileFormat.Pileup;
break;
}
|| ((data.indexOf("!!") > -1) && (data.indexOf("!!") < data
.indexOf("_MULTIPLE_ALIGNMENT "))))
{
- reply = "MSF";
+ reply = FileFormat.MSF;
break;
}
else if (data.indexOf("CLUSTAL") > -1)
{
- reply = "CLUSTAL";
+ reply = FileFormat.Clustal;
break;
}
else if (data.indexOf("HEADER") == 0 || data.indexOf("ATOM") == 0)
{
- reply = "PDB";
+ reply = FileFormat.PDB;
break;
}
else if (data.matches("\\s*\\d+\\s+\\d+\\s*"))
{
- reply = PhylipFile.FILE_DESC;
+ reply = FileFormat.Phylip;
break;
}
else
{
if (!lineswereskipped && looksLikeJnetData(data))
{
- reply = "JnetFile";
+ reply = FileFormat.Jnet;
break;
}
}
} catch (Exception ex)
{
System.err.println("File Identification failed!\n" + ex);
- return source.errormessage;
+ throw new FileFormatException(source.errormessage);
}
if (trimmedLength == 0)
{
System.err
.println("File Identification failed! - Empty file was read.");
- return "EMPTY DATA FILE";
+ throw new FileFormatException("EMPTY DATA FILE");
}
return reply;
}
public static void main(String[] args)
{
-
for (int i = 0; args != null && i < args.length; i++)
{
IdentifyFile ider = new IdentifyFile();
- String type = ider.identify(args[i], AppletFormatAdapter.FILE);
+ FileFormatI type = null;
+ try
+ {
+ type = ider.identify(args[i], DataSourceType.FILE);
+ } catch (FileFormatException e)
+ {
+ System.err.println(String.format(
+ "Error '%s' identifying file type for %s", args[i],
+ e.getMessage()));
+ }
System.out.println("Type of " + args[i] + " is " + type);
}
if (args == null || args.length == 0)
*
* @param inFile
* DOCUMENT ME!
- * @param type
+ * @param sourceType
* DOCUMENT ME!
*
* @throws IOException
* DOCUMENT ME!
*/
- public JPredFile(String inFile, String type) throws IOException
+ public JPredFile(String inFile, DataSourceType sourceType)
+ throws IOException
{
- super(inFile, type);
+ super(inFile, sourceType);
}
public JPredFile(FileParse source) throws IOException
/**
* DOCUMENT ME!
*/
+ @Override
public void initData()
{
super.initData();
/**
* parse a JPred concise file into a sequence-alignment like object.
*/
+ @Override
public void parse() throws IOException
{
// JBPNote log.System.out.println("all read in ");
ascore = symbols.nextToken();
Float score = new Float(ascore);
- scores.addElement((Object) score);
+ scores.addElement(score);
}
Scores.put(id, scores);
for (int j = 0; j < i; j++)
{
scores.setElementAt(
- (Object) ((Float) scores.elementAt(j)).toString(), j);
+ ((Float) scores.elementAt(j)).toString(), j);
}
- scores.addElement((Object) ascore);
+ scores.addElement(ascore);
while (symbols.hasMoreTokens())
{
ascore = symbols.nextToken();
- scores.addElement((Object) ascore);
+ scores.addElement(ascore);
}
Scores.put(id, scores);
}
if (QuerySeqPosition == -1)
+ {
QuerySeqPosition = ids.size();
+ }
ids.addElement(name);
noSeqs++;
}
seq_entries.addElement(newseq.toString());
ids.addElement(id);
- Symscores.put((Object) id, (Object) new Integer(ids.size() - 1));
+ Symscores.put(id, new Integer(ids.size() - 1));
}
}
}
*
* @return String
*/
+ @Override
public String print()
{
return "Not Supported";
{
try
{
- JPredFile blc = new JPredFile(args[0], "File");
+ JPredFile jpred = new JPredFile(args[0], DataSourceType.FILE);
- for (int i = 0; i < blc.seqs.size(); i++)
+ for (int i = 0; i < jpred.seqs.size(); i++)
{
- System.out.println(((Sequence) blc.seqs.elementAt(i)).getName()
+ System.out.println(((Sequence) jpred.seqs.elementAt(i)).getName()
+ "\n"
- + ((Sequence) blc.seqs.elementAt(i)).getSequenceAsString()
+ + ((Sequence) jpred.seqs.elementAt(i)).getSequenceAsString()
+ "\n");
}
} catch (java.io.IOException e)
}
// check that no stray annotations have been added at the end.
{
- SequenceI sq = (SequenceI) seqs.elementAt(j - 1);
+ SequenceI sq = seqs.elementAt(j - 1);
if (sq.getName().toUpperCase().startsWith("JPRED"))
{
annotSeqs.addElement(sq);
private String application = "Jalview";
- public static final String FILE_EXT = "json";
-
- public static final String FILE_DESC = "JSON";
-
private String globalColourScheme;
private boolean showSeqFeatures;
super(source);
}
- public JSONFile(String inFile, String type) throws IOException
+ public JSONFile(String inFile, DataSourceType sourceType)
+ throws IOException
{
- super(inFile, type);
+ super(inFile, sourceType);
}
@Override
}
}
- public String getSelectedFormat()
+ public FileFormat getSelectedFormat()
{
if (getFileFilter() == null)
{
}
String format = getFileFilter().getDescription();
-
- if (format.toUpperCase().startsWith("JALVIEW"))
- {
- format = "Jalview";
- }
- else if (format.toUpperCase().startsWith("FASTA"))
- {
- format = "FASTA";
- }
- else if (format.toUpperCase().startsWith("MSF"))
- {
- format = "MSF";
- }
- else if (format.toUpperCase().startsWith("CLUSTAL"))
- {
- format = "CLUSTAL";
- }
- else if (format.toUpperCase().startsWith("BLC"))
- {
- format = "BLC";
- }
- else if (format.toUpperCase().startsWith("PIR"))
- {
- format = "PIR";
- }
- else if (format.toUpperCase().startsWith("PFAM"))
- {
- format = "PFAM";
- }
- else if (format.toUpperCase().startsWith(PhylipFile.FILE_DESC))
- {
- format = PhylipFile.FILE_DESC;
- }
-
- return format;
+ return FileFormat.valueOf(format);
}
@Override
*
* @param inFile
* DOCUMENT ME!
- * @param type
+ * @param sourceType
* DOCUMENT ME!
*
* @throws IOException
* DOCUMENT ME!
*/
- public MSFfile(String inFile, String type) throws IOException
+ public MSFfile(String inFile, DataSourceType sourceType)
+ throws IOException
{
- super(inFile, type);
+ super(inFile, sourceType);
}
public MSFfile(FileParse source) throws IOException
*/
public NewickFile(String inStr) throws IOException
{
- super(inStr, "Paste");
+ super(inStr, DataSourceType.PASTE);
}
/**
*
* @param inFile
* DOCUMENT ME!
- * @param type
+ * @param protocol
* DOCUMENT ME!
*
* @throws IOException
* DOCUMENT ME!
*/
- public NewickFile(String inFile, String type) throws IOException
+ public NewickFile(String inFile, DataSourceType protocol)
+ throws IOException
{
- super(inFile, type);
+ super(inFile, protocol);
}
public NewickFile(FileParse source) throws IOException
treefile.close();
System.out.println("Read file :\n");
- NewickFile trf = new NewickFile(args[0], "File");
+ NewickFile trf = new NewickFile(args[0], DataSourceType.FILE);
trf.parse();
System.out.println("Original file :\n");
{
}
- public PIRFile(String inFile, String type) throws IOException
+ public PIRFile(String inFile, DataSourceType sourceType)
+ throws IOException
{
- super(inFile, type);
+ super(inFile, sourceType);
}
public PIRFile(FileParse source) throws IOException
{
}
- public PfamFile(String inFile, String type) throws IOException
+ public PfamFile(String inFile, DataSourceType sourceType)
+ throws IOException
{
- super(inFile, type);
+ super(inFile, sourceType);
}
public PfamFile(FileParse source) throws IOException
public class PhylipFile extends AlignFile
{
- // Define file extension and description to save repeating it elsewhere
- public static final String FILE_EXT = "phy";
-
public static final String FILE_DESC = "PHYLIP";
/**
/**
* @param inFile
- * @param type
+ * @param sourceType
* @throws IOException
* @see {@link AlignFile#AlignFile(FileParse)}
*/
- public PhylipFile(String inFile, String type) throws IOException
+ public PhylipFile(String inFile, DataSourceType sourceType)
+ throws IOException
{
- super(inFile, type);
+ super(inFile, sourceType);
}
/**
*
* @param inFile
* DOCUMENT ME!
- * @param type
+ * @param sourceType
* DOCUMENT ME!
*
* @throws IOException
* DOCUMENT ME!
*/
- public PileUpfile(String inFile, String type) throws IOException
+ public PileUpfile(String inFile, DataSourceType sourceType)
+ throws IOException
{
- super(inFile, type);
+ super(inFile, sourceType);
}
public PileUpfile(FileParse source) throws IOException
}
- public RnamlFile(String inFile, String type) throws IOException
+ public RnamlFile(String inFile, DataSourceType sourceType)
+ throws IOException
{
- super(inFile, type);
+ super(inFile, sourceType);
}
*
* @see jalview.io.AlignFile#parse()
*/
+ @Override
public void parse() throws IOException
{
if (System.getProperty("java.version").indexOf("1.6") > -1
return "not yet implemented";
}
+ @Override
public String print()
{
System.out.print("print :");
{
}
- public SimpleBlastFile(String inFile, String type) throws IOException
+ public SimpleBlastFile(String inFile, DataSourceType sourceType)
+ throws IOException
{
- super(inFile, type);
+ super(inFile, sourceType);
}
public SimpleBlastFile(FileParse source) throws IOException
super(source);
}
+ @Override
public void initData()
{
super.initData();
seqids = new Vector();
}
+ @Override
public void parse() throws IOException
{
String line;
return new String("Not Implemented.");
}
+ @Override
public String print()
{
return print(getSeqsAsArray());
this.al = al;
}
- public StockholmFile(String inFile, String type) throws IOException
+ public StockholmFile(String inFile, DataSourceType sourceType)
+ throws IOException
{
- super(inFile, type);
+ super(inFile, sourceType);
}
public StockholmFile(FileParse source) throws IOException
super(source);
}
+ @Override
public void initData()
{
super.initData();
* @throws IOException
* If there is an error with the input file
*/
+ @Override
public void parse() throws IOException
{
StringBuffer treeString = new StringBuffer();
return seq;
}
+ @Override
public String print()
{
out = new StringBuffer();
private Vector<PDBChain> chains;
- public StructureFile(String inFile, String type) throws IOException
+ public StructureFile(String inFile, DataSourceType sourceType)
+ throws IOException
{
- super(inFile, type);
+ super(inFile, sourceType);
}
public StructureFile(FileParse fp) throws IOException
}
- public StructureFile(boolean parseImmediately, String dataObject, String type)
- throws IOException
+ public StructureFile(boolean parseImmediately, String dataObject,
+ DataSourceType sourceType) throws IOException
{
- super(parseImmediately, dataObject, type);
+ super(parseImmediately, dataObject, sourceType);
}
public StructureFile(boolean a, FileParse fp) throws IOException
new Object[] {});
AlignmentI al = ((AlignmentI) cl.getMethod("getRNAMLFor",
new Class[] { FileParse.class }).invoke(annotate3d,
- new Object[] { new FileParse(getDataName(), type) }));
+ new Object[] { new FileParse(getDataName(), dataSourceType) }));
for (SequenceI sq : al.getSequences())
{
if (sq.getDatasetSequence() != null)
boolean.class, boolean.class, boolean.class, FileParse.class });
final Object[] args = new Object[] { visibleChainAnnotation,
predictSecondaryStructure, externalSecondaryStructure,
- new FileParse(getDataName(), type) };
+ new FileParse(getDataName(), dataSourceType) };
StructureImportSettings.setShowSeqFeatures(false);
StructureImportSettings.setVisibleChainAnnotation(false);
*/
public class TCoffeeScoreFile extends AlignFile
{
- public TCoffeeScoreFile(String inFile, String type) throws IOException
+ public TCoffeeScoreFile(String inFile, DataSourceType fileSourceType)
+ throws IOException
{
- super(inFile, type);
+ super(inFile, fileSourceType);
}
return result;
}
+ @Override
public void parse() throws IOException
{
/*
*/
package jalview.jbgui;
+import jalview.io.FileFormatI;
import jalview.util.MessageManager;
import java.awt.BorderLayout;
showDialog;
public GAlignExportSettings(boolean hasHiddenSeq, boolean hasHiddenCols,
- String alignFileFormat)
+ FileFormatI format)
{
this.hasHiddenSeq = hasHiddenSeq;
this.hasHiddenCols = hasHiddenCols;
- String[] complexFormats = { "JSON", "HTML" };
-
- for (String format : complexFormats)
- {
- if (format.equalsIgnoreCase(alignFileFormat))
- {
- this.isComplexAlignFile = true;
- break;
- }
- }
+ this.isComplexAlignFile = format.isComplexAlignFile();
if (this.hasHiddenCols || this.hasHiddenSeq || this.isComplexAlignFile)
{
this.showDialog = true;
chkAll.addItemListener(new ItemListener()
{
+ @Override
public void itemStateChanged(ItemEvent e)
{
checkAllAction();
btnOk.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
ok_actionPerformed(e);
btnCancel.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
cancel_actionPerformed(e);
package jalview.jbgui;
import jalview.api.AlignmentViewPanel;
+import jalview.io.FileFormatException;
import jalview.util.MessageManager;
import java.awt.FlowLayout;
inputLocalFileMenuItem
.addActionListener(new java.awt.event.ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
inputLocalFileMenuItem_actionPerformed(null);
inputURLMenuItem.setText(MessageManager.getString("label.from_url"));
inputURLMenuItem.addActionListener(new java.awt.event.ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
- inputURLMenuItem_actionPerformed(null);
+ try
+ {
+ inputURLMenuItem_actionPerformed(null);
+ } catch (FileFormatException e1)
+ {
+ System.err.println("Error loading from URL: " + e1.getMessage());
+ }
}
});
inputTextboxMenuItem.setText(MessageManager
inputTextboxMenuItem
.addActionListener(new java.awt.event.ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
inputTextboxMenuItem_actionPerformed(null);
quit.setText(MessageManager.getString("action.quit"));
quit.addActionListener(new java.awt.event.ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
quit();
aboutMenuItem.setText(MessageManager.getString("label.about"));
aboutMenuItem.addActionListener(new java.awt.event.ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
aboutMenuItem_actionPerformed(e);
documentationMenuItem
.addActionListener(new java.awt.event.ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
documentationMenuItem_actionPerformed(e);
preferences.setText(MessageManager.getString("label.preferences"));
preferences.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
preferences_actionPerformed(e);
saveState.setText(MessageManager.getString("action.save_project"));
saveState.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
saveState_actionPerformed(e);
loadState.setText(MessageManager.getString("action.load_project"));
loadState.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
loadState_actionPerformed(e);
vamsasStart.setVisible(false);
vamsasStart.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
vamsasStart_actionPerformed(e);
vamsasImport.setVisible(false);
vamsasImport.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
vamsasImport_actionPerformed(e);
vamsasSave.setVisible(false);
vamsasSave.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
vamsasSave_actionPerformed(e);
.getString("action.fetch_sequences"));
inputSequence.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
inputSequence_actionPerformed(e);
vamsasStop.setVisible(false);
vamsasStop.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
vamsasStop_actionPerformed(e);
closeAll.setText(MessageManager.getString("action.close_all"));
closeAll.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
closeAll_actionPerformed(e);
.getString("action.raise_associated_windows"));
raiseRelated.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
raiseRelated_actionPerformed(e);
.getString("action.minimize_associated_windows"));
minimizeAssociated.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
minimizeAssociated_actionPerformed(e);
.getString("label.collect_garbage"));
garbageCollect.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
garbageCollect_actionPerformed(e);
.getString("label.show_memory_usage"));
showMemusage.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
showMemusage_actionPerformed(e);
.setText(MessageManager.getString("label.show_java_console"));
showConsole.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
showConsole_actionPerformed(e);
showNews.setText(MessageManager.getString("label.show_jalview_news"));
showNews.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
showNews_actionPerformed(e);
snapShotWindow.setText(MessageManager.getString("label.take_snapshot"));
snapShotWindow.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
snapShotWindow_actionPerformed(e);
*
* @param e
* DOCUMENT ME!
+ * @throws FileFormatException
*/
protected void inputURLMenuItem_actionPerformed(
- jalview.gui.AlignViewport av)
+ jalview.gui.AlignViewport av) throws FileFormatException
{
}
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SearchResults;
import jalview.datamodel.SequenceI;
+import jalview.ext.jmol.JmolParser;
import jalview.gui.IProgressIndicator;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
import jalview.io.StructureFile;
import jalview.util.MappingUtils;
import jalview.util.MessageManager;
* (may be nill, individual elements may be nill)
* @param pdbFile
* - structure data resource
- * @param protocol
+ * @param paste
* - how to resolve data from resource
* @return null or the structure data parsed as a pdb file
*/
synchronized public StructureFile setMapping(SequenceI[] sequence,
- String[] targetChains, String pdbFile, String protocol)
+ String[] targetChains, String pdbFile, DataSourceType paste)
{
- return setMapping(true, sequence, targetChains, pdbFile, protocol);
+ return setMapping(true, sequence, targetChains, pdbFile, paste);
}
* (may be nill, individual elements may be nill)
* @param pdbFile
* - structure data resource
- * @param protocol
+ * @param sourceType
* - how to resolve data from resource
* @return null or the structure data parsed as a pdb file
*/
synchronized public StructureFile setMapping(boolean forStructureView,
SequenceI[] sequenceArray, String[] targetChainIds,
String pdbFile,
- String protocol)
+ DataSourceType sourceType)
{
/*
* There will be better ways of doing this in the future, for now we'll use
if (pdbFile != null && isCIFFile(pdbFile))
{
- pdb = new jalview.ext.jmol.JmolParser(addTempFacAnnot, parseSecStr,
- secStructServices, pdbFile, protocol);
+ pdb = new JmolParser(addTempFacAnnot, parseSecStr,
+ secStructServices, pdbFile, sourceType);
}
else
{
pdb = new PDBfile(addTempFacAnnot, parseSecStr, secStructServices,
- pdbFile, protocol);
+ pdbFile, sourceType);
}
if (pdb.getId() != null && pdb.getId().trim().length() > 0
- && AppletFormatAdapter.FILE.equals(protocol))
+ && sourceType == DataSourceType.FILE)
{
registerPDBFile(pdb.getId().trim(), pdbFile);
}
continue;
}
- if (protocol.equals(jalview.io.AppletFormatAdapter.PASTE))
+ if (sourceType == DataSourceType.PASTE)
{
pdbFile = "INLINE" + pdb.getId();
}
import jalview.datamodel.AlignmentI;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
+import jalview.io.DataSourceType;
import jalview.structure.AtomSpec;
import jalview.structure.StructureListener;
import jalview.structure.StructureMapping;
/*
* datasource protocol for access to PDBEntrylatest
*/
- String protocol = null;
+ DataSourceType protocol = null;
protected boolean colourBySequence = true;
* @param pdbentry
* @param sequenceIs
* @param chains
- * @param protocol
+ * @param protocol2
*/
public AAStructureBindingModel(StructureSelectionManager ssm,
PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
- String protocol)
+ DataSourceType protocol2)
{
this.ssm = ssm;
this.sequence = sequenceIs;
this.nucleotide = Comparison.isNucleotide(sequenceIs);
this.chains = chains;
this.pdbEntry = pdbentry;
- this.protocol = protocol;
+ this.protocol = protocol2;
if (chains == null)
{
this.chains = new String[pdbentry.length][];
return chains;
}
- public String getProtocol()
+ public DataSourceType getProtocol()
{
return protocol;
}
{
pdbAlignment = new FormatAdapter().readFile(file,
- jalview.io.AppletFormatAdapter.FILE,
+ jalview.io.DataSourceType.FILE,
StructureImportSettings.getCurrentDefaultFormat());
if (pdbAlignment != null)
{
package jalview.ws.jws1;
import jalview.analysis.AlignSeq;
+import jalview.analysis.SeqsetUtils;
import jalview.bin.Cache;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.gui.AlignFrame;
import jalview.gui.Desktop;
import jalview.gui.WebserviceInfo;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormatI;
import jalview.io.FormatAdapter;
+import jalview.io.IdentifyFile;
+import jalview.io.JPredFile;
+import jalview.io.JnetAnnotationMaker;
import jalview.util.Comparison;
import jalview.util.MessageManager;
import jalview.ws.AWsJob;
* @return true if getResultSet will return a valid alignment and prediction
* result.
*/
+ @Override
public boolean hasResults()
{
if (subjobComplete && result != null && result.isFinished()
return false;
}
+ @Override
public boolean hasValidInput()
{
if (sequence != null)
JpredResult result = (JpredResult) this.result;
- jalview.bin.Cache.log.debug("Parsing output from JNet job.");
+ Cache.log.debug("Parsing output from JNet job.");
// JPredFile prediction = new JPredFile("C:/JalviewX/files/jpred.txt",
// "File");
- jalview.io.JPredFile prediction = new jalview.io.JPredFile(
- result.getPredfile(), "Paste");
+ JPredFile prediction = new JPredFile(
+ result.getPredfile(), DataSourceType.PASTE);
SequenceI[] preds = prediction.getSeqsAsArray();
- jalview.bin.Cache.log.debug("Got prediction profile.");
+ Cache.log.debug("Got prediction profile.");
if ((this.msa != null) && (result.getAligfile() != null))
{
- jalview.bin.Cache.log.debug("Getting associated alignment.");
+ Cache.log.debug("Getting associated alignment.");
// we ignore the returned alignment if we only predicted on a single
// sequence
- String format = new jalview.io.IdentifyFile().identify(
- result.getAligfile(), "Paste");
+ FileFormatI format = new IdentifyFile().identify(
+ result.getAligfile(), DataSourceType.PASTE);
- if (jalview.io.FormatAdapter.isValidFormat(format))
+ if (format != null)
{
SequenceI sqs[];
if (predMap != null)
else
{
al = new FormatAdapter().readFile(result.getAligfile(),
- "Paste", format);
+ DataSourceType.PASTE, format);
sqs = new SequenceI[al.getHeight()];
for (int i = 0, j = al.getHeight(); i < j; i++)
{
sqs[i] = al.getSequenceAt(i);
}
- if (!jalview.analysis.SeqsetUtils.deuniquify(SequenceInfo, sqs))
+ if (!SeqsetUtils.deuniquify(SequenceInfo, sqs))
{
throw (new Exception(
MessageManager
{
al.setDataset(null);
}
- jalview.io.JnetAnnotationMaker.add_annotation(prediction, al,
+ JnetAnnotationMaker.add_annotation(prediction, al,
FirstSeq, false, predMap);
}
{
throw (new Exception(MessageManager.formatMessage(
"exception.unknown_format_for_file", new String[] {
- format, result.getAligfile() })));
+ format.toString(), result.getAligfile() })));
}
}
else
}
}
+ @Override
public void StartJob(AWsJob j)
{
if (!(j instanceof JPredJob))
}
}
+ @Override
public void parseResult()
{
int results = 0; // number of result sets received
wsInfo.showResultsNewFrame
.addActionListener(new java.awt.event.ActionListener()
{
+ @Override
public void actionPerformed(java.awt.event.ActionEvent evt)
{
displayResults(true);
wsInfo.mergeResults
.addActionListener(new java.awt.event.ActionListener()
{
+ @Override
public void actionPerformed(java.awt.event.ActionEvent evt)
{
displayResults(false);
}
}
+ @Override
public void pollJob(AWsJob job) throws Exception
{
((JPredJob) job).result = server.getresult(job.getJobId());
}
+ @Override
public boolean isCancellable()
{
return false;
}
+ @Override
public void cancelJob()
{
throw new Error(MessageManager.getString("error.implementation_error"));
}
+ @Override
public boolean canMergeResults()
{
return false;
if (inFile != null && inFile.length() > 0)
{
new jalview.io.AnnotationFile().readAnnotationFile(al, inFile,
- jalview.io.AppletFormatAdapter.PASTE);
+ jalview.io.DataSourceType.PASTE);
}
} catch (Exception e)
{
if (inFile != null && inFile.length() > 0)
{
jalview.io.FeaturesFile ff = new jalview.io.FeaturesFile(
- inFile, jalview.io.AppletFormatAdapter.PASTE);
+ inFile, jalview.io.DataSourceType.PASTE);
ff.parse(al, featureColours, false);
}
} catch (Exception e)
if (inFile != null && inFile.length() > 0)
{
nf = new jalview.io.NewickFile(inFile,
- jalview.io.AppletFormatAdapter.PASTE);
+ jalview.io.DataSourceType.PASTE);
if (!nf.isValid())
{
nf.close();
import jalview.datamodel.PDBEntry;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
import java.io.IOException;
import java.util.List;
* Constructor with file path performs parse()
*/
PDBfile pf = new PDBfile(false, false, false, "examples/3W5V.pdb",
- AppletFormatAdapter.FILE);
+ DataSourceType.FILE);
assertEquals("3W5V", pf.getId());
// verify no alignment annotations created
public void testParse_withAnnotations_noSS() throws IOException
{
PDBfile pf = new PDBfile(true, false, false, "examples/3W5V.pdb",
- AppletFormatAdapter.FILE);
+ DataSourceType.FILE);
AlignmentAnnotation[] anns = getAlignmentAnnotations(pf);
assertEquals(4, anns.length);
public void testParse_withJmol_noAnnotations() throws IOException
{
PDBfile pf = new PDBfile(false, true, false, "examples/3W5V.pdb",
- AppletFormatAdapter.FILE);
+ DataSourceType.FILE);
/*
* alignment annotations _are_ created anyway (in
throws IOException
{
PDBfile pf = new PDBfile(true, true, false, "examples/3W5V.pdb",
- AppletFormatAdapter.FILE);
+ DataSourceType.FILE);
/*
* Alignment annotations for TempFactor, SecStruct, per sequence (chain)
// TODO requires a mock for Annotate3D processing
// and/or run as an integration test
PDBfile pf = new PDBfile(true, true, true, "examples/2GIS.pdb",
- AppletFormatAdapter.FILE);
+ DataSourceType.FILE);
}
/**
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
import jalview.datamodel.SequenceI;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
import java.io.IOException;
import java.util.ArrayList;
public void setUp() throws IOException
{
alignment = new jalview.io.FormatAdapter().readFile(TEST_DATA,
- AppletFormatAdapter.PASTE, "FASTA");
+ DataSourceType.PASTE, FileFormat.Fasta);
AlignmentAnnotation[] anns = new AlignmentAnnotation[SEQ_ANN_COUNT];
for (int i = 0; i < anns.length; i++)
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FileFormatI;
import jalview.io.FormatAdapter;
import jalview.util.MapList;
import jalview.util.MappingUtils;
SequenceI s1 = ts.deriveSequence().getSubSequence(i, i + 7);
al.addSequence(s1);
}
- System.out.println(new AppletFormatAdapter().formatSequences("Clustal",
+ System.out.println(new AppletFormatAdapter().formatSequences(
+ FileFormat.Clustal,
al, true));
for (int flnk = -1; flnk < 25; flnk++)
{
AlignmentI exp = AlignmentUtils.expandContext(al, flnk);
System.out.println("\nFlank size: " + flnk);
System.out.println(new AppletFormatAdapter().formatSequences(
- "Clustal", exp, true));
+ FileFormat.Clustal, exp, true));
if (flnk == -1)
{
/*
{
final String data = ">Seq1Name\nKQYL\n" + ">Seq2Name\nRFPW\n"
+ ">Seq1Name\nABCD\n";
- AlignmentI al = loadAlignment(data, "FASTA");
+ AlignmentI al = loadAlignment(data, FileFormat.Fasta);
Map<String, List<SequenceI>> map = AlignmentUtils
.getSequencesByName(al);
assertEquals(2, map.keySet().size());
* @return
* @throws IOException
*/
- protected AlignmentI loadAlignment(final String data, String format)
+ protected AlignmentI loadAlignment(final String data, FileFormatI format)
throws IOException
{
AlignmentI a = new FormatAdapter().readFile(data,
- AppletFormatAdapter.PASTE, format);
+ DataSourceType.PASTE, format);
a.setDataset(null);
return a;
}
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignViewport;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
import jalview.io.FormatAdapter;
import java.io.IOException;
throws IOException
{
AlignmentI alf = new FormatAdapter().readFile(
- JAL_1312_example_align_fasta, jalview.io.FormatAdapter.PASTE,
- "FASTA");
+ JAL_1312_example_align_fasta, DataSourceType.PASTE,
+ FileFormat.Fasta);
ColumnSelection cs = new ColumnSelection();
AlignViewportI av = new AlignViewport(alf, cs);
Dna dna = new Dna(av, new int[] { 0, alf.getWidth() - 1 });
throws IOException
{
AlignmentI alf = new FormatAdapter().readFile(
- JAL_1312_example_align_fasta, jalview.io.FormatAdapter.PASTE,
- "FASTA");
+ JAL_1312_example_align_fasta, DataSourceType.PASTE,
+ FileFormat.Fasta);
int vwidth = 15;
for (int ipos = 0; ipos + vwidth < alf.getWidth(); ipos += vwidth)
{
public void testTranslateCdna_simple() throws IOException
{
AlignmentI alf = new FormatAdapter().readFile(fasta,
- FormatAdapter.PASTE, "FASTA");
+ DataSourceType.PASTE, FileFormat.Fasta);
ColumnSelection cs = new ColumnSelection();
AlignViewportI av = new AlignViewport(alf, cs);
Dna dna = new Dna(av, new int[] { 0, alf.getWidth() - 1 });
public void testTranslateCdna_hiddenColumns() throws IOException
{
AlignmentI alf = new FormatAdapter().readFile(fasta,
- FormatAdapter.PASTE, "FASTA");
- ColumnSelection cs = new jalview.datamodel.ColumnSelection();
+ DataSourceType.PASTE, FileFormat.Fasta);
+ ColumnSelection cs = new ColumnSelection();
cs.hideColumns(6, 14); // hide codons 3/4/5
cs.hideColumns(24, 35); // hide codons 9-12
cs.hideColumns(177, 191); // hide codons 60-64
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
+import jalview.io.DataSourceType;
import jalview.io.FileLoader;
-import jalview.io.FormatAdapter;
import org.testng.Assert;
import org.testng.annotations.Test;
public AlignFrame getTestAlignmentFrame()
{
AlignFrame alf = new FileLoader(false).LoadFileWaitTillLoaded(
- alntestFile, FormatAdapter.PASTE);
+ alntestFile, DataSourceType.PASTE);
AlignmentI al = alf.getViewport().getAlignment();
Assert.assertEquals(al.getHeight(), 4);
Assert.assertEquals(al.getWidth(), 5);
import jalview.analysis.AlignSeq;
import jalview.io.AppletFormatAdapter;
+import jalview.io.FileFormat;
import org.testng.annotations.Test;
alSeq2.setEnd(sqTo.getStart() + align.getSeq2End() - 1);
alSeq2.setDatasetSequence(sqTo);
System.out.println(new AppletFormatAdapter()
- .formatSequences("STH", new Alignment(new SequenceI[] { sqFrom,
+.formatSequences(
+ FileFormat.Stockholm, new Alignment(new SequenceI[] { sqFrom,
alSeq1, sqTo, alSeq2 }), true));
Mapping mp = align.getMappingFromS1(false);
AlignmentI all = new Alignment(new SequenceI[] { alSeq1, alSeq2 });
all.addAnnotation(almap1);
all.addAnnotation(almap2);
- System.out.println(new AppletFormatAdapter().formatSequences("STH",
+ System.out.println(new AppletFormatAdapter().formatSequences(
+ FileFormat.Stockholm,
all, true));
for (int p = 0; p < alSeq1.getLength(); p++)
import static org.testng.AssertJUnit.assertSame;
import static org.testng.AssertJUnit.assertTrue;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FileFormatI;
import jalview.io.FormatAdapter;
import jalview.util.MapList;
* @return
* @throws IOException
*/
- protected AlignmentI loadAlignment(final String data, String format)
+ protected AlignmentI loadAlignment(final String data, FileFormatI format)
throws IOException
{
- AlignmentI a = new FormatAdapter().readFile(data,
- AppletFormatAdapter.PASTE, format);
+ AlignmentI a = new FormatAdapter().readFile(data, DataSourceType.PASTE,
+ format);
a.setDataset(null);
return a;
}
@BeforeMethod(alwaysRun = true)
public void setUp() throws IOException
{
- al = loadAlignment(TEST_DATA, "STH");
+ al = loadAlignment(TEST_DATA, FileFormat.Stockholm);
int i = 0;
for (AlignmentAnnotation ann : al.getAlignmentAnnotation())
{
public void testAlignAs_dnaAsDna() throws IOException
{
// aligned cDNA:
- AlignmentI al1 = loadAlignment(CDNA_SEQS_1, "FASTA");
+ AlignmentI al1 = loadAlignment(CDNA_SEQS_1, FileFormat.Fasta);
// unaligned cDNA:
- AlignmentI al2 = loadAlignment(CDNA_SEQS_2, "FASTA");
+ AlignmentI al2 = loadAlignment(CDNA_SEQS_2, FileFormat.Fasta);
/*
* Make mappings between sequences. The 'aligned cDNA' is playing the role
public void testAlignAs_proteinAsCdna() throws IOException
{
// see also AlignmentUtilsTests
- AlignmentI al1 = loadAlignment(CDNA_SEQS_1, "FASTA");
- AlignmentI al2 = loadAlignment(AA_SEQS_1, "FASTA");
+ AlignmentI al1 = loadAlignment(CDNA_SEQS_1, FileFormat.Fasta);
+ AlignmentI al2 = loadAlignment(AA_SEQS_1, FileFormat.Fasta);
makeMappings(al1, al2);
// Fudge - alignProteinAsCdna expects mappings to be on protein
/*
* Load alignments and add mappings for cDNA to protein
*/
- AlignmentI al1 = loadAlignment(CDNA_SEQS_1, "FASTA");
- AlignmentI al2 = loadAlignment(AA_SEQS_1, "FASTA");
+ AlignmentI al1 = loadAlignment(CDNA_SEQS_1, FileFormat.Fasta);
+ AlignmentI al2 = loadAlignment(AA_SEQS_1, FileFormat.Fasta);
makeMappings(al1, al2);
/*
* Load alignments and add mappings from nucleotide to protein (or from
* first to second if both the same type)
*/
- AlignmentI al1 = loadAlignment(fromSeqs, "FASTA");
- AlignmentI al2 = loadAlignment(toSeqs, "FASTA");
+ AlignmentI al1 = loadAlignment(fromSeqs, FileFormat.Fasta);
+ AlignmentI al2 = loadAlignment(toSeqs, FileFormat.Fasta);
makeMappings(al1, al2);
/*
String dna1 = "A-Aa-gG-GCC-cT-TT";
String dna2 = "c--CCGgg-TT--T-AA-A";
AlignmentI al1 = loadAlignment(">Dna1/6-17\n" + dna1
- + "\n>Dna2/20-31\n" + dna2 + "\n", "FASTA");
+ + "\n>Dna2/20-31\n" + dna2 + "\n", FileFormat.Fasta);
AlignmentI al2 = loadAlignment(
- ">Pep1/7-9\n-P--YK\n>Pep2/11-13\nG-T--F\n", "FASTA");
+ ">Pep1/7-9\n-P--YK\n>Pep2/11-13\nG-T--F\n", FileFormat.Fasta);
AlignedCodonFrame acf = new AlignedCodonFrame();
// Seq1 has intron at dna positions 3,4,9 so splice is AAG GCC TTT
// Seq2 has intron at dna positions 1,5,6 so splice is CCG TTT AAA
@Test(groups = "Functional")
public void testCopyConstructor() throws IOException
{
- AlignmentI protein = loadAlignment(AA_SEQS_1, FormatAdapter.PASTE);
+ AlignmentI protein = loadAlignment(AA_SEQS_1, FileFormat.Fasta);
// create sequence and alignment datasets
protein.setDataset(null);
AlignedCodonFrame acf = new AlignedCodonFrame();
public void testCreateDatasetAlignment() throws IOException
{
AlignmentI protein = new FormatAdapter().readFile(AA_SEQS_1,
- AppletFormatAdapter.PASTE, "FASTA");
+ DataSourceType.PASTE, FileFormat.Fasta);
/*
* create a dataset sequence on first sequence
* leave the second without one
import jalview.datamodel.Alignment;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
import jalview.io.FastaFile;
import jalview.io.FileParse;
import jalview.io.gff.SequenceOntologyFactory;
.asList(new String[]
{ sq }));
SequenceI[] sqs = new FastaFile(fp).getSeqsAsArray();
- FastaFile trueRes = new FastaFile(fastasq, AppletFormatAdapter.PASTE);
+ FastaFile trueRes = new FastaFile(fastasq, DataSourceType.PASTE);
SequenceI[] trueSqs = trueRes.getSeqsAsArray();
Assert.assertEquals(sqs.length, trueSqs.length,
"Different number of sequences retrieved for query " + sq);
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
import jalview.io.FileLoader;
import jalview.structure.StructureImportSettings;
{
FileLoader fl = new jalview.io.FileLoader(false);
AlignFrame af = fl
- .LoadFileWaitTillLoaded(f, AppletFormatAdapter.FILE);
+ .LoadFileWaitTillLoaded(f, DataSourceType.FILE);
validateSecStrRows(af.getViewport().getAlignment());
}
}
for (String pdbStr : testFile)
{
PDBfile mctest = new PDBfile(false, false, false, pdbStr,
- AppletFormatAdapter.FILE);
+ DataSourceType.FILE);
JmolParser jtest = new JmolParser(false, false, false, pdbStr,
- jalview.io.AppletFormatAdapter.FILE);
+ jalview.io.DataSourceType.FILE);
Vector<SequenceI> seqs = jtest.getSeqs(), mcseqs = mctest.getSeqs();
assertTrue(
for (String pdbStr : testFile)
{
PDBfile mctest = new PDBfile(false, false, false, pdbStr,
- AppletFormatAdapter.FILE);
+ DataSourceType.FILE);
JmolParser jtest = new JmolParser(false, false, false, pdbStr,
- jalview.io.AppletFormatAdapter.FILE);
+ jalview.io.DataSourceType.FILE);
Vector<SequenceI> seqs = jtest.getSeqs(), mcseqs = mctest.getSeqs();
assertTrue(
{
PDBfile mctest = new PDBfile(false, false, false,
pastePDBDataWithChainBreak,
- AppletFormatAdapter.PASTE);
+ DataSourceType.PASTE);
boolean annotFromStructure = false;
boolean localSecondaryStruct = false;
boolean serviceSecondaryStruct = false;
JmolParser jtest = new JmolParser(annotFromStructure,
localSecondaryStruct, serviceSecondaryStruct,
pastePDBDataWithChainBreak,
- jalview.io.AppletFormatAdapter.PASTE);
+ jalview.io.DataSourceType.PASTE);
Vector<SequenceI> seqs = jtest.getSeqs();
Vector<SequenceI> mcseqs = mctest.getSeqs();
public void testParse_alternativeResidues() throws Exception
{
PDBfile mctest = new PDBfile(false, false, false, pdbWithAltLoc,
- AppletFormatAdapter.PASTE);
+ DataSourceType.PASTE);
boolean annotFromStructure = false;
boolean localSecondaryStruct = false;
boolean serviceSecondaryStruct = false;
JmolParser jtest = new JmolParser(annotFromStructure,
localSecondaryStruct, serviceSecondaryStruct, pdbWithAltLoc,
- jalview.io.AppletFormatAdapter.PASTE);
+ jalview.io.DataSourceType.PASTE);
Vector<SequenceI> seqs = jtest.getSeqs();
Vector<SequenceI> mcseqs = mctest.getSeqs();
import jalview.gui.Preferences;
import jalview.gui.StructureViewer;
import jalview.gui.StructureViewer.ViewerType;
-import jalview.io.FormatAdapter;
+import jalview.io.DataSourceType;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
Cache.setProperty(Preferences.STRUCTURE_DISPLAY, ViewerType.JMOL.name());
String inFile = "examples/1gaq.txt";
AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
- inFile, FormatAdapter.FILE);
+ inFile, DataSourceType.FILE);
assertTrue("Didn't read input file " + inFile, af != null);
for (SequenceI sq : af.getViewport().getAlignment().getSequences())
{
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceI;
+import jalview.io.DataSourceType;
import jalview.io.FastaFile;
+import jalview.io.FileFormat;
import jalview.io.FormatAdapter;
import java.io.BufferedReader;
public void testPDBfileVsRNAML() throws Exception
{
PDBfile pdbf = new PDBfile(true, false, true, "examples/2GIS.pdb",
- FormatAdapter.FILE);
+ DataSourceType.FILE);
Assert.assertTrue(pdbf.isValid());
// Comment - should add new FileParse constructor like new FileParse(Reader
// ..). for direct reading
assertTrue("No data returned by Annotate3D", sb.length() > 0);
final String lines = sb.toString();
AlignmentI al = new FormatAdapter().readFile(lines,
- FormatAdapter.PASTE, "RNAML");
+ DataSourceType.PASTE, FileFormat.Rnaml);
if (al == null || al.getHeight() == 0)
{
System.out.println(lines);
import jalview.gui.Preferences;
import jalview.gui.StructureViewer;
import jalview.gui.StructureViewer.ViewerType;
-import jalview.io.FormatAdapter;
+import jalview.io.DataSourceType;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
ViewerType.CHIMERA.name());
String inFile = "examples/1gaq.txt";
AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
- inFile, FormatAdapter.FILE);
+ inFile, DataSourceType.FILE);
assertTrue("Didn't read input file " + inFile, af != null);
for (SequenceI sq : af.getViewport().getAlignment().getSequences())
{
import jalview.datamodel.PDBEntry.Type;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
+import jalview.io.DataSourceType;
import jalview.io.FileLoader;
-import jalview.io.FormatAdapter;
import jalview.structure.StructureSelectionManager;
import java.util.ArrayList;
* alignment with reference to mappings
*/
AlignFrame af1 = new FileLoader().LoadFileWaitTillLoaded(
- ">Seq1\nCAGT\n", FormatAdapter.PASTE);
+ ">Seq1\nCAGT\n", DataSourceType.PASTE);
AlignedCodonFrame acf1 = new AlignedCodonFrame();
AlignedCodonFrame acf2 = new AlignedCodonFrame();
ssm.resetAll();
AlignFrame af1 = new FileLoader().LoadFileWaitTillLoaded(
- ">Seq1\nRSVQ\n", FormatAdapter.PASTE);
+ ">Seq1\nRSVQ\n", DataSourceType.PASTE);
AlignFrame af2 = new FileLoader().LoadFileWaitTillLoaded(
- ">Seq2\nDGEL\n", FormatAdapter.PASTE);
+ ">Seq2\nDGEL\n", DataSourceType.PASTE);
AlignedCodonFrame acf1 = new AlignedCodonFrame();
AlignedCodonFrame acf2 = new AlignedCodonFrame();
ssm.resetAll();
AlignFrame af1 = new FileLoader().LoadFileWaitTillLoaded(
- ">Seq1\nRSVQ\n", FormatAdapter.PASTE);
+ ">Seq1\nRSVQ\n", DataSourceType.PASTE);
AlignFrame af2 = new FileLoader().LoadFileWaitTillLoaded(
- ">Seq2\nDGEL\n", FormatAdapter.PASTE);
+ ">Seq2\nDGEL\n", DataSourceType.PASTE);
AlignedCodonFrame acf1 = new AlignedCodonFrame();
AlignedCodonFrame acf2 = new AlignedCodonFrame();
import jalview.datamodel.Annotation;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FormatAdapter;
import jalview.util.MessageManager;
import java.awt.BorderLayout;
Cache.applicationProperties.setProperty("SHOW_CONSERVATION", TRUE);
Cache.applicationProperties.setProperty("SHOW_IDENTITY", TRUE);
- AlignmentI al = new jalview.io.FormatAdapter().readFile(TEST_DATA,
- AppletFormatAdapter.PASTE, "FASTA");
+ AlignmentI al = new FormatAdapter().readFile(TEST_DATA,
+ DataSourceType.PASTE, FileFormat.Fasta);
af = new AlignFrame(al, 700, 500);
parentPanel = new AlignmentPanel(af, af.getViewport());
addAnnotations();
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
import jalview.datamodel.SequenceI;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
import jalview.io.FormatAdapter;
import jalview.util.MessageManager;
public void setUp() throws IOException
{
alignment = new FormatAdapter().readFile(TEST_DATA,
- AppletFormatAdapter.PASTE, "FASTA");
+ DataSourceType.PASTE, FileFormat.Fasta);
AlignFrame af = new AlignFrame(alignment, 700, 500);
parentPanel = new AlignmentPanel(af, af.getViewport());
testee = new PopupMenu(parentPanel, null, null);
Boolean.TRUE.toString());
FileLoader loader = new FileLoader(false);
AlignFrame af = loader.LoadFileWaitTillLoaded("examples/1gaq.txt",
- FormatAdapter.FILE);
+ DataSourceType.FILE);
al = af.getViewport().getAlignment();
pdbId = al.getSequenceAt(0).getDatasetSequence().getAllPDBEntries()
.get(0).getId();
String tfile = File.createTempFile("JalviewTest", ".jvp")
.getAbsolutePath();
AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
- inFile, FormatAdapter.FILE);
+ inFile, DataSourceType.FILE);
assertTrue("Didn't read input file " + inFile, af != null);
assertTrue("Failed to store as a project.",
- af.saveAlignment(tfile, "Jalview"));
+ af.saveAlignment(tfile, FileFormat.Jalview));
af.closeMenuItem_actionPerformed(true);
af = null;
af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(tfile,
- FormatAdapter.FILE);
+ DataSourceType.FILE);
assertTrue("Failed to import new project", af != null);
for (SequenceI asq : af.getViewport().getAlignment().getSequences())
{
{
FormatAdapter rf = new FormatAdapter();
- AlignmentI al = rf.readFile(ff, AppletFormatAdapter.FILE,
- new IdentifyFile().identify(ff, AppletFormatAdapter.FILE));
+ AlignmentI al = rf.readFile(ff, DataSourceType.FILE,
+ new IdentifyFile().identify(ff, DataSourceType.FILE));
// make sure dataset is initialised ? not sure about this
for (int i = 0; i < al.getSequencesArray().length; ++i)
+ testname
+ "\nAlignment was not annotated - annotation file not imported.",
new AnnotationFile().readAnnotationFile(al, cs, af,
- FormatAdapter.FILE));
+ DataSourceType.FILE));
AnnotationFile aff = new AnnotationFile();
ViewDef v = aff.new ViewDef(null, al.getHiddenSequences(), cs,
+ testname
+ "\nregenerated annotation file did not annotate alignment.",
new AnnotationFile().readAnnotationFile(al_new, anfileout,
- FormatAdapter.PASTE));
+ DataSourceType.PASTE));
// test for consistency in io
StockholmFileTest.testAlignmentEquivalence(al, al_new, false);
Map<String, FeatureColourI> colours = af.getFeatureRenderer()
.getFeatureColours();
FeaturesFile featuresFile = new FeaturesFile(
- "examples/exampleFeatures.txt", FormatAdapter.FILE);
+ "examples/exampleFeatures.txt", DataSourceType.FILE);
assertTrue("Test " + "Features file test"
+ "\nFailed to parse features file.",
featuresFile.parse(al.getDataset(), colours, true));
+ "FER_CAPAA\tuniprot\tMETAL\t44\t45\t4.0\t.\t.\tNote Iron-sulfur; Note 2Fe-2S\n"
+ "FER1_SOLLC\tuniprot\tPfam\t55\t130\t2.0\t.\t.";
FeaturesFile featuresFile = new FeaturesFile(gffData,
- FormatAdapter.PASTE);
+ DataSourceType.PASTE);
assertTrue("Failed to parse features file",
featuresFile.parse(al.getDataset(), colours, true));
String ff = f.getPath();
FormatAdapter rf = new FormatAdapter();
- AlignmentI al = rf.readFile(ff, FormatAdapter.FILE,
- new IdentifyFile().identify(ff, FormatAdapter.FILE));
+ AlignmentI al = rf.readFile(ff, DataSourceType.FILE,
+ new IdentifyFile().identify(ff, DataSourceType.FILE));
al.setDataset(null); // creates dataset sequences
assertNotNull("Couldn't read supplied alignment data.", al);
+ "Note=Iron-sulfur (2Fe-2S);Note=another note;evidence=ECO:0000255|PROSITE-ProRule:PRU00465\n"
+ "FER1_SOLLC\tuniprot\tPfam\t55\t130\t3.0\t.\t.\tID=$23";
FeaturesFile featuresFile = new FeaturesFile(gffData,
- FormatAdapter.PASTE);
+ DataSourceType.PASTE);
assertTrue("Failed to parse features file",
featuresFile.parse(al.getDataset(), colours, true));
String featureData = "Iron-sulfur (2Fe-2S)\tFER_CAPAA\t-1\t39\t39\tMETAL\n"
+ "Iron-phosphorus (2Fe-P)\tID_NOT_SPECIFIED\t2\t86\t87\tMETALLIC\n";
FeaturesFile featuresFile = new FeaturesFile(featureData,
- FormatAdapter.PASTE);
+ DataSourceType.PASTE);
assertTrue("Failed to parse features file",
featuresFile.parse(al.getDataset(), colours, true));
public void readGff3File() throws IOException
{
FeaturesFile gffreader = new FeaturesFile(true, simpleGffFile,
- FormatAdapter.FILE);
+ DataSourceType.FILE);
Alignment dataset = new Alignment(gffreader.getSeqsAsArray());
gffreader.addProperties(dataset);
checkDatasetfromSimpleGff3(dataset);
{
AlignmentI dataset = new Alignment(new SequenceI[] {});
FeaturesFile ffile = new FeaturesFile(simpleGffFile,
- FormatAdapter.FILE);
+ DataSourceType.FILE);
boolean parseResult = ffile.parse(dataset, null, false, false);
assertTrue("return result should be true", parseResult);
public void simpleGff3FileLoader() throws IOException
{
AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded(
- simpleGffFile, FormatAdapter.FILE);
+ simpleGffFile, DataSourceType.FILE);
assertTrue(
"Didn't read the alignment into an alignframe from Gff3 File",
af != null);
{
AlignmentI dataset = new Alignment(new SequenceI[] {});
FeaturesFile ffile = new FeaturesFile(simpleGffFile,
- FormatAdapter.FILE);
+ DataSourceType.FILE);
boolean parseResult = ffile.parse(dataset, null, false, true);
assertTrue("return result (relaxedID matching) should be true",
+ "<html>Pfam domain<a href=\"http://pfam.xfam.org/family/PF00111\">Pfam_3_4</a></html>\tFER_CAPAA\t-1\t20\t20\tPfam\n"
+ "ENDGROUP\tuniprot\n";
FeaturesFile featuresFile = new FeaturesFile(features,
- FormatAdapter.PASTE);
+ DataSourceType.PASTE);
featuresFile.parse(al.getDataset(), colours, false);
/*
final static File STARS_FA_FILE2 = new File(
"test/jalview/io/test_fasta_stars2.fa");
- private void assertValidFormat(String fmt, String src, FileParse fp)
+ private void assertValidFormat(FileFormatI fmt, String src, FileParse fp)
+ throws FileFormatException
{
AssertJUnit.assertTrue("Couldn't resolve " + src + " as a valid file",
fp.isValid());
- String type = new IdentifyFile().identify(fp);
- AssertJUnit.assertTrue("Data from '" + src + "' Expected to be '" + fmt
- + "' identified as '" + type + "'", type.equalsIgnoreCase(fmt));
+ FileFormatI type = new IdentifyFile().identify(fp);
+ AssertJUnit.assertSame("Data from '" + src + "' Expected to be '" + fmt
+ + "' identified as '" + type + "'", type, fmt);
}
@Test(groups = { "Functional" })
{
String uri;
FileParse fp = new FileParse(uri = STARS_FA_FILE1.getAbsoluteFile()
- .toString(), AppletFormatAdapter.FILE);
- assertValidFormat("FASTA", uri, fp);
+ .toString(), DataSourceType.FILE);
+ assertValidFormat(FileFormat.Fasta, uri, fp);
}
@Test(groups = { "Functional" })
{
String uri;
FileParse fp = new FileParse(uri = STARS_FA_FILE2.getAbsoluteFile()
- .toString(), AppletFormatAdapter.FILE);
- assertValidFormat("FASTA", uri, fp);
+ .toString(), DataSourceType.FILE);
+ assertValidFormat(FileFormat.Fasta, uri, fp);
}
@Test(groups = { "Functional" })
{
String uri;
FileParse fp = new FileParse(uri = ALIGN_FILE.getAbsoluteFile().toURI()
- .toString(), AppletFormatAdapter.URL);
- assertValidFormat("FASTA", uri, fp);
+ .toString(), DataSourceType.URL);
+ assertValidFormat(FileFormat.Fasta, uri, fp);
}
@Test(groups = { "Functional" })
{
String filepath;
FileParse fp = new FileParse(filepath = ALIGN_FILE.getAbsoluteFile()
- .toString(), AppletFormatAdapter.FILE);
- assertValidFormat("FASTA", filepath, fp);
+ .toString(), DataSourceType.FILE);
+ assertValidFormat(FileFormat.Fasta, filepath, fp);
}
@Test(groups = { "Functional" })
{
String uri;
FileParse fp = new FileParse(uri = NOTGZALIGN_FILE.getAbsoluteFile()
- .toURI().toString(), AppletFormatAdapter.URL);
- assertValidFormat("FASTA", uri, fp);
+ .toURI().toString(), DataSourceType.URL);
+ assertValidFormat(FileFormat.Fasta, uri, fp);
}
@Test(groups = { "Functional" })
{
String filepath;
FileParse fp = new FileParse(filepath = NOTGZALIGN_FILE
- .getAbsoluteFile().toString(), AppletFormatAdapter.FILE);
- assertValidFormat("FASTA", filepath, fp);
+ .getAbsoluteFile().toString(), DataSourceType.FILE);
+ assertValidFormat(FileFormat.Fasta, filepath, fp);
}
}
@Test(groups = { "Functional" }, dataProvider = "identifyFiles")
public void testIdentify(String data, String expectedFileType)
+ throws FileFormatException
{
- String protocol = AppletFormatAdapter.FILE;
+ DataSourceType protocol = DataSourceType.FILE;
IdentifyFile ider = new IdentifyFile();
- String actualFiletype = ider.identify(data, protocol);
+ String actualFiletype = ider.identify(data, protocol).toString();
Assert.assertEquals(actualFiletype, expectedFileType,
"File identification Failed!");
}
/**
* Additional tests for Jalview features file
+ *
+ * @throws FileFormatException
*/
@Test(groups = "Functional")
- public void testIdentify_featureFile()
+ public void testIdentify_featureFile() throws FileFormatException
{
IdentifyFile ider = new IdentifyFile();
String data = "Iron-sulfur (2Fe-2S)\tFER_CAPAA\t-1\t39\t39\tMETAL\n"
+ "Iron-phosphorus (2Fe-P)\tID_NOT_SPECIFIED\t2\t86\t87\tMETALLIC\n";
assertEquals(IdentifyFile.FeaturesFile,
- ider.identify(data, AppletFormatAdapter.PASTE));
+ ider.identify(data, DataSourceType.PASTE));
/*
* Jalview feature colour followed by GFF format feature data
data = "METAL\tcc9900\n" + "GFF\n"
+ "FER_CAPAA\tuniprot\tMETAL\t44\t45\t4.0\t.\t.\n";
assertEquals(IdentifyFile.FeaturesFile,
- ider.identify(data, AppletFormatAdapter.PASTE));
+ ider.identify(data, DataSourceType.PASTE));
/*
* Feature with '<' in the name (JAL-2098)
*/
data = "kD < 3\tred\n" + "Low kD\tFER_CAPAA\t-1\t39\t39\tkD < 3\n";
assertEquals(IdentifyFile.FeaturesFile,
- ider.identify(data, AppletFormatAdapter.PASTE));
+ ider.identify(data, DataSourceType.PASTE));
}
@DataProvider(name = "identifyFiles")
try
{
alignment = (Alignment) formatAdapter.readFile(TEST_JSON_FILE,
- AppletFormatAdapter.FILE, JSONFile.FILE_DESC);
+ DataSourceType.FILE, FileFormat.Json);
jf = (JSONFile) formatAdapter.getAlignFile();
AlignFrame af = new AlignFrame(alignment, jf.getHiddenSequences(),
af.getViewport().setFeaturesDisplayed(jf.getDisplayedFeatures());
formatAdapter = new AppletFormatAdapter(af.alignPanel, exportSettings);
- String jsonOutput = formatAdapter.formatSequences(JSONFile.FILE_DESC,
+ String jsonOutput = formatAdapter.formatSequences(FileFormat.Json,
af.alignPanel.getAlignment(), false);
formatAdapter = new AppletFormatAdapter();
testAlignment = formatAdapter.readFile(jsonOutput,
- AppletFormatAdapter.PASTE, JSONFile.FILE_DESC);
+ DataSourceType.PASTE, FileFormat.Json);
testJsonFile = (JSONFile) formatAdapter.getAlignFile();
// System.out.println(jsonOutput);
} catch (IOException e)
String tfile = File.createTempFile("JalviewTest", ".jvp")
.getAbsolutePath();
AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
- inFile, FormatAdapter.FILE);
+ inFile, DataSourceType.FILE);
assertTrue("Didn't read input file " + inFile, af != null);
int olddsann = countDsAnn(af.getViewport());
assertTrue("Didn't find any dataset annotations", olddsann > 0);
"Couldn't apply RNA helices colourscheme",
af.getViewport().getGlobalColourScheme() instanceof jalview.schemes.RNAHelicesColour);
assertTrue("Failed to store as a project.",
- af.saveAlignment(tfile, "Jalview"));
+ af.saveAlignment(tfile, FileFormat.Jalview));
af.closeMenuItem_actionPerformed(true);
af = null;
af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(tfile,
- FormatAdapter.FILE);
+ DataSourceType.FILE);
assertTrue("Failed to import new project", af != null);
int newdsann = countDsAnn(af.getViewport());
assertTrue(
String tfile = File.createTempFile("JalviewTest", ".jvp")
.getAbsolutePath();
AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
- inFile, FormatAdapter.FILE);
+ inFile, DataSourceType.FILE);
assertTrue("Didn't read input file " + inFile, af != null);
- af.loadJalviewDataFile(inAnnot, FormatAdapter.FILE, null, null);
+ af.loadJalviewDataFile(inAnnot, DataSourceType.FILE, null, null);
assertTrue(
"Didn't set T-coffee colourscheme",
af.getViewport().getGlobalColourScheme().getClass()
.getViewport().getGlobalColourScheme())) != null);
assertTrue("Failed to store as a project.",
- af.saveAlignment(tfile, "Jalview"));
+ af.saveAlignment(tfile, FileFormat.Jalview));
af.closeMenuItem_actionPerformed(true);
af = null;
af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(tfile,
- FormatAdapter.FILE);
+ DataSourceType.FILE);
assertTrue("Failed to import new project", af != null);
assertTrue(
"Didn't set T-coffee colourscheme for imported project.",
String tfile = File.createTempFile("JalviewTest", ".jvp")
.getAbsolutePath();
AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
- inFile, FormatAdapter.FILE);
+ inFile, DataSourceType.FILE);
assertTrue("Didn't read input file " + inFile, af != null);
- af.loadJalviewDataFile(inAnnot, FormatAdapter.FILE, null, null);
+ af.loadJalviewDataFile(inAnnot, DataSourceType.FILE, null, null);
AlignmentAnnotation[] aa = af.getViewport().getAlignment()
.getSequenceAt(0).getAnnotation("IUPredWS (Short)");
assertTrue(
sg.addSequence(af.getViewport().getAlignment().getSequenceAt(2), true);
af.alignPanel.alignmentChanged();
assertTrue("Failed to store as a project.",
- af.saveAlignment(tfile, "Jalview"));
+ af.saveAlignment(tfile, FileFormat.Jalview));
af.closeMenuItem_actionPerformed(true);
af = null;
af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(tfile,
- FormatAdapter.FILE);
+ DataSourceType.FILE);
assertTrue("Failed to import new project", af != null);
// check for group and alignment colourschemes
int origCount = Desktop.getAlignFrames() == null ? 0 : Desktop
.getAlignFrames().length;
AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
- "examples/exampleFile_2_7.jar", FormatAdapter.FILE);
+ "examples/exampleFile_2_7.jar", DataSourceType.FILE);
assertTrue("Didn't read in the example file correctly.", af != null);
assertTrue("Didn't gather the views in the example file.",
Desktop.getAlignFrames().length == 1 + origCount);
Cache.applicationProperties.setProperty("ADD_SS_ANN",
Boolean.TRUE.toString());
AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
- "examples/exampleFile_2_7.jar", FormatAdapter.FILE);
+ "examples/exampleFile_2_7.jar", DataSourceType.FILE);
assertTrue("Didn't read in the example file correctly.", af != null);
AlignmentViewPanel sps = null;
for (AlignmentViewPanel ap : af.alignPanel.alignFrame.getAlignPanels())
public void testCopyViewSettings() throws Exception
{
AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
- "examples/exampleFile_2_7.jar", FormatAdapter.FILE);
+ "examples/exampleFile_2_7.jar", DataSourceType.FILE);
assertTrue("Didn't read in the example file correctly.", af != null);
AlignmentViewPanel sps = null, groups = null;
for (AlignmentViewPanel ap : af.alignPanel.alignFrame.getAlignPanels())
public void testStoreAndRecoverExpandedviews() throws Exception
{
AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
- "examples/exampleFile_2_7.jar", FormatAdapter.FILE);
+ "examples/exampleFile_2_7.jar", DataSourceType.FILE);
assertTrue("Didn't read in the example file correctly.", af != null);
String afid = af.getViewport().getSequenceSetId();
{
Assert.assertEquals(Desktop.getAlignFrames().length, 0);
}
af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
- tfile.getAbsolutePath(), FormatAdapter.FILE);
+ tfile.getAbsolutePath(), DataSourceType.FILE);
Assert.assertNotNull(af);
Assert.assertEquals(
Desktop.getAlignFrames().length,
{
Desktop.instance.closeAll_actionPerformed(null);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
- "examples/exampleFile_2_7.jar", FormatAdapter.FILE);
+ "examples/exampleFile_2_7.jar", DataSourceType.FILE);
assertTrue("Didn't read in the example file correctly.", af != null);
String afid = af.getViewport().getSequenceSetId();
}
af = new FileLoader().LoadFileWaitTillLoaded(
- tfile.getAbsolutePath(), FormatAdapter.FILE);
+ tfile.getAbsolutePath(), DataSourceType.FILE);
afid = af.getViewport().getSequenceSetId();
for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(afid))
{
Desktop.instance.closeAll_actionPerformed(null);
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
- "examples/uniref50.fa", FormatAdapter.FILE);
+ "examples/uniref50.fa", DataSourceType.FILE);
assertTrue("Didn't read in the example file correctly.", af != null);
String afid = af.getViewport().getSequenceSetId();
// make a second view of the alignment
}
af = new FileLoader().LoadFileWaitTillLoaded(
- tfile.getAbsolutePath(), FormatAdapter.FILE);
+ tfile.getAbsolutePath(), DataSourceType.FILE);
afid = af.getViewport().getSequenceSetId();
for (AlignmentViewPanel ap : Desktop.getAlignmentPanels(afid))
assertTrue("Couldn't set gap character to '.'",
".".equals("" + jalview.bin.Cache.getProperty("GAP_SYMBOL")));
AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
- "examples/uniref50.fa", FormatAdapter.FILE);
+ "examples/uniref50.fa", DataSourceType.FILE);
assertTrue("Didn't read in the example file correctly.", af != null);
assertTrue("Didn't set the gap character correctly", af.getViewport()
.getAlignment().getSequenceAt(0).getCharAt(5) == '.');
sg.setEndRes(7);
af.getViewport().setSelectionGroup(sg);
String fseqs = new FormatAdapter(af.alignPanel).formatSequences(
- "FASTA", af.alignPanel, true);
+ FileFormat.Fasta, af.alignPanel, true);
assertTrue("Couldn't find '.' in the exported region\n" + fseqs,
fseqs.indexOf(".") > -1);
}
{
stage = "Parsing testTree " + treename;
System.out.println(treename + "\n" + testTree);
- NewickFile nf = new NewickFile(testTree, FormatAdapter.PASTE);
+ NewickFile nf = new NewickFile(testTree, DataSourceType.PASTE);
nf.parse();
AssertJUnit.assertTrue(
stage + "Invalid Tree '" + nf.getWarningMessage() + "'",
AssertJUnit.assertTrue(stage + "Empty string generated",
gentree != null && gentree.trim().length() > 0);
stage = "Parsing regenerated testTree " + treename;
- NewickFile nf_regen = new NewickFile(gentree, FormatAdapter.PASTE);
+ NewickFile nf_regen = new NewickFile(gentree, DataSourceType.PASTE);
nf_regen.parse();
AssertJUnit.assertTrue(
stage + "Newick file is invalid ('"
public void testPfamFormatNoLimits() throws IOException
{
AlignmentI al = new jalview.io.AppletFormatAdapter().readFile("ASEQ"
- + '\t' + "...--FFAFAFF--", AppletFormatAdapter.PASTE, "PFAM");
+ + '\t' + "...--FFAFAFF--", DataSourceType.PASTE,
+ FileFormat.Pfam);
Assert.assertEquals(1, al.getHeight(), "Wrong number of sequences");
Assert.assertTrue(al.hasValidSequence(),
"Didn't extract limits from PFAM ID");
{
AlignmentI al = new jalview.io.AppletFormatAdapter().readFile(
"ASEQ/15-25" + '\t' + "...--FFAFAFF--",
- AppletFormatAdapter.PASTE, "PFAM");
+ DataSourceType.PASTE,
+ FileFormat.Pfam);
Assert.assertEquals(1, al.getHeight(), "Wrong number of sequences");
Assert.assertTrue(al.hasValidSequence(),
"Didn't extract limits from PFAM ID");
private void testDataExtraction(String file) throws IOException
{
AppletFormatAdapter rf = new AppletFormatAdapter();
- AlignmentI al = rf.readFile(file, AppletFormatAdapter.FILE,
- PhylipFile.FILE_DESC);
+ AlignmentI al = rf.readFile(file, DataSourceType.FILE,
+ FileFormat.Phylip);
assertNotNull("Couldn't read supplied alignment data.", al);
Map<String, String> data = PhylipFileTests.getTestData();
public void testIO(String file) throws IOException
{
AppletFormatAdapter rf = new AppletFormatAdapter();
- AlignmentI al = rf.readFile(file, AppletFormatAdapter.FILE,
- PhylipFile.FILE_DESC);
+ AlignmentI al = rf.readFile(file, DataSourceType.FILE,
+ FileFormat.Phylip);
assertNotNull("Couldn't read supplied alignment data.", al);
- String outputfile = rf.formatSequences(PhylipFile.FILE_DESC, al, true);
+ String outputfile = rf.formatSequences(FileFormat.Phylip, al, true);
AlignmentI al_input = new AppletFormatAdapter().readFile(outputfile,
- AppletFormatAdapter.PASTE, PhylipFile.FILE_DESC);
+ DataSourceType.PASTE, FileFormat.Phylip);
assertNotNull("Couldn't parse reimported alignment data.", al_input);
StockholmFileTest.testAlignmentEquivalence(al, al_input, false);
public void testRnamlToStockholmIO()
{
StockholmFileTest.testFileIOwithFormat(new File(
- "examples/testdata/rna-alignment.xml"), "STH", -1, -1);
+ "examples/testdata/rna-alignment.xml"), FileFormat.Stockholm,
+ -1, -1);
}
@Test(groups = { "Functional" })
public void pfamFileIO() throws Exception
{
- testFileIOwithFormat(new File(PfamFile), "STH", -1, 0);
+ testFileIOwithFormat(new File(PfamFile), FileFormat.Stockholm, -1, 0);
}
@Test(groups = { "Functional" })
public void pfamFileDataExtraction() throws Exception
{
AppletFormatAdapter af = new AppletFormatAdapter();
- AlignmentI al = af.readFile(PfamFile, af.FILE,
- new IdentifyFile().identify(PfamFile, af.FILE));
+ AlignmentI al = af.readFile(PfamFile, DataSourceType.FILE,
+ new IdentifyFile().identify(PfamFile, DataSourceType.FILE));
int numpdb = 0;
for (SequenceI sq : al.getSequences())
{
@Test(groups = { "Functional" })
public void rfamFileIO() throws Exception
{
- testFileIOwithFormat(new File(RfamFile), "STH", 2, 1);
+ testFileIOwithFormat(new File(RfamFile), FileFormat.Stockholm, 2, 1);
}
/**
* f
*/
- public static void testFileIOwithFormat(File f, String ioformat,
+ public static void testFileIOwithFormat(File f, FileFormatI ioformat,
int naliannot, int nminseqann)
{
System.out.println("Reading file: " + f);
{
AppletFormatAdapter rf = new AppletFormatAdapter();
- AlignmentI al = rf.readFile(ff, AppletFormatAdapter.FILE,
- new IdentifyFile().identify(ff, AppletFormatAdapter.FILE));
+ AlignmentI al = rf.readFile(ff, DataSourceType.FILE,
+ new IdentifyFile().identify(ff, DataSourceType.FILE));
assertNotNull("Couldn't read supplied alignment data.", al);
+ outputfile + "\n<<EOF\n");
// test for consistency in io
AlignmentI al_input = new AppletFormatAdapter().readFile(outputfile,
- AppletFormatAdapter.PASTE, ioformat);
+ DataSourceType.PASTE, ioformat);
assertNotNull("Couldn't parse reimported alignment data.", al_input);
- String identifyoutput = new IdentifyFile().identify(outputfile,
- AppletFormatAdapter.PASTE);
+ FileFormatI identifyoutput = new IdentifyFile().identify(outputfile,
+ DataSourceType.PASTE);
assertNotNull("Identify routine failed for outputformat " + ioformat,
identifyoutput);
assertTrue(
{
TCoffeeScoreFile scoreFile = new TCoffeeScoreFile(SCORE_FILE.getPath(),
- AppletFormatAdapter.FILE);
+ DataSourceType.FILE);
AssertJUnit.assertTrue(scoreFile.getWarningMessage(),
scoreFile.isValid());
try
{
TCoffeeScoreFile result = new TCoffeeScoreFile(ALIGN_FILE.getPath(),
- FormatAdapter.FILE);
+ DataSourceType.FILE);
AssertJUnit.assertFalse(result.isValid());
} catch (IOException x)
{
public void testHeightAndWidth() throws IOException
{
TCoffeeScoreFile result = new TCoffeeScoreFile(SCORE_FILE.getPath(),
- FormatAdapter.FILE);
+ DataSourceType.FILE);
AssertJUnit.assertTrue(result.isValid());
AssertJUnit.assertEquals(8, result.getHeight());
AssertJUnit.assertEquals(83, result.getWidth());
+ "1QCF 99999999999999999999999999974-------2---------24\n"
+ "cons 999999999999999999999999999851000110321100001134\n"
+ "\n" + "\n";
- FileParse source = new FileParse(BLOCK, FormatAdapter.PASTE);
+ FileParse source = new FileParse(BLOCK, DataSourceType.PASTE);
Block block = TCoffeeScoreFile.readBlock(source, 0);
AssertJUnit.assertNotNull(block);
{
TCoffeeScoreFile parser = new TCoffeeScoreFile(SCORE_FILE.getPath(),
- FormatAdapter.FILE);
+ DataSourceType.FILE);
AssertJUnit
.assertEquals(
{
TCoffeeScoreFile parser = new TCoffeeScoreFile(SCORE_FILE.getPath(),
- FormatAdapter.FILE);
+ DataSourceType.FILE);
AssertJUnit.assertTrue(parser.getWarningMessage(), parser.isValid());
List<String> scores = parser.getScoresList();
AssertJUnit
{
TCoffeeScoreFile parser = new TCoffeeScoreFile(SCORE_FILE.getPath(),
- FormatAdapter.FILE);
+ DataSourceType.FILE);
AssertJUnit.assertTrue(parser.getWarningMessage(), parser.isValid());
byte[][] scores = parser.getScoresArray();
public void testHeightAndWidthWithResidueNumbers() throws Exception
{
String file = "test/jalview/io/tcoffee.score_ascii_with_residue_numbers";
- TCoffeeScoreFile result = new TCoffeeScoreFile(file, FormatAdapter.FILE);
+ TCoffeeScoreFile result = new TCoffeeScoreFile(file, DataSourceType.FILE);
AssertJUnit.assertTrue(result.isValid());
AssertJUnit.assertEquals(5, result.getHeight());
AssertJUnit.assertEquals(84, result.getWidth());
import jalview.datamodel.SequenceDummy;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
+import jalview.io.DataSourceType;
import jalview.io.FileLoader;
-import jalview.io.FormatAdapter;
import java.io.IOException;
import java.util.ArrayList;
FileLoader loader = new FileLoader(false);
AlignFrame af = loader.LoadFileWaitTillLoaded(
"examples/testdata/exonerateseqs.fa",
- FormatAdapter.FILE);
+ DataSourceType.FILE);
af.loadJalviewDataFile("examples/testdata/exonerateoutput.gff",
- FormatAdapter.FILE, null, null);
+ DataSourceType.FILE, null, null);
/*
* verify one mapping to a dummy sequence, one to a real one
import jalview.datamodel.SequenceDummy;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
+import jalview.io.DataSourceType;
import jalview.io.FileLoader;
-import jalview.io.FormatAdapter;
import java.util.List;
{
String proteinSeq = ">prot1/10-16\nYCWRSGA";
AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded(
- proteinSeq, FormatAdapter.PASTE);
+ proteinSeq, DataSourceType.PASTE);
/*
* exonerate GFF output mapping residues 11-15 (CWRSG)
*/
String exonerateGff = "##gff-version 2\n"
+ "prot1\tprotein2genome\tsimilarity\t11\t15\t99\t-\t.\talignment_id 0 ; Target dna1 ; Align 11 24 5";
- af.loadJalviewDataFile(exonerateGff, FormatAdapter.PASTE, null, null);
+ af.loadJalviewDataFile(exonerateGff, DataSourceType.PASTE, null, null);
/*
* check we have a mapping from prot1 to SequenceDummy 'dna1'
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
import jalview.io.FileLoader;
-import jalview.io.FormatAdapter;
import jalview.io.StructureFile;
import org.testng.Assert;
StructureSelectionManager ssm = new jalview.structure.StructureSelectionManager();
StructureFile pmap = ssm.setMapping(true, new SequenceI[] { uprot },
new String[] { "A" }, "test/jalview/ext/jmol/1QCF.pdb",
- jalview.io.FormatAdapter.FILE);
+ jalview.io.DataSourceType.FILE);
assertTrue(pmap != null);
SequenceI protseq = pmap.getSeqsAsArray()[0];
AlignmentAnnotation pstra = protseq
// source
StructureFile pde = ssm.setMapping(true, new SequenceI[] { sq },
new String[]
- { "A" }, inFile = "examples/1gaq.txt", jalview.io.FormatAdapter.FILE);
+ { "A" }, inFile = "examples/1gaq.txt", jalview.io.DataSourceType.FILE);
assertTrue("PDB File couldn't be found", pde != null);
StructureMapping[] mp = ssm.getMapping(inFile);
assertTrue("No mappings made.", mp != null && mp.length > 0);
AlignFrame seqf = new FileLoader(false)
.LoadFileWaitTillLoaded(
">FER1_MAIZE/1-150 Ferredoxin-1, chloroplast precursor\nMATVLGSPRAPAFFFSSSSLRAAPAPTAVALPAAKVGIMGRSASSRRRLRAQATYNVKLITPEGEVELQVPD\nDVYILDQAEEDGIDLPYSCRAGSCSSCAGKVVSGSVDQSDQSYLDDGQIADGWVLTCHAYPTSDVVIETHKE\nEELTGA",
- FormatAdapter.PASTE, "FASTA");
+ DataSourceType.PASTE, FileFormat.Fasta);
SequenceI newseq = seqf.getViewport().getAlignment().getSequenceAt(0);
StructureSelectionManager ssm = new jalview.structure.StructureSelectionManager();
StructureFile pmap = ssm.setMapping(true, new SequenceI[] { newseq },
new String[] { null }, "examples/3W5V.pdb",
- jalview.io.FormatAdapter.FILE);
+ jalview.io.DataSourceType.FILE);
if (pmap == null)
{
AssertJUnit.fail("Couldn't make a mapping for 3W5V to FER1_MAIZE");
StructureImportSettings.setShowSeqFeatures(true);
AlignFrame ref = new FileLoader(false)
.LoadFileWaitTillLoaded("test/jalview/ext/jmol/1QCF.pdb",
- jalview.io.FormatAdapter.FILE);
+ jalview.io.DataSourceType.FILE);
SequenceI refseq = ref.getViewport().getAlignment().getSequenceAt(0);
SequenceI newseq = new Sequence(refseq.getName() + "Copy",
refseq.getSequenceAsString());
ssm.setAddTempFacAnnot(true);
StructureFile pmap = ssm.setMapping(true, new SequenceI[] { newseq },
new String[] { null }, "test/jalview/ext/jmol/1QCF.pdb",
- jalview.io.FormatAdapter.FILE);
+ jalview.io.DataSourceType.FILE);
assertTrue(pmap != null);
assertEquals("Original and copied sequence of different lengths.",
refseq.getLength(), newseq.getLength());
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
-import jalview.io.FormatAdapter;
+import jalview.io.DataSourceType;
import jalview.io.StructureFile;
import java.util.ArrayList;
sm.setProcessSecondaryStructure(true);
sm.setAddTempFacAnnot(true);
StructureFile pmap = sm.setMapping(true, new SequenceI[] { seq },
- new String[] { null }, "examples/1gaq.txt", FormatAdapter.FILE);
+ new String[] { null }, "examples/1gaq.txt", DataSourceType.FILE);
assertTrue(pmap != null);
assertEquals(3, pmap.getSeqs().size());
import jalview.datamodel.PDBEntry.Type;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
import jalview.structure.AtomSpec;
import jalview.structure.StructureSelectionManager;
import jalview.structures.models.AAStructureBindingModel.SuperposeData;
StructureSelectionManager ssm = new StructureSelectionManager();
ssm.setMapping(new SequenceI[] { seq1 }, null, PDB_1,
- AppletFormatAdapter.PASTE);
+ DataSourceType.PASTE);
ssm.setMapping(new SequenceI[] { seq2 }, null, PDB_2,
- AppletFormatAdapter.PASTE);
+ DataSourceType.PASTE);
ssm.setMapping(new SequenceI[] { seq3 }, null, PDB_3,
- AppletFormatAdapter.PASTE);
+ DataSourceType.PASTE);
testee = new AAStructureBindingModel(ssm, pdbFiles, seqs, chains, null)
{
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignViewport;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
+import jalview.io.FileFormatI;
import jalview.io.FormatAdapter;
import java.awt.Color;
* viewport).
*/
AlignmentI cdna = loadAlignment(">Seq1\nACG\n>Seq2\nTGA\n>Seq3\nTAC\n",
- "FASTA");
+ FileFormat.Fasta);
cdna.setDataset(null);
AlignmentI protein = loadAlignment(">Seq1\nK\n>Seq2\nL\n>Seq3\nQ\n",
- "FASTA");
+ FileFormat.Fasta);
protein.setDataset(null);
AlignedCodonFrame acf = new AlignedCodonFrame();
MapList map = new MapList(new int[] { 1, 3 }, new int[] { 1, 1 }, 3, 1);
* @return
* @throws IOException
*/
- protected AlignmentI loadAlignment(final String data, String format)
+ protected AlignmentI loadAlignment(final String data, FileFormatI format)
throws IOException
{
AlignmentI a = new FormatAdapter().readFile(data,
- AppletFormatAdapter.PASTE, format);
+ DataSourceType.PASTE, format);
a.setDataset(null);
return a;
}
*/
AlignmentI cdna = loadAlignment(">Seq1/10-18\nAC-GctGtC-T\n"
+ ">Seq2/20-27\nTc-GA-G-T-Tc\n" + ">Seq3/30-38\nTtTT-AaCGg-\n",
- "FASTA");
+ FileFormat.Fasta);
cdna.setDataset(null);
AlignmentI protein = loadAlignment(
">Seq1/40-41\n-K-P\n>Seq2/50-51\nL--Q\n>Seq3/60-61\nG--S\n",
- "FASTA");
+ FileFormat.Fasta);
protein.setDataset(null);
// map first dna to first protein seq
* viewport).
*/
AlignmentI cdna = loadAlignment(
- ">Seq1\nACGGCA\n>Seq2\nTGACAG\n>Seq3\nTACGTA\n", "FASTA");
+ ">Seq1\nACGGCA\n>Seq2\nTGACAG\n>Seq3\nTACGTA\n",
+ FileFormat.Fasta);
cdna.setDataset(null);
AlignmentI protein = loadAlignment(">Seq1\nKA\n>Seq2\nLQ\n>Seq3\nQV\n",
- "FASTA");
+ FileFormat.Fasta);
protein.setDataset(null);
AlignedCodonFrame acf = new AlignedCodonFrame();
MapList map = new MapList(new int[] { 1, 6 }, new int[] { 1, 2 }, 3, 1);
*/
AlignmentI cdna = loadAlignment(
">Seq1\nA-CG-GC--AT-CA\n>Seq2\n-TG-AC-AG-T-AT\n>Seq3\n-T--ACG-TAAT-G\n",
- "FASTA");
+ FileFormat.Fasta);
cdna.setDataset(null);
AlignmentI protein = loadAlignment(
- ">Seq1\n-KA-S\n>Seq2\n--L-QY\n>Seq3\nQ-V-M\n", "FASTA");
+ ">Seq1\n-KA-S\n>Seq2\n--L-QY\n>Seq3\nQ-V-M\n", FileFormat.Fasta);
protein.setDataset(null);
AlignedCodonFrame acf = new AlignedCodonFrame();
MapList map = new MapList(new int[] { 1, 9 }, new int[] { 1, 3 }, 3, 1);
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.io.AnnotationFile;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
import jalview.io.FormatAdapter;
import jalview.io.StockholmFileTest;
import jalview.ws.jws2.AADisorderClient;
assertTrue("Couldn't discover any IUPred services to use to test.",
iupreds.size() > 0);
jalview.io.FileLoader fl = new jalview.io.FileLoader(false);
- af = fl.LoadFileWaitTillLoaded(testseqs, jalview.io.FormatAdapter.FILE);
+ af = fl.LoadFileWaitTillLoaded(testseqs, jalview.io.DataSourceType.FILE);
assertNotNull("Couldn't load test data ('" + testseqs + "')", af);
}
+ "\n<<EOF\n");
AlignmentI al_new = new FormatAdapter().readFile(aligfileout,
- FormatAdapter.PASTE, "PFAM");
+ DataSourceType.PASTE, FileFormat.Pfam);
assertTrue(
"Test "
+ testname
+ "\nregenerated annotation file did not annotate alignment.",
new AnnotationFile().readAnnotationFile(al_new, anfileout,
- FormatAdapter.PASTE));
+ DataSourceType.PASTE));
// test for consistency in io
StockholmFileTest.testAlignmentEquivalence(al, al_new, true);
import jalview.datamodel.AlignmentI;
import jalview.gui.Jalview2XML;
import jalview.io.AnnotationFile;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
import jalview.io.FormatAdapter;
import jalview.io.StockholmFileTest;
import jalview.ws.jws2.JPred301Client;
System.out.println("State of jpredws: " + jpredws);
Assert.assertNotNull(jpredws, "jpredws is null!");
jalview.io.FileLoader fl = new jalview.io.FileLoader(false);
- af = fl.LoadFileWaitTillLoaded(testseqs, jalview.io.FormatAdapter.FILE);
+ af = fl.LoadFileWaitTillLoaded(testseqs, jalview.io.DataSourceType.FILE);
assertNotNull("Couldn't load test data ('" + testseqs + "')", af);
}
// again what format would be appropriate?
AlignmentI al_new = new FormatAdapter().readFile(aligfileout,
- FormatAdapter.PASTE, "PFAM");
+ DataSourceType.PASTE, FileFormat.Fasta);
assertTrue(
"Test "
+ testname
+ "\nregenerated annotation file did not annotate alignment.",
new AnnotationFile().readAnnotationFile(al_new, anfileout,
- FormatAdapter.PASTE));
+ DataSourceType.PASTE));
// test for consistency in io
StockholmFileTest.testAlignmentEquivalence(al, al_new, false);
import jalview.datamodel.AlignmentI;
import jalview.gui.Jalview2XML;
import jalview.io.AnnotationFile;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
import jalview.io.FormatAdapter;
import jalview.io.StockholmFileTest;
import jalview.ws.jws2.Jws2Discoverer;
jalview.io.FileLoader fl = new jalview.io.FileLoader(false);
- af = fl.LoadFileWaitTillLoaded(testseqs, jalview.io.FormatAdapter.FILE);
+ af = fl.LoadFileWaitTillLoaded(testseqs, jalview.io.DataSourceType.FILE);
assertNotNull("Couldn't load test data ('" + testseqs + "')", af);
// again what format would be appropriate?
AlignmentI al_new = new FormatAdapter().readFile(aligfileout,
- FormatAdapter.PASTE, "PFAM");
+ DataSourceType.PASTE, FileFormat.Pfam);
assertTrue(
"Test "
+ testname
+ "\nregenerated annotation file did not annotate alignment.",
new AnnotationFile().readAnnotationFile(al_new, anfileout,
- FormatAdapter.PASTE));
+ DataSourceType.PASTE));
// test for consistency in io
StockholmFileTest.testAlignmentEquivalence(al, al_new, false);
assertNotNull(_rc);
AlignFrame alf = new jalview.io.FileLoader(false)
.LoadFileWaitTillLoaded("examples/testdata/smad.fa",
- jalview.io.FormatAdapter.FILE);
+ jalview.io.DataSourceType.FILE);
assertNotNull("Couldn't find test data.", alf);
alf.loadJalviewDataFile("examples/testdata/smad_groups.jva",
- jalview.io.FormatAdapter.FILE, null, null);
+ jalview.io.DataSourceType.FILE, null, null);
assertTrue(
"Couldn't load the test data's annotation file (should be 5 groups but found "
+ alf.getViewport().getAlignment().getGroups().size()
import jalview.datamodel.DBRefSource;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
import jalview.structure.StructureMapping;
import jalview.xml.binding.sifts.Entry.Entity;
try
{
pdbFile = new PDBfile(false, false, false, "test/jalview/io/"
- + testPDBId + ".pdb", AppletFormatAdapter.FILE);
+ + testPDBId + ".pdb", DataSourceType.FILE);
siftsClient = new SiftsClient(pdbFile);
} catch (Exception e)
{
try
{
pdbFile = new PDBfile(false, false, false, "test/jalview/io/2nq2"
- + ".pdb", AppletFormatAdapter.FILE);
+ + ".pdb", DataSourceType.FILE);
siftsClientX = new SiftsClient(pdbFile);
} catch (Exception e)
{