Esempio n. 1
0
static void readSequenceAnnotationReferences(xmlNode *node) {
	SequenceAnnotation *ann;
	xmlChar *path;
	xmlChar *ann_uri;
	xmlChar *ref_uri;
	xmlNode *ref_node;
	PointerArray *results;
	int n;

 	// get SequenceAnnotation
	ann_uri = getNodeURI(node);
	ann = getSequenceAnnotation(DESTINATION, (char *)ann_uri);
	xmlFree(ann_uri);

	// add subComponent
	path = BAD_CAST "./" NSPREFIX_SBOL ":" NODENAME_SUBCOMPONENT
					 "/" NSPREFIX_SBOL ":" NODENAME_DNACOMPONENT;
	if ((ref_uri = getURIOfNodeMatchingXPath(node, path))) {
		setSequenceAnnotationSubComponent(ann, getDNAComponent(DESTINATION, (char *)ref_uri));
		xmlFree(ref_uri);
	}

	// add precedes
	path = BAD_CAST "./" NSPREFIX_SBOL ":" NODENAME_PRECEDES;
	if ((results = getNodesMatchingXPath(node, path))) {
		for (n=0; n<getNumPointersInArray(results); n++) {
			ref_node = (xmlNode *) getNthPointerInArray(results, n);
			ref_uri  = getNodeURI(ref_node);
			addPrecedesRelationship(ann, getSequenceAnnotation(DESTINATION, (char *)ref_uri));
			xmlFree(ref_uri);
		}
		deletePointerArray(results);
	}
}
Esempio n. 2
0
static void readCollectionReferences(xmlNode *node) {
    Collection *col;
	xmlChar *path;
    xmlChar *col_uri;
    xmlChar *ref_uri;
    PointerArray *ref_nodes;
    xmlNode *ref_node;
    int n;

    // get Collection
    col_uri = getNodeURI(node);
    col = getCollection(DESTINATION, (char *)col_uri);
    xmlFree(col_uri);

    // add components
    path = BAD_CAST "./" NSPREFIX_SBOL ":" NODENAME_COMPONENT
    				 "/" NSPREFIX_SBOL ":" NODENAME_DNACOMPONENT;
    if ((ref_nodes = getNodesMatchingXPath(node, path))) {
        for (n=0; n<getNumPointersInArray(ref_nodes); n++) {
            ref_node = (xmlNode *) getNthPointerInArray(ref_nodes, n);
            ref_uri = getNodeURI(ref_node);
            addDNAComponentToCollection(col, getDNAComponent(DESTINATION, (char *)ref_uri));
            xmlFree(ref_uri);
        }
        deletePointerArray(ref_nodes);
    }
}
Esempio n. 3
0
static xmlNode *getSingleNodeMatchingXPath(xmlNode *node, xmlChar *path) {
	PointerArray *results_array = getNodesMatchingXPath(node, path);
	if (!results_array)
		return NULL;
	else if (getNumPointersInArray(results_array) == 0) {
		deletePointerArray(results_array);
		return NULL;
	} else {
		if (getNumPointersInArray(results_array) > 1) {
			#ifdef SBOL_DEBUG_STATEMENTS
			printf("Got too many nodes matching xpath %s\n", (char *)path);
			#endif
		}
		xmlNode *result = getNthPointerInArray(results_array, 0);
		deletePointerArray(results_array);
		return result;
	}
}
Esempio n. 4
0
static void cleanupSBOLWriter() {
	xmlFreeTextWriter(WRITER);
	xmlFreeDoc(OUTPUT);
	WRITER = NULL;
	OUTPUT = NULL;
	deletePointerArray(PROCESSED);
	PROCESSED = NULL;
	xmlCleanupParser();
}
Esempio n. 5
0
static void applyFunctionToNodesMatchingXPath(void (*fn)(xmlNode *), xmlNode *node, xmlChar *path) {
	if (!path)
		return;
	PointerArray *results = getNodesMatchingXPath(node, path);
	if (results) {
        if (getNumPointersInArray(results) > 0) {
            int n;
            for (n=0; n<getNumPointersInArray(results); n++)
                fn(getNthPointerInArray(results, n));
        }
	deletePointerArray(results);
    }
}
Esempio n. 6
0
void deleteSBOLObject(SBOLObject* obj) {
	if (obj) {
		if (obj->uri) {
			deleteURIProperty(obj->uri);
			obj->uri = NULL;
		}
		if (obj->xml_annotations) {
			/// @todo free xmlNodes contained in PointerArray
			deletePointerArray(obj->xml_annotations);
		}
		//free(obj); /// @todo what's wrong with this?
		obj = NULL;
	}
}
Esempio n. 7
0
void deleteCollection(Collection* col) {
	if (col) {
		if (col->base) {
			deleteSBOLCompoundObject(col->base);
			col->base = NULL;
		}
		if (col->components) {
			deletePointerArray(col->components);
			col->components = NULL;
		}
		if (col->doc) {
			removeCollection(col->doc, col);
			col->doc = NULL;
		}
		free(col);
		col = NULL;
	}
}
Esempio n. 8
0
void deleteSequenceAnnotation(SequenceAnnotation* ann) {
	if (ann) {
		if (ann->base)
			deleteSBOLObject(ann->base);
			ann->base = NULL;
		if (ann->subComponent)
			ann->subComponent = NULL;
		if (ann->precedes) {
			deletePointerArray(ann->precedes);
			ann->precedes = NULL; // TODO needed?
		}
		if (ann->doc) {
			removeSequenceAnnotation(ann->doc, ann);
			ann->doc = NULL;
		}
		free(ann);
		ann = NULL;
	}
}
Esempio n. 9
0
static void readDNAComponentReferences(xmlNode *node) {
    DNAComponent *com;
	xmlChar *path;
    xmlChar *com_uri;
    xmlChar *ref_uri;
    PointerArray *ref_nodes;
    xmlNode *ref_node;
    int n;

    // get DNAComponent
    com_uri = getNodeURI(node);
    com = getDNAComponent(DESTINATION, (char *)com_uri);
    xmlFree(com_uri);

    // add sequence
    path = BAD_CAST "./" NSPREFIX_SBOL ":" NODENAME_DNASEQUENCE_REF
    				 "/" NSPREFIX_SBOL ":" NODENAME_DNASEQUENCE;
    if ((ref_uri = getURIOfNodeMatchingXPath(node, path))) {
        setDNAComponentSequence(com, getDNASequence(DESTINATION, (char *)ref_uri));
        xmlFree(ref_uri);
    }
    
    // add annotations
    path = BAD_CAST "./" NSPREFIX_SBOL ":" NODENAME_ANNOTATION
      "/" NSPREFIX_SBOL ":" NODENAME_SEQUENCEANNOTATION;

    if ((ref_nodes = getNodesMatchingXPath(node, path))) {
        for (n=0; n<getNumPointersInArray(ref_nodes); n++) {
            ref_node = (xmlNode *) getNthPointerInArray(ref_nodes, n);
            ref_uri = getNodeURI(ref_node);
            addSequenceAnnotation(com, getSequenceAnnotation(DESTINATION, (char *)ref_uri));
            xmlFree(ref_uri);
        }
        deletePointerArray(ref_nodes);
    }
}
Esempio n. 10
0
static void resetProcessed() {
	deletePointerArray(PROCESSED);
	PROCESSED = createPointerArray();
}