Skip to content

Commit

Permalink
Merge pull request #214 from SynBioDex/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
bbartley authored Jul 6, 2019
2 parents 12a288f + 3da100a commit 60022a9
Show file tree
Hide file tree
Showing 28 changed files with 2,800 additions and 2,392 deletions.
16 changes: 12 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ before_install:
- sudo apt-get update -q=2

# install dependencies
- sudo apt-get -y install build-essential libxml2-dev gcc-multilib g++-multilib libraptor2-dev libjsoncpp-dev swig3.0 python-dev

- sudo apt-get -y install build-essential libxml2-dev gcc-multilib g++-multilib libraptor2-dev swig3.0 python-dev
- curl --tlsv1.2 -L https://github.com/open-source-parsers/jsoncpp/archive/1.7.7.tar.gz > jsoncpp-1.7.7.tar.gz
- tar -xzf jsoncpp-1.7.7.tar.gz
- cd jsoncpp-1.7.7
- cmake . -Bbuild -DBUILD_SHARED_LIBS=TRUE
- cd build
- sudo make install
- cd ../..
- ls /usr/local/lib
- echo "TRAVIS_BUILD_DIR $TRAVIS_BUILD_DIR"
# build
- mkdir -p ~/build/libSBOL
Expand All @@ -36,7 +43,7 @@ install:
- cd ~/build/libSBOL
- sudo apt-get install -q=2 g++-4.8
- export CXX="g++-5" CC="gcc-5"
- cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/install_x64 -DSBOL_BUILD_64=ON -DSBOL_BUILD_SHARED=ON -DCURL_LIBRARY=/usr/lib/x86_64-linux-gnu/libcurl.so -DJsonCpp_LIBRARY=/usr/lib/x86_64-linux-gnu/libjsoncpp.so -DLIBXSLT_LIBRARIES=/usr/lib/x86_64-linux-gnu/libxslt.so -DRAPTOR_LIBRARY=/usr/lib/x86_64-linux-gnu/libraptor2.so -DSBOL_BUILD_PYTHON2=ON -DPYTHON_EXECUTABLE=/usr/bin/python -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython2.7.so python2.7 -DSWIG_EXECUTABLE=/usr/bin/swig3.0 "$TRAVIS_BUILD_DIR"
- cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/install_x64 -DSBOL_BUILD_64=ON -DSBOL_BUILD_SHARED=ON -DCURL_LIBRARY=/usr/lib/x86_64-linux-gnu/libcurl.so -DLIBXSLT_LIBRARIES=/usr/lib/x86_64-linux-gnu/libxslt.so -DRAPTOR_LIBRARY=/usr/lib/x86_64-linux-gnu/libraptor2.so -DSBOL_BUILD_PYTHON2=ON -DPYTHON_EXECUTABLE=/usr/bin/python -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython2.7.so python2.7 -DSWIG_EXECUTABLE=/usr/bin/swig3.0 "$TRAVIS_BUILD_DIR"
- make
- make install

Expand All @@ -53,7 +60,8 @@ script:
- ls ~/build/SynBioDex
- cd ~/build/SynBioDex/libSBOL/release/wrapper/Linux_64_2
- python -c "from sbol import *; testSBOL()"

- python -c "from sbol.unit_tests import *; runRoundTripTests()"

