import jalview.gui.AlignmentPanel;
import jalview.gui.FeatureRenderer;
import jalview.gui.SequenceRenderer;
+import jalview.io.DataSourceType;
import jalview.io.StructureFile;
import jalview.structure.AtomSpec;
import jalview.structure.StructureListener;
String errorMessage;
void init(PDBEntry pdbentry, SequenceI[] seq, String[] chains,
- AlignmentPanel ap, String protocol)
+ AlignmentPanel ap, DataSourceType protocol)
{
this.ap = ap;
this.pdbentry = pdbentry;
AlignmentPanel ap;
- String protocol;
+ DataSourceType protocol;
String tmpPDBFile;
public PDBViewer(PDBEntry pdbentry, SequenceI[] seq, String[] chains,
- AlignmentPanel ap, String protocol)
+ AlignmentPanel ap, DataSourceType protocol)
{
this.pdbentry = pdbentry;
this.seq = seq;
import jalview.analysis.AlignmentAnnotationUtils;
import jalview.analysis.AlignmentUtils;
import jalview.analysis.Conservation;
+import jalview.bin.JalviewLite;
import jalview.commands.ChangeCaseCommand;
import jalview.commands.EditCommand;
import jalview.commands.EditCommand.Action;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
import jalview.io.SequenceAnnotationReport;
import jalview.schemes.Blosum62ColourScheme;
import jalview.schemes.BuriedColourScheme;
Frame frame = new Frame();
frame.add(cap);
- jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage(
+ JalviewLite.addFrame(frame, MessageManager.formatMessage(
"label.selection_output_command",
new Object[] { e.getActionCommand() }), 600, 500);
// JBPNote: getSelectionAsNewSequence behaviour has changed - this method
// now returns a full copy of sequence data
// TODO consider using getSequenceSelection instead here
- cap.setText(new jalview.io.AppletFormatAdapter().formatSequences(
- e.getActionCommand(), ap.av.getShowJVSuffix(), ap, true));
+ FileFormat fileFormat = FileFormat.valueOf(e.getActionCommand());
+ cap.setText(new AppletFormatAdapter().formatSequences(fileFormat,
+ ap.av.getShowJVSuffix(), ap, true));
}
if (ap.av.applet.jmolAvailable)
{
new jalview.appletgui.AppletJmol(entry, new SequenceI[] { seq },
- null, ap, AppletFormatAdapter.URL);
+ null, ap, DataSourceType.URL);
}
else
{
new MCview.AppletPDBViewer(entry, new SequenceI[] { seq }, null,
- ap, AppletFormatAdapter.URL);
+ ap, DataSourceType.URL);
}
}
CutAndPasteTransfer cap = new CutAndPasteTransfer(true, this);
Frame frame = new Frame();
frame.add(cap);
- jalview.bin.JalviewLite.addFrame(frame, MessageManager.formatMessage(
+ JalviewLite.addFrame(frame, MessageManager.formatMessage(
"label.alignment_output_command",
new Object[] { e.getActionCommand() }), 600, 500);
- FeatureRenderer fr = this.alignPanel.cloneFeatureRenderer();
+ FileFormat fileFormat = FileFormat.valueOf(e.getActionCommand());
cap.setText(new AppletFormatAdapter(alignPanel).formatSequences(
- e.getActionCommand(), viewport.getAlignment(),
+ fileFormat, viewport.getAlignment(),
viewport.getShowJVSuffix()));
}
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.ext.jmol.JalviewJmolBinding;
+import jalview.io.DataSourceType;
import java.awt.Container;
import java.util.ArrayList;
private AlignmentPanel ap;
- protected ExtJmol(jalview.appletgui.AlignFrame alframe,
+ protected ExtJmol(AlignFrame alframe,
PDBEntry[] pdbentry, SequenceI[][] seq, String[][] chains,
- String protocol)
+ DataSourceType protocol)
{
super(alframe.alignPanel.getStructureSelectionManager(), pdbentry, seq,
chains, protocol);
notifyFileLoaded(null, null, null, null, 0);
}
+ @Override
public void updateColours(Object source)
{
}
+ @Override
public void showUrl(String arg0)
{
showUrl(arg0, "jmol");
// ignore
}
+ @Override
public void selectionChanged(BS arg0)
{
System.out.println(arg0);
*/
@Override
public String getSelectedSequencesAsAlignmentFrom(AlignFrame alf,
- String format, String suffix)
+ FileFormatI format, String suffix)
{
try
{
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.io.DataSourceType;
import jalview.io.FeaturesFile;
import jalview.util.MessageManager;
}
@Override
- public boolean parseFeaturesFile(String file, String protocol,
+ public boolean parseFeaturesFile(String file, DataSourceType protocol,
boolean relaxedIdMatching)
{
boolean featuresFile = false;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.httpserver.AbstractRequestHandler;
+import jalview.io.DataSourceType;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ResidueProperties;
import jalview.structure.AtomSpec;
*/
public JalviewChimeraBinding(StructureSelectionManager ssm,
PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
- String protocol)
+ DataSourceType protocol)
{
super(ssm, pdbentry, sequenceIs, chains, protocol);
viewer = new ChimeraManager(
// originating file's format
// TODO: work out how to recover feature settings for correct view(s) when
// file is reloaded.
- if (currentFileFormat.equals("Jalview"))
+ if (currentFileFormat == FileFormat.Jalview)
{
JInternalFrame[] frames = Desktop.desktop.getAllFrames();
for (int i = 0; i < frames.length; i++)
Desktop.instance.closeAssociatedWindows();
FileLoader loader = new FileLoader();
- String protocol = fileName.startsWith("http:") ? "URL" : "File";
+ DataSourceType protocol = fileName.startsWith("http:") ? DataSourceType.URL
+ : DataSourceType.FILE;
loader.LoadFile(viewport, fileName, protocol, currentFileFormat);
}
else
Rectangle bounds = this.getBounds();
FileLoader loader = new FileLoader();
- String protocol = fileName.startsWith("http:") ? "URL" : "File";
+ DataSourceType protocol = fileName.startsWith("http:") ? DataSourceType.URL
+ : DataSourceType.FILE;
AlignFrame newframe = loader.LoadFileWaitTillLoaded(fileName,
protocol, currentFileFormat);
@Override
public void save_actionPerformed(ActionEvent e)
{
- if (fileName == null
- || (currentFileFormat == null || !jalview.io.FormatAdapter
- .isValidIOFormat(currentFileFormat, true))
+ if (fileName == null || (currentFileFormat == null)
|| fileName.startsWith("http"))
{
saveAs_actionPerformed(null);
public void saveAs_actionPerformed(ActionEvent e)
{
JalviewFileChooser chooser = new JalviewFileChooser(
- jalview.bin.Cache.getProperty("LAST_DIRECTORY"),
- jalview.io.AppletFormatAdapter.WRITABLE_EXTENSIONS,
- jalview.io.AppletFormatAdapter.WRITABLE_FNAMES,
+ Cache.getProperty("LAST_DIRECTORY"),
+ // AppletFormatAdapter.WRITABLE_EXTENSIONS,
+ // AppletFormatAdapter.WRITABLE_FNAMES,
currentFileFormat, false);
chooser.setFileView(new JalviewFileView());
currentFileFormat.toString());
Cache.setProperty("LAST_DIRECTORY", fileName);
- if (currentFileFormat.indexOf(" ") > -1)
- {
- currentFileFormat = currentFileFormat.substring(0,
- currentFileFormat.indexOf(" "));
- }
saveAlignment(fileName, currentFileFormat);
}
}
}
else
{
- if (!jalview.io.AppletFormatAdapter.isValidFormat(format, true))
- {
- warningMessage("Cannot save file " + fileName + " using format "
- + format, "Alignment output format not supported");
- if (!Jalview.isHeadlessMode())
- {
- saveAs_actionPerformed(null);
- }
- return false;
- }
+ // if (!jalview.io.AppletFormatAdapter.isValidFormat(format, true))
+ // {
+ // warningMessage("Cannot save file " + fileName + " using format "
+ // + format, "Alignment output format not supported");
+ // if (!Jalview.isHeadlessMode())
+ // {
+ // saveAs_actionPerformed(null);
+ // }
+ // return false;
+ // }
AlignmentExportData exportData = getAlignmentForExport(format,
viewport, null);
protected void outputText_actionPerformed(ActionEvent e)
{
+ FileFormat fileFormat = FileFormat.valueOf(e.getActionCommand());
AlignmentExportData exportData = getAlignmentForExport(
- e.getActionCommand(), viewport, null);
+fileFormat,
+ viewport, null);
if (exportData.getSettings().isCancelled())
{
return;
cap.setForInput(null);
try
{
- FileFormatI format = FileFormat.valueOf(e.getActionCommand());
+ FileFormatI format = fileFormat;
cap.setText(new FormatAdapter(alignPanel, exportData.getSettings())
.formatSequences(format,
exportData.getAlignment(),
return;
}
- String str, format;
+ String str;
+ FileFormatI format;
try
{
str = (String) contents.getTransferData(DataFlavor.stringFlavor);
return;
}
- format = new IdentifyFile().identify(str, "Paste");
+ format = new IdentifyFile().identify(str, DataSourceType.PASTE);
} catch (OutOfMemoryError er)
{
else
{
// parse the clipboard as an alignment.
- alignment = new FormatAdapter().readFile(str, "Paste", format);
+ alignment = new FormatAdapter().readFile(str, DataSourceType.PASTE,
+ format);
sequences = alignment.getSequencesArray();
}
}
if (mtch != null)
{
- String type = null;
+ FileFormatI type = null;
try
{
type = new IdentifyFile().identify(file, protocol);
}
if (type != null)
{
- if (type.equalsIgnoreCase("PDB"))
+ if (type == FileFormat.PDB)
{
filesmatched.add(new Object[] { file, protocol, mtch });
continue;
{
PDBEntry pe = new AssociatePdbFileWithSeq()
.associatePdbWithSeq((String) fm[0],
- (String) fm[1], toassoc, false,
+ (DataSourceType) fm[1], toassoc, false,
Desktop.instance);
if (pe != null)
{
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 AppJmolBinding(AppJmol appJmol, StructureSelectionManager sSm,
PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
- String protocol)
+ DataSourceType protocol)
{
super(sSm, pdbentry, sequenceIs, chains, protocol);
appJmolWindow = appJmol;
// appJmolWindow.repaint();
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
+ @Override
public void run()
{
appJmolWindow.updateTitleAndMenus();
});
}
+ @Override
public void updateColours(Object source)
{
AlignmentPanel ap = (AlignmentPanel) source;
// msWalltime);
}
+ @Override
public void showUrl(String url)
{
showUrl(url, "jmol");
import jalview.api.StructureSelectionManagerProvider;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
+import jalview.io.DataSourceType;
import jalview.io.StructureFile;
import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
* @param choice
* @param sequence
*/
- public PDBEntry associatePdbWithSeq(String choice, String protocol,
+ public PDBEntry associatePdbWithSeq(String choice, DataSourceType file,
SequenceI sequence, boolean prompt,
StructureSelectionManagerProvider ssmp)
{
StructureFile pdbfile = null;
pdbfile = StructureSelectionManager.getStructureSelectionManager(ssmp)
.setMapping(false, new SequenceI[] { sequence }, null, choice,
- protocol);
+ file);
if (pdbfile == null)
{
// stacktrace already thrown so just return
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.SequenceI;
+import jalview.io.AlignmentFileI;
import jalview.io.AppletFormatAdapter;
import jalview.io.DataSourceType;
+import jalview.io.FileFormatException;
import jalview.io.FileFormatI;
-import jalview.io.FileParse;
import jalview.io.FormatAdapter;
import jalview.io.IdentifyFile;
import jalview.io.JalviewFileChooser;
AlignViewportI viewport;
- FileParse source = null;
+ AlignmentFileI source = null;
public CutAndPasteTransfer()
{
return;
}
- FileFormatI format = new IdentifyFile().identify(text,
- DataSourceType.PASTE);
+ FileFormatI format = null;
+ try
+ {
+ format = new IdentifyFile().identify(text, DataSourceType.PASTE);
+ } catch (FileFormatException e1)
+ {
+ // leave as null
+ }
if (format == null)
{
System.err.println(MessageManager
// TODO: identify feature, annotation or tree file and parse appropriately.
AlignmentI al = null;
- if (FormatAdapter.isValidFormat(format))
+ try
{
- try
- {
- FormatAdapter fa = new FormatAdapter(alignpanel);
- al = fa.readFile(getText(), DataSourceType.PASTE, format);
- source = fa.getAlignFile();
+ FormatAdapter fa = new FormatAdapter(alignpanel);
+ al = fa.readFile(getText(), DataSourceType.PASTE, format);
+ source = fa.getAlignFile();
- } catch (java.io.IOException ex)
- {
- JOptionPane.showInternalMessageDialog(Desktop.desktop,
- MessageManager.formatMessage(
- "label.couldnt_read_pasted_text",
- new String[] { ex.toString() }), MessageManager
- .getString("label.error_parsing_text"),
- JOptionPane.WARNING_MESSAGE);
- }
+ } catch (java.io.IOException ex)
+ {
+ JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
+ .formatMessage("label.couldnt_read_pasted_text", new String[]
+ { ex.toString() }), MessageManager
+ .getString("label.error_parsing_text"),
+ JOptionPane.WARNING_MESSAGE);
}
if (al != null && al.hasValidSequence())
{
String title = MessageManager.formatMessage(
- "label.input_cut_paste_params", new String[] { format });
+ "label.input_cut_paste_params",
+ new String[] { format.getShortDescription() });
FeatureSettingsModelI proxyColourScheme = source
.getFeatureColourScheme();
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;
public void run()
{
Cache.log.debug("Filechooser init thread started.");
- 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"));
+ FileFormat fileFormat = FileFormat.valueOf(Cache
+ .getProperty("DEFAULT_FILE_FORMAT"));
+ new JalviewFileChooser(Cache.getProperty("LAST_DIRECTORY"),
+ // jalview.io.AppletFormatAdapter.READABLE_EXTENSIONS,
+ // jalview.io.AppletFormatAdapter.READABLE_FNAMES,
+ fileFormat);
Cache.log.debug("Filechooser init thread finished.");
}
}).start();
@Override
public void inputLocalFileMenuItem_actionPerformed(AlignViewport viewport)
{
+ FileFormat fileFormat = FileFormat.valueOf(Cache
+ .getProperty("DEFAULT_FILE_FORMAT"));
JalviewFileChooser chooser = new JalviewFileChooser(
Cache.getProperty("LAST_DIRECTORY"),
- AppletFormatAdapter.READABLE_EXTENSIONS,
- AppletFormatAdapter.READABLE_FNAMES,
- Cache.getProperty("DEFAULT_FILE_FORMAT"));
+ // AppletFormatAdapter.READABLE_EXTENSIONS,
+ // AppletFormatAdapter.READABLE_FNAMES,
+ fileFormat);
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import jalview.ext.rbvi.chimera.JalviewChimeraBinding;
+import jalview.io.DataSourceType;
import jalview.structure.StructureSelectionManager;
public class JalviewChimeraBindingModel extends JalviewChimeraBinding
public JalviewChimeraBindingModel(ChimeraViewFrame chimeraViewFrame,
StructureSelectionManager ssm, PDBEntry[] pdbentry,
- SequenceI[][] sequenceIs, String[][] chains, String protocol)
+ SequenceI[][] sequenceIs, String[][] chains,
+ DataSourceType protocol)
{
super(ssm, pdbentry, sequenceIs, chains, protocol);
cvf = chimeraViewFrame;
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
+ @Override
public void run()
{
cvf.updateTitleAndMenus();
});
}
+ @Override
public void updateColours(Object source)
{
AlignmentPanel ap = (AlignmentPanel) source;
* Send an asynchronous command to Chimera, in a new thread, optionally with
* an 'in progress' message in a progress bar somewhere
*/
+ @Override
protected void sendAsynchronousCommand(final String command,
final String progressMsg)
{
import jalview.bin.Cache;
import jalview.gui.Help.HelpId;
import jalview.gui.StructureViewer.ViewerType;
+import jalview.io.FileFormat;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
import jalview.jbgui.GPreferences;
@Override
public void startupFileTextfield_mouseClicked()
{
+ FileFormat fileFormat = FileFormat.valueOf(Cache.getProperty("DEFAULT_FILE_FORMAT"));
JalviewFileChooser chooser = new JalviewFileChooser(
+ // fixme push into enum
Cache.getProperty("LAST_DIRECTORY"), new String[] {
"fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
"jar" }, new String[] { "Fasta", "Clustal", "PFAM", "MSF",
"PIR", "BLC", "Jalview" },
- Cache.getProperty("DEFAULT_FILE_FORMAT"));
+ fileFormat);
chooser.setFileView(new JalviewFileView());
chooser.setDialogTitle(MessageManager
.getString("label.select_startup_file"));
import jalview.datamodel.SequenceI;
import jalview.fts.service.pdb.PDBFTSPanel;
import jalview.fts.service.uniprot.UniprotFTSPanel;
+import jalview.io.FileFormatI;
import jalview.io.gff.SequenceOntologyI;
import jalview.util.DBRefUtils;
import jalview.util.MessageManager;
}
AlignmentI parseResult(AlignmentI al, String title,
- String currentFileFormat,
+ FileFormatI currentFileFormat,
FeatureSettingsModelI preferredFeatureColours)
{
import jalview.fts.core.FTSRestRequest;
import jalview.fts.core.FTSRestResponse;
import jalview.fts.service.pdb.PDBFTSRestClient;
+import jalview.io.DataSourceType;
import jalview.jbgui.GStructureChooser;
import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
}
PDBEntry fileEntry = new AssociatePdbFileWithSeq()
.associatePdbWithSeq(selectedPdbFileName,
- jalview.io.DataSourceType.FILE,
+ DataSourceType.FILE,
selectedSequence, true, Desktop.instance);
launchStructureViewer(ssm, new PDBEntry[] { fileEntry }, ap,
// just in case the caller didn't identify the file for us
if (source != null)
{
- format = new IdentifyFile().identify(source, false); // identify
- // stream and
- // rewind rather
- // than close
+ format = new IdentifyFile().identify(source, false);
+ // identify stream and rewind rather than close
}
else
{
public boolean getCacheSuffixDefault(FileFormatI format)
{
- if (isValidFormat(format))
- {
- return Cache.getDefault(format.toUpperCase()
- + "_JVSUFFIX", true);
- }
- return false;
+ return Cache.getDefault(format.toString() + "_JVSUFFIX", true);
}
public String formatSequences(FileFormatI format, AlignmentI alignment,
init(suffix, desc, selected, true);
}
+ public JalviewFileChooser(String property, FileFormatI currentFileFormat,
+ boolean b)
+ {
+ todo write this
+ // TODO Auto-generated constructor stub
+ }
+
void init(String[] suffix, String[] desc, String selected,
boolean selectAll)
{
import jalview.datamodel.AlignmentI;
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.DBRefSource;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
import jalview.io.FormatAdapter;
import com.stevesoft.pat.Regex;
// retrieved.
startQuery();
AlignmentI rcds = new FormatAdapter().readFile(getXFAMURL()
- + queries.trim().toUpperCase(), jalview.io.FormatAdapter.URL,
- "STH");
+ + queries.trim().toUpperCase(), DataSourceType.URL,
+ FileFormat.Stockholm);
for (int s = 0, sNum = rcds.getHeight(); s < sNum; s++)
{
rcds.getSequenceAt(s).addDBRef(
import jalview.datamodel.AlignmentI;
import jalview.datamodel.DBRefEntry;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormat;
import jalview.io.FormatAdapter;
import jalview.ws.seqfetcher.DbSourceProxyImpl;
// TODO: trap HTTP 404 exceptions and return null
AlignmentI rcds = new FormatAdapter().readFile(getXFAMURL()
+ queries.trim().toUpperCase() + getXFAMURLSUFFIX(),
- jalview.io.FormatAdapter.URL,
- "STH");
+ DataSourceType.URL, FileFormat.Stockholm);
for (int s = 0, sNum = rcds.getHeight(); s < sNum; s++)
{
rcds.getSequenceAt(s).addDBRef(new DBRefEntry(getXfamSource(),
package jalview.ws.rest.params;
import jalview.datamodel.AlignmentI;
+import jalview.io.FileFormat;
+import jalview.io.FileFormatI;
+import jalview.io.FormatAdapter;
import jalview.ws.params.OptionI;
import jalview.ws.params.simple.BooleanOption;
import jalview.ws.params.simple.Option;
super(new Class[] { AlignmentI.class });
}
- String format = "FASTA";
+ FileFormatI format = FileFormat.Fasta;
molType type;
PrintWriter pw = new PrintWriter(
new OutputStreamWriter(new BufferedOutputStream(
new FileOutputStream(fa)), "UTF-8"));
- pw.append(new jalview.io.FormatAdapter().formatSequences(format,
+ pw.append(new FormatAdapter().formatSequences(format,
alignment, jvsuffix));
pw.close();
return new FileBody(fa, "text/plain");
}
else
{
- jalview.io.FormatAdapter fa = new jalview.io.FormatAdapter();
+ FormatAdapter fa = new FormatAdapter();
fa.setNewlineString("\r\n");
return new StringBody(
(fa.formatSequences(format, alignment, jvsuffix)));
{
prms.add("jvsuffix");
}
- ;
if (writeAsFile)
{
prms.add("writeasfile");
}
- ;
return prms;
}