-
Notifications
You must be signed in to change notification settings - Fork 177
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
Macro: #3869 - Left-to-right ("Snake-like") layout for RNA #3932
Conversation
f644475
to
916d69e
Compare
…-to-right-snake-like-layout-for-rna
…-to-right-snake-like-layout-for-rna
const phosphate1 = await page | ||
.locator(`//\*[name() = 'g' and ./\*[name()='text' and .='P']]`) | ||
.nth(0); | ||
|
There was a problem hiding this comment.
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
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(); |
There was a problem hiding this comment.
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
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, | ||
); |
There was a problem hiding this comment.
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.
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, | ||
)) | ||
); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
polymerBond?.secondMonomer === rnaBase | ||
? polymerBond?.firstMonomer | ||
: polymerBond?.secondMonomer; |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here also
…-to-right-snake-like-layout-for-rna
await bondTwoMonomers(page, peptide2, peptide3); | ||
await bondTwoMonomers(page, peptide3, peptide4); | ||
|
||
await takeEditorScreenshot(page); | ||
// await takeEditorScreenshot(page); |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
DISTANCE_BETWEEN_MONOMERS + | ||
HORIZONTAL_DISTANCE_FROM_MONOMER + |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
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
There was a problem hiding this 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
How the feature works? / How did you fix the issue?
(Screenshots, videos, or GIFs, if applicable)
Check list
#1234 – issue name