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

added center on click functionality #56

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 73 additions & 92 deletions src/privateer/cpp/privateer-lib.cpp

Large diffs are not rendered by default.

65 changes: 39 additions & 26 deletions src/privateer/cpp/privateer-lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,23 @@ namespace privateer
std::string get_tooltip ( ) { return this->tooltip; }
void set_mmdbsel ( std::string mmdbsel ) { this->mmdbsel = mmdbsel; }
std::string get_mmdbsel ( ) { return this->mmdbsel; }
void set_chainID ( std::string chainID ) { this -> chainID = chainID; }
std::string get_chainID () { return this-> chainID; }
void set_resname ( std::string resname ) { this -> resname = resname; }
std::string get_resname () { return this -> resname; }
void set_seqnum ( int seqnum ) { this -> seqnum = seqnum; }
int get_seqnum ( ) { return this -> seqnum; }

protected:
int pos_x;
int pos_y;
std::string svg_id;
std::string tooltip;
std::string mmdbsel;
std::string chainID;
std::string resname;
int seqnum;

};


Expand Down Expand Up @@ -489,15 +499,15 @@ namespace privateer
{
public:
shadedCircle() { } //!< null constructor
shadedCircle( int x, int y, std::string message, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
shadedCircle( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I deliberately excluded shaded nodes from including the metadata, but on other hand I can see the benefit of this in case users don't aim their mouse at the sugar nodes themselves.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Did I change something from your PR here? If I did it wasn't intentional

Copy link
Collaborator

Choose a reason for hiding this comment

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

My bad, you're right. The change was done by me and I have gone delusional here. Please disregard my comment

std::string get_XML ( );
};

class Glc : public virtual Circle
{
public:
Glc() { } //!< null constructor
Glc( int x, int y, std::string message, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
Glc( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );

};
Expand All @@ -506,7 +516,7 @@ namespace privateer
{
public:
Gal() { } //!< null constructor
Gal( int x, int y, std::string message, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
Gal( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );

};
Expand All @@ -515,7 +525,7 @@ namespace privateer
{
public:
Man() { } //!< null constructor
Man( int x, int y, std::string message, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
Man( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );

};
Expand All @@ -524,15 +534,15 @@ namespace privateer
{
public:
shadedTriangle() { } //!< null constructor
shadedTriangle( int x, int y, std::string message, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
shadedTriangle( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );
};

class Fuc : public virtual Triangle
{
public:
Fuc() { } //!< null constructor
Fuc( int x, int y, std::string message, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
Fuc( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );

};
Expand All @@ -541,15 +551,15 @@ namespace privateer
{
public:
shadedStar() { } //!< null constructor
shadedStar( int x, int y, std::string message, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
shadedStar( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );
};

class Xyl : public virtual Star
{
public:
Xyl() { } //!< null constructor
Xyl( int x, int y, std::string message, std::string mmdbsel = "") { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
Xyl( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );

};
Expand All @@ -561,15 +571,15 @@ namespace privateer
{
public:
shadedSquare() { } //!< null constructor
shadedSquare( int x, int y, std::string message, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
shadedSquare( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );
};

class GlcN : public virtual Square
{
public:
GlcN() { } //!< null constructor
GlcN( int x, int y, std::string message, std::string mmdbsel = "") { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
GlcN( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );

};
Expand All @@ -578,7 +588,7 @@ namespace privateer
{
public:
GalN() { } //!< null constructor
GalN( int x, int y, std::string message, std::string mmdbsel = "") { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
GalN( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );

};
Expand All @@ -587,7 +597,7 @@ namespace privateer
{
public:
ManN() { } //!< null constructor
ManN( int x, int y, std::string message, std::string mmdbsel = "") { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
ManN( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );

};
Expand All @@ -599,7 +609,7 @@ namespace privateer
{
public:
GlcNAc() { } //!< null constructor
GlcNAc( int x, int y, std::string message, std::string mmdbsel = "") { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
GlcNAc( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );

};
Expand All @@ -608,7 +618,7 @@ namespace privateer
{
public:
GalNAc() { } //!< null constructor
GalNAc( int x, int y, std::string message, std::string mmdbsel = "") { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
GalNAc( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );

};
Expand All @@ -617,7 +627,7 @@ namespace privateer
{
public:
ManNAc() { } //!< null constructor
ManNAc( int x, int y, std::string message, std::string mmdbsel = "") { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
ManNAc( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );

};
Expand All @@ -628,15 +638,15 @@ namespace privateer
{
public:
shadedDiamond() { } //!< null constructor
shadedDiamond( int x, int y, std::string message, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
shadedDiamond( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );
};

class Neu5Ac : public virtual Diamond
{
public:
Neu5Ac() { } //!< null constructor
Neu5Ac( int x, int y, std::string message, std::string mmdbsel = "") { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
Neu5Ac( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );

};
Expand All @@ -645,7 +655,7 @@ namespace privateer
{
public:
Neu5Gc() { } //!< null constructor
Neu5Gc( int x, int y, std::string message, std::string mmdbsel = "") { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
Neu5Gc( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );

};
Expand All @@ -654,7 +664,7 @@ namespace privateer
{
public:
KDN() { } //!< null constructor
KDN( int x, int y, std::string message, std::string mmdbsel = "") { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
KDN( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );

};
Expand All @@ -663,7 +673,7 @@ namespace privateer
{
public:
GlcA() { } //!< null constructor
GlcA( int x, int y, std::string message, std::string mmdbsel = "") { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
GlcA( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );

};
Expand All @@ -672,7 +682,7 @@ namespace privateer
{
public:
IdoA() { } //!< null constructor
IdoA( int x, int y, std::string message, std::string mmdbsel = "") { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); }
IdoA( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );

};
Expand All @@ -681,7 +691,7 @@ namespace privateer
{
public:
GalA() { } //!< null constructor
GalA( int x, int y, std::string message, std::string mmdbsel = "") { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
GalA( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );

};
Expand All @@ -690,7 +700,7 @@ namespace privateer
{
public:
ManA() { } //!< null constructor
ManA( int x, int y, std::string message, std::string mmdbsel = "") { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
ManA( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );

};
Expand All @@ -699,15 +709,15 @@ namespace privateer
{
public:
shadedHexagon() { } //!< null constructor
shadedHexagon( int x, int y, std::string message, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel);}
shadedHexagon( int x, int y, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );
};

class Unk : public virtual Hexagon
{
public:
Unk() { } //!< null constructor
Unk( int x, int y, const char letter, std::string message, std::string mmdbsel = "") { set_pos(x, y); set_tooltip ( message ); code += letter; set_mmdbsel(mmdbsel);}
Unk( int x, int y, const char letter, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel = "" ) { set_pos(x, y); set_tooltip ( message ); code += letter; set_mmdbsel(mmdbsel); set_chainID(chainID); set_resname(resname); set_seqnum(seqnum);}
std::string get_XML ( );
private:
std::string code;
Expand Down Expand Up @@ -756,14 +766,17 @@ namespace privateer
public:
GlycanRoot() {} //!< null constructor

GlycanRoot( int x, int y, std::string link_atom, std::string root_name, std::string root_id, std::string message, std::string mmdbsel="" )
GlycanRoot( int x, int y, std::string link_atom, std::string root_name, std::string root_id, std::string message, std::string chainID = "N/A", std::string resname = "N/A", int seqnum = 0, std::string mmdbsel="" )
{
set_pos(x, y);
set_tooltip ( message );
set_link_atom ( link_atom );
set_root_name ( root_name );
set_root_id ( root_id );
set_mmdbsel ( mmdbsel );
set_chainID ( chainID );
set_resname ( resname );
set_seqnum ( seqnum );
}

std::string get_XML ( );
Expand Down
Binary file modified webserver/api/privateer.wasm
Binary file not shown.
23 changes: 17 additions & 6 deletions webserver/src/components/GlycanDetail/GlycanDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,30 @@ import TorsionMultiPlot from "../TorsionPlot/TorsionMultiPlot";

const GlycanDetailTable = lazy(() => import('./GlycanDetailTable'));

export default function GlycanDetail({tableData, hideMoorhen, setHideMoorhen, rowID, forwardControls, scrollPosition}) {
export default function GlycanDetail({tableData, hideMoorhen, setHideMoorhen, rowID, forwardControls, scrollPosition, controls, molecule}) {

async function handle_click(e) {

let new_center_string = e.target.dataset.chainid + "/" + e.target.dataset.seqnum + "(" + e.target.dataset.resname + ")"
const selectedMolecule = controls.current.molecules.find((molecule) => molecule.name === "mol-1")
await selectedMolecule.centreOn(new_center_string)

}

const ref = useCallback((node) => {
let useList = document.querySelectorAll('use')
if (node !== null) {

for (let i = 0; i < useList.length; i++) {
useList[i].addEventListener("click", (e) => {
console.log(useList[i].id)
})
let useList = node.querySelectorAll('use')

for (let i = 0; i < useList.length; i++) {
useList[i].addEventListener('click', handle_click)
}
}


document.querySelectorAll("svg")[0].setAttribute("width", "50vw")
document.querySelectorAll("svg")[0].setAttribute("height", "100%")

})

// useEffect( () => {
Expand Down
7 changes: 5 additions & 2 deletions webserver/src/components/PrivateerDisplay/SNFG.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function SNFG({tableData, fileName, pdbString}) {

const [cootInitialized, setCootInitialized] = useState(false)
const controls = useRef()

const [molecule, setMolecule] = useState()
const forwardControls = (forwardedControls) => {
setCootInitialized(true)
controls.current = forwardedControls
Expand Down Expand Up @@ -49,8 +49,9 @@ export default function SNFG({tableData, fileName, pdbString}) {
let sugar_chain = id.split("/")[1].split("_")[0]

let center_string = sugar_chain + "/" + sugar_id + "(" + sugar_name + ")"
console.log("PRIVATEER", center_string)

newMolecule.centreOn(center_string)
setMolecule(newMolecule)
}
)
})
Expand All @@ -76,6 +77,8 @@ export default function SNFG({tableData, fileName, pdbString}) {
rowID={rowID}
forwardControls={forwardControls}
scrollPosition={yScrollPosition}
controls={controls}
molecule={molecule}
/>

</div>
Expand Down
Binary file modified webserver/src/wasm/privateer.wasm
Binary file not shown.