Do a loop for multiple seq matches
authoramwaterhouse <Andrew Waterhouse>
Mon, 14 Aug 2006 15:09:43 +0000 (15:09 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 14 Aug 2006 15:09:43 +0000 (15:09 +0000)
src/jalview/io/DBRefFetcher.java

index 17526ac..23e5bf6 100644 (file)
@@ -244,7 +244,7 @@ public class DBRefFetcher implements Runnable
     if(!file.exists())\r
       return;\r
 \r
-    SequenceI sequence = null;\r
+    SequenceI [] sequence = null;\r
 \r
     Vector entries = getUniprotEntries(file);\r
 \r
@@ -254,43 +254,45 @@ public class DBRefFetcher implements Runnable
     {\r
       entry = (UniprotEntry) entries.elementAt(i);\r
       String idmatch = entry.getAccession().elementAt(0).toString();\r
-      sequence = dataset.findName(idmatch);\r
+      sequence = dataset.findSequenceMatch(idmatch);\r
 \r
-      if (sequence == null)\r
+      if (sequence.length==0)\r
       {\r
         //Sequence maybe Name, not Accession\r
         idmatch = entry.getName().elementAt(0).toString();\r
-        sequence = dataset.findName(idmatch);\r
+        sequence = dataset.findSequenceMatch(idmatch);\r
       }\r
 \r
-      if(sequence!=null)\r
-        ids.remove(sequence.getName());\r
+      if(sequence.length>0)\r
+        ids.remove(sequence[0].getName());\r
 \r
-      else  if (sequence == null && uniprotFlag)\r
+      else  if (sequence.length==0 && uniprotFlag)\r
       {\r
           StringBuffer upid = new StringBuffer("UniProt/Swiss-Prot|");\r
           for(int u=0; u<entry.getAccession().size(); u++)\r
             upid.append(entry.getAccession().elementAt(u)+"|");\r
 \r
-          sequence = dataset.findName(upid+idmatch);\r
+          sequence = dataset.findSequenceMatch(upid+idmatch);\r
           ids.remove(idmatch);\r
       }\r
 \r
-      if(sequence ==null)\r
+      if(sequence.length==0)\r
       {\r
         System.out.println(idmatch+" not found");\r
         continue;\r
       }\r
 \r
+      for(int m=0; m<sequence.length; m++)\r
+      {\r
 \r
-      sequence.addDBRef(new DBRefEntry(DBRefSource.UNIPROT,\r
+      sequence[m].addDBRef(new DBRefEntry(DBRefSource.UNIPROT,\r
                                        "0",\r
                                        entry.getAccession().elementAt(0).toString()));\r
 \r
-      System.out.println("Adding dbref to "+sequence.getName()+" : "+\r
+      System.out.println("Adding dbref to "+sequence[m].getName()+" : "+\r
                          entry.getAccession().elementAt(0).toString());\r
 \r
-      String nonGapped = AlignSeq.extractGaps("-. ", sequence.getSequence());\r
+      String nonGapped = AlignSeq.extractGaps("-. ", sequence[m].getSequence());\r
 \r
       int absStart = entry.getUniprotSequence().getContent().indexOf(\r
           nonGapped.toString());\r
@@ -301,7 +303,7 @@ public class DBRefFetcher implements Runnable
         absStart = nonGapped.toString().indexOf(entry.getUniprotSequence().getContent());\r
         if(absStart == -1)\r
         {\r
-          sbuffer.append(sequence.getName() +\r
+          sbuffer.append(sequence[m].getName() +\r
                          " SEQUENCE NOT %100 MATCH \n");\r
 \r
           continue;\r
@@ -317,7 +319,7 @@ public class DBRefFetcher implements Runnable
             sf.setEnd(sf.getEnd() + absStart + 1);\r
           }\r
 \r
-          sbuffer.append(sequence.getName() +\r
+          sbuffer.append(sequence[m].getName() +\r
                          " HAS " + absStart +\r
               " PREFIXED RESIDUES COMPARED TO UNIPROT - ANY SEQUENCE FEATURES"\r
                          + " HAVE BEEN ADJUSTED ACCORDINGLY \n");\r
@@ -339,58 +341,19 @@ public class DBRefFetcher implements Runnable
         if(!pdb.getType().equals(DBRefSource.PDB))\r
           continue;\r
 \r
-        sequence.addDBRef(new DBRefEntry(DBRefSource.PDB,\r
+        sequence[m].addDBRef(new DBRefEntry(DBRefSource.PDB,\r
                                        "0",\r
                                        pdb.getId()));\r
 \r
         onlyPdbEntries.addElement(pdb);\r
       }\r
 \r
-      sequence.setPDBId(onlyPdbEntries);\r
+      sequence[m].setPDBId(onlyPdbEntries);\r
 \r
-      if (entry.getFeature()!=null) {\r
-        //e = entry.getFeature().elements();\r
-      //  while (e.hasMoreElements())\r
-        {\r
-        //  SequenceFeature sf = (SequenceFeature) e.nextElement();\r
-         // sf.setFeatureGroup("Uniprot");\r
-        //  sequence.addSequenceFeature( sf );\r
-        }\r
-      }\r
-      sequence.setStart(absStart);\r
-      sequence.setEnd(absEnd);\r
+      sequence[m].setStart(absStart);\r
+      sequence[m].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
-          nonGapped = AlignSeq.extractGaps("-. ", seq2.getSequence());\r
-\r
-          absStart = sequence.getSequence().indexOf(nonGapped);\r
-          absEnd = absStart + nonGapped.toString().length() - 1;\r
-\r
-          // This is the Viewd alignment sequences\r
-          // No need to tell the user of the dataset updates\r
-          if ( (seq2.getStart() != absStart+sequence.getStart())\r
-             || (seq2.getEnd() != absEnd+sequence.getStart()))\r
-          {\r
-            sbuffer.append("Updated: " + seq2.getName() + " " +\r
-                           seq2.getStart() + "/" + seq2.getEnd() +\r
-                           "  to  " + (absStart + sequence.getStart()) + "/" +\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