Skip to content

Commit

Permalink
Merge pull request #56 from glycojones/center_sugar_on_click
Browse files Browse the repository at this point in the history
added center on click functionality
  • Loading branch information
Dialpuri authored Oct 24, 2023
2 parents 953723c + 4be0d42 commit 84380fe
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 126 deletions.
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);}
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.

0 comments on commit 84380fe

Please sign in to comment.