19package denoptim.fragspace;
21import static org.junit.jupiter.api.Assertions.assertEquals;
22import static org.junit.jupiter.api.Assertions.assertTrue;
24import java.util.ArrayList;
25import java.util.Arrays;
26import java.util.HashMap;
27import java.util.HashSet;
28import java.util.LinkedHashMap;
31import java.util.Map.Entry;
34import org.junit.jupiter.api.Test;
36import denoptim.exception.DENOPTIMException;
37import denoptim.graph.APClass;
38import denoptim.graph.APMapping;
39import denoptim.graph.AttachmentPoint;
40import denoptim.graph.DGraph;
41import denoptim.graph.Edge;
42import denoptim.graph.EmptyVertex;
43import denoptim.graph.Vertex;
44import denoptim.graph.Vertex.BBType;
67 HashMap<APClass,ArrayList<APClass>> cpMap =
68 new HashMap<APClass,ArrayList<APClass>>();
69 ArrayList<APClass> lstA =
new ArrayList<APClass>();
71 cpMap.put(
APCA, lstA);
72 ArrayList<APClass> lstB =
new ArrayList<APClass>();
75 cpMap.put(
APCB, lstB);
76 ArrayList<APClass> lstC =
new ArrayList<APClass>();
79 cpMap.put(
APCC, lstC);
80 ArrayList<APClass> lstD =
new ArrayList<APClass>();
82 cpMap.put(
APCD, lstD);
83 ArrayList<APClass> lstE =
new ArrayList<APClass>();
85 cpMap.put(
APCE, lstE);
107 HashMap<APClass,APClass> capMap =
new HashMap<APClass,APClass>();
108 HashSet<APClass> forbEnds =
new HashSet<APClass>();
112 new ArrayList<Vertex>(),
113 new ArrayList<Vertex>(),
114 new ArrayList<Vertex>(),
115 cpMap, capMap, forbEnds, cpMap);
301 Map<Integer,Integer> expected =
new HashMap<Integer,Integer>();
306 expected.put(11, 84);
309 LinkedHashMap<Vertex, List<APMapping>> allAltLinks =
311 Set<Vertex> keys = allAltLinks.keySet();
314 int bbId = k.getBuildingBlockId();
315 assertTrue(expected.containsKey(bbId),
"Vertex with building block "
316 +
"ID '" + bbId +
"' should not be among the results.");
317 assertEquals(expected.get(bbId), allAltLinks.get(k).size(),
318 "Number of APmapping is wrong for bbId '" + bbId +
"'.");
336 Map<Integer,List<APClass>> expected =
337 new HashMap<Integer,List<APClass>>();
338 expected.put(0,
new ArrayList<APClass>(Arrays.asList(
340 expected.put(3,
new ArrayList<APClass>(Arrays.asList(
342 expected.put(4,
new ArrayList<APClass>(Arrays.asList(
344 expected.put(5,
new ArrayList<APClass>(Arrays.asList(
346 expected.put(9,
new ArrayList<APClass>(Arrays.asList(
348 expected.put(10,
new ArrayList<APClass>(Arrays.asList(
350 expected.put(11,
new ArrayList<APClass>(Arrays.asList(
382 Map<Integer,List<APClass>> expected =
383 new HashMap<Integer,List<APClass>>();
384 expected.put(12,
new ArrayList<APClass>(Arrays.asList(
407 Map<Integer,List<APClass>> expected =
408 new HashMap<Integer,List<APClass>>();
417 Map<Integer,List<APClass>> expected,
418 Map<
Vertex, List<APMapping>> actual)
421 boolean debug =
false;
423 for (
Vertex k : actual.keySet())
425 int bbId = k.getBuildingBlockId();
429 System.out.println(
"BBID: "+bbId);
432 List<APMapping> list = actual.get(k);
434 assertTrue(expected.containsKey(bbId),
"Vertex with building block "
435 +
"ID '" + bbId +
"' should not among the results.");
436 assertEquals(expected.get(bbId).size() / 4, actual.get(k).size(),
437 "Number of APmappings is wrong for bbId '" + bbId +
"'.");
440 List<APClass> refList = expected.get(bbId);
445 System.out.println(
" -> "+apm.toString());
447 for (Entry<AttachmentPoint, AttachmentPoint> e
452 System.out.println(
" -> "+e.getKey().getAPClass()
453 +
" "+e.getValue().getAPClass());
456 assertEquals(refList.get(i),e.getKey().getAPClass(),
457 "APClass in APMapping for bbId "+bbId+
" entry " +i);
459 assertEquals(refList.get(i),e.getValue().getAPClass(),
460 "APClass in APMapping for bbId "+bbId+
" entry " +i);
Class defining a space of building blocks.
void appendVertexToLibrary(Vertex v, Vertex.BBType bbt, ArrayList< Vertex > library)
Takes a vertex and add it to a given library.
Vertex getVertexFromLibrary(Vertex.BBType bbType, int bbIdx)
Returns a clone of the requested building block.
void setAPclassBasedApproach(boolean useAPC)
Set the fragment space to behave according to APClass-based approach.
void groupAndClassifyFragments(boolean apClassBasedApproch)
Performs grouping and classification operations on the library of building blocks of BBType#FRAGMENT.
ArrayList< Vertex > getScaffoldLibrary()
ArrayList< Vertex > getFragmentLibrary()
Parameters defining the fragment space.
An utility class to encapsulate the search for vertexes that satisfy constraints.
LinkedHashMap< Vertex, List< APMapping > > getAllAlternativesFound()
Returns all the AP mapping that were identified for any candidate vertex that could be used either as...
void testLinkFromEdgeNoMatch()
void testLinkFromEdgeOneMatch()
void testLinkFromVertex()
DGraph makeTestGraphA()
Creates a test graph that looks like this: v0(A)-(A)v1(B)-(B)v2.
DGraph makeTestGraphE()
Creates a test graph that looks like this: v0(E)-(E)v1.
DGraph makeTestGraphF()
Creates a test graph that looks like this: v0(F)-(F)v1.
void ensureConsistencyWithExpectations(Map< Integer, List< APClass > > expected, Map< Vertex, List< APMapping > > actual)
static APClass make(String ruleAndSubclass)
Creates an APClass if it does not exist already, or returns the reference to the existing instance.
Class representing a mapping between attachment points (APs).
Container for the list of vertices and the edges that connect them.
Edge getEdgeAtPosition(int pos)
void addVertex(Vertex vertex)
Appends a vertex to this graph without creating any edge.
Vertex getVertexAtPosition(int pos)
Returns the vertex that is in the given position of the list of vertices belonging to this graph.
void renumberGraphVertices()
Reassign vertex IDs to all vertices of this graph.
void addEdge(Edge edge)
Adds the edge to the list of edges belonging to this graph.
This class represents the edge between two vertices.
An empty vertex has the behaviors of a vertex, but has no molecular structure.
void addAP()
Adds an attachment point with no APClass or other attribute.
A vertex is a data structure that has an identity and holds a list of AttachmentPoints.
void setBuildingBlockType(Vertex.BBType buildingBlockType)
AttachmentPoint getAP(int i)
Get attachment point i on this vertex.
The type of building block.