addons:
apt:
sources:
Expand Down
1 change: 1 addition & 0 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ FILE(GLOB SBOL_HEADER_FILES
properties.h
object.h
identified.h
measure.h
toplevel.h
sequenceannotation.h
component.h
Expand Down
26 changes: 25 additions & 1 deletion source/assembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,10 @@ std::string ComponentDefinition::compile()
{
if (Config::getOption("sbol_compliant_uris") == "True")
{
seq = &doc->sequences.create(displayId.get());
string display_id = displayId.get();
if (Config::getOption("sbol_typed_uris") == "False")
display_id = display_id + "_seq";
seq = &doc->sequences.create(display_id);
sequence.set(*seq);
sequences.set(seq->identity.get());

Expand Down Expand Up @@ -1979,6 +1982,27 @@ void nest_ranges(std::vector < sbol::Range* > ranges, ComponentDefinition* cdef_
removed_ann->close();
}

vector<SequenceAnnotation*> ComponentDefinition::sortSequenceAnnotations()
{
vector<Range*> unsorted_ranges;
vector<SequenceAnnotation*> sorted_annotations;
for (auto & ann : sequenceAnnotations)
{
for (auto & l : ann.locations)
{
if (l.type == SBOL_RANGE)
unsorted_ranges.push_back((Range*)&l);
}
}
sort(unsorted_ranges.begin(), unsorted_ranges.end(), compare_ranges);
for (auto & r : unsorted_ranges)
{
sorted_annotations.push_back((SequenceAnnotation*)r->parent);
}
return sorted_annotations;
};


void disassemble(ComponentDefinition * cdef_node, int range_start)
{
// std::cout << "Dissembling " << cdef_node->identity.get() << " at " << range_start << std::endl;
Expand Down
17 changes: 14 additions & 3 deletions source/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#include "identified.h"
#include "mapsto.h"
#include "location.h"
#include "measurement.h"

#include <string>

Expand Down Expand Up @@ -56,13 +58,17 @@ namespace sbol
/// The mapsTos property is OPTIONAL and MAY contain a set of MapsTo objects that refer to and link together ComponentInstance objects (both Component objects and FunctionalComponent objects) within a larger design.
OwnedObject<MapsTo> mapsTos;

/// The measurements property links a ComponentInstance to parameters or measurements and their associated units. For example a Measurement attached to a FunctionalComponent might indicate the quantity of a component ingredient in a growth medium recipe.
OwnedObject<Measurement> measurements;

virtual ~ComponentInstance() {};
protected:
ComponentInstance(rdf_type type, std::string uri, std::string definition, std::string access, std::string version) :
Identified(type, uri, version),
definition(this, SBOL_DEFINITION, SBOL_COMPONENT_DEFINITION, '1', '1', ValidationRules({}), definition),
access(this, SBOL_ACCESS, '0', '1', ValidationRules({}), access),
mapsTos(this, SBOL_MAPS_TOS, '0', '*', ValidationRules({}))
mapsTos(this, SBOL_MAPS_TOS, '0', '*', ValidationRules({})),
measurements(this, SBOL_MEASUREMENTS, '0', '*', ValidationRules({}))
{
};

Expand All @@ -87,6 +93,10 @@ namespace sbol
/// | http://sbols.org/v2#mergeRoles | Use the union of the two sets: both the set of zero or more roles given for this Component as well |
/// | | as the set of zero or more roles given for the included sub-ComponentDefinition. |
URIProperty roleIntegration;

/// The sourceLocations property allows only a portion of the Component's sequence to be used when compiling a composite Sequence from a component hierarchy. This serves two related purposes: (1) To support the insertion of parts within a larger plasmid or genome "backbone". Typically, this will replace a small segment of the backbone which, currently, cannot be expressed in SBOL. (2) To support the "trimming" of part boundaries as it may happen during DNA assembly.
OwnedObject<Location> sourceLocations;


/// Construct a Component. If operating in SBOL-compliant mode, use ComponentDefinition::components::create instead.
/// @param A full URI including a scheme, namespace, and identifier. If SBOLCompliance configuration is enabled, then this argument is simply the displayId for the new object and a full URI will automatically be constructed.
Expand All @@ -104,7 +114,8 @@ namespace sbol
Component(rdf_type type, std::string uri, std::string definition, std::string access, std::string version) :
ComponentInstance(type, uri, definition, access, version),
roles(this, SBOL_ROLES, '0', '*', ValidationRules({})),
roleIntegration(this, SBOL_ROLE_INTEGRATION, '0', '1', ValidationRules({}), SBOL_ROLE_INTEGRATION_MERGE)
roleIntegration(this, SBOL_ROLE_INTEGRATION, '0', '1', ValidationRules({}), SBOL_ROLE_INTEGRATION_MERGE),
sourceLocations(this, SBOL_LOCATIONS, '0', '*', ValidationRules({}))
{};

// Component(sbol_type type, std::string uri_prefix, std::string display_id, std::string version, std::string definition, std::string access) : ComponentInstance(type, uri_prefix, display_id, version, definition, access) {};
Expand Down Expand Up @@ -160,4 +171,4 @@ namespace sbol
};
}

#endif
#endif
2 changes: 2 additions & 0 deletions source/componentdefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ namespace sbol

ComponentDefinition& build();

std::vector<SequenceAnnotation*> sortSequenceAnnotations();

/// A convenience method that assigns a component to participate in a biochemical reaction. Behind the scenes, it auto-constructs a FunctionalComponent for this ComponentDefinition and assigns it to a Participation
/// @param species A Participation object (ie, participant species in a biochemical Interaction).
void participate(Participation& species);
Expand Down
4 changes: 3 additions & 1 deletion source/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ std::map<std::string, std::string> sbol::Config::options {
{"main_file_name", "main file"},
{"diff_file_name", "comparison file"},
{"return_file", "False"},
{"verbose", "False"}
{"verbose", "False"},
{"ca-path", ""}

};

std::map<std::string, std::vector<std::string>> sbol::Config::valid_options {
Expand Down
5 changes: 4 additions & 1 deletion source/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
#define SBOL_IMPLEMENTATION SBOL_URI "#Implementation"
#define SBOL_EXPERIMENT SBOL_URI "#Experiment"
#define SBOL_EXPERIMENTAL_DATA SBOL_URI "#ExperimentalData"

#define SBOL_MEASURE SBOL_URI "#Measure"
#define UNDEFINED SBOL_URI "#Undefined"

/* URIs for SBOL Properties */
Expand Down Expand Up @@ -129,6 +129,9 @@
#define SBOL_STRATEGY SBOL_URI "#strategy"
#define SBOL_TEMPLATE SBOL_URI "#template"
#define SBOL_ATTACHMENTS SBOL_URI "#attachment"
#define SBOL_VALUE SBOL_URI "#hasNumericalValue"
#define SBOL_UNIT SBOL_URI "#unit"
#define SBOL_MEASUREMENTS SBOL_URI "#measure"

/* SBOL internal ontologies */
#define SBOL_ACCESS_PRIVATE SBOL_URI "#private" ///< Option for Component::access or FunctionalComponent::access property
Expand Down
155 changes: 77 additions & 78 deletions source/dbtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,13 @@ namespace sbol
// If the progenitor object is a Build, set samples property to the Build
test.samples.set(this->identity.get());
}
else if (properties[SYSBIO_URI "#type"].front() == "<" SYSBIO_TEST ">")
{
// The progenitor object is another Test
Test& progenitor = *(Test*)this;
test.samples.copy(progenitor.samples);
}
}

else if (this->type == SBOL_TEST)
{
// The progenitor object is another Test
Test& progenitor = *(Test*)this;
test.samples.copy(progenitor.samples);
}
// Form URI for auto-constructing an Activity
std::string id;
if (Config::getOption("sbol_compliant_uris") == "True")
Expand Down Expand Up @@ -544,16 +543,16 @@ namespace sbol

}

