Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro: #3869 - Left-to-right ("Snake-like") layout for RNA #3932

Merged

Conversation

StarlaStarla
Copy link
Contributor

@StarlaStarla StarlaStarla commented Jan 18, 2024

How the feature works? / How did you fix the issue?

(Screenshots, videos, or GIFs, if applicable)
image

Check list

  • unit-tests written
  • e2e-tests written
  • documentation updated
  • PR name follows the pattern #1234 – issue name
  • branch name doesn't contain '#'
  • PR is linked with the issue
  • base branch (master or release/xx) is correct
  • task status changed to "Code review"
  • reviewers are notified about the pull request

@StarlaStarla StarlaStarla force-pushed the 3869-macro-left-to-right-snake-like-layout-for-rna branch from f644475 to 916d69e Compare January 19, 2024 09:13
Comment on lines 284 to 287
const phosphate1 = await page
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='P']]`)
.nth(0);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would propose to add it to addRnaPresetOnCanvas method so that it will return object with 3 locators, one for each part of rna preset

Comment on lines 605 to 607
await page.locator('button[title=R2]').nth(0).click();
await page.locator('button[title=R1]').nth(1).click();
await page.locator('button[title=Connect]').click();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would propose to move it to bondTwoMonomers. Check if modal window appeared after connecting monomers so choose attachment points (by default R2 - R1, but could be configured by function parameters) and click connect

Comment on lines 569 to 600
const monomer5 = await addMonomerToCanvas(
page,
'A___Alanine',
'A',
700,
700,
4,
);
const monomer6 = await addMonomerToCanvas(
page,
'Bal___beta-Alanine',
'Bal',
600,
500,
0,
);
const monomer7 = await addMonomerToCanvas(
page,
'Bal___beta-Alanine',
'Bal',
650,
500,
1,
);
const monomer8 = await addMonomerToCanvas(
page,
'Bal___beta-Alanine',
'Bal',
750,
500,
2,
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to have some helper to create monomers like that:

await addMonomersToCanvas([
  { name: 'Bal', fullName: 'Bal___beta-Alanine', amount 5, x: 50, y: 100, deltaX: 100, deltaY: 100 }
])

Where deltaX and deltaY will be an increment of position of each monomer from initial x and y.

Also we probably can create addBondedMonomersToCanvas over it. If it is time consuming we can create a separate ticket for that. Please let me know if so.

Comment on lines 48 to 63
private isMonomersTypeDifferent() {
return (
(this.polymerBond.secondMonomer &&
[Peptide, Chem].some(
(type) => this.polymerBond.firstMonomer instanceof type,
) &&
[Sugar, Phosphate].some(
(type) => this.polymerBond.secondMonomer instanceof type,
)) ||
([Peptide, Chem].some(
(type) => this.polymerBond.secondMonomer instanceof type,
) &&
[Sugar, Phosphate].some(
(type) => this.polymerBond.firstMonomer instanceof type,
))
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would propose to move part of this logic into concrete monomer classes (Like Peptide, Chem, e t c). Like so for Peptide:

public isMonomerTypeDifferentForChaining(monomerToChain: BaseMonomer) {
return monomerToChain instanceof Sugar || monomerToChain instanceof Phosphate
}

const height =
(nucleotide.sugar.renderer?.monomerSize.height || 0) +
(nucleotide.rnaBase.renderer?.monomerSize.height || 0) +
45;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would propose to move 45 into constant with appropriate name

Comment on lines 1041 to 1043
polymerBond?.secondMonomer === rnaBase
? polymerBond?.firstMonomer
: polymerBond?.secondMonomer;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is polymerBond.getAnotherMonomer(rnaBase) method I believe

lastPosition.y +
(nucleotide.sugar.renderer?.monomerSize?.height ?? 0) / 2 +
(nucleotide.rnaBase.renderer?.monomerSize?.height ?? 0) / 2 +
45,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to constant please.

lastPosition.x +
(nucleotide.sugar.renderer?.monomerSize?.width ?? 0) / 2 +
(nucleotide.phosphate?.renderer?.monomerSize?.width ?? 0) / 2 +
45,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here also

await bondTwoMonomers(page, peptide2, peptide3);
await bondTwoMonomers(page, peptide3, peptide4);

await takeEditorScreenshot(page);
// await takeEditorScreenshot(page);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excess comment I believe


return { command, lastPosition };
private getRnaBaseSideChainMonomers(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please rename this method? Currently it starts from "get" which means that it should return the value and should not mutate some external state, but it does.

Comment on lines +1221 to +1222
DISTANCE_BETWEEN_MONOMERS +
HORIZONTAL_DISTANCE_FROM_MONOMER +
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between these two values?

Copy link
Contributor Author

@StarlaStarla StarlaStarla Feb 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I just copied the legency code for use. I would assume DISTANCE_BETWEEN_MONOMERS is the length of the corner line that connects two lines of chain, while the HORIZONTAL_DISTANCE_FROM_MONOMER is the distance between monomers.
image

Comment on lines 1298 to 1307
public getPhosphateFromRnaBase(baseMonomer: RNABase) {
const r1PolymerBond = baseMonomer.attachmentPointsToBonds.R1;
const sugarMonomer = r1PolymerBond?.getAnotherMonomer(baseMonomer);
if (sugarMonomer && sugarMonomer instanceof Sugar) {
const phosphate = getNextMonomerInChain(sugarMonomer);
if (phosphate && phosphate instanceof Phosphate) {
return phosphate;
}
}
return undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this method is not used

Copy link
Collaborator

@rrodionov91 rrodionov91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix comments above

@rrodionov91 rrodionov91 merged commit fb33861 into master Feb 2, 2024
5 checks passed
@rrodionov91 rrodionov91 deleted the 3869-macro-left-to-right-snake-like-layout-for-rna branch February 2, 2024 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Macro: Left-to-right ("Snake-like") layout for RNA
2 participants