Skip to content

Commit

Permalink
Merge pull request #328 from SynBioDex/fix-reverse--complement
Browse files Browse the repository at this point in the history
Reverse Complement Sequences
  • Loading branch information
Drock54651 authored Sep 25, 2024
2 parents f757578 + 8fa7058 commit c3feff1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
1 change: 0 additions & 1 deletion SBOLCanvasBackend/src/utils/SBOLToMx.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.util.List;
import java.util.Set;
import java.util.Stack;
import java.util.concurrent.atomic.AtomicBoolean;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
Expand Down
23 changes: 22 additions & 1 deletion SBOLCanvasFrontend/src/app/graph-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,15 @@ export class GraphHelpers extends GraphBase {
if (child) childGlyphInfo = this.getFromInfoDict(child.value)

if (childGlyphInfo !== undefined && childGlyphInfo.sequence) {
glyphInfo.sequence += childGlyphInfo.sequence
let direction = this.graph.getCellStyle(child)[mx.mxConstants.STYLE_DIRECTION]

// Cell is flipped
if(direction === "west"){
glyphInfo.sequence += this.reverseComplement(childGlyphInfo.sequence)
}
else{
glyphInfo.sequence += childGlyphInfo.sequence
}
}
}
}
Expand Down Expand Up @@ -2166,6 +2174,19 @@ export class GraphHelpers extends GraphBase {
circuitContainer.refreshCircuitContainer(this.graph)
}

private reverseComplement(glyphSequence: string){
glyphSequence = glyphSequence.split("").reverse().join("")
let reverseComplement = ""

const complementDict = {"a":"t", "t":"a", "c":"g", "g":"c"}

for(let base of glyphSequence.toLowerCase()){
reverseComplement += complementDict[base] || base
}

return glyphSequence === glyphSequence.toUpperCase() ? reverseComplement.toUpperCase() : reverseComplement
}

protected createViewCell(uri: string, module: boolean = false): mxCell {
// construct the view cell
const cell1 = this.graph.getModel().getCell(1)
Expand Down
9 changes: 2 additions & 7 deletions SBOLCanvasFrontend/src/app/graph.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,7 @@ export class GraphService extends GraphHelpers {
this.graph.setCellStyles(mx.mxConstants.STYLE_DIRECTION, "east", [cell])
console.debug("turning east")
}

// if a glyph has been flipped its sequence needs to be reversed
let glyphInfo
if (cell) glyphInfo = this.getFromInfoDict(cell.value)
glyphInfo.sequence = glyphInfo.sequence.split("").reverse().join("")

this.metadataService.setSelectedGlyphInfo(glyphInfo)

} else if (cell.isInteraction()) {
this.flipInteractionEdge(cell)
} else if (cell.isInteractionNode()) {
Expand Down Expand Up @@ -654,6 +648,7 @@ export class GraphService extends GraphHelpers {
*/
copy(){
mx.mxClipboard.copy(this.graph, this.graph.getSelectionCells())
console.log(this.graph.getSelectionCell())
}

// Map old cells to newly created cells in the paste method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class InfoEditorComponent implements OnInit {
}

getTypes() {
this.metadataService.loadTypes().subscribe(types => this.partTypes = types);
this.metadataService.loadTypes().subscribe(types => this.partTypes = types.filter(type => type != "Circular"));
}

getRoles() {
Expand Down

0 comments on commit c3feff1

Please sign in to comment.