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;
184 reason.append(
"Different source AP.");
189 reason.append(
"Different target AP.");
194 reason.append(
"Different bond type ("+this.
getBondType()+
":"
244 String invariantThis = invariantTA + invariantTB;
245 if (invariantTA.compareTo(invariantTB) > 0)
246 invariantThis = invariantTB + invariantTA;
248 String invariantOther = invariantOA + invariantOB;
249 if (invariantOA.compareTo(invariantOB) > 0)
250 invariantOther = invariantOB + invariantOA;
252 int resultIgnoringBondType = invariantThis.compareTo(invariantOther);
254 if (resultIgnoringBondType == 0)
258 return resultIgnoringBondType;
272 StringBuilder sb =
new StringBuilder(64);
274 .append(srcAPID).append(
"_").
276 .append(trgAPID).append(
"_").
284 return sb.toString();
305 NONE, UNDEFINED,
ANY, SINGLE, DOUBLE, TRIPLE, QUADRUPLE;
307 private int valenceUsed = 0;
309 private IBond.Order bo =
null;
312 ANY.bo = IBond.Order.SINGLE;
313 SINGLE.bo = IBond.Order.SINGLE;
314 DOUBLE.bo = IBond.Order.DOUBLE;
315 TRIPLE.bo = IBond.Order.TRIPLE;
316 QUADRUPLE.bo = IBond.Order.QUADRUPLE;
318 SINGLE.valenceUsed = 1;
319 DOUBLE.valenceUsed = 2;
320 TRIPLE.valenceUsed = 3;
321 QUADRUPLE.valenceUsed = 4;
373 if (bt.name().equals(
string.trim().toUpperCase()))
376 switch (
string.trim())
405 implements JsonSerializer<Edge>
409 JsonSerializationContext context)
411 JsonObject jsonObject =
new JsonObject();
414 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)