Serialization/Unserialization issues
-
Hi Elisa,
The parent functions do many things (all the way up to
SBNode
itself, i.e.SBStructuralModel::serialize
callsSBModel::serialize
which callsSBNode::serialize
) and are needed for correct saving and loading of node properties.I'm not sure what you mean by "non bottom-up model", but serialization works even for nodes that reference each other in a non-bottom-up way, thanks to the
nodeIndexer
that's passed to the function (we need to include this in the documentation). Here's how it works.When SAMSON serializes a group of nodes, it proceeds in two passes:
- First, all nodes are added to a
nodeIndexer
. This way, each node that's about to be serialized has an index. It's those indices that need to be used to indicate which nodes are referenced by other nodes. The reason is that, for example if you save to a file, you will not be able to recreate nodes at the same memory addresses. - Then, the
serialize
function of each node is called. This function receives thenodeIndexer
.
Assume for example a bond pointing to its left atom and right atom. Its
serialize
function looks like this:unsigned int leftAtomIndex = 0; // the index of the left atom in the indexer if (nodeIndexer.getIndex(getLeftAtom(), leftAtomIndex)) { // the left atom is indexed serializer->writeBoolElement("leftAtomIsIndexed", true); serializer->writeUnsignedIntElement("leftAtomIndex", leftAtomIndex); } else { // the left atom is not indexed, the user must be copying just the bond // so we serialize the atom address itself serializer->writeBoolElement("leftAtomIsIndexed", false); serializer->writeUnsignedLongLongElement("leftAtomAddress", (unsigned long long)getLeftAtom()); } // same for the right atom
During unserialization, SAMSON also proceeds in two steps:
- First, it creates all required nodes and indexes them in a
nodeIndexer
, in the same order as during serialization. - Then, the
unserialize
function of each node is called. This function receives thenodeIndexer
.
Thus, the
unserialize
function of a bond looks like this:bool leftAtomIsIndexed = serializer->readBoolElement(); if (leftAtomIsIndexed) { // the left atom was serialized too unsigned int leftAtomIndex = serializer->readUnsignedIntElement(); setLeftAtom(static_cast<SBAtom*>(nodeIndexer[leftAtomIndex])); // note how nodeIndexer[leftAtomIndex] contains the new address of the new left atom, which was also serialized } else { // the left atom was not serialized, it must still exist in memory setLeftAtom((SBAtom*)serializer->readUnsignedLongLongElement()); } // same for the right atom
I hope this helps,
Best,
Stephane
- First, all nodes are added to a
-
Hi Stephane,
Sorry for the late reply, my laptop broke and I couldn't test it.
The problem that I'm having is that when calling the parent functions the unserialize function crashes:
void MyStructuralModel::serialize(SBCSerializer * serializer, const SBNodeIndexer & nodeIndexer, const SBVersionNumber & sdkVersionNumber, const SBVersionNumber & classVersionNumber) { SBStructuralModel::serialize(serializer, nodeIndexer, sdkVersionNumber, classVersionNumber); serializer->writeIntElement("one_property", number1); serializer->writeIntElement("another_property", number2); }
and:
void MyStructuralModel::unserialize(SBCSerializer * serializer, const SBNodeIndexer & nodeIndexer, const SBVersionNumber & sdkVersionNumber, const SBVersionNumber & classVersionNumber) { SBStructuralModel::unserialize(serializer, nodeIndexer, sdkVersionNumber, classVersionNumber); int p1 = serializer->readIntElement(); int p2 = serializer->readIntElement(); }
After saving, I get the crash at
int p1 = serializer->readIntElement();
as an overflow, like the serializer didn't move into the next value.I can avoid this crash if I don't call the parent functions, but then if I save more than one of my models, it will crash (again same error, probably because I'm reading something else from the .samx file)
I think this might be because I didn't implement serialize and unserialize functions for all elements of my model, I just re-used the code that we had for our internal saving (we are using json). I will try to set properly all serialize/unserialize functions.
Best regards,
Elisa
-
Sorry for the double posting,
I have now done very basic serialization in my model, basically every element calls the parent function serialize or unserialize methods. I get all the nodes back, except for the atoms belonging to classes inheriting from SBBackbone and SBSideChain.
void MyBackbone::serialize(SBCSerializer * serializer, const SBNodeIndexer & nodeIndexer, const SBVersionNumber & sdkVersionNumber, const SBVersionNumber & classVersionNumber) const { SBBackbone::serialize(serializer, nodeIndexer, sdkVersionNumber, classVersionNumber); } void MyBackbone::unserialize(SBCSerializer * serializer, const SBNodeIndexer & nodeIndexer, const SBVersionNumber & sdkVersionNumber, const SBVersionNumber & classVersionNumber) { SBBackbone::unserialize(serializer, nodeIndexer, sdkVersionNumber, classVersionNumber); SB_FOR(SBNode* n, *getChildren()) { SBPointer<MyAtom> at = static_cast<MyAtom*>(n); //at->create(); } }
I can check in this way that the atoms are correctly added as children to MyBackbone, but they are not created in the Datagraph. I don't have this problem with classes deriving from SBStructuralGroup, where atoms are correctly created in the data graph.
Thanks and best regards!
Elisa
-
Hi Elisa,
if this is not confidential, could you please post the contents of the simplest .samx file that creates an issue with a backbone?
Stephane
-
The file is quite long, so I will post the relevant parts:
<SAMSON> <majorVersionNumber> 0 </majorVersionNumber> <minorVersionNumber> 7 </minorVersionNumber> <patchVersionNumber> 0 </patchVersionNumber> <numberOfNodeTypes> 15 </numberOfNodeTypes> <nodeTypes> <nodeType> <nodeTypeIndex> 0 </nodeTypeIndex> <className> MySidechain </className> <elementUUID> DDA2A078-1AB6-96BA-0D14-EE1717632D7A </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 1.0.0 </classVersionNumber> </nodeType> <nodeType> <nodeTypeIndex> 1 </nodeTypeIndex> <className> MyBackbone </className> <elementUUID> DDA2A078-1AB6-96BA-0D14-EE1717632D7A </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 1.0.0 </classVersionNumber> </nodeType> ... <nodeType> <nodeTypeIndex> 4 </nodeTypeIndex> <className> MyStructuralGroup </className> <elementUUID> DDA2A078-1AB6-96BA-0D14-EE1717632D7A </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 1.0.0 </classVersionNumber> </nodeType> ... <nodeType> <nodeTypeIndex> 11 </nodeTypeIndex> <className> SBMStructuralModelNodeRoot </className> <elementUUID> 5A3CE002-9368-1EAF-7DBA-66567958AB1F </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 0.7.0 </classVersionNumber> </nodeType> <nodeType> <nodeTypeIndex> 12 </nodeTypeIndex> <className> SBDDocumentCamera </className> <elementUUID> 131D70CF-3B19-61A8-B67C-BBDA93776B38 </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 0.7.0 </classVersionNumber> </nodeType> <nodeType> <nodeTypeIndex> 13 </nodeTypeIndex> <className> SBDDocumentLayer </className> <elementUUID> 131D70CF-3B19-61A8-B67C-BBDA93776B38 </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 0.7.0 </classVersionNumber> </nodeType> <nodeType> <nodeTypeIndex> 14 </nodeTypeIndex> <className> SBDDocument </className> <elementUUID> 131D70CF-3B19-61A8-B67C-BBDA93776B38 </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 0.7.0 </classVersionNumber> </nodeType> </nodeTypes> ... <nodeContents> <node> <index> 0 </index> <expandedFlag> 1 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <numberOfCameras> 1 </numberOfCameras> <nodeIndex> 1 </nodeIndex> <numberOfLayers> 1 </numberOfLayers> <nodeIndex> 2 </nodeIndex> <numberOfGroups> 0 </numberOfGroups> <numberOfStoredConformations> 0 </numberOfStoredConformations> <numberOfStoredPaths> 0 </numberOfStoredPaths> <activeCameraIndex> 1 </activeCameraIndex> <activeLayerIndex> 2 </activeLayerIndex> </node> <node> <index> 1 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <name> Camera 1 </name> <eyePosition> <v[0]> -49817.3 </v[0]> <v[1]> -37448.3 </v[1]> <v[2]> -27528.1 </v[2]> </eyePosition> <targetPosition> <v[0]> -2.47394 </v[0]> <v[1]> -0.57391 </v[1]> <v[2]> -5.94904 </v[2]> </targetPosition> <upVector> <v[0]> -0.569802 </v[0]> <v[1]> 0.166545 </v[1]> <v[2]> 0.804729 </v[2]> </upVector> <nearPlane> 100 </nearPlane> <farPlane> 2e+06 </farPlane> <aspectRatio> 1.41675 </aspectRatio> <fieldOfViewAngleY> 19 </fieldOfViewAngleY> <inertiaFlag> 0 </inertiaFlag> </node> <node> <index> 2 </index> <expandedFlag> 1 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <name> Layer 1 </name> <numberOfModels> 1 </numberOfModels> <nodeIndex> 3 </nodeIndex> <numberOfSimulators> 0 </numberOfSimulators> <numberOfControllers> 0 </numberOfControllers> <numberOfLabels> 0 </numberOfLabels> <hasActiveModel> 0 </hasActiveModel> </node> <node> <index> 3 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <name> 01_tetrahedron </name> <rootIndex> 4 </rootIndex> <propertyFlags> 0 </propertyFlags> <backboneNeighborGridInitialized> 0 </backboneNeighborGridInitialized> </node> <node> <index> 4 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <name> Nodes </name> <numberOfChildren> 26 </numberOfChildren> <nodeIndex> 5 </nodeIndex> <nodeIndex> 137 </nodeIndex> <nodeIndex> 269 </nodeIndex> <nodeIndex> 401 </nodeIndex> <nodeIndex> 533 </nodeIndex> <nodeIndex> 665 </nodeIndex> <nodeIndex> 797 </nodeIndex> <nodeIndex> 929 </nodeIndex> <nodeIndex> 1061 </nodeIndex> <nodeIndex> 1193 </nodeIndex> <nodeIndex> 1325 </nodeIndex> <nodeIndex> 1457 </nodeIndex> <nodeIndex> 1589 </nodeIndex> <nodeIndex> 4110 </nodeIndex> <nodeIndex> 4321 </nodeIndex> <nodeIndex> 4427 </nodeIndex> <nodeIndex> 4533 </nodeIndex> <nodeIndex> 4639 </nodeIndex> <nodeIndex> 4745 </nodeIndex> <nodeIndex> 4956 </nodeIndex> <nodeIndex> 5062 </nodeIndex> <nodeIndex> 5168 </nodeIndex> <nodeIndex> 5379 </nodeIndex> <nodeIndex> 5770 </nodeIndex> <nodeIndex> 6161 </nodeIndex> <nodeIndex> 6552 </nodeIndex> <propertyFlags> 0 </propertyFlags> </node> ... <node> <index> 6 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <name> My Structural Group </name> <numberOfChildren> 2 </numberOfChildren> <nodeIndex> 7 </nodeIndex> <nodeIndex> 8 </nodeIndex> <propertyFlags> 0 </propertyFlags> </node> ... <node> <index> 8 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 0 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <position> <v[0]> -1485.23 </v[0]> <v[1]> 172.5 </v[1]> <v[2]> 9081.48 </v[2]> </position> <element> 109 </element> <propertyFlags> 0 </propertyFlags> </node> ... <node> <index> 6552 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <name> Chain </name> <numberOfChildren> 78 </numberOfChildren> <nodeIndex> 6553 </nodeIndex> ... <propertyFlags> 0 </propertyFlags> </node> <node> <index> 6553 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <name> Nucleotide </name> <numberOfChildren> 2 </numberOfChildren> <nodeIndex> 6554 </nodeIndex> <nodeIndex> 6556 </nodeIndex> <propertyFlags> 0 </propertyFlags> <residueType> 34 </residueType> <residueTypeString> </residueTypeString> </node> <node> <index> 6554 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <name> Backbone </name> <numberOfChildren> 1 </numberOfChildren> <nodeIndex> 6555 </nodeIndex> <propertyFlags> 0 </propertyFlags> </node> <node> <index> 6555 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 0 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <position> <v[0]> 5569.81 </v[0]> <v[1]> 2913.26 </v[1]> <v[2]> -3182.39 </v[2]> </position> <element> 99 </element> <propertyFlags> 0 </propertyFlags> </node> <node> <index> 6556 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <name>Sidechain </name> <numberOfChildren> 1 </numberOfChildren> <nodeIndex> 6557 </nodeIndex> <propertyFlags> 0 </propertyFlags> </node> <node> <index> 6557 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 0 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <position> <v[0]> 5667.77 </v[0]> <v[1]> 2915.8 </v[1]> <v[2]> -2721.34 </v[2]> </position> <element> 100 </element> <propertyFlags> 0 </propertyFlags> </node> ... </nodeContents> </SAMSON>
Everything is in the data graph except for the atoms belonging to the backbone and sidechain.
-
I might need more information from the file but a quick check indicates that the visibility flag of the atoms is set to false:
<visibilityFlag> 0 </visibilityFlag>
Is this normal? Also, do you have a
MyAtom
class or you use theSBAtom
class? There are also Einsteinium and Meitnerium atoms? -
It is normal, we hide them on purpose.
MyAtom class inherits from SBAtom, yes. I will try to produce a very small example so I can paste the entire file.
Edit: This is a small full sample
<SAMSON> <majorVersionNumber> 0 </majorVersionNumber> <minorVersionNumber> 7 </minorVersionNumber> <patchVersionNumber> 0 </patchVersionNumber> <numberOfNodeTypes> 13 </numberOfNodeTypes> <nodeTypes> <nodeType> <nodeTypeIndex> 0 </nodeTypeIndex> <className> MySidechain </className> <elementUUID> DDA2A078-1AB6-96BA-0D14-EE1717632D7A </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 1.0.0 </classVersionNumber> </nodeType> <nodeType> <nodeTypeIndex> 1 </nodeTypeIndex> <className> MyBackbone </className> <elementUUID> DDA2A078-1AB6-96BA-0D14-EE1717632D7A </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 1.0.0 </classVersionNumber> </nodeType> <nodeType> <nodeTypeIndex> 2 </nodeTypeIndex> <className> MyChain </className> <elementUUID> DDA2A078-1AB6-96BA-0D14-EE1717632D7A </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 1.0.0 </classVersionNumber> </nodeType> <nodeType> <nodeTypeIndex> 3 </nodeTypeIndex> <className> MyStructuralModel </className> <elementUUID> DDA2A078-1AB6-96BA-0D14-EE1717632D7A </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 1.0.0 </classVersionNumber> </nodeType> <nodeType> <nodeTypeIndex> 4 </nodeTypeIndex> <className> MyStructuralGroup </className> <elementUUID> DDA2A078-1AB6-96BA-0D14-EE1717632D7A </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 1.0.0 </classVersionNumber> </nodeType> <nodeType> <nodeTypeIndex> 5 </nodeTypeIndex> <className> MyResidue </className> <elementUUID> DDA2A078-1AB6-96BA-0D14-EE1717632D7A </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 1.0.0 </classVersionNumber> </nodeType> <nodeType> <nodeTypeIndex> 6 </nodeTypeIndex> <className> MyAtom </className> <elementUUID> DDA2A078-1AB6-96BA-0D14-EE1717632D7A </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 1.0.0 </classVersionNumber> </nodeType> <nodeType> <nodeTypeIndex> 7 </nodeTypeIndex> <className> MyStructuralGroup2 </className> <elementUUID> DDA2A078-1AB6-96BA-0D14-EE1717632D7A </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 1.0.0 </classVersionNumber> </nodeType> <nodeType> <nodeTypeIndex> 8 </nodeTypeIndex> <className> MyStructuralGroup3 </className> <elementUUID> DDA2A078-1AB6-96BA-0D14-EE1717632D7A </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 1.0.0 </classVersionNumber> </nodeType> <nodeType> <nodeTypeIndex> 9 </nodeTypeIndex> <className> SBMStructuralModelNodeRoot </className> <elementUUID> 5A3CE002-9368-1EAF-7DBA-66567958AB1F </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 0.7.0 </classVersionNumber> </nodeType> <nodeType> <nodeTypeIndex> 10 </nodeTypeIndex> <className> SBDDocumentCamera </className> <elementUUID> 131D70CF-3B19-61A8-B67C-BBDA93776B38 </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 0.7.0 </classVersionNumber> </nodeType> <nodeType> <nodeTypeIndex> 11 </nodeTypeIndex> <className> SBDDocumentLayer </className> <elementUUID> 131D70CF-3B19-61A8-B67C-BBDA93776B38 </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 0.7.0 </classVersionNumber> </nodeType> <nodeType> <nodeTypeIndex> 12 </nodeTypeIndex> <className> SBDDocument </className> <elementUUID> 131D70CF-3B19-61A8-B67C-BBDA93776B38 </elementUUID> <sdkVersionNumber> 0.7.0 </sdkVersionNumber> <classVersionNumber> 0.7.0 </classVersionNumber> </nodeType> </nodeTypes> <numberOfNodes> 21 </numberOfNodes> <nodes> <nodeTypeIndex> 12 </nodeTypeIndex> <nodeTypeIndex> 10 </nodeTypeIndex> <nodeTypeIndex> 11 </nodeTypeIndex> <nodeTypeIndex> 3 </nodeTypeIndex> <nodeTypeIndex> 9 </nodeTypeIndex> <nodeTypeIndex> 7 </nodeTypeIndex> <nodeTypeIndex> 4 </nodeTypeIndex> <nodeTypeIndex> 8 </nodeTypeIndex> <nodeTypeIndex> 6 </nodeTypeIndex> <nodeTypeIndex> 2 </nodeTypeIndex> <nodeTypeIndex> 5 </nodeTypeIndex> <nodeTypeIndex> 1 </nodeTypeIndex> <nodeTypeIndex> 6 </nodeTypeIndex> <nodeTypeIndex> 0 </nodeTypeIndex> <nodeTypeIndex> 6 </nodeTypeIndex> <nodeTypeIndex> 2 </nodeTypeIndex> <nodeTypeIndex> 5 </nodeTypeIndex> <nodeTypeIndex> 1 </nodeTypeIndex> <nodeTypeIndex> 6 </nodeTypeIndex> <nodeTypeIndex> 0 </nodeTypeIndex> <nodeTypeIndex> 6 </nodeTypeIndex> </nodes> <nodeContents> <node> <index> 0 </index> <expandedFlag> 1 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <numberOfCameras> 1 </numberOfCameras> <nodeIndex> 1 </nodeIndex> <numberOfLayers> 1 </numberOfLayers> <nodeIndex> 2 </nodeIndex> <numberOfGroups> 0 </numberOfGroups> <numberOfStoredConformations> 0 </numberOfStoredConformations> <numberOfStoredPaths> 0 </numberOfStoredPaths> <activeCameraIndex> 1 </activeCameraIndex> <activeLayerIndex> 2 </activeLayerIndex> </node> <node> <index> 1 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <name> Camera 1 </name> <eyePosition> <v[0]> 0 </v[0]> <v[1]> 0 </v[1]> <v[2]> 10000 </v[2]> </eyePosition> <targetPosition> <v[0]> 0 </v[0]> <v[1]> 0 </v[1]> <v[2]> 0 </v[2]> </targetPosition> <upVector> <v[0]> 0 </v[0]> <v[1]> 1 </v[1]> <v[2]> 0 </v[2]> </upVector> <nearPlane> 100 </nearPlane> <farPlane> 2e+06 </farPlane> <aspectRatio> 1.41675 </aspectRatio> <fieldOfViewAngleY> 19 </fieldOfViewAngleY> <inertiaFlag> 0 </inertiaFlag> </node> <node> <index> 2 </index> <expandedFlag> 1 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <name> Layer 1 </name> <numberOfModels> 1 </numberOfModels> <nodeIndex> 3 </nodeIndex> <numberOfSimulators> 0 </numberOfSimulators> <numberOfControllers> 0 </numberOfControllers> <numberOfLabels> 0 </numberOfLabels> <hasActiveModel> 0 </hasActiveModel> </node> <node> <index> 3 </index> <expandedFlag> 1 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <name> Structural model </name> <rootIndex> 4 </rootIndex> <propertyFlags> 0 </propertyFlags> <backboneNeighborGridInitialized> 0 </backboneNeighborGridInitialized> </node> <node> <index> 4 </index> <expandedFlag> 1 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <name> Nodes </name> <numberOfChildren> 3 </numberOfChildren> <nodeIndex> 5 </nodeIndex> <nodeIndex> 9 </nodeIndex> <nodeIndex> 15 </nodeIndex> <propertyFlags> 0 </propertyFlags> </node> <node> <index> 5 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <name> Double Strand 1 </name> <numberOfChildren> 1 </numberOfChildren> <nodeIndex> 6 </nodeIndex> <propertyFlags> 0 </propertyFlags> </node> <node> <index> 6 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <name> Base Segment 4099 </name> <numberOfChildren> 2 </numberOfChildren> <nodeIndex> 7 </nodeIndex> <nodeIndex> 8 </nodeIndex> <propertyFlags> 0 </propertyFlags> </node> <node> <index> 7 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <name> Base Pair 4100 </name> <numberOfChildren> 0 </numberOfChildren> <propertyFlags> 0 </propertyFlags> </node> <node> <index> 8 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 0 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <position> <v[0]> -877.886 </v[0]> <v[1]> 516.92 </v[1]> <v[2]> 0.0153761 </v[2]> </position> <element> 109 </element> <propertyFlags> 0 </propertyFlags> </node> <node> <index> 9 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <name> Single Strand 1 </name> <numberOfChildren> 1 </numberOfChildren> <nodeIndex> 10 </nodeIndex> <propertyFlags> 0 </propertyFlags> </node> <node> <index> 10 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <name> N4102 </name> <numberOfChildren> 2 </numberOfChildren> <nodeIndex> 11 </nodeIndex> <nodeIndex> 13 </nodeIndex> <propertyFlags> 0 </propertyFlags> <residueType> 36 </residueType> <residueTypeString> </residueTypeString> </node> <node> <index> 11 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <name> N4102 Backbone </name> <numberOfChildren> 1 </numberOfChildren> <nodeIndex> 12 </nodeIndex> <propertyFlags> 0 </propertyFlags> </node> <node> <index> 12 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 0 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <position> <v[0]> -970.453 </v[0]> <v[1]> -85.8914 </v[1]> <v[2]> 538.434 </v[2]> </position> <element> 99 </element> <propertyFlags> 0 </propertyFlags> </node> <node> <index> 13 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <name> N4102 Sidechain </name> <numberOfChildren> 1 </numberOfChildren> <nodeIndex> 14 </nodeIndex> <propertyFlags> 0 </propertyFlags> </node> <node> <index> 14 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 0 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <position> <v[0]> -880.731 </v[0]> <v[1]> 352.262 </v[1]> <v[2]> 220.392 </v[2]> </position> <element> 100 </element> <propertyFlags> 0 </propertyFlags> </node> <node> <index> 15 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <name> Single Strand 2 </name> <numberOfChildren> 1 </numberOfChildren> <nodeIndex> 16 </nodeIndex> <propertyFlags> 0 </propertyFlags> </node> <node> <index> 16 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <name> N4108 </name> <numberOfChildren> 2 </numberOfChildren> <nodeIndex> 17 </nodeIndex> <nodeIndex> 19 </nodeIndex> <propertyFlags> 0 </propertyFlags> <residueType> 36 </residueType> <residueTypeString> </residueTypeString> </node> <node> <index> 17 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <name> N4108 Backbone </name> <numberOfChildren> 1 </numberOfChildren> <nodeIndex> 18 </nodeIndex> <propertyFlags> 0 </propertyFlags> </node> <node> <index> 18 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 0 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <position> <v[0]> -788.488 </v[0]> <v[1]> 1018.95 </v[1]> <v[2]> -570.406 </v[2]> </position> <element> 99 </element> <propertyFlags> 0 </propertyFlags> </node> <node> <index> 19 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 1 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <name> N4108 Sidechain </name> <numberOfChildren> 1 </numberOfChildren> <nodeIndex> 20 </nodeIndex> <propertyFlags> 0 </propertyFlags> </node> <node> <index> 20 </index> <expandedFlag> 0 </expandedFlag> <visibilityFlag> 0 </visibilityFlag> <hasMaterial> 0 </hasMaterial> <mobilityFlag> 1 </mobilityFlag> <position> <v[0]> -874.781 </v[0]> <v[1]> 804.363 </v[1]> <v[2]> -159.697 </v[2]> </position> <element> 100 </element> <propertyFlags> 0 </propertyFlags> </node> </nodeContents> </SAMSON>
The atoms below the Sidechain and Backbone are not created when reading the same, but the atom below the structural group is.
Thanks!
-
This looks perfect. Could you please try the following things:
- load the short file above, and send me the log (Edit / Show log / Submit).
- in the document view, select a MyAtom in a MyBackbone, and press Ctrl+C, Ctrl+V. Do you see a copy of the MyAtom appear in the document view? Serialization is also used for copy/paste, so issues should appear at that moment too.
Thanks,
Stephane
-
@stephane-redon
The log doesn't seem to show anything, I submitted it.
In the document view of the original system you can see the atoms in the document view. I attach two pictures showing the system I save and the system after loading the samx file.
Thanks!
PS: The element is now on the samson store, we are still debugging a lot but I could give you access if you want.
PS2: Copy and paste seems to work fine.
And another edit: I assumed the error would be on the atom, but I tried copy and pasting the Backbone or Sidechain and this time it didn't work. Could this be the problem?
-
Could you please add developer [(at)] oneangstrom.com as a collaborator and send me a samx so I can test here?
-
I did some checks in the code like:
void MyBackbone::unserialize(SBCSerializer * serializer, const SBNodeIndexer & nodeIndexer, const SBVersionNumber & sdkVersionNumber, const SBVersionNumber & classVersionNumber)
{
SBBackbone::unserialize(serializer, nodeIndexer, sdkVersionNumber, classVersionNumber);auto test = getNumberOfAtoms();
int here = 1;
}And the number of atoms there looks correct. I tried also with more than one atom, and all the number is still fine, but they are not produced in the data graph. I will try to create a mock project to test this, just in case.
-
You can also check an updated Developer guide: Serialization.
-
@Elisa could you please pack the debug version as well in your SAMSON Element ? (before using the packager, you would need to build both the debug and release version). Thanks!
-
Hi,
I think I found the problem. Some initialization functions in the constructor of my class were overriding the unserialization. I tried to make a quick fix but when I do static casts in the unserialize function, SAMSON is crashing, so I will modify my constructor and check, it will take a bit though.
Thanks for your help!