View Javadoc

1   package uk.ac.ebi.intenz.domain.enzyme;
2   
3   import java.util.ArrayList;
4   import java.util.Iterator;
5   import java.util.List;
6   import java.util.Set;
7   import java.util.SortedSet;
8   import java.util.TreeSet;
9   
10  import uk.ac.ebi.biobabel.util.collections.OperatorSet;
11  import uk.ac.ebi.intenz.domain.constants.EnzymeNameTypeConstant;
12  import uk.ac.ebi.intenz.domain.constants.EnzymeSourceConstant;
13  import uk.ac.ebi.intenz.domain.constants.EnzymeViewConstant;
14  import uk.ac.ebi.intenz.domain.constants.Status;
15  import uk.ac.ebi.intenz.domain.constants.View;
16  import uk.ac.ebi.intenz.domain.constants.XrefDatabaseConstant;
17  import uk.ac.ebi.intenz.domain.exceptions.EnzymeNameException;
18  import uk.ac.ebi.intenz.domain.exceptions.EnzymeReactionException;
19  import uk.ac.ebi.intenz.domain.exceptions.EnzymeReferenceException;
20  import uk.ac.ebi.intenz.domain.history.HistoryGraph;
21  import uk.ac.ebi.intenz.domain.history.HistoryNode;
22  import uk.ac.ebi.intenz.domain.reference.Reference;
23  import uk.ac.ebi.rhea.domain.Reaction;
24  
25  /**
26   * This class stores the information of an IntEnz enzyme.
27   * <p/>
28   * Such an enzyme includes information from three different sources:
29   * <p/>
30   * <ul>
31   * <li>NC-IUBMB (the official data)</li>
32   * <li>enzyme.dat (Amos' enzyme file)</li>
33   * <li>BRENDA (enzyme database from the University of Cologne)</li>
34   * </ul>
35   *
36   * @author Michael Darsow
37   * @version $Revision: 1.4 $ $Date: 2009/04/20 13:44:24 $
38   */
39  public class EnzymeEntry {
40  
41    /**
42     * The enzyme's unique ID.
43     */
44    private Long id;
45  
46    /**
47     * If an enzyme gets approved it must have a valid EC number.
48     */
49    private EnzymeCommissionNumber ec;
50  
51    /**
52     * An enzyme belongs to a class of enzymes.
53     */
54    private String className;
55  
56    /**
57     * An enzyme belongs to a subclass of a class of enzymes.
58     */
59    private String subclassName;
60  
61    /**
62     * The sub-subclass is the lowest hierarchical level to which an enzyme belongs.
63     */
64    private String subSubclassName;
65  
66    /**
67     * The common name of an enzyme.
68     */
69    private List<EnzymeName> commonNames;
70  
71    /**
72     * The systematic name of this enzyme.
73     */
74    private EnzymeName systematicName;
75  
76    /**
77     * Synonyms will be ordered by their order number internally.
78     */
79    private List<EnzymeName> synonyms;
80  
81    /**
82     * An enzyme may catalyse more than one reaction.
83     * @deprecated use enzymaticReactions istead
84     */
85    private List<Reaction> reactions;
86  
87    /**
88     * Map to reactions catalyzed by this enzyme.
89     */
90    private EnzymaticReactions enzymaticReactions;
91  
92    /**
93     * List of all cofactors.
94     */
95    private Set<Object> cofactors;
96  
97    /**
98     * Stores links of this enzyme.
99     */
100   private SortedSet<EnzymeLink> links;
101 
102   /**
103    * Some enzymes contain comments.
104    */
105   private List<EnzymeComment> comments;
106 
107   /**
108    * At least one reference must be present to describe the enzyme.
109    */
110   private List<Reference> references;
111 
112   /**
113    * The note can be added by a curator but it will not be publicly visible.
114    */
115   private String note;
116 
117   /**
118    * Stores the enzyme's history as a graph for all history events stored in the database (since 2002).
119    */
120   private HistoryGraph historyGraph;
121 
122   /**
123    * The status of this enzyme (can be suggested, proposed or approved).
124    */
125   private Status status;
126 
127   /**
128    * The source of the enzyme (can be IUBMB, SIB, BRENDA or INTENZ).
129    */
130   private EnzymeSourceConstant source;
131 
132   /**
133    * A flag to indicate whether this enzyme is isActive (not transferred or deleted) or not.
134    */
135   private boolean isActive;
136 
137   /**
138    * Has this enzyme been lazy-loaded or does it contain the whole set of information?
139    */
140   private boolean isGhost;
141 
142   /**
143    * The default source is <code>INTENZ</code>.
144    * Every new instance is active by default.
145    */
146   @SuppressWarnings("unchecked")
147   public EnzymeEntry() {
148     id = new Long(-1);
149     ec = EnzymeCommissionNumber.UNDEF;
150     className = "";
151     subclassName = "";
152     subSubclassName = "";
153     commonNames = new ArrayList<EnzymeName>();
154     systematicName = EnzymeName.UNDEF;
155     reactions = new ArrayList<Reaction>();
156     cofactors = new OperatorSet();
157     synonyms = new ArrayList<EnzymeName>();
158     links = new TreeSet<EnzymeLink>();
159     comments = new ArrayList<EnzymeComment>();
160     references = new ArrayList<Reference>();
161     note = "";
162     HistoryNode currentNode = new HistoryNode();
163     currentNode.setEnzymeEntry(this);
164     historyGraph = new HistoryGraph(currentNode);
165     status = Status.SUGGESTED;
166     source = EnzymeSourceConstant.INTENZ;
167     isActive = true;
168     isGhost = false;
169   }
170 
171   /**
172    * Adds a reaction to the list of reactions.
173    * <p/>
174    * Duplicates are not stored.
175    *
176    * @param reaction The reaction to be added.
177    * @throws NullPointerException if <code>reaction</code> is <code>null</code>.
178    * @deprecated use addEnzymaticReaction instead
179    */
180   public void addReaction(Reaction reaction) {
181     if (reaction == null) throw new NullPointerException("Parameter 'reaction' must not be null.");
182     for (Iterator<Reaction> it = reactions.iterator(); it.hasNext();) {
183       Reaction storedReaction = it.next();
184       if (storedReaction.equals(reaction)) return;
185     }
186 
187     reactions.add(reaction);
188   }
189 
190     /**
191      * Adds a reaction to the list of alternative reactions.
192      * @param reaction
193      * @param view
194      * @param iubmb the IUBMB flag.
195      */
196     public void addEnzymaticReaction(Reaction reaction, String view,
197     		boolean iubmb){
198         if (enzymaticReactions == null)
199             enzymaticReactions = new EnzymaticReactions();
200         enzymaticReactions.add(reaction, view, iubmb);
201     }
202 
203   /**
204    * Adds a cofactor to the list of cofactors.
205    * <p/>
206    * Duplicates are not stored.
207    *
208    * @param cofactor The cofactor to be added.
209    * @throws NullPointerException if <code>cofactor</code> is <code>null</code>.
210    * @deprecated use {@link #addCofactor(Object)} instead
211    */
212   public void addCofactor(Cofactor cofactor) {
213     if (cofactor == null)
214         throw new NullPointerException("Parameter 'cofactor' must not be null.");
215     if (!cofactors.contains(cofactor))
216         cofactors.add(cofactor);
217   }
218 
219   /**
220    * Adds a cofactor to the list of cofactors.
221    * @param cofactor A <code>Cofactor</code> or <code>OperatorSet</code> object.
222    */
223   public void addCofactor(Object cofactor){
224 	  if (cofactor == null)
225 		  throw new NullPointerException("Parameter 'cofactor' must not be null.");
226 	  if (!(cofactor instanceof Cofactor) && !(cofactor instanceof OperatorSet))
227 		  throw new IllegalArgumentException("The cofactor class is " + cofactor.getClass());
228 	  cofactors.add(cofactor);
229   }
230 
231   /**
232    * Removes a reaction from the list of reactions.
233    *
234    * @param equation The reaction to be removed.
235    * @throws NullPointerException if <code>equation</code> is <code>null</code>.
236    * @deprecated use removeEnzymaticReaction instead
237    */
238   public void removeReaction(String equation) {
239     if (equation == null) throw new NullPointerException("Parameter 'equation' must not be null.");
240     for (Iterator<Reaction> it = reactions.iterator(); it.hasNext();) {
241       Reaction reaction = it.next();
242       if (reaction.getTextualRepresentation().equals(equation)) {
243         reactions.remove(reaction);
244         return;
245       }
246     }
247   }
248 
249     public void removeEnzymaticReaction(Reaction reaction){
250         enzymaticReactions.removeReaction(reaction);
251     }
252 
253   /**
254    * Removes a cofactor from the list of cofactors.
255    *
256    * @param cofactorString The cofactor string to be removed.
257    * @throws NullPointerException if <code>cofactorString</code> is <code>null</code>.
258    * @deprecated use removeCofactor(Object) instead
259    */
260   public void removeCofactor(String cofactorString) {
261       if (cofactorString == null) throw new NullPointerException("Parameter 'cofactorString' must not be null.");
262       for (Iterator<Object> it = cofactors.iterator(); it.hasNext();) {
263           Cofactor cofactor = (Cofactor) it.next(); // FIXME: what if it is a OperatorSet?
264           if (cofactor.getCompound().getName().equals(cofactorString)) {
265               cofactors.remove(cofactor);
266               return;
267           }
268       }
269   }
270 
271   /**
272    * Removes a cofactor from the list of cofactors.
273    * @param cofactor
274    * @deprecated use {@link #removeCofactor(Object)} instead
275    */
276   public void removeCofactor(Cofactor cofactor){
277       if (cofactor == null)
278           throw new NullPointerException("Cannot remove a null cofactor");
279       cofactors.remove(cofactor);
280   }
281 
282 
283   /**
284    * Removes a cofactor from the list of cofactors.
285    * @param cofactor
286    */
287   public void removeCofactor(Object cofactor){
288       if (cofactor == null)
289           throw new NullPointerException("Cannot remove a null cofactor");
290       cofactors.remove(cofactor);
291   }
292 
293   /**
294    * Adds a synonsm to the list of synonyms.
295    *
296    * @param synonym The synonym to be added.
297    * @throws NullPointerException if <code>synonym</code> is <code>null</code>.
298    */
299   public void addSynonym(EnzymeName synonym) {
300     if (synonym == null) throw new NullPointerException("Parameter 'synonym' must not be null.");
301     synonyms.add(synonym);
302   }
303 
304   /**
305    * Removes a synonsm from the list of synonyms.
306    *
307    * @param synonym The synonym to be removed.
308    * @throws NullPointerException if <code>synonym</code> is <code>null</code>.
309    */
310   public void removeSynonym(String synonym) {
311     if (synonym == null) throw new NullPointerException("Parameter 'synonym' must not be null.");
312     synonyms.remove(synonym);
313   }
314 
315   /**
316    * Adds a link to the list of additional links.
317    * <p/>
318    * Duplicates are not stored.
319    *
320    * @param link The link to be added.
321    * @throws NullPointerException if <code>link</code> is <code>null</code>.
322    */
323   public void addLink(EnzymeLink link) {
324     if (link == null) throw new NullPointerException("Parameter 'link' must not be null.");
325     // Don't save duplicates.
326     if (!links.contains(link)) links.add(link);
327   }
328 
329   /**
330    * Removes a link from the list of additional links.
331    *
332    * @param link The link to be removed.
333    * @throws NullPointerException if <code>link</code> is <code>null</code>.
334    */
335   public void removeLink(EnzymeLink link) {
336     if (link == null) throw new NullPointerException("Parameter 'link' must not be null.");
337     links.remove(link);
338   }
339 
340   /**
341    * Adds a reference to the list of references.
342    *
343    * @param reference The reference to be added.
344    * @throws NullPointerException if <code>reference</code> is <code>null</code>.
345    */
346   public void addReference(Reference reference) {
347     if (reference == null) throw new NullPointerException("Parameter 'reference' must not be null.");
348     for (Iterator<Reference> it = references.iterator(); it.hasNext();) {
349       Reference storedReference = it.next();
350       if (storedReference.equals(reference)) return;
351     }
352 
353     references.add(reference);
354   }
355 
356   /**
357    * Removes a reference from the list of references.
358    *
359    * @param reference The reference to be removed.
360    * @throws NullPointerException if <code>reference</code> is <code>null</code>.
361    */
362   public void removeReference(Reference reference) {
363     if (reference == null) throw new NullPointerException("Parameter 'reference' must not be null.");
364     for (Iterator<Reference> it = references.iterator(); it.hasNext();) {
365       Reference storedReference = it.next();
366       if (reference.equals(storedReference)) {
367         references.remove(storedReference);
368         return;
369       }
370     }
371   }
372 
373   /**
374    * Standard equals method.
375    *
376    * @param o Object to be compared to this one.
377    * @return <code>true</code> if the objects are equal.
378    */
379     @Override
380   public boolean equals(Object o) {
381     if (this == o) return true;
382     if (!(o instanceof EnzymeEntry)) return false;
383 
384     final EnzymeEntry enzymeEntry = (EnzymeEntry) o;
385 
386     if (isActive != enzymeEntry.isActive) return false;
387     if (isGhost != enzymeEntry.isGhost) return false;
388     if (className != null ? !className.equals(enzymeEntry.className) : enzymeEntry.className != null) return false;
389     if (cofactors != null ? !cofactors.equals(enzymeEntry.cofactors) : enzymeEntry.cofactors != null) return false;
390     if (comments != null ? !comments.equals(enzymeEntry.comments) : enzymeEntry.comments != null) return false;
391     if (commonNames != null ? !commonNames.equals(enzymeEntry.commonNames) : enzymeEntry.commonNames != null) return false;
392     if (ec != null ? !ec.equals(enzymeEntry.ec) : enzymeEntry.ec != null) return false;
393     if (historyGraph != null ? !historyGraph.equals(enzymeEntry.historyGraph) : enzymeEntry.historyGraph != null) return false;
394     if (id != null ? !id.equals(enzymeEntry.id) : enzymeEntry.id != null) return false;
395     if (links != null ? !links.equals(enzymeEntry.links) : enzymeEntry.links != null) return false;
396     if (note != null ? !note.equals(enzymeEntry.note) : enzymeEntry.note != null) return false;
397 //    if (reactions != null ? !reactions.equals(enzymeEntry.reactions) : enzymeEntry.reactions != null) return false;
398     if (enzymaticReactions != null ?
399         !enzymaticReactions.equals(enzymeEntry.enzymaticReactions) :
400 		enzymeEntry.enzymaticReactions != null) return false;
401     if (references != null ? !references.equals(enzymeEntry.references) : enzymeEntry.references != null) return false;
402     if (source != null ? !source.equals(enzymeEntry.source) : enzymeEntry.source != null) return false;
403     if (status != null ? !status.equals(enzymeEntry.status) : enzymeEntry.status != null) return false;
404     if (subSubclassName != null ? !subSubclassName.equals(enzymeEntry.subSubclassName) : enzymeEntry.subSubclassName !=
405                                                                                          null)
406       return false;
407     if (subclassName != null ? !subclassName.equals(enzymeEntry.subclassName) : enzymeEntry.subclassName != null) return false;
408     if (synonyms != null ? !synonyms.equals(enzymeEntry.synonyms) : enzymeEntry.synonyms != null) return false;
409     if (systematicName != null ? !systematicName.equals(enzymeEntry.systematicName) : enzymeEntry.systematicName !=
410                                                                                       null)
411       return false;
412 
413     return true;
414   }
415 
416   /**
417    * Returns the hash code of this object.
418    *
419    * @return the hash code of this object.
420    */
421     @Override
422   public int hashCode() {
423     int result;
424     result = (id != null ? id.hashCode() : 0);
425     result = 29 * result + (ec != null ? ec.hashCode() : 0);
426     result = 29 * result + (className != null ? className.hashCode() : 0);
427     result = 29 * result + (subclassName != null ? subclassName.hashCode() : 0);
428     result = 29 * result + (subSubclassName != null ? subSubclassName.hashCode() : 0);
429     result = 29 * result + (commonNames != null ? commonNames.hashCode() : 0);
430     result = 29 * result + (systematicName != null ? systematicName.hashCode() : 0);
431     result = 29 * result + (synonyms != null ? synonyms.hashCode() : 0);
432     result = 29 * result + (reactions != null ? reactions.hashCode() : 0);
433     result = 29 * result + (cofactors != null ? cofactors.hashCode() : 0);
434     result = 29 * result + (links != null ? links.hashCode() : 0);
435     result = 29 * result + (comments != null ? comments.hashCode() : 0);
436     result = 29 * result + (references != null ? references.hashCode() : 0);
437     result = 29 * result + (note != null ? note.hashCode() : 0);
438     result = 29 * result + (historyGraph != null ? historyGraph.hashCode() : 0);
439     result = 29 * result + (status != null ? status.hashCode() : 0);
440     result = 29 * result + (source != null ? source.hashCode() : 0);
441     result = 29 * result + (isActive ? 1 : 0);
442     result = 29 * result + (isGhost ? 1 : 0);
443     return result;
444   }
445 
446   // ----------------  GETTER & SETTER ------------------
447 
448   public Long getId() {
449     return id;
450   }
451 
452   public void setId(Long id) {
453     this.id = id;
454   }
455 
456   public EnzymeCommissionNumber getEc() {
457     return ec;
458   }
459 
460   /**
461    * Sets the EC number.
462    *
463    * @param ec The new EC number.
464    * @throws NullPointerException if <code>ec</code> is <code>null</code>.
465    */
466   public void setEc(EnzymeCommissionNumber ec) {
467     if (ec == null) throw new NullPointerException("Parameter 'ec' must not be null.");
468     this.ec = ec;
469   }
470 
471   public String getClassName() {
472     return className;
473   }
474 
475   /**
476    * Sets the class name.
477    *
478    * @param className The class name.
479    * @throws NullPointerException     if <code>className</code> is <code>null</code>
480    * @throws IllegalArgumentException if <code>className</code> is empty.
481    */
482   public void setClassName(String className) {
483     if (className == null) throw new NullPointerException("Parameter 'className' must not be null.");
484     if (className.equals("")) throw new IllegalArgumentException("Parameter 'className' must not be empty.");
485     this.className = className;
486   }
487 
488   public String getSubclassName() {
489     return subclassName;
490   }
491 
492   /**
493    * Sets the subclass name.
494    *
495    * @param subclassName The subclass name.
496    * @throws NullPointerException     if <code>subclassName</code> is <code>null</code>
497    * @throws IllegalArgumentException if <code>subclassName</code> is empty.
498    */
499   public void setSubclassName(String subclassName) {
500     if (subclassName == null) throw new NullPointerException("Parameter 'subclassName' must not be null.");
501     if (subclassName.equals("")) throw new IllegalArgumentException("Parameter 'subclassName' must not be empty.");
502     this.subclassName = subclassName;
503   }
504 
505   public String getSubSubclassName() {
506     return subSubclassName;
507   }
508 
509   /**
510    * Sets the sub-subclass name.
511    *
512    * @param subSubclassName The sub-subclass name.
513    * @throws NullPointerException if <code>subSubclassName</code> is <code>null</code>.
514    */
515   public void setSubSubclassName(String subSubclassName) {
516     if (subSubclassName == null) throw new NullPointerException("Parameter 'subSubclassName' must not be null.");
517     this.subSubclassName = subSubclassName;
518   }
519 
520   public List<EnzymeName> getCommonNames() {
521     return commonNames;
522   }
523   
524   /**
525    * @return the IntEnz common name.
526    */
527   public EnzymeName getCommonName(){
528 	  return getCommonName(null);
529   }
530 
531   /**
532    * Returns the first common name which <code>view</code> value matches the
533    * parameter's view value.
534    * @param view web view (defaults to INTENZ)
535    * @return the common name.
536    * @throws IllegalArgumentException if <code>view</code> is not either
537    *                                  {@link uk.ac.ebi.intenz.domain.constants.EnzymeViewConstant.INTENZ},
538    *                                  {@link uk.ac.ebi.intenz.domain.constants.EnzymeViewConstant.IUBMB} or
539    *                                  {@link uk.ac.ebi.intenz.domain.constants.EnzymeViewConstant.SIB} .
540    */
541   public EnzymeName getCommonName(EnzymeViewConstant view) {
542     if (view == null) view = EnzymeViewConstant.INTENZ;
543     if (view != EnzymeViewConstant.INTENZ && view != EnzymeViewConstant.IUBMB && view != EnzymeViewConstant.SIB)
544       throw new IllegalArgumentException("Parameter 'view' must be either 'EnzymeViewConstant.INTENZ', 'EnzymeViewConstant.IUBMB' or 'EnzymeViewConstant.SIB'");
545     if (commonNames == null || commonNames.size() == 0) return EnzymeName.UNDEF;
546     for (int iii = 0; iii < commonNames.size(); iii++) {
547       EnzymeName enzymeName = commonNames.get(iii);
548       if (view.toString().equals(EnzymeViewConstant.INTENZ.toString()) &&
549           EnzymeViewConstant.isInIntEnzView(enzymeName.getView().toString()))
550         return enzymeName;
551       if (view.toString().equals(EnzymeViewConstant.IUBMB.toString()) &&
552           EnzymeViewConstant.isInIUBMBView(enzymeName.getView().toString()))
553         return enzymeName;
554       if (view.toString().equals(EnzymeViewConstant.SIB.toString()) &&
555           EnzymeViewConstant.isInSIBView(enzymeName.getView().toString()))
556         return enzymeName;
557     }
558     return commonNames.get(0);
559   }
560 
561   /**
562    * Sets the list of common names.
563    * <p/>
564    * An enzyme must have at least one or at most two common names.
565    * Empty strings will be omitted.
566    *
567    * @param commonNames List of common names.
568    * @throws NullPointerException if <code>commonNames</code> is <code>null</code>.
569    * @throws EnzymeNameException  if the list of common names does contain less than 1 or more than 2 common names or
570    *                              if the type of a name in the list is not defined as {@link EnzymeNameTypeConstant.COMMON_NAME}.
571    */
572   public void setCommonNames(List<EnzymeName> commonNames) throws EnzymeNameException {
573     if (commonNames == null) throw new NullPointerException("Parameter 'commonNames' must not be null.");
574     if (commonNames.size() > 2)
575       throw new EnzymeNameException("At most two common names can be part of this list.");
576     for (int iii = 0; iii < commonNames.size(); iii++) {
577       EnzymeName enzymeName = commonNames.get(iii);
578       if (enzymeName.getType() != EnzymeNameTypeConstant.COMMON_NAME)
579         throw new EnzymeNameException("The name's type " +
580                                       "must be of type 'uk.ac.ebi.intenz.domain.constants.EnzymeNameTypeConstant.COMMON_NAME'.");
581       if (enzymeName.getName().equals("")) commonNames.remove(iii--);
582     }
583     if (commonNames.size() < 1)
584       throw new EnzymeNameException("At least one common name must be part of this list.");
585 
586     this.commonNames = commonNames;
587   }
588 
589   /**
590    * Adds a common name to the list of common names.
591    * <p/>
592    * If the list already contains two elements an {@link uk.ac.ebi.intenz.webapp.exceptions.EnzymeNameException} is thrown.
593    * Empty strings will be omitted.
594    *
595    * @param commonName The common name to be added.
596    * @throws EnzymeNameException if the list of common names already contains two elements.
597    */
598   public void addCommonName(EnzymeName commonName) throws EnzymeNameException {
599     if (commonName == null) throw new NullPointerException("Parameter 'commonName' must not be null.");
600     if (commonNames.size() == 2) throw new EnzymeNameException("The list of common names already contains two common names.");
601     if (commonName.getName().equals("")) return;
602     commonNames.add(commonName);
603   }
604 
605   public EnzymeName getSystematicName() {
606     return systematicName;
607   }
608 
609   /**
610    * Sets the systematic name of the enzyme.
611    *
612    * @param systematicName The systematic name.
613    * @throws NullPointerException if <code>systematicName</code> is <code>null</code>.
614    */
615   public void setSystematicName(EnzymeName systematicName) {
616     if (systematicName == null) throw new NullPointerException("Parameter 'systematicName' must not be null.");
617     this.systematicName = systematicName;
618   }
619 
620   /** @deprecated use getEnzymaticReactions instead */
621   public List<Reaction> getReactions() {
622     return reactions;
623   }
624 
625   /**
626    * Returns a list of reactions which <code>view</code> values match the parameter's view value.
627    *
628    * @return the {@link java.util.ArrayList} of reactions.
629    * @throws NullPointerException     if <code>view</code> is <code>null</code>.
630    * @throws IllegalArgumentException if <code>view</code> is not either
631    *                                  {@link uk.ac.ebi.intenz.domain.constants.EnzymeViewConstant.INTENZ},
632    *                                  {@link uk.ac.ebi.intenz.domain.constants.EnzymeViewConstant.IUBMB} or
633    *                                  {@link uk.ac.ebi.intenz.domain.constants.EnzymeViewConstant.SIB} .
634    * @deprecated use {@link #getReactions(View)} or {@link #getReactions(String)} instead.
635    */
636   public List<Reaction> getReactions(EnzymeViewConstant view) {
637 	  return getReactions(view.toString());
638   }
639   
640   public List<Reaction> getReactions(String view){
641     View theView = View.valueOf(view);
642     return getReactions(theView);
643   }
644 
645   public List<Reaction> getReactions(View view){
646 	return enzymaticReactions.getReactions(view);
647   }
648   
649   /**
650    * Gets a collection of enzymatic reactions for the given view.
651    * @param view a web view.
652    * @return an {@link EnzymaticReactions} object containing only reactions in
653    * 		the given view.
654    * @since 4.3.0
655    */
656   public EnzymaticReactions getEnzymaticReactions(View view){
657 	  return enzymaticReactions.forView(view);
658   }
659 
660   /**
661    * Sets the list of reactions.
662    * <p/>
663    * Empty reaction strings will be omitted.
664    *
665    * @param reactions The list of reactions.
666    * @throws EnzymeReactionException if the list of reactions is empty.
667    */
668   public void setReactions(List<Reaction> reactions) throws EnzymeReactionException {
669     if (reactions == null) throw new NullPointerException("Parameter 'reactions' must not be null.");
670     if (reactions.isEmpty())
671         throw new EnzymeReactionException("At least one reaction must be part of this list.");
672     for (int iii = 0; iii < reactions.size(); iii++) {
673       Reaction reaction = reactions.get(iii);
674       if (reaction.getTextualRepresentation().equals("")) reactions.remove(iii--);
675     }
676     this.reactions = reactions;
677   }
678 
679   public EnzymaticReactions getEnzymaticReactions(){
680 	  return enzymaticReactions;
681   }
682 
683   public void setEnzymaticReactions(EnzymaticReactions enzymaticReactions) {
684 	this.enzymaticReactions = enzymaticReactions;
685   }
686 
687   public Set<Object> getCofactors() {
688     return cofactors;
689   }
690 
691   public void setCofactors(Set<Object> cofactors) {
692     this.cofactors = cofactors;
693   }
694 
695   public List<EnzymeName> getSynonyms() {
696     return synonyms;
697   }
698   
699   public List<EnzymeName> getSynonyms(String view){
700 	  View theView = View.valueOf(view);
701 	  return getSynonyms(theView);
702   }
703   
704   public List<EnzymeName> getSynonyms(View theView){
705 	  if (synonyms == null) return new ArrayList<EnzymeName>();
706 	  if (synonyms.size() == 0) return synonyms;
707 	  boolean isInView = false;
708 	  List<EnzymeName> names = new ArrayList<EnzymeName>();
709 	  for (EnzymeName name : synonyms){
710 		  switch (theView) {
711 		  case INTENZ:
712 			  isInView = name.getView().isInIntEnzView();
713 			  break;
714 		  case IUBMB:
715 			  isInView = name.getView().isInIUBMBView();
716 			  break;
717 		  case SIB:
718 			  isInView = name.getView().isInSIBView();
719 			  break;
720 		  }
721 		  if (isInView) names.add(name);
722 	  }
723 	  return names;
724   }
725 
726   /**
727    * Returns a list of synonyms which <code>view</code> values match the parameter's view value.
728    *
729    * @return the {@link java.util.ArrayList} of synonyms.
730    * @throws NullPointerException     if <code>view</code> is <code>null</code>.
731    * @throws IllegalArgumentException if <code>view</code> is not either
732    *                                  {@link uk.ac.ebi.intenz.domain.constants.EnzymeViewConstant.INTENZ},
733    *                                  {@link uk.ac.ebi.intenz.domain.constants.EnzymeViewConstant.IUBMB} or
734    *                                  {@link uk.ac.ebi.intenz.domain.constants.EnzymeViewConstant.SIB} .
735    * @deprecated use {@link #getSynonyms(String)} or {@link #getSynonyms(View)} instead.
736    */
737   public List<EnzymeName> getSynonyms(EnzymeViewConstant view) {
738     return getSynonyms(view.toString());
739   }
740 
741   /**
742    * Sets the list of synonyms.
743    *
744    * @param synonyms The list of synonyms.
745    * @throws NullPointerException if <code>synonyms</code> is <code>null</code>.
746    */
747   public void setSynonyms(List<EnzymeName> synonyms) {
748     if (synonyms == null) throw new NullPointerException("Parameter 'synonyms' must not be null.");
749     this.synonyms = synonyms;
750   }
751 
752   public List<EnzymeComment> getComments() {
753     return comments;
754   }
755   
756   public List<EnzymeComment> getComments(String view){
757 	  View theView = View.valueOf(view);
758 	  return getComments(theView);
759   }
760 
761   public List<EnzymeComment> getComments(View theView){
762 	  if (comments == null) return new ArrayList<EnzymeComment>();
763 	  if (comments.size() == 0) return comments;
764 	  boolean isInView = false;
765 	  List<EnzymeComment> commentsInView = new ArrayList<EnzymeComment>();
766 	  for (EnzymeComment comment : comments){
767 		  switch (theView) {
768 		  case INTENZ:
769 			  isInView = comment.getView().isInIntEnzView();
770 			  break;
771 		  case IUBMB:
772 			  isInView = comment.getView().isInIUBMBView();
773 			  break;
774 		  case SIB:
775 			  isInView = comment.getView().isInSIBView();
776 			  break;
777 		  }
778 		  if (isInView) commentsInView.add(comment);
779 	  }
780 	  return commentsInView;
781   }
782 
783   /**
784    * Returns a list of comments which <code>view</code> values match the parameter's view value.
785    *
786    * @return the {@link java.util.ArrayList} of comments.
787    * @throws NullPointerException     if <code>view</code> is <code>null</code>.
788    * @throws IllegalArgumentException if <code>view</code> is not either
789    *                                  {@link uk.ac.ebi.intenz.domain.constants.EnzymeViewConstant.INTENZ},
790    *                                  {@link uk.ac.ebi.intenz.domain.constants.EnzymeViewConstant.IUBMB} or
791    *                                  {@link uk.ac.ebi.intenz.domain.constants.EnzymeViewConstant.SIB} .
792    * @deprecated use {@link #getComments(String)} instead
793    * */
794   public List<EnzymeComment> getComments(EnzymeViewConstant view) {
795     if (view == null) throw new NullPointerException("Parameter 'view' must not be null.");
796     if (view != EnzymeViewConstant.INTENZ && view != EnzymeViewConstant.IUBMB && view != EnzymeViewConstant.SIB)
797       throw new IllegalArgumentException("Parameter 'view' must be either 'EnzymeViewConstant.INTENZ', 'EnzymeViewConstant.IUBMB' or 'EnzymeViewConstant.SIB'");
798     if (comments == null) return new ArrayList<EnzymeComment>();
799     if (comments.size() == 0) return comments;
800     List<EnzymeComment> groupedComments = new ArrayList<EnzymeComment>();
801     for (int iii = 0; iii < comments.size(); iii++) {
802       EnzymeComment comment = comments.get(iii);
803       if (view.toString().equals(EnzymeViewConstant.INTENZ.toString()) &&
804           EnzymeViewConstant.isInIntEnzView(comment.getView().toString())) {
805         groupedComments.add(comment);
806         continue;
807       }
808       if (view.toString().equals(EnzymeViewConstant.IUBMB.toString()) &&
809           EnzymeViewConstant.isInIUBMBView(comment.getView().toString())) {
810         groupedComments.add(comment);
811         continue;
812       }
813       if (view.toString().equals(EnzymeViewConstant.SIB.toString()) &&
814           EnzymeViewConstant.isInSIBView(comment.getView().toString())) {
815         groupedComments.add(comment);
816         continue;
817       }
818     }
819     return groupedComments;
820   }
821 
822   /**
823    * Sets the list of comments.
824    *
825    * @param comments The list of comments.
826    * @throws NullPointerException if <code>comments</code> is <code>null</code>.
827    */
828   public void setComments(List<EnzymeComment> comments) {
829     if (comments == null) throw new NullPointerException("Parameter 'comments' must not be null.");
830     this.comments = comments;
831   }
832 
833   public SortedSet<EnzymeLink> getLinks() {
834     return links;
835   }
836   
837   public SortedSet<EnzymeLink> getLinks(String view){
838 	  View theView = View.valueOf(view);
839 	  return getLinks(theView);
840   }
841   
842   /**
843    * CAS numbers for IntEnz and IUBMB views.
844    * @return
845    */
846   public SortedSet<EnzymeLink> getCasNumbers(){
847 	  SortedSet<EnzymeLink> cas = new TreeSet<EnzymeLink>();
848 	  for (EnzymeLink link : links){
849 		  if (link.getXrefDatabaseConstant().equals(XrefDatabaseConstant.CAS)){
850 			  cas.add(link);
851 		  }
852 	  }
853 	  return cas;
854   }
855 
856   public SortedSet<EnzymeLink> getUniProtLinks(){
857       SortedSet<EnzymeLink> uniProtLinks = new TreeSet<EnzymeLink>();
858  	  for (EnzymeLink link : links){
859 		  if (link.getXrefDatabaseConstant().equals(XrefDatabaseConstant.SWISSPROT))
860             uniProtLinks.add(link);
861       }
862       return uniProtLinks;
863   }
864   
865   /**
866    * Return the links to entries in external databases.
867    * These exclude:
868    * <ul>
869    * <li>CAS numbers (they are just identifiers, without
870    * any URL to go to). Use getCasNumbers.</li>
871    * <li>UniProt links. Use getUniProtLinks.</li>
872    * </ul>
873    * @param theView
874    * @return
875    */
876   public SortedSet<EnzymeLink> getLinks(View theView){
877 	  boolean isInView = false;
878 	  SortedSet<EnzymeLink> linksInView = new TreeSet<EnzymeLink>();
879 	  for (EnzymeLink link : links){
880 		  if (link.getXrefDatabaseConstant().equals(XrefDatabaseConstant.CAS) ||
881               link.getXrefDatabaseConstant().equals(XrefDatabaseConstant.SWISSPROT))
882 			  continue;
883 		  switch (theView) {
884 		  case INTENZ:
885 			  isInView = link.getView().isInIntEnzView();
886 			  break;
887 		  case IUBMB:
888 			  isInView = link.getView().isInIUBMBView();
889 			  break;
890 		  case SIB:
891 			  isInView = link.getView().isInSIBView();
892 			  break;
893 		  }
894 		  if (isInView) linksInView.add(link);
895 	  }
896 	  // Automatic links (not in the database):
897       if (status.equals(Status.PRELIMINARY)){
898           if (theView == View.INTENZ)
899               linksInView.add(EnzymeLink.EXPASY);
900       } else {
901           switch (theView) {
902           case INTENZ:
903               linksInView.add(EnzymeLink.CSA);
904               linksInView.add(EnzymeLink.NC_IUBMB);
905               linksInView.add(EnzymeLink.UNIPATHWAY);
906               linksInView.add(EnzymeLink.EXPLORENZ);
907               linksInView.add(EnzymeLink.METACYC);
908           case IUBMB:
909               linksInView.add(EnzymeLink.PDB);
910               linksInView.add(EnzymeLink.BRENDA);
911               linksInView.add(EnzymeLink.EXPASY);
912               linksInView.add(EnzymeLink.KEGG);
913               break;
914           }
915       }
916 	  return linksInView;
917   }
918 
919   /**
920    * 
921    * @param view
922    * @return
923    * @deprecated use {@link #getLinks(String)} instead
924    */
925   public SortedSet<EnzymeLink> getLinks(EnzymeViewConstant view) {
926     if (view == null) throw new NullPointerException("Parameter 'view' must not be null.");
927     if (view != EnzymeViewConstant.INTENZ && view != EnzymeViewConstant.IUBMB && view != EnzymeViewConstant.SIB)
928       throw new IllegalArgumentException("Parameter 'view' must be either 'EnzymeViewConstant.INTENZ', 'EnzymeViewConstant.IUBMB' or 'EnzymeViewConstant.SIB'");
929     if (links == null) return new TreeSet<EnzymeLink>();
930     if (links.size() == 0) return links;
931     SortedSet<EnzymeLink> groupedLinks = new TreeSet<EnzymeLink>();
932     for (Iterator<EnzymeLink> it = links.iterator(); it.hasNext();) {
933       EnzymeLink link = it.next();
934       if (view.toString().equals(EnzymeViewConstant.INTENZ.toString()) &&
935           EnzymeViewConstant.isInIntEnzView(link.getView().toString())) {
936         groupedLinks.add(link);
937         continue;
938       }
939       if (view.toString().equals(EnzymeViewConstant.IUBMB.toString()) &&
940           EnzymeViewConstant.isInIUBMBView(link.getView().toString())) {
941         groupedLinks.add(link);
942         continue;
943       }
944       if (view.toString().equals(EnzymeViewConstant.SIB.toString()) &&
945           EnzymeViewConstant.isInSIBView(link.getView().toString())) {
946         groupedLinks.add(link);
947         continue;
948       }
949     }
950     return groupedLinks;
951   }
952 
953   /**
954    * Sets the list of links.
955    *
956    * @param links The list of links.
957    * @throws NullPointerException if <code>links</code> is <code>null</code>.
958    */
959   public void setLinks(SortedSet<EnzymeLink> links) {
960     if (links == null) throw new NullPointerException("Parameter 'links' must not be null.");
961     this.links = links;
962   }
963 
964   public List<Reference> getReferences() {
965     return references;
966   }
967 
968   /**
969    * Sets the list of refernces.
970    *
971    * @param references The list of references.
972    * @throws EnzymeReferenceException if <code>references</code> is <code>null</code>.
973    */
974   public void setReferences(List<Reference> references) throws EnzymeReferenceException {
975     if (references == null) throw new NullPointerException("Parameter 'references' must not be null.");
976     if (references.size() < 1)
977       throw new EnzymeReferenceException("At least one reference must be part of this list.");
978     this.references = references;
979   }
980 
981   public String getNote() {
982     return note;
983   }
984 
985   /**
986    * Sets the note.
987    *
988    * @param note the note.
989    * @throws NullPointerException if <code>note</code> is <code>null</code>.
990    */
991   public void setNote(String note) {
992     if (note == null) throw new NullPointerException("Parameter 'note' must not be null.");
993     this.note = note;
994   }
995 
996   public HistoryGraph getHistory() {
997     return historyGraph;
998   }
999 
1000   /**
1001    * Sets the history graph.
1002    *
1003    * @param historyGraph the history graph.
1004    * @throws NullPointerException if <code>historyGraph</code> is <code>null</code>.
1005    */
1006   public void setHistory(HistoryGraph historyGraph) {
1007     if (historyGraph == null) throw new NullPointerException("Parameter 'historyGraph' must not be null.");
1008     this.historyGraph = historyGraph;
1009   }
1010 
1011   public Status getStatus() {
1012     return status;
1013   }
1014 
1015   /**
1016    * Sets the enzyme's status.
1017    *
1018    * @param status The enzyme's status.
1019    * @throws NullPointerException if <code>status</code> is <code>null</code>.
1020    */
1021   public void setStatus(Status status) {
1022     if (status == null) throw new NullPointerException("Parameter 'status' must not be null.");
1023     this.status = status;
1024   }
1025 
1026   public EnzymeSourceConstant getSource() {
1027     return source;
1028   }
1029 
1030   /**
1031    * Sets the enzyme's source.
1032    *
1033    * @param source The enzyme's source.
1034    * @throws NullPointerException if <code>source</code> is <code>null</code>.
1035    */
1036   public void setSource(EnzymeSourceConstant source) {
1037     if (source == null) throw new NullPointerException("Parameter 'source' must not be null.");
1038     this.source = source;
1039   }
1040 
1041   public boolean isActive() {
1042     return isActive;
1043   }
1044 
1045   public void setActive(boolean active) {
1046     this.isActive = active;
1047   }
1048 
1049   public boolean isGhost() {
1050     return isGhost;
1051   }
1052 
1053   public void setGhost(boolean ghost) {
1054     isGhost = ghost;
1055   }
1056 
1057   public boolean hasNames() {
1058     if (commonNames != null && commonNames.size() > 0) return true;
1059     if (synonyms != null && synonyms.size() > 0) return true;
1060     if (systematicName != null && !systematicName.getName().equals("")) return true;
1061     return false;
1062   }
1063 
1064   // ------------------- PRIVATE METHODS ------------------------
1065 
1066 }