void insertAnnotationAfter(SequenceAnnotation* upstream, SequenceAnnotation* new_annotation) { // Update start and end of annotation int insert_size = strlen(getDNASequenceNucleotides(getDNAComponentSequence(getSequenceAnnotationSubComponent(new_annotation)))); int insertion_site = getPositionProperty(upstream->genbankEnd) + 1; setSequenceAnnotationStart(new_annotation, insertion_site); setSequenceAnnotationEnd(new_annotation, insertion_site + insert_size - 1); // Update precedes relationship of annotations SequenceAnnotation* downstream = NULL; if (getNumPointersInArray(upstream->precedes) > 0) { downstream = getNthPrecedes(upstream, 0); removePrecedesRelationship(upstream, downstream); addPrecedesRelationship(upstream, new_annotation); addPrecedesRelationship(new_annotation, downstream); upstream = new_annotation; // Update all start and end indices for annotations downstream from insertion int old_start, old_end = 0; int new_start = 0; int new_end = 0; while (getNumPointersInArray(upstream->precedes) > 0) { downstream = getNthPrecedes(upstream, 0); old_start = getPositionProperty(downstream->genbankStart); old_end = getPositionProperty(downstream->genbankEnd); new_start = old_start + insert_size; new_end = old_end + insert_size; setPositionProperty(downstream->genbankStart, new_start); setPositionProperty(downstream->genbankEnd, new_end); upstream = downstream; } } }
static void writeDNASequence(DNASequence* seq) { if (!seq) return; xmlTextWriterStartElement(WRITER, xmlCharStrdup(NSPREFIX_SBOL ":" NODENAME_DNASEQUENCE)); xmlTextWriterWriteAttribute(WRITER, xmlCharStrdup(NSPREFIX_RDF ":" NODENAME_ABOUT), xmlCharStrdup(getDNASequenceURI(seq))); // nucleotides if (!alreadyProcessed((void *)seq)) { char* nt = getDNASequenceNucleotides(seq); if (nt) { xmlTextWriterWriteElement(WRITER, xmlCharStrdup(NSPREFIX_SBOL ":" NODENAME_NUCLEOTIDES), xmlCharStrdup(nt)); markProcessed((void *)seq); } free(nt); } xmlTextWriterEndElement(WRITER); }