addKeyListener();
}
-
+ /**
+ * Change the filename and format for the alignment, and
+ * enable the 'reload' button functionality.
+ * @param file valid filename
+ * @param format format of file
+ */
public void setFileName(String file, String format)
{
fileName = file;
validate();
}
-
-
-
-
+ /**
+ *
+ * @return true if any progress bars are still active
+ */
+ public boolean operationInProgress()
+ {
+ if (progressBars!=null && progressBars.size()>0)
+ {
+ return true;
+ }
+ return false;
+ }
/*
Added so Castor Mapping file can obtain Jalview Version
*/
public void save_actionPerformed(ActionEvent e)
{
if(fileName==null
- || currentFileFormat==null
+ || (currentFileFormat==null || jalview.io.AppletFormatAdapter.isValidFormat(currentFileFormat, true))
|| fileName.startsWith("http")
)
{
{
JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
getProperty( "LAST_DIRECTORY"),
- new String[]
- { "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc","amsa","jar" },
- new String[]
- { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "Jalview" },
+ jalview.io.AppletFormatAdapter.WRITABLE_EXTENSIONS,
+ jalview.io.AppletFormatAdapter.WRITABLE_FNAMES,
currentFileFormat,
false);
}
else
- {
-
+ {
+ if (!jalview.io.AppletFormatAdapter.isValidFormat(format, true))
+ {
+ // JBPNote need to have a raise_gui flag here
+ JOptionPane.showInternalMessageDialog(
+ this, "Cannot save file " + fileName + " using format "+format,
+ "Alignment output format not supported",
+ JOptionPane.WARNING_MESSAGE);
+ saveAs_actionPerformed(null);
+ return false;
+ }
+
String[] omitHidden = null;
if (viewport.hasHiddenColumns)
}
}
FormatAdapter f = new FormatAdapter();
-
String output = f.formatSequences(
format,
(Alignment) viewport.alignment, // class cast exceptions will occur in the distant future
}
/**
- * DOCUMENT ME!
+ * Paste contents of Jalview clipboard
*
- * @param newAlignment DOCUMENT ME!
+ * @param newAlignment true to paste to a new alignment, otherwise add to this.
*/
void paste(boolean newAlignment)
{
{
SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
AlignmentSorter.sortByPID(viewport.getAlignment(),
- viewport.getAlignment().getSequenceAt(0));
+ viewport.getAlignment().getSequenceAt(0), null);
addHistoryItem(new OrderCommand("Pairwise Sort", oldOrder,
viewport.alignment));
alignPanel.paintAlignment(true);
public void actionPerformed(ActionEvent e)
{
SequenceI [] oldOrder = viewport.getAlignment().getSequencesArray();
- AlignmentSorter.sortByAnnotationScore(scoreLabel, viewport.getAlignment());
+ AlignmentSorter.sortByAnnotationScore(scoreLabel, viewport.getAlignment());//,viewport.getSelectionGroup());
addHistoryItem(new OrderCommand("Sort by "+scoreLabel, oldOrder, viewport.alignment));
alignPanel.paintAlignment(true);
}
*/
public void BuildWebServiceMenu()
{
+ // TODO: add support for context dependent disabling of services based on alignment and current selection
+ // TODO: refactor to allow list of AbstractName/Handler bindings to be stored or retrieved from elsewhere
+ // TODO: add additional serviceHandle parameter to specify abstract handler class independently of AbstractName
+ // TODO: add in rediscovery GUI function to restart discoverer
+ // TODO: group services by location as well as function and/or introduce object broker mechanism.
if ( (Discoverer.services != null)
&& (Discoverer.services.size() > 0))
{
resetWebServiceMenu();
this.webService.add(this.webServiceNoServices);
}
- // TODO: add in rediscovery function
- // TODO: reduce code redundancy.
- // TODO: group services by location as well as function.
}
public void actionPerformed(ActionEvent e)
{
+ // TODO: new thread for this call with vis-delay
af.showProductsFor(sel, ds, isRegSel, dna, source);
}
}
protected void showProductsFor(SequenceI[] sel, Alignment ds, boolean isRegSel, boolean dna, String source)
{
- ds = this.getViewport().alignment.getDataset(); // update our local dataset reference
- Alignment prods = CrossRef.findXrefSequences(sel, dna, source, ds);
- if (prods!=null)
- {
- SequenceI[] sprods = new SequenceI[prods.getHeight()];
- for (int s=0; s<sprods.length;s++)
- {
- sprods[s] = (prods.getSequenceAt(s)).deriveSequence();
- if (ds.getSequences()==null || !ds.getSequences().contains(sprods[s].getDatasetSequence()))
- ds.addSequence(sprods[s].getDatasetSequence());
- }
- Alignment al = new Alignment(sprods);
- AlignedCodonFrame[] cf = prods.getCodonFrames();
- for (int s=0; cf!=null && s<cf.length; s++)
+ final boolean fisRegSel = isRegSel;
+ final boolean fdna = dna;
+ final String fsrc = source;
+ final AlignFrame ths = this;
+ final SequenceI[] fsel = sel;
+ Runnable foo = new Runnable() {
+
+ public void run()
{
- al.addCodonFrame(cf[s]);
- cf[s] = null;
+ final long sttime = System.currentTimeMillis();
+ ths.setProgressBar("Searching for sequences from "+fsrc, sttime);
+ try {
+ Alignment ds = ths.getViewport().alignment.getDataset(); // update our local dataset reference
+ Alignment prods = CrossRef.findXrefSequences(fsel, fdna, fsrc, ds);
+ if (prods!=null)
+ {
+ SequenceI[] sprods = new SequenceI[prods.getHeight()];
+ for (int s=0; s<sprods.length;s++)
+ {
+ sprods[s] = (prods.getSequenceAt(s)).deriveSequence();
+ if (ds.getSequences()==null || !ds.getSequences().contains(sprods[s].getDatasetSequence()))
+ ds.addSequence(sprods[s].getDatasetSequence());
+ sprods[s].updatePDBIds();
+ }
+ Alignment al = new Alignment(sprods);
+ AlignedCodonFrame[] cf = prods.getCodonFrames();
+ for (int s=0; cf!=null && s<cf.length; s++)
+ {
+ al.addCodonFrame(cf[s]);
+ cf[s] = null;
+ }
+ al.setDataset(ds);
+ AlignFrame naf = new AlignFrame(al, DEFAULT_WIDTH, DEFAULT_HEIGHT);
+ String newtitle =""+((fdna) ? "Proteins " : "Nucleotides ") + " for "+((fisRegSel) ? "selected region of " : "")
+ + getTitle();
+ Desktop.addInternalFrame(naf, newtitle, DEFAULT_WIDTH,
+ DEFAULT_HEIGHT);
+ } else {
+ System.err.println("No Sequences generated for xRef type "+fsrc);
+ }
+ }
+ catch (Exception e)
+ {
+ jalview.bin.Cache.log.error("Exception when finding crossreferences",e);
+ }
+ catch (Error e)
+ {
+ jalview.bin.Cache.log.error("Error when finding crossreferences",e);
+ }
+ ths.setProgressBar("Finished searching for sequences from "+fsrc, sttime);
}
- al.setDataset(ds);
- AlignFrame naf = new AlignFrame(al, DEFAULT_WIDTH, DEFAULT_HEIGHT);
- String newtitle =""+((dna) ? "Proteins " : "Nucleotides ") + " for "+((isRegSel) ? "selected region of " : "")
- + getTitle();
- Desktop.addInternalFrame(naf, newtitle, DEFAULT_WIDTH,
- DEFAULT_HEIGHT);
- } else {
- System.err.println("No Sequences generated for xRef type "+source);
- }
+
+ };
+ Thread frunner = new Thread(foo);
+ frunner.start();
}
}
/**
- * DOCUMENT ME!
- *
- * @param String DOCUMENT ME!
+ * Try to load a features file onto the alignment.
+ * @param file contents or path to retrieve file
+ * @param type access mode of file (see jalview.io.AlignFile)
+ * @return true if features file was parsed corectly.
*/
public boolean parseFeaturesFile(String file, String type)
{
}
}
- // This method will attempt to load a "dropped" file first by testing
- // whether its and Annotation file, then features file. If both are
- // false then the user may have dropped an alignment file onto this
- // AlignFrame
+ /**
+ * Attempt to load a "dropped" file: First by testing
+ * whether it's and Annotation file, then a JNet file, and finally a features file. If all are
+ * false then the user may have dropped an alignment file onto this
+ * AlignFrame.
+ * @param file either a filename or a URL string.
+ */
public void loadJalviewDataFile(String file)
- {
+ {
try
{
String protocol = "File";
if (!isAnnotation)
{
- boolean isGroupsFile = parseFeaturesFile(file,protocol);
- if (!isGroupsFile)
+ // try to see if its a JNet 'concise' style annotation file *before* we try to parse it as a features file
+ String format = new IdentifyFile().Identify(file, protocol);
+ if(format.equalsIgnoreCase("JnetFile"))
{
- String format = new IdentifyFile().Identify(file, protocol);
-
- if(format.equalsIgnoreCase("JnetFile"))
- {
- jalview.io.JPredFile predictions = new jalview.io.JPredFile(
- file, protocol);
- new JnetAnnotationMaker().add_annotation(predictions,
+ jalview.io.JPredFile predictions = new jalview.io.JPredFile(
+ file, protocol);
+ new JnetAnnotationMaker().add_annotation(predictions,
viewport.getAlignment(),
0, false);
- alignPanel.adjustAnnotationHeight();
- alignPanel.paintAlignment(true);
- }
- else
+ isAnnotation=true;
+ }
+ else
+ {
+ // try to parse it as a features file
+ boolean isGroupsFile = parseFeaturesFile(file,protocol);
+ // if it wasn't a features file then we just treat it as a general alignment file to load into the current view.
+ if (!isGroupsFile)
{
new FileLoader().LoadFile(viewport, file, protocol, format);
+ } else {
+ alignPanel.paintAlignment(true);
+ }
}
}
- }
- else
+ if (isAnnotation)
{
- // (isAnnotation)
+
alignPanel.adjustAnnotationHeight();
buildSortByAnnotationScoresMenu();
+ alignPanel.paintAlignment(true);
}
-
}
catch (Exception ex)
{
protected void extractScores_actionPerformed(ActionEvent e)
{
ParseProperties pp = new jalview.analysis.ParseProperties(viewport.alignment);
- if (pp.getScoresFromDescription("col", "score column ", "\\W+([-+]?\\d*\\.?\\d*e?-?\\d*)\\W+([-+]?\\d*\\.?\\d*e?-?\\d*)")>0)
+ if (pp.getScoresFromDescription("col", "score column ", "\\W*([-+]?\\d*\\.?\\d*e?-?\\d*)\\W+([-+]?\\d*\\.?\\d*e?-?\\d*)", true)>0)
{
buildSortByAnnotationScoresMenu();
}