{\r
if (viewport.getSelectionGroup() == null)\r
{\r
+ System.out.println("null here");\r
return;\r
}\r
\r
SequenceGroup sg = viewport.getSelectionGroup();\r
\r
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();\r
- StringBuffer buffer = new StringBuffer();\r
\r
Hashtable orderedSeqs = new Hashtable();\r
+ SequenceI [] seqs = new SequenceI[sg.getSize()];\r
\r
for (int i = 0; i < sg.getSize(); i++)\r
{\r
index++;\r
}\r
}\r
+\r
+\r
//FIND START RES\r
//Returns residue following index if gap\r
startRes = seq.findPosition(sg.getStartRes());\r
endRes += seq.getStart() - 1;\r
}\r
\r
- buffer.append(seq.getName() + "\t" +\r
- startRes + "\t" +\r
- endRes + "\t" +\r
- seq.getSequence(sg.getStartRes(),\r
- sg.getEndRes() + 1) + "\n");\r
+ seqs[i] = new Sequence(seq.getName(),\r
+ seq.getSequence(sg.getStartRes(), sg.getEndRes()+1),\r
+ startRes,\r
+ endRes);\r
}\r
\r
- c.setContents(new StringSelection(buffer.toString()), null);\r
+ System.out.println("BLOBL"+FastaFile.print(seqs));\r
+\r
+ c.setContents(new StringSelection(FastaFile.print(seqs)), null);\r
}\r
\r
/**\r
}\r
\r
String str = (String) contents.getTransferData(DataFlavor.stringFlavor);\r
- StringTokenizer st = new StringTokenizer(str);\r
- ArrayList seqs = new ArrayList();\r
\r
- while (st.hasMoreElements())\r
- {\r
- String name = st.nextToken();\r
- int start = Integer.parseInt(st.nextToken());\r
- int end = Integer.parseInt(st.nextToken());\r
- Sequence sequence = new Sequence(name, st.nextToken(), start,\r
- end);\r
+ String format = IdentifyFile.Identify(str, "Paste");\r
+ SequenceI[] sequences = FormatAdapter.readFile(str, "Paste", format);\r
\r
- if (!newAlignment)\r
- {\r
- viewport.alignment.addSequence(sequence);\r
- }\r
- else\r
- {\r
- seqs.add(sequence);\r
- }\r
- }\r
\r
if (newAlignment)\r
{\r
- SequenceI[] newSeqs = new SequenceI[seqs.size()];\r
- seqs.toArray(newSeqs);\r
-\r
- AlignFrame af = new AlignFrame(new Alignment(newSeqs));\r
+ AlignFrame af = new AlignFrame(new Alignment(sequences));\r
String newtitle = new String("Copied sequences");\r
\r
if (title.startsWith("Copied sequences"))\r
}\r
else\r
{\r
+ //!newAlignment\r
+ for (int i = 0; i < sequences.length; i++)\r
+ viewport.alignment.addSequence(sequences[i]);\r
+\r
viewport.setEndSeq(viewport.alignment.getHeight());\r
viewport.alignment.getWidth();\r
viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());\r
import java.awt.event.*;\r
import javax.swing.*;\r
import javax.swing.event.*;\r
+import jalview.io.FormatAdapter;\r
+import jalview.datamodel.SequenceI;\r
+import java.awt.datatransfer.DataFlavor;\r
+import jalview.io.IdentifyFile;\r
\r
public class GFinder\r
extends JPanel\r
\r
public void textfield_caretUpdate(CaretEvent e)\r
{\r
- if (textfield.getText().indexOf("\t") > -1)\r
+ if (textfield.getText().indexOf(">") > -1)\r
{\r
SwingUtilities.invokeLater(new Runnable()\r
{\r
public void run()\r
{\r
- String text = textfield.getText();\r
- text = text.substring(text.lastIndexOf("\t") + 1).trim();\r
- text = jalview.analysis.AlignSeq.extractGaps(\r
- jalview.util.Comparison.GapChars, text);\r
- textfield.setText(text);\r
+ String str = textfield.getText();\r
+ SequenceI[] sequences = FormatAdapter.readFile(str, "Paste", "FASTA");\r
+ if(sequences!=null && sequences.length>0)\r
+ {\r
+ str = jalview.analysis.AlignSeq.extractGaps(\r
+ jalview.util.Comparison.GapChars, sequences[0].getSequence());\r
+\r
+ textfield.setText(str);\r
+ }\r
}\r
});\r
}\r