From: amwaterhouse Date: Mon, 14 Nov 2005 12:00:03 +0000 (+0000) Subject: Use shortname X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5aeb9ce3b99be8cbe7ca47c04a31dca3e3bbc282;p=jalview.git Use shortname --- diff --git a/src/jalview/io/SequenceFeatureFetcher.java b/src/jalview/io/SequenceFeatureFetcher.java index 5ecb417..a70aaef 100755 --- a/src/jalview/io/SequenceFeatureFetcher.java +++ b/src/jalview/io/SequenceFeatureFetcher.java @@ -109,10 +109,10 @@ public class SequenceFeatureFetcher implements Runnable seqIndex++, i++) { SequenceI sequence = (SequenceI) sequences.get(seqIndex); - if(!ids.contains(sequence.getName())) + if(!ids.contains(sequence.getShortName())) { - ids.add(sequence.getName()); - unknownSequences.add(sequence.getName()); + ids.add(sequence.getShortName()); + unknownSequences.add(sequence); } } @@ -205,13 +205,13 @@ public class SequenceFeatureFetcher implements Runnable { entry = (UniprotEntry) entries.elementAt(i); String idmatch = entry.getAccession().elementAt(0).toString(); - sequence = dataset.findName(idmatch); + sequence = dataset.findShortName(idmatch); if (sequence == null) { //Sequence maybe Name, not Accession idmatch = entry.getName().elementAt(0).toString();; - sequence = dataset.findName(idmatch); + sequence = dataset.findShortName(idmatch); } if (sequence == null) @@ -221,7 +221,7 @@ public class SequenceFeatureFetcher implements Runnable } ids.remove(sequence.getName()); - unknownSequences.remove(sequence.getName()); + unknownSequences.remove(sequence); String nonGapped = AlignSeq.extractGaps("-. ", sequence.getSequence()); diff --git a/src/jalview/io/WSWUBlastClient.java b/src/jalview/io/WSWUBlastClient.java index 99beb5f..e6800bc 100755 --- a/src/jalview/io/WSWUBlastClient.java +++ b/src/jalview/io/WSWUBlastClient.java @@ -29,6 +29,7 @@ import java.util.*; import javax.swing.*; import javax.xml.namespace.QName; +import jalview.analysis.AlignSeq; /** @@ -44,7 +45,7 @@ public class WSWUBlastClient CutAndPasteTransfer output = new CutAndPasteTransfer(); int jobsRunning = 0; - Hashtable suggestedIds = new Hashtable(); + Vector suggestedIds = new Vector(); /** * Creates a new WSWUBlastClient object. * @@ -63,21 +64,10 @@ public class WSWUBlastClient for (int i = 0; i < ids.size(); i++) { - SequenceI sequence = al.findName(ids.get(i).toString()); - System.out.println(ids.get(i).toString()); - StringBuffer nonGapped = new StringBuffer(); + Sequence sequence = (Sequence)ids.get(i); + System.out.println(sequence.getName()); - - for (int n = 0; n < sequence.getSequence().length(); n++) - { - if (!jalview.util.Comparison.isGap(sequence.getCharAt(n))) - { - nonGapped.append(sequence.getCharAt(n)); - } - } - - BlastThread thread = new BlastThread(ids.get(i).toString(), - nonGapped.toString()); + BlastThread thread = new BlastThread(sequence); thread.start(); jobsRunning++; } @@ -93,13 +83,13 @@ public class WSWUBlastClient * @param id1 DOCUMENT ME! * @param res DOCUMENT ME! */ - void parseResult(String id1, String res) + void parseResult(Sequence seq, String res) { StringTokenizer st = new StringTokenizer(res, "\n"); String data; String id2; int maxFound = 90; - StringBuffer buffer = new StringBuffer("\n\n" + id1 + " :"); + StringBuffer buffer = new StringBuffer("\n\n" + seq.getShortName() + " :"); while (st.hasMoreTokens()) { @@ -127,10 +117,7 @@ public class WSWUBlastClient { maxFound = value; buffer.append(" " + id2 + " " + value + "%; "); - if(!suggestedIds.containsKey(id1)) - { - suggestedIds.put(id1, id2); - } + suggestedIds.addElement( new Object[]{seq, id2}); } } } @@ -150,29 +137,35 @@ public class WSWUBlastClient if (reply == JOptionPane.YES_OPTION) { - Enumeration keys = suggestedIds.keys(); + Enumeration keys = suggestedIds.elements(); while(keys.hasMoreElements()) { - String oldid = keys.nextElement().toString(); - SequenceI sequence = al.findName(oldid); - sequence.setName( suggestedIds.get(oldid).toString() ); + Object [] object = (Object[])keys.nextElement(); - sequence = sequence.getDatasetSequence(); - if(sequence!=null) - { + Sequence oldseq = (Sequence)object[0]; - sequence.setName(suggestedIds.get(oldid).toString()); + oldseq.setName( object[1].toString() ); - Vector entries = sequence.getDBRef(); - if(entries!=null) + // Oldseq is actually in the dataset, we must find the + // Visible seq and change its name also. + for (int i = 0; i < al.getHeight(); i++) + { + if (al.getSequenceAt(i).getDatasetSequence() == oldseq) { - DBRefEntry entry = (DBRefEntry) entries.elementAt(0); - sequence.addDBRef(new jalview.datamodel.DBRefEntry("UNIPROT", - "0", - entry.getAccessionId())); + al.getSequenceAt(i).setName(oldseq.getName()); + break; } } - System.out.println("replace "+oldid+" with "+suggestedIds.get(oldid)); + + Vector entries = oldseq.getDBRef(); + if (entries != null) + { + DBRefEntry entry = (DBRefEntry) entries.elementAt(0); + oldseq.addDBRef(new jalview.datamodel. + DBRefEntry("UNIPROT", + "0", + entry.getAccessionId())); + } } } ap.repaint(); @@ -227,16 +220,14 @@ public class WSWUBlastClient class BlastThread extends Thread { - String sequence; - String seqid; + Sequence sequence; String jobid; boolean jobComplete = false; - BlastThread(String id, String sequence) + BlastThread(Sequence sequence) { - System.out.println("blasting for: "+id); - this.sequence = sequence; - seqid = id; + System.out.println("blasting for: "+sequence.getName()); + this.sequence = sequence; } public void run() @@ -259,14 +250,14 @@ public class WSWUBlastClient if(object instanceof String) { - parseResult(seqid, (String)object); + parseResult(sequence, (String)object); jobComplete = true; jobsRunning--; } Thread.sleep(5000); - System.out.println("WSWuBlastClient: I'm alive "+seqid+" "+jobid); // log.debug + System.out.println("WSWuBlastClient: I'm alive "+sequence.getShortName()+" "+jobid); // log.debug } catch (Exception ex) { @@ -286,7 +277,8 @@ public class WSWUBlastClient params.put("type", "xml"); params.put("async", "true"); - byte[] seqbytes = sequence.getBytes(); + byte[] seqbytes = AlignSeq.extractGaps("-. ", + sequence.getSequence()).getBytes(); try { @@ -307,7 +299,7 @@ public class WSWUBlastClient { jobComplete = true; jobsRunning--; - parseResult(seqid, (String)object); + parseResult(sequence, (String)object); } }