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

Why is the effect after superposition not as good as before superposition #1029

Open
tang2552 opened this issue Mar 9, 2024 · 1 comment
Labels

Comments

@tang2552
Copy link

tang2552 commented Mar 9, 2024

before superposition
before
after superposition
after

Previous code
`const pdbFile1 = “./data/7KMB.pdb”;
const pdbFile2 = ”./data/7KMS.pdb“;

function initNGL() {
// Create a stage
const stage = new NGL.Stage("viewport");

// Load protein structure files (PDB or MMCIF)
stage.loadFile(pdbFile1).then(function (component1) {
    stage.loadFile(pdbFile2).then(function (component2) {
        // Add components to the stage
        stage.addComponent(component1);
        stage.addComponent(component2);

        console.log("Components added to stage");

        // Representations (e.g., cartoon representation)
        component1.addRepresentation("cartoon", {color: "red"});
        component2.addRepresentation("cartoon", {color: "blue"});

        console.log("Representations added");

        // Align structures (you may have to perform alignment before loading)
        // Make sure alignView is supported in your NGL version
        if (typeof stage.alignView === "function") {
            stage.alignView();
            console.log("Aligning view");
        } else {
            console.warn("alignView method is not available");
        }
        stage.setParameters({ backgroundColor: "white" });

        // Auto view
        stage.autoView();
    }).catch(function(error) {
        console.error("Error loading file 2:", error);
    });
}).catch(function(error) {
    console.error("Error loading file 1:", error);
});

}`

The following code refers to the following URL https://github.com/nglviewer/ngl/blob/master/examples/scripts/test/superposition.js

Obviously, the effect after superpose is not as good as before.

I'd appreciate it if someone could solve my problem. Thanks!

@ppillot
Copy link
Collaborator

ppillot commented Mar 10, 2024

This code looks strange to me: you are referring to this link https://github.com/nglviewer/ngl/blob/master/examples/scripts/test/superposition.js but none of the code pasted is looking alike, in particular stage.alignView() which is not a method existing on the stage object (it exists on the ViewerControls class, but that's not how superposition are done in the examples; all examples are using NGL.superpose(...) for performing superpositions). To me, this looks like code that has been hallucinated by an AI.

Regarding the issue you are reporting, I have no experience with using the superposition method, but my recommandation would be to use the code from the following example, https://github.com/nglviewer/ngl/blob/master/examples/scripts/test/alignment2.js where the chains to be aligned are specified (:A). In the case of the 2 structures you want to superpose, I suppose that getting good results would require to specify the correct pair of chains for the alignment, otherwise the combinatorial is too random.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants