{\r
if (viewport.getSelectionGroup() == null)\r
{\r
- System.out.println("nothing selected");\r
return;\r
}\r
\r
seqs[i].setDBRef(seq.getDBRef());\r
seqs[i].setSequenceFeatures(seq.getSequenceFeatures());\r
seqs[i].setDatasetSequence(seq.getDatasetSequence());\r
+\r
}\r
\r
- Desktop.jalviewClipboard = new Object[]{seqs, viewport.alignment.getDataset()};\r
FastaFile ff = new FastaFile();\r
ff.addDBPrefix( viewport.showDBPrefix );\r
ff.addJVSuffix( viewport.showJVSuffix );\r
c.setContents(new StringSelection( ff.print(seqs)), this);\r
+ Desktop.jalviewClipboard = new Object[]{seqs, viewport.alignment.getDataset()};\r
}\r
\r
/**\r
sequences = (SequenceI[])Desktop.jalviewClipboard[0];\r
}\r
else\r
+ {\r
sequences = new FormatAdapter().readFile(str, "Paste", format);\r
-\r
+ }\r
\r
if (newAlignment)\r
{\r
{\r
//!newAlignment\r
for (int i = 0; i < sequences.length; i++)\r
+ {\r
viewport.alignment.addSequence(sequences[i]);\r
+ if(sequences[i].getDatasetSequence()==null)\r
+ {\r
+ ////////////////////////////\r
+ //Datset needs extension;\r
+ /////////////////////////////\r
+ Sequence ds = new Sequence(sequences[i].getName(),\r
+ AlignSeq.extractGaps("-. ", sequences[i].getSequence()),\r
+ sequences[i].getStart(),\r
+ sequences[i].getEnd());\r
+ sequences[i].setDatasetSequence(ds);\r
+ viewport.alignment.getDataset().addSequence(ds);\r
+\r
\r
+ }\r
+\r
+ }\r
viewport.setEndSeq(viewport.alignment.getHeight());\r
viewport.alignment.getWidth();\r
viewport.firePropertyChange("alignment", null, viewport.getAlignment().getSequences());\r
{\r
viewport.showSequenceFeatures(sequenceFeatures.isSelected());\r
\r
- // if (viewport.showSequenceFeatures &&\r
- // ! ( (Alignment) viewport.alignment.getDataset()).featuresAdded)\r
+ if (viewport.showSequenceFeatures &&\r
+ ! ( (Alignment) viewport.alignment.getDataset()).featuresAdded)\r
{\r
- // System.out.println("new fetcher");\r
- // new SequenceFeatureFetcher(viewport.\r
- // alignment,\r
- // alignPanel);\r
+ System.out.println("new fetcher");\r
+ new SequenceFeatureFetcher(viewport.\r
+ alignment,\r
+ alignPanel);\r
}\r
\r
featureSettings.setEnabled(true);\r
{\r
\r
AlignmentI align;\r
+ AlignmentI dataset;\r
AlignmentPanel ap;\r
ArrayList unknownSequences;\r
CutAndPasteTransfer output = new CutAndPasteTransfer();\r
StringBuffer sbuffer = new StringBuffer();\r
\r
- Vector localCache = new Vector();\r
-\r
Vector getUniprotEntries(File file)\r
{\r
\r
unmar.setIgnoreExtraElements(true);\r
unmar.setMapping(map);\r
uni = (UniprotFile) unmar.unmarshal(new FileReader(file));\r
- localCache.addAll( uni.getUniprotEntries() );\r
-\r
- // 3. marshal the data with the total price back and print the XML in the console\r
- // Marshaller marshaller = new Marshaller(\r
- // new FileWriter(jalview.bin.Cache.getProperty("UNIPROT_CACHE"))\r
- // );\r
- // marshaller.setMapping(map);\r
- // marshaller.marshal(uni);\r
\r
}\r
catch (Exception e)\r
{\r
System.out.println("Error getUniprotEntries() "+e);\r
- // e.printStackTrace();\r
- // if(!updateLocalCache)\r
- // file.delete();\r
-\r
}\r
return uni.getUniprotEntries();\r
}\r
public SequenceFeatureFetcher(AlignmentI align, AlignmentPanel ap)\r
{\r
unknownSequences = new ArrayList();\r
- this.align = align.getDataset();\r
+ this.align = align;\r
+ this.dataset = align.getDataset();\r
this.ap = ap;\r
\r
Thread thread = new Thread(this);\r
try\r
{\r
int seqIndex = 0;\r
- Vector sequences = align.getSequences();\r
+ Vector sequences = dataset.getSequences();\r
\r
while (seqIndex < sequences.size())\r
{\r
seqIndex++, i++)\r
{\r
SequenceI sequence = (SequenceI) sequences.get(seqIndex);\r
- ids.add(sequence.getName());\r
- unknownSequences.add(sequence.getName());\r
+ if(!ids.contains(sequence.getName()))\r
+ {\r
+ ids.add(sequence.getName());\r
+ unknownSequences.add(sequence.getName());\r
+ }\r
}\r
\r
///////////////////////////////////\r
\r
if (file != null)\r
{\r
- ReadUniprotFile(file, align, ids);\r
+ ReadUniprotFile(file, ids);\r
}\r
}\r
}\r
"Save your alignment to maintain the updated id.\n\n" +\r
sbuffer.toString());\r
Desktop.addInternalFrame(output, "Sequence names updated ", 600, 300);\r
+ // The above is the dataset, we must now find out the index\r
+ // of the viewed sequence\r
+\r
}\r
\r
if (unknownSequences.size() > 0)\r
new WSWUBlastClient(ap, align, unknownSequences);\r
}\r
else\r
- ((Alignment)align).featuresAdded = true;\r
+ ((Alignment)dataset).featuresAdded = true;\r
\r
\r
ap.repaint();\r
* @param out DOCUMENT ME!\r
* @param align DOCUMENT ME!\r
*/\r
- void ReadUniprotFile(File file, AlignmentI align, Vector ids)\r
+ void ReadUniprotFile(File file, Vector ids)\r
{\r
if(!file.exists())\r
return;\r
{\r
entry = (UniprotEntry) entries.elementAt(i);\r
String idmatch = entry.getAccession().elementAt(0).toString();\r
- sequence = align.findName(idmatch);\r
+ sequence = dataset.findName(idmatch);\r
\r
if (sequence == null)\r
{\r
//Sequence maybe Name, not Accession\r
-\r
idmatch = entry.getName().elementAt(0).toString();;\r
- sequence = align.findName(idmatch);\r
+ sequence = dataset.findName(idmatch);\r
}\r
\r
if (sequence == null)\r
int absEnd = absStart + nonGapped.toString().length();\r
absStart += 1;\r
\r
- if ( (absStart != sequence.getStart()) ||\r
- (absEnd != sequence.getEnd()))\r
+ sequence.setSequenceFeatures(entry.getFeatures());\r
+ sequence.setStart(absStart);\r
+ sequence.setEnd(absEnd);\r
+\r
+ if ( (absStart != sequence.getStart()) || (absEnd != sequence.getEnd()))\r
{\r
sbuffer.append("Updated: " + sequence.getName() + " " +\r
sequence.getStart() + "/" + sequence.getEnd() +\r
" to " + absStart + "/" + absEnd + "\n");\r
}\r
\r
- sequence.setSequenceFeatures(entry.getFeatures());\r
- sequence.setStart(absStart);\r
- sequence.setEnd(absEnd);\r
+\r
+\r
+ int n = 0;\r
+ SequenceI seq2;\r
+ while (n < align.getHeight())\r
+ {\r
+ //This loop enables multiple sequences with the same\r
+ //id to have features added and seq limits updated\r
+ seq2 = align.getSequenceAt(n);\r
+ if (seq2.getName().equals(idmatch))\r
+ {\r
+\r
+ nonGapped = AlignSeq.extractGaps("-. ", seq2.getSequence());\r
+\r
+ absStart = sequence.getSequence().indexOf(nonGapped);\r
+ absEnd = absStart + nonGapped.toString().length() - 1;\r
+\r
+ sbuffer.append("Updated: VISUAL " + seq2.getName() + " " +\r
+ seq2.getStart() + "/" + seq2.getEnd() +\r
+ " to " + (absStart + sequence.getStart()) + "/" +\r
+\r
+ (absEnd + sequence.getStart()) + "\n");\r
+\r
+ seq2.setStart(absStart + sequence.getStart());\r
+ seq2.setEnd(absEnd + sequence.getStart());\r
+\r
+ }\r
+\r
+ n++;\r
+ }\r
}\r
}\r
}\r
\r
void updateIds()\r
{\r
+ int reply = JOptionPane.showConfirmDialog(\r
+ Desktop.desktop, "Automatically update suggested ids?",\r
+ "Auto replace sequence ids", JOptionPane.YES_NO_OPTION);\r
+\r
+ if (reply == JOptionPane.YES_OPTION)\r
+ {\r
+ Enumeration keys = suggestedIds.keys();\r
+ while(keys.hasMoreElements())\r
+ {\r
+ String oldid = keys.nextElement().toString();\r
+ SequenceI sequence = al.findName(oldid);\r
+ sequence.setName( suggestedIds.get(oldid).toString() );\r
+\r
+ sequence = sequence.getDatasetSequence();\r
+ if(sequence!=null)\r
+ {\r
+\r
+ sequence.setName(suggestedIds.get(oldid).toString());\r
+\r
+ Vector entries = sequence.getDBRef();\r
+ if(entries!=null)\r
+ {\r
+ DBRefEntry entry = (DBRefEntry) entries.elementAt(0);\r
+ sequence.addDBRef(new jalview.datamodel.DBRefEntry("UNIPROT",\r
+ "0",\r
+ entry.getAccessionId()));\r
+ }\r
+ }\r
+ System.out.println("replace "+oldid+" with "+suggestedIds.get(oldid));\r
+ }\r
+ }\r
+ ap.repaint();\r
\r
}\r
\r
\r
if (jobsRunning == 0)\r
{\r
- int reply = JOptionPane.showConfirmDialog(\r
- Desktop.desktop, "Automatically update suggested ids?",\r
- "Auto replace sequence ids", JOptionPane.YES_NO_OPTION);\r
-\r
- if (reply == JOptionPane.YES_OPTION)\r
- {\r
- Enumeration keys = suggestedIds.keys();\r
- while(keys.hasMoreElements())\r
- {\r
- String oldid = keys.nextElement().toString();\r
- SequenceI sequence = al.findName(oldid);\r
- sequence.setName( suggestedIds.get(oldid).toString() );\r
-\r
- sequence = al.getDataset().findName(oldid);\r
- Vector entries = sequence.getDBRef();\r
- DBRefEntry entry = (DBRefEntry) entries.elementAt(0);\r
- sequence.addDBRef(new jalview.datamodel.DBRefEntry("UNIPROT",\r
- "0",\r
- entry.getAccessionId()));\r
-\r
- sequence.setName(suggestedIds.get(oldid).toString());\r
-\r
- System.out.println("replace "+oldid+" with "+suggestedIds.get(oldid));\r
- }\r
- }\r
- ap.repaint();\r
+ updateIds();\r
}\r
}\r
}\r