This repository was archived by the owner on Aug 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReaction.java
105 lines (78 loc) · 2.96 KB
/
Reaction.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package no.uib.pap.model;
import com.google.common.collect.HashMultimap;
import java.io.Serializable;
/**
* Represents chemical reactions or "reaction-like events" as in the Reactome data model.
*/
public class Reaction implements Comparable<Reaction>, Serializable {
private String stId;
public String getStId() {
return stId;
}
public void setStId(String stId) {
this.stId = stId;
}
private String displayName;
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
/**
* Protein proteinParticipantsWithRole with their role: input(reactant), output(product), catalyst, regulator
* A protein can have multiple roles in the same reaction
*/
private HashMultimap<String, Role> proteinParticipantsWithRole;
public HashMultimap<String, Role> getProteinParticipantsWithRole() {
return proteinParticipantsWithRole;
}
/**
* Proteoform proteinParticipantsWithRole with their role: input(reactant), output(product), catalyst, regulator
* A protein can have multiple roles in the same reaction
*/
private HashMultimap<Proteoform, Role> proteoformParticipants;
public HashMultimap<Proteoform, Role> getProteoformParticipants() {
return proteoformParticipants;
}
public Reaction(String stId, String displayName) {
this.stId = stId;
this.displayName = displayName;
proteinParticipantsWithRole = HashMultimap.create();
proteoformParticipants = HashMultimap.create();
}
@Override
public String toString() {
return this.stId + "\t" + this.displayName;
}
public String toString(String separator) {
return this.stId + separator + this.displayName;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || !(obj instanceof Reaction)) return false;
Reaction that = (Reaction) obj;
return this.stId.equals(that.stId) && this.displayName.equals(that.displayName);
}
@Override
public int compareTo(Reaction that) {
if (this.equals(that)) return 0;
// First by displayName
if (!this.displayName.equals(that.displayName)) {
return this.displayName.compareTo(that.displayName);
}
// Second by stId
if (!this.stId.equals(that.stId)) {
return this.stId.compareTo(that.stId);
}
assert this.equals(that) : "Check consistency with equals";
return 0;
}
public void addParticipant(String proteinAccession, Role role) {
this.proteinParticipantsWithRole.put(proteinAccession, role);
}
public void addParticipant(Proteoform proteoform, Role role) {
this.proteoformParticipants.put(proteoform, role);
}
}