Skip to content

Commit

Permalink
Fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
leb2 committed Aug 5, 2024
1 parent 822d04b commit 1d22996
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
selectSnakeLayoutModeTool,
selectFlexLayoutModeTool,
clickUndo,
moveMouseAway,
startNewSequence,
moveMouseAway,
waitForRender,
switchSequenceEnteringType,
SequenceType,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -198,76 +198,79 @@ export class SequenceRenderer {
> = new Map();

chainsCollection.chains.forEach((chain) => {
chain.forEachNode(({ node, subChain }) => {
if (node instanceof EmptySequenceNode) {
return;
}

if (!handledMonomersToAttachmentPoints.has(node.monomer)) {
handledMonomersToAttachmentPoints.set(node.monomer, new Set());
}
node.monomer.forEachBond((polymerBond, attachmentPointName) => {
if (!subChain.bonds.includes(polymerBond)) {
subChain.bonds.push(polymerBond);
}
if (!polymerBond.isSideChainConnection) {
polymerBond.setRenderer(
new BackBoneBondSequenceRenderer(polymerBond),
);
return;
}

const handledAttachmentPoints = handledMonomersToAttachmentPoints.get(
node.monomer,
) as Set<AttachmentPointName>;

if (handledAttachmentPoints.has(attachmentPointName)) {
chain.subChains.forEach((subChain) => {
subChain.nodes.forEach((node) => {
if (node instanceof EmptySequenceNode) {
return;
}

const anotherMonomer = polymerBond.getAnotherMonomer(
node.monomer,
) as BaseMonomer;

// Skip handling side chains for sugar(R3) + base(R1) connections.
if (
(node.monomer instanceof Sugar &&
getRnaBaseFromSugar(node.monomer) === anotherMonomer) ||
(anotherMonomer instanceof Sugar &&
getRnaBaseFromSugar(anotherMonomer) === node.monomer)
) {
return;
if (!handledMonomersToAttachmentPoints.has(node.monomer)) {
handledMonomersToAttachmentPoints.set(node.monomer, new Set());
}

let bondRenderer;

// If side connection comes from rna base then take connected sugar and draw side connection from it
// because for rna we display only one letter instead of three
const connectedSugarToBase = getSugarFromRnaBase(anotherMonomer);
if (anotherMonomer instanceof RNABase && connectedSugarToBase) {
bondRenderer = new PolymerBondSequenceRenderer(
new PolymerBond(node.monomer, connectedSugarToBase),
node.monomer.forEachBond((polymerBond, attachmentPointName) => {
if (!subChain.bonds.includes(polymerBond)) {
subChain.bonds.push(polymerBond);
}
if (!polymerBond.isSideChainConnection) {
polymerBond.setRenderer(
new BackBoneBondSequenceRenderer(polymerBond),
);
return;
}

const handledAttachmentPoints =
handledMonomersToAttachmentPoints.get(
node.monomer,
) as Set<AttachmentPointName>;

if (handledAttachmentPoints.has(attachmentPointName)) {
return;
}

const anotherMonomer = polymerBond.getAnotherMonomer(
node.monomer,
) as BaseMonomer;

// Skip handling side chains for sugar(R3) + base(R1) connections.
if (
(node.monomer instanceof Sugar &&
getRnaBaseFromSugar(node.monomer) === anotherMonomer) ||
(anotherMonomer instanceof Sugar &&
getRnaBaseFromSugar(anotherMonomer) === node.monomer)
) {
return;
}

let bondRenderer;

// If side connection comes from rna base then take connected sugar and draw side connection from it
// because for rna we display only one letter instead of three
const connectedSugarToBase = getSugarFromRnaBase(anotherMonomer);
if (anotherMonomer instanceof RNABase && connectedSugarToBase) {
bondRenderer = new PolymerBondSequenceRenderer(
new PolymerBond(node.monomer, connectedSugarToBase),
);
} else {
bondRenderer = new PolymerBondSequenceRenderer(polymerBond);
}
bondRenderer.show();
polymerBond.setRenderer(bondRenderer);
handledAttachmentPoints.add(attachmentPointName);

if (!handledMonomersToAttachmentPoints.get(anotherMonomer)) {
handledMonomersToAttachmentPoints.set(anotherMonomer, new Set());
}
const anotherMonomerHandledAttachmentPoints =
handledMonomersToAttachmentPoints.get(
anotherMonomer,
) as Set<AttachmentPointName>;

anotherMonomerHandledAttachmentPoints.add(
anotherMonomer?.getAttachmentPointByBond(
polymerBond,
) as AttachmentPointName,
);
} else {
bondRenderer = new PolymerBondSequenceRenderer(polymerBond);
}
bondRenderer.show();
polymerBond.setRenderer(bondRenderer);
handledAttachmentPoints.add(attachmentPointName);

if (!handledMonomersToAttachmentPoints.get(anotherMonomer)) {
handledMonomersToAttachmentPoints.set(anotherMonomer, new Set());
}
const anotherMonomerHandledAttachmentPoints =
handledMonomersToAttachmentPoints.get(
anotherMonomer,
) as Set<AttachmentPointName>;

anotherMonomerHandledAttachmentPoints.add(
anotherMonomer?.getAttachmentPointByBond(
polymerBond,
) as AttachmentPointName,
);
});
});
});
if (chain.isCyclic) {
Expand Down

0 comments on commit 1d22996

Please sign in to comment.