template<>
void Document::add<Test>(Test& sbol_obj)
{
// Call recursive adder
add<Collection>((Collection&)sbol_obj);
// Move from Collection store to Test store
this->owned_objects[SBOL_COLLECTION].pop_back();
this->owned_objects[SYSBIO_TEST].push_back(&sbol_obj);
}
// template<>
// void Document::add<Test>(Test& sbol_obj)
// {
// // Call recursive adder
// add<Collection>((Collection&)sbol_obj);
//
// // Move from Collection store to Test store
// this->owned_objects[SBOL_COLLECTION].pop_back();
// this->owned_objects[SYSBIO_TEST].push_back(&sbol_obj);
// }

// template<>
// Build& OwnedObject<Build>::get(std::string uri)
Expand Down Expand Up @@ -635,67 +634,67 @@ namespace sbol
}
}

template<>
Test& OwnedObject<Test>::create(std::string uri)
{
Test* child_obj = new Test();

SBOLObject* parent_obj = this->sbol_owner;
Document* parent_doc = this->sbol_owner->doc;

if (Config::getOption("sbol_compliant_uris").compare("True") == 0)
{
string persistent_id = getHomespace();
if (Config::getOption("sbol_typed_uris").compare("True") == 0)
persistent_id += "/" + parseClassName(SYSBIO_TEST);
string version = VERSION_STRING;
string child_persistent_id = persistent_id + "/" + uri;
string child_id = child_persistent_id + "/" + version;
// Check for uniqueness of URI in the Document
if (parent_doc && parent_doc->find(child_id))
throw SBOLError(DUPLICATE_URI_ERROR, "An object with URI " + child_id + " is already in the Document");
// Initialize SBOLCompliant properties
child_obj->identity.set(child_id);
child_obj->persistentIdentity.set(child_persistent_id);
child_obj->displayId.set(uri);
child_obj->version.set(version);

// Add the new object to this OwnedObject property
// this->add(*child_obj); Can't use this because the add method is prohibited in SBOLCompliant mode!!!
child_obj->parent = parent_obj; // Set back-pointer to parent object
std::vector< sbol::SBOLObject* >& object_store = this->sbol_owner->owned_objects[this->type];
object_store.push_back((SBOLObject*)child_obj);

// The following effectively adds the child object to the Document by setting its back-pointer. However, the Document itself only maintains a register of TopLevel objects, otherwise the returned object will not be registered
if (parent_doc)
{
child_obj->doc = parent_doc;
parent_doc->SBOLObjects[child_id] = (SBOLObject*)child_obj;
}
this->validate(child_obj);
return *child_obj;
}
else
{
if (parent_doc && parent_doc->find(uri))
throw SBOLError(DUPLICATE_URI_ERROR, "An object with URI " + uri + " is already in the Document");
// Add the new object to this OwnedObject property
Identified* parent_obj = (Identified*)this->sbol_owner;
child_obj->parent = parent_obj; // Set back-pointer to parent object
child_obj->identity.set(uri);
child_obj->persistentIdentity.set(uri);
this->add(*child_obj);
if (parent_doc)
child_obj->doc = parent_doc;
this->validate(child_obj);
return *child_obj;
}
}
// template<>
// Test& OwnedObject<Test>::create(std::string uri)
// {
// Test* child_obj = new Test();
//
// SBOLObject* parent_obj = this->sbol_owner;
// Document* parent_doc = this->sbol_owner->doc;
//
// if (Config::getOption("sbol_compliant_uris").compare("True") == 0)
// {
// string persistent_id = getHomespace();
// if (Config::getOption("sbol_typed_uris").compare("True") == 0)
// persistent_id += "/" + parseClassName(SYSBIO_TEST);
// string version = VERSION_STRING;
//
// string child_persistent_id = persistent_id + "/" + uri;
// string child_id = child_persistent_id + "/" + version;
//
// // Check for uniqueness of URI in the Document
// if (parent_doc && parent_doc->find(child_id))
// throw SBOLError(DUPLICATE_URI_ERROR, "An object with URI " + child_id + " is already in the Document");
//
// // Initialize SBOLCompliant properties
// child_obj->identity.set(child_id);
// child_obj->persistentIdentity.set(child_persistent_id);
// child_obj->displayId.set(uri);
// child_obj->version.set(version);
//
// // Add the new object to this OwnedObject property
// // this->add(*child_obj); Can't use this because the add method is prohibited in SBOLCompliant mode!!!
// child_obj->parent = parent_obj; // Set back-pointer to parent object
// std::vector< sbol::SBOLObject* >& object_store = this->sbol_owner->owned_objects[this->type];
// object_store.push_back((SBOLObject*)child_obj);
//
// // The following effectively adds the child object to the Document by setting its back-pointer. However, the Document itself only maintains a register of TopLevel objects, otherwise the returned object will not be registered
// if (parent_doc)
// {
// child_obj->doc = parent_doc;
// parent_doc->SBOLObjects[child_id] = (SBOLObject*)child_obj;
// }
// this->validate(child_obj);
// return *child_obj;
// }
// else
// {
// if (parent_doc && parent_doc->find(uri))
// throw SBOLError(DUPLICATE_URI_ERROR, "An object with URI " + uri + " is already in the Document");
//
// // Add the new object to this OwnedObject property
// Identified* parent_obj = (Identified*)this->sbol_owner;
// child_obj->parent = parent_obj; // Set back-pointer to parent object
// child_obj->identity.set(uri);
// child_obj->persistentIdentity.set(uri);
//
// this->add(*child_obj);
// if (parent_doc)
// child_obj->doc = parent_doc;
// this->validate(child_obj);
// return *child_obj;
// }
// }

//
// template<>
Expand Down
Loading

0 comments on commit 60022a9

Please sign in to comment.