Skip to content

Clotho Internals : Convenience Methods

Jerome Wilfred G. Andaya Jr edited this page Jun 9, 2017 · 14 revisions

Convenience Create

Part Diagram
Device Diagram

Overview

These methods are used to create basic Parts and Devices. Assuming all optional fields are provided, the following objects are created:

Convenience Method Objects
Part BioDesign, Part, Sequence, Annotation, Feature, BasicModule, Parameter(s)
Device BioDesign, Part, Sequence, Annotation(s), Feature, BasicModule, Parameter(s) and additional Parts provided through partIDs are included in the Biodesign as SubDesigns and Assemblies.

Create Part

public static ObjectId createPart(Persistor persistor, String name, String displayID, Map<String, String> seqrole, List<Parameter> parameters, String author)
Parameter Required? Description
persistor Required Used to save the generated part
name Required The name of the part, attached to all created sub-objects
author Required The author of the part. Will be created if they do not already exist.
displayID Optional A human-friendly ID, can be used to differentiate between similarly named objects. Attached to all created sub-objects
seqrole Optional An optional map containing an optional role string value and/or sequence string value
parameters Optional A list containing Parameter objects to be attached to the Part's BioDesign

Create Device

public static ObjectId createDevice(Persistor persistor, String name, List<String> partIDs, Map<String, String> seqrole, List<Parameter> parameters, String displayID, String author, boolean createSeqFromParts)
Parameter Required? Description
persistor Required Used to save the generated Device
name Required The name of the part, attached to all created sub-objects
partIDs Required A list of Part ObjectId's that should be sub-sequences of the Device's sequence. When creating the Device, each of these parts will be added as a SubDesign, and if a given Part has a sequence and that sequence is a substring of the Device's sequence, an Annotation will be created for that Part.
author Required The author of the part. Will be created if they do not already exist.
createSeqFromParts Required If no sequence is provided and this evaluates to true, the sequence of the created Device will be equivalent to the concatenation of the sequences of the provided parts
displayID Optional A human-friendly ID, can be used to differentiate between similarly named objects. Attached to all created sub-objects
seqrole Optional An optional map containing an optional role value and/or sequence value. If sequence is provided, the createSeqFromParts boolean is overrided to be false.
parameters Optional A list containing Parameter objects to be attached to the Device's BioDesign

Convenience Query

Overview

The query methods are used to return a group of Devices/Parts that match some amount of optional criteria. Keep in mind that the query methods use AND logic when searching for items. If any field provided does not match the desired object, the object will not be returned.

The following is an example of a general object generated by the query methods:

  • Part/Device #1 Name
    • id : value
    • name : value
    • role : value
    • sequence : value
  • Part/Device #2 Name
    • id : value
    • name : value
    • displayID : value
    • role : value
    • sequence : value
    • parameters : array of values
    • parts : array of values

Get Part

public static Map<String, Map<String, String>> getPart(Persistor persistor, String name, String displayID, String role, String sequence, List<Parameter> parameters)

At least one of the optional fields must be used to receive a non-empty map

Parameter Required? Description
persistor Required Used to query for Parts
name Optional The name of the Part, a substring of the name, or any regex string to search for the name.
displayID Optional The displayID of the Part, a substring, or any regex match
role Optional The role of the Part, a substring, or any regex match
sequence Optional The sequence of the Part, a substring, or any regex match
parameters Optional A list containing Parameter objects that must be included in the parts returned. Note that the parameter objects do not need to have the same ID as the corresponding object attached to the Part, the only requirement is that all the fields match, are a substring, or are a regex match.

Get Device

public static Map<String, Map<String, String>> getDevice(Persistor persistor, String name, String displayID, String role, String sequence, List<Part> parts, List<Parameter> parameters)

At least one of the optional fields must be used to receive a non-empty map

