}\r
else if(alignFrame!=null)\r
{\r
- SequenceI[] sequences = null;\r
+ Alignment al = null;\r
\r
String format = new IdentifyFile().Identify(text, AppletFormatAdapter.PASTE);\r
try{\r
- sequences = new AppletFormatAdapter().readFile(text, AppletFormatAdapter.PASTE, format);\r
+ al = new AppletFormatAdapter().readFile(text, AppletFormatAdapter.PASTE, format);\r
}catch(java.io.IOException ex)\r
{\r
ex.printStackTrace();\r
}\r
- if (sequences != null)\r
+ if (al != null)\r
{\r
- AlignFrame af = new AlignFrame(new Alignment(sequences), alignFrame.viewport.applet,\r
+ AlignFrame af = new AlignFrame(al, alignFrame.viewport.applet,\r
"Cut & Paste input - " + format,\r
false);\r
af.statusBar.setText("Successfully pasted alignment file");\r
\r
String format = new jalview.io.IdentifyFile().Identify(args[0],AppletFormatAdapter.FILE);\r
\r
- SequenceI[] sequences = null;\r
+ Alignment al = null;\r
try{\r
- sequences = new AppletFormatAdapter().readFile(args[0], AppletFormatAdapter.FILE, format);\r
+ al = new AppletFormatAdapter().readFile(args[0], AppletFormatAdapter.FILE, format);\r
}catch(java.io.IOException ex)\r
{\r
ex.printStackTrace();\r
}\r
- if ( (sequences != null) && (sequences.length > 0))\r
+ if ( (al != null) && (al.getHeight() > 0))\r
{\r
- AlignFrame af = new AlignFrame(new Alignment(sequences), null, args[0], false);\r
+ AlignFrame af = new AlignFrame(al, null, args[0], false);\r
af.statusBar.setText("Successfully loaded file " + args[0]);\r
}\r
}\r
\r
public void run()\r
{\r
- SequenceI[] sequences = null;\r
+ Alignment al = null;\r
try{\r
- sequences = new AppletFormatAdapter().readFile(file, protocol,\r
+ al = new AppletFormatAdapter().readFile(file, protocol,\r
format);\r
}catch(java.io.IOException ex)\r
{\r
ex.printStackTrace();\r
}\r
- if ((sequences != null) && (sequences.length > 0))\r
+ if ((al != null) && (al.getHeight() > 0))\r
{\r
- currentAlignFrame = new AlignFrame(new Alignment(sequences),\r
+ currentAlignFrame = new AlignFrame(al,\r
applet,\r
file,\r
embedded);\r
}
else
{
- sequences = new FormatAdapter().readFile(str, "Paste", format);
+ sequences = new FormatAdapter().readFile(str, "Paste", format).getSequencesArray();
}
AlignmentI alignment = null;
public void ok_actionPerformed(ActionEvent e)\r
{\r
String format = new IdentifyFile().Identify(getText(), "Paste");\r
- SequenceI[] sequences = null;\r
+ Alignment al = null;\r
\r
if (FormatAdapter.isValidFormat(format))\r
{\r
try{\r
- sequences = new FormatAdapter().readFile(getText(), "Paste", format);\r
+ al = new FormatAdapter().readFile(getText(), "Paste", format);\r
}catch(java.io.IOException ex)\r
{\r
JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
}\r
}\r
\r
- if (sequences != null)\r
+ if (al != null)\r
{\r
if(viewport!=null)\r
{\r
- for(int i=0; i<sequences.length; i++)\r
- viewport.getAlignment().addSequence(sequences[i]);\r
+ for(int i=0; i<al.getHeight(); i++)\r
+ viewport.getAlignment().addSequence(al.getSequenceAt(i));\r
\r
viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());\r
}\r
else\r
{\r
- AlignFrame af = new AlignFrame(new Alignment(sequences),\r
+ AlignFrame af = new AlignFrame(al,\r
AlignFrame.DEFAULT_WIDTH,\r
AlignFrame.DEFAULT_HEIGHT);\r
af.currentFileFormat = format;\r
}
- jalview.gui.VamsasClient v_client=null;
- public void vamsasLoad_actionPerformed(ActionEvent e)
- {
- if (v_client==null) {
- // Start a session.
- JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.
- getProperty("LAST_DIRECTORY"));
-
- chooser.setFileView(new JalviewFileView());
- chooser.setDialogTitle("Load Vamsas file");
- chooser.setToolTipText("Import");
-
- int value = chooser.showOpenDialog(this);
-
- if (value == JalviewFileChooser.APPROVE_OPTION)
- {
- v_client = new jalview.gui.VamsasClient(this,
- chooser.getSelectedFile());
- this.vamsasLoad.setText("Session Update");
- this.vamsasStop.setVisible(true);
- v_client.initial_update();
- v_client.startWatcher();
- }
- } else {
- // store current data in session.
- v_client.push_update();
- }
- }
- public void vamsasStop_actionPerformed(ActionEvent e) {
- if (v_client!=null) {
- v_client.end_session();
- v_client=null;
- this.vamsasStop.setVisible(false);
- this.vamsasLoad.setText("Start Vamsas Session...");
- }
- }
- /**
- * hide vamsas user gui bits when a vamsas document event is being handled.
- * @param b true to hide gui, false to reveal gui
- */
- public void setVamsasUpdate(boolean b) {
- jalview.bin.Cache.log.debug("Setting gui for Vamsas update "+(b ? "in progress" : "finished"));
- vamsasLoad.setVisible(!b);
- vamsasStop.setVisible(!b);
- }
}
}
//Then read in the features and apply them to the dataset
- SequenceI[] sequence = parseResult(result.toString(), null);
+ Alignment al = parseResult(result.toString(), null);
for (int i = 0; i < entries.size(); i++)
{
UniprotEntry entry = (UniprotEntry) entries.elementAt(i);
Enumeration en2 = entry.getAccession().elements();
while (en2.hasMoreElements())
{
- sequence[i].getDatasetSequence().addDBRef(new DBRefEntry(DBRefSource.UNIPROT,
+ al.getSequenceAt(i).getDatasetSequence().addDBRef(new DBRefEntry(DBRefSource.UNIPROT,
"0",
en2.nextElement().toString()));
}
- sequence[i].getDatasetSequence().setPDBId(onlyPdbEntries);
+ al.getSequenceAt(i).getDatasetSequence().setPDBId(onlyPdbEntries);
if (entry.getFeature() != null)
{
e = entry.getFeature().elements();
{
SequenceFeature sf = (SequenceFeature) e.nextElement();
sf.setFeatureGroup("Uniprot");
- sequence[i].getDatasetSequence().addSequenceFeature( sf );
+ al.getSequenceAt(i).getDatasetSequence().addSequenceFeature( sf );
}
}
}
return result;
}
- SequenceI[] parseResult(String result, String title)
+ Alignment parseResult(String result, String title)
{
String format = new IdentifyFile().Identify(result, "Paste");
- SequenceI[] sequences = null;
+ Alignment al = null;
if (FormatAdapter.isValidFormat(format))
{
- sequences = null;
- try{ sequences = new FormatAdapter().readFile(result.toString(), "Paste",
+
+ try{ al = new FormatAdapter().readFile(result.toString(), "Paste",
format);}
catch(Exception ex){}
- if (sequences != null && sequences.length > 0)
+ if (al != null && al.getHeight() > 0)
{
if (alignFrame == null)
{
- AlignFrame af = new AlignFrame(new Alignment(sequences),
+ AlignFrame af = new AlignFrame(al,
AlignFrame.DEFAULT_WIDTH,
AlignFrame.DEFAULT_HEIGHT
);
}
else
{
- for (int i = 0; i < sequences.length; i++)
+ for (int i = 0; i < al.getHeight(); i++)
{
- alignFrame.viewport.alignment.addSequence(sequences[i]);
+ alignFrame.viewport.alignment.addSequence(al.getSequenceAt(i));
////////////////////////////
//Dataset needs extension;
/////////////////////////////
- Sequence ds = new Sequence(sequences[i].getName(),
+ Sequence ds = new Sequence(al.getSequenceAt(i).getName(),
AlignSeq.extractGaps("-. ",
- sequences[i].getSequenceAsString()),
- sequences[i].getStart(),
- sequences[i].getEnd());
- sequences[i].setDatasetSequence(ds);
+ al.getSequenceAt(i).getSequenceAsString()),
+ al.getSequenceAt(i).getStart(),
+ al.getSequenceAt(i).getEnd());
+ al.getSequenceAt(i).setDatasetSequence(ds);
alignFrame.viewport.alignment.getDataset().addSequence(ds);
}
alignFrame.viewport.setEndSeq(alignFrame.viewport.alignment.
{
// Parse out the ids from the structured names
boolean errors = false;
- for (int i = 0; i < sequences.length; i++)
+ for (int i = 0; i < al.getHeight(); i++)
{
PDBEntry entry = new PDBEntry();
com.stevesoft.pat.Regex idbits = new com.stevesoft.pat.Regex(
"PDB\\|([0-9A-z]{4})\\|(.)");
- if (idbits.search(sequences[i].getName()))
+ if (idbits.search(al.getSequenceAt(i).getName()))
{
String pdbid = idbits.substring(1);
String pdbccode = idbits.substring(2);
entry.setProperty(new Hashtable());
entry.getProperty().put("chains",
pdbccode
- + "=" + sequences[i].getStart()
- + "-" + sequences[i].getEnd());
- sequences[i].getDatasetSequence().addPDBId(entry);
+ + "=" + al.getSequenceAt(i).getStart()
+ + "-" + al.getSequenceAt(i).getEnd());
+ al.getSequenceAt(i).getDatasetSequence().addPDBId(entry);
// We make a DBRefEtntry because we have obtained the PDB file from a verifiable source
// JBPNote - PDB DBRefEntry should also carry the chain and mapping information
DBRefEntry dbentry = new DBRefEntry(jalview.datamodel.DBRefSource.PDB,"0",pdbid);
- sequences[i].getDatasetSequence().addDBRef(dbentry);
+ al.getSequenceAt(i).getDatasetSequence().addDBRef(dbentry);
}
else
{
// that the user should know about.
jalview.bin.Cache.log.warn(
"No PDBEntry constructed for sequence " + i + " : " +
- sequences[i].getName());
+ al.getSequenceAt(i).getName());
errors = true;
}
}
+ " from " + database.getSelectedItem());
}
- return sequences;
+ return al;
}
int noSeqs = 0;\r
int maxLength = 0;\r
Vector seqs;\r
- Vector headers;\r
+ Vector annotations;\r
long start;\r
long end;\r
boolean jvSuffix = true;\r
return s;\r
}\r
\r
+ public void addAnnotations(Alignment al)\r
+ {\r
+ for(int i=0; i<annotations.size(); i++)\r
+ {\r
+ al.addAnnotation(\r
+ (AlignmentAnnotation)annotations.elementAt(i)\r
+ );\r
+ }\r
+\r
+ }\r
+\r
/**\r
* Initialise objects to store sequence data in.\r
*/\r
protected void initData()\r
{\r
seqs = new Vector();\r
- headers = new Vector();\r
+ annotations = new Vector();\r
}\r
\r
/**\r
*\r
* @return DOCUMENT ME!\r
*/\r
- public SequenceI[] readFile(String inFile, String type, String format)\r
+ public Alignment readFile(String inFile, String type, String format)\r
throws java.io.IOException\r
{\r
this.inFile = inFile;\r
afile = new StockholmFile(inFile, type);\r
}\r
\r
+ Alignment al = new Alignment(afile.getSeqsAsArray());\r
\r
- return afile.getSeqsAsArray();\r
+ afile.addAnnotations(al);\r
+\r
+ return al;\r
}\r
catch (Exception e)\r
{\r
try{\r
// Possible sequence is just residues with no label\r
afile = new FastaFile(">UNKNOWN\n" + inFile, "Paste");\r
- return afile.getSeqsAsArray();\r
+ Alignment al = new Alignment(afile.getSeqsAsArray());\r
+ afile.addAnnotations(al);\r
+ return al;\r
+\r
}\r
catch(Exception ex)\r
{\r
\r
import java.io.*;\r
\r
+import java.util.*;\r
+\r
\r
/**\r
* DOCUMENT ME!\r
public void parse() throws IOException\r
{\r
StringBuffer sb = new StringBuffer();\r
- int count = 0;\r
+ boolean firstLine = true;\r
\r
String line;\r
Sequence seq = null;\r
\r
+ boolean annotation = false;\r
+\r
while ((line = nextLine()) != null)\r
{\r
line = line.trim();\r
if (line.length() > 0)\r
{\r
- if (line.charAt(0)=='>')\r
+ if (line.charAt(0)=='>')\r
{\r
- if (count != 0)\r
+ if (line.startsWith(">#_"))\r
+ {\r
+ if (annotation)\r
{\r
- if (!isValidProteinSequence(sb.toString().toCharArray()))\r
+ Annotation[] anots = new Annotation[sb.length()];\r
+ for (int i = 0; i < sb.length(); i++)\r
+ {\r
+ anots[i] = new Annotation(sb.substring(i, i+1),\r
+ null,\r
+ ' ', 0);\r
+ }\r
+ AlignmentAnnotation aa = new AlignmentAnnotation(\r
+ seq.getName().substring(2), seq.getDescription(),\r
+ anots);\r
+\r
+ annotations.add(aa);\r
+ }\r
+ annotation = true;\r
+ }\r
+ else\r
+ annotation = false;\r
+\r
+ if (!firstLine)\r
+ {\r
+ if (!annotation && !isValidProteinSequence(sb.toString().toCharArray()))\r
{\r
throw new IOException(AppletFormatAdapter.INVALID_CHARACTERS\r
+" : "+seq.getName()\r
}\r
\r
seq.setSequence(sb.toString());\r
- seqs.addElement(seq);\r
+\r
+ if (!annotation)\r
+ seqs.addElement(seq);\r
}\r
\r
seq = parseId(line.substring(1));\r
+ firstLine = false;\r
\r
- count++;\r
sb = new StringBuffer();\r
}\r
else\r
}\r
}\r
\r
- if (count > 0)\r
+ if (annotation)\r
+ {\r
+ Annotation[] anots = new Annotation[sb.length()];\r
+ for (int i = 0; i < sb.length(); i++)\r
+ {\r
+ anots[i] = new Annotation(sb.substring(i, i + 1),\r
+ null,\r
+ ' ', 0);\r
+ }\r
+ AlignmentAnnotation aa = new AlignmentAnnotation(\r
+ seq.getName().substring(2), seq.getDescription(),\r
+ anots);\r
+\r
+ annotations.add(aa);\r
+ }\r
+\r
+ else if (!firstLine)\r
{\r
+\r
if (!isValidProteinSequence(sb.toString().toCharArray()))\r
{\r
throw new IOException(AppletFormatAdapter.INVALID_CHARACTERS\r
if (Desktop.instance != null)\r
Desktop.instance.startLoading(file);\r
\r
- SequenceI[] sequences = null;\r
+ Alignment al = null;\r
\r
if (format.equalsIgnoreCase("Jalview"))\r
{\r
{\r
try\r
{\r
- sequences = new FormatAdapter().readFile(file, protocol, format);\r
+ al = new FormatAdapter().readFile(file, protocol, format);\r
}\r
catch (java.io.IOException ex)\r
{\r
}\r
}\r
\r
- if ( (sequences != null) && (sequences.length > 0))\r
+ if ( (al != null) && (al.getHeight() > 0))\r
{\r
if (viewport != null)\r
{\r
- for (int i = 0; i < sequences.length; i++)\r
+ for (int i = 0; i < al.getHeight(); i++)\r
{\r
- viewport.getAlignment().addSequence(sequences[i]);\r
+ viewport.getAlignment().addSequence(al.getSequenceAt(i));\r
}\r
viewport.firePropertyChange("alignment", null,\r
viewport.getAlignment().getSequences());\r
}\r
else\r
{\r
- Alignment al = new Alignment(sequences);\r
-\r
alignFrame = new AlignFrame(al,\r
AlignFrame.DEFAULT_WIDTH,\r
AlignFrame.DEFAULT_HEIGHT);\r
{\r
SequenceI [] tmp = new SequenceI[seqs.length];\r
for(int i=0; i<seqs.length; i++)\r
- tmp [i] = new Sequence(\r
+ {\r
+ tmp[i] = new Sequence(\r
seqs[i].getName(), omitHiddenColumns[i],\r
seqs[i].getStart(), seqs[i].getEnd());\r
-\r
+ tmp[i].setDescription(seqs[i].getDescription());\r
+ }\r
seqs = tmp;\r
}\r
\r
import javax.swing.*;\r
import javax.swing.event.*;\r
import jalview.io.FormatAdapter;\r
-import jalview.datamodel.SequenceI;\r
+import jalview.datamodel.Alignment;;\r
import java.awt.BorderLayout;\r
\r
public class GFinder\r
public void run()\r
{\r
String str = textfield.getText();\r
- SequenceI[] sequences = null;\r
- try{sequences = new FormatAdapter().readFile(str, "Paste", "FASTA");}\r
+ Alignment al = null;\r
+ try{al = new FormatAdapter().readFile(str, "Paste", "FASTA");}\r
catch(Exception ex){}\r
- if(sequences!=null && sequences.length>0)\r
+ if(al!=null && al.getHeight()>0)\r
{\r
str = jalview.analysis.AlignSeq.extractGaps(\r
jalview.util.Comparison.GapChars,\r
- sequences[0].getSequenceAsString());\r
+ al.getSequenceAt(0).getSequenceAsString());\r
\r
textfield.setText(str);\r
}\r
al = new Alignment(sqs);\r
alcsel=(ColumnSelection) alandcolsel[1];\r
} else {\r
- al = new Alignment(new FormatAdapter().readFile(result.getAligfile(),\r
- "Paste", format));\r
+ al = new FormatAdapter().readFile(result.getAligfile(),\r
+ "Paste", format);\r
sqs = new SequenceI[al.getHeight()];\r
\r
for (int i = 0, j = al.getHeight(); i < j; i++)\r