implemented embl validation properly
[jalview.git] / src / jalview / ws / dbsources / Uniprot.java
index 1140a1b..ab0b10c 100644 (file)
@@ -51,11 +51,12 @@ import jalview.ws.seqfetcher.DbSourceProxyImpl;
  */
 public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy
 {
-  public Uniprot() {
+  public Uniprot()
+  {
     super();
     addDbSourceProperty(DBRefSource.SEQDB, DBRefSource.SEQDB);
     addDbSourceProperty(DBRefSource.PROTSEQDB);
-//    addDbSourceProperty(DBRefSource.MULTIACC, new Integer(50));
+    // addDbSourceProperty(DBRefSource.MULTIACC, new Integer(50));
   }
 
   /*
@@ -106,7 +107,8 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy
     try
     {
       // 1. Load the mapping information from the file
-      org.exolab.castor.mapping.Mapping map = new org.exolab.castor.mapping.Mapping(uni.getClass().getClassLoader());
+      org.exolab.castor.mapping.Mapping map = new org.exolab.castor.mapping.Mapping(
+              uni.getClass().getClassLoader());
       java.net.URL url = getClass().getResource("/uniprot_mapping.xml");
       map.loadMapping(url);
 
@@ -116,8 +118,7 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy
       unmar.setMapping(map);
 
       uni = (UniprotFile) unmar.unmarshal(new FileReader(file));
-    }
-    catch (Exception e)
+    } catch (Exception e)
     {
       System.out.println("Error getUniprotEntries() " + e);
     }
@@ -135,11 +136,12 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy
     startQuery();
     try
     {
-      Alignment al=null;
+      Alignment al = null;
       ebi = new EBIFetchClient();
-      StringBuffer result=new StringBuffer();
+      StringBuffer result = new StringBuffer();
       // uniprotxml parameter required since december 2007
-      File file = ebi.fetchDataAsFile("uniprot:" + queries, "uniprotxml", null);
+      File file = ebi.fetchDataAsFile("uniprot:" + queries, "uniprotxml",
+              null);
       Vector entries = getUniprotEntries(file);
 
       if (entries != null)
@@ -164,12 +166,13 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy
             name.append(en2.nextElement());
           }
 
-          if (entry.getProtein()!=null && entry.getProtein().getName()!=null)
+          if (entry.getProtein() != null
+                  && entry.getProtein().getName() != null)
           {
-              for (int nm=0,nmSize=entry.getProtein().getName().size(); nm<nmSize;nm++)
-              {
-                name.append(" " + entry.getProtein().getName().elementAt(nm));
-              }
+            for (int nm = 0, nmSize = entry.getProtein().getName().size(); nm < nmSize; nm++)
+            {
+              name.append(" " + entry.getProtein().getName().elementAt(nm));
+            }
           }
 
           result.append(name + "\n"
@@ -179,11 +182,13 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy
 
         // Then read in the features and apply them to the dataset
         al = parseResult(result.toString());
-        if (al!=null)
+        if (al != null)
         {
           // Decorate the alignment with database entries.
           addUniprotXrefs(al, entries);
-        } else {
+        }
+        else
+        {
           results = result;
         }
       }
@@ -192,7 +197,7 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy
     } catch (Exception e)
     {
       stopQuery();
-      throw(e);
+      throw (e);
     }
   }
 
@@ -200,9 +205,9 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy
    * add an ordered set of UniprotEntry objects to an ordered set of seuqences.
    * 
    * @param al -
-   *          a sequence of n sequences
+   *                a sequence of n sequences
    * @param entries
-   *          a seuqence of n uniprot entries to be analysed.
+   *                a seuqence of n uniprot entries to be analysed.
    */
   public void addUniprotXrefs(Alignment al, Vector entries)
   {
@@ -218,17 +223,17 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy
         DBRefEntry dbr = new DBRefEntry();
         dbr.setSource(pdb.getType());
         dbr.setAccessionId(pdb.getId());
-        dbr.setVersion(DBRefSource.UNIPROT+":"+getDbVersion());
+        dbr.setVersion(DBRefSource.UNIPROT + ":" + getDbVersion());
         dbxrefs.addElement(dbr);
         if (!pdb.getType().equals("PDB"))
         {
           continue;
         }
-        
+
         onlyPdbEntries.addElement(pdb);
       }
       SequenceI sq = al.getSequenceAt(i);
-      while (sq.getDatasetSequence()!=null)
+      while (sq.getDatasetSequence() != null)
       {
         sq = sq.getDatasetSequence();
       }
@@ -237,16 +242,15 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy
       while (en2.hasMoreElements())
       {
         // we always add as uniprot if we retrieved from uniprot or uniprot name
-        sq.addDBRef(
-                new DBRefEntry(DBRefSource.UNIPROT, getDbVersion(), en2.nextElement()
-                        .toString()));
+        sq.addDBRef(new DBRefEntry(DBRefSource.UNIPROT, getDbVersion(), en2
+                .nextElement().toString()));
       }
       en2 = dbxrefs.elements();
       while (en2.hasMoreElements())
       {
-     // we always add as uniprot if we retrieved from uniprot or uniprot name
+        // we always add as uniprot if we retrieved from uniprot or uniprot name
         sq.addDBRef((DBRefEntry) en2.nextElement());
-                    
+
       }
       sq.setPDBId(onlyPdbEntries);
       if (entry.getFeature() != null)
@@ -271,6 +275,7 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy
   {
     return true;
   }
+
   /**
    * return LDHA_CHICK uniprot entry
    */
@@ -278,6 +283,7 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy
   {
     return "P00340";
   }
+
   public String getDbName()
   {
     return "Uniprot"; // getDbSource();