Parameter Required? Description
persistor Required Used to query for Devices
name Optional The name of the Devices, a substring of the name, or any regex string to search for the name.
displayID Optional The displayID of the Device, a substring, or any regex match
role Optional The role of the Device, a substring, or any regex match
sequence Optional The sequence of the Device, a substring, or any regex match
parts Optional A list containing Part objects that must be included as sub-Parts in the Parts returned. Note that the Part objects do not need to have the same Id as the corresponding object attached to the Device, the only requirement is that all the fields match, are a substring, or are a regex match.
parameters Optional A list containing Parameter objects that must be included in the Devices returned. Note that the Parameter objects do not need to have the same ID as the corresponding object attached to the Device, the only requirement is that all the fields match, are a substring, or are a regex match.

Part

Part Diagram

Device

Device Diagram

Convenience Delete

Overview:

The delete methods will be used to delete an entire BioDesign module.

Approach: via bottom-up through the Parts Diagram in the wiki:

  1. Get the BioDesign Id
  2. Delete the instance to the List of Objects, using the BioDesign Id
  3. Delete each occurrence of the parts (via getting the id of each individual part(s))
  4. Delete each annotation within part(s)
  5. Delete each feature within part(s)
  6. Delete the sequence from each part(s) if not null
  7. Delete the BioDesign module

Note: Make sure that all of the BioDesign module pieces are not null, or the Clotho file will throw an exception

General Methods:

Delete:

The main delete method of the ConvenienceMethods.java file.

public static boolean delete(Persistor persistor, ObjectId id, boolean bDevice)

The ObjectId must be specified for the delete function to be successful

Parameter Required? Description
persistor Required Used to query for Devices (CRUD) methods
id Required The Object Id to delete the BioDesign instance
bDevice Optional Determine (via a boolean value) whether the BioDevice was successfully deleted

Mongo will not delete a BioDesign instance without a valid Object Id

AnnotateMe:

Wikipedia URL for the algorithm:

https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_algorithm

Picture of the Algorithm (using a Global Trie data structure):

Aho-Corasick Algorithm

The annotation helper method (using the Aho-Corasick Algorithm)

static void annotateMe(Persistor persistor, Sequence seq, List<String> partIDs)

Annotation is required to show each test of the delete methods (via an @Test annotation) in the ConvenienceMethodsTest.java file

Parameter Required? Description
persistor Required Used to call the Persistor.java class to query for devices
seq Required The sequence to annotate within the database in mongoDB
partIDs Required The list of partIDs into the mongoDB for Clotho (ConvenienceMethodsTest.java)

Code example:

parts = [5935ba4f2080280d2efe4e5e, 5935ba4f2080280d2efe4e63, 5935ba4f2080280d2efe4e64];

Delete References:

The helper method that will delete a reference to the sub-designs of each BioDesign object

public static void deleteReferences(Persistor persistor, ObjectId bioId)

The partId must be initialized to null in this method

Parameter Required? Description
persistor Required Used to query the convenience methods
bioId Required BioDesign id to be de-referenced (removed from the sub-design storage within the Clotho mongoDB)

Convenience Update

Overview:

The update methods will be able to update either a Clotho Part or Device.

** Note: Only the displayID, name, parameters... can be updated if the user did not initially update the parameters to NULL**

General methods:

Update Bio Design:

private static void updateBioDesign(Persistor persistor, ObjectId obj, String displayID, String name, List<Parameter> parameters, List<String> subPartIds, Map<String, String> seqrole, boolean createSeqParts) 
Parameter Required? Description
persistor Required Used to query the Convenience Methods via the Create, Read, Update, Delete approach
obj Required The objectId of the ConvenienceMethods' BioDesign part / device to be updated
displayID Optional The new displayId of the Construct
name Optional The new name of the Construct
parameters Optional The new parameters (value, name, variable, units) in of the Construct
subPartIds Optional(can be initialized to NULL) The new subpart Ids of the Construct
seqrole Optional The new sequence or role of the Construct
createSeqFromParts Optional boolean To be used with subPartIds. Should the sequence be created with the concatenation of part sequences provided?