19package denoptim.graph;
21import java.lang.reflect.Type;
23import org.openscience.cdk.interfaces.IBond;
24import org.openscience.cdk.interfaces.IBond.Order;
26import com.google.gson.JsonElement;
27import com.google.gson.JsonObject;
28import com.google.gson.JsonSerializationContext;
29import com.google.gson.JsonSerializer;
31import denoptim.utils.GeneralUtils;
186 reason.append(
"Different source AP.");
191 reason.append(
"Different target AP.");
196 reason.append(
"Different bond type ("+this.
getBondType()+
":"
246 String invariantThis = invariantTA + invariantTB;
247 if (invariantTA.compareTo(invariantTB) > 0)
248 invariantThis = invariantTB + invariantTA;
250 String invariantOther = invariantOA + invariantOB;
251 if (invariantOA.compareTo(invariantOB) > 0)
252 invariantOther = invariantOB + invariantOA;
254 int resultIgnoringBondType = invariantThis.compareTo(invariantOther);
256 if (resultIgnoringBondType == 0)
260 return resultIgnoringBondType;
274 StringBuilder sb =
new StringBuilder(64);
276 .append(srcAPID).append(
"_").
278 .append(trgAPID).append(
"_").
286 return sb.toString();
307 NONE, UNDEFINED,
ANY, SINGLE, DOUBLE, TRIPLE, QUADRUPLE;
309 private int valenceUsed = 0;
311 private IBond.Order bo =
null;
314 ANY.bo = IBond.Order.SINGLE;
315 SINGLE.bo = IBond.Order.SINGLE;
316 DOUBLE.bo = IBond.Order.DOUBLE;
317 TRIPLE.bo = IBond.Order.TRIPLE;
318 QUADRUPLE.bo = IBond.Order.QUADRUPLE;
320 SINGLE.valenceUsed = 1;
321 DOUBLE.valenceUsed = 2;
322 TRIPLE.valenceUsed = 3;
323 QUADRUPLE.valenceUsed = 4;
375 if (bt.name().equals(
string.trim().toUpperCase()))
378 switch (
string.trim())
407 implements JsonSerializer<Edge>
411 JsonSerializationContext context)
413 JsonObject jsonObject =
new JsonObject();
416 jsonObject.add(
"bondType", context.serialize(edge.
getBondType()));
An attachment point (AP) is a possibility to attach a Vertex onto the vertex holding the AP (i....
AttachmentPoint getEmbeddedAP()
For vertices that are templates this method returns the attachment point that is embedded in the temp...
void setUser(Edge edge)
Sets the reference to the edge that is using this attachment point.
APClass getAPClass()
Returns the Attachment Point class.
int getID()
Returns a unique integer that is used to sort list of attachment points.
JsonElement serialize(Edge edge, Type typeOfSrc, JsonSerializationContext context)
This class represents the edge between two vertices.
boolean sameAs(Edge other, StringBuilder reason)
Compares this and another edge ignoring edge and vertex IDs.
AttachmentPoint getSrcAPThroughout()
int compareAsUndirected(Edge other)
Compares this and another edge ignoring the directionality of both, i.e., as if both edges were undir...
BondType bondType
The bond type associated with the connection between the fragments.
AttachmentPoint getTrgAP()
void flipEdge()
Exchanges source and target vertices and respective APs of this edge.
AttachmentPoint srcAP
Attachment point at source end.
AttachmentPoint getSrcAP()
Edge(AttachmentPoint srcAP, AttachmentPoint trgAP, BondType bondType)
Constructor for an edge that connects two APs.
AttachmentPoint trgAP
Attachment point at target end.
Edge(AttachmentPoint srcAP, AttachmentPoint trgAP)
Constructor for an edge that connects two APs.
AttachmentPoint getTrgAPThroughout()
A vertex is a data structure that has an identity and holds a list of AttachmentPoints.
int getBuildingBlockId()
Returns the index of the building block that should correspond to the position of the building block ...
int getIndexOfAP(AttachmentPoint ap)
Returns the position of the given AP in the list of APs of this vertex.
Vertex.BBType getBuildingBlockType()
static String getPaddedString(int count, int number)
returns the padded string with zeroes placed to the left of 'number' up to reach the desired number o...
Possible chemical bond types an edge can represent.
static BondType parseStr(String string)
boolean hasCDKAnalogue()
Checks if it is possible to convert this edge type into a CDK bond.
static BondType parseInt(int i)