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

Are "Reversible" and "Weighted" arrows mutually exclusive? #9

Open
man-shu opened this issue Jun 12, 2018 · 1 comment
Open

Are "Reversible" and "Weighted" arrows mutually exclusive? #9

man-shu opened this issue Jun 12, 2018 · 1 comment

Comments

@man-shu
Copy link

man-shu commented Jun 12, 2018

I was trying to add the fluxes to the reactions by adding the "solution" dictionary to the "flux_dict" parameter. I did get the weighted links, but lost all the reversible links (with arrows on both sides). The cobrapy model and the .json file for the representation still have the "reversibility" property as "true", though. So, is there any workaround?

@pstjohn
Copy link
Owner

pstjohn commented Jun 12, 2018

The way the code's currently written it would be mutually exclusive. Otherwise it would be tough to indicate which way the flux was flowing if you had arrowheads in both directions. I think some papers use different sized arrowheads to indicate direction and reversibility, which is something I could look into.

If you knew a bit of javascript, you're welcome to send in a PR :)
the relevant code would be here

svg.append("defs").selectAll("marker")
.data(reactions)
.enter()
.append("marker")
.attr("id", function (d) { return "{{ figure_id }}" + d.id + "_rev"; })
.attr("viewBox", "0 0 10 10")
.attr("refX", 9)
.attr("refY", 5)
.attr("markerUnits", "userSpaceOnUse")
.attr("markerWidth", "7pt")
.attr("markerHeight", "7pt")
.attr("orient", "auto")
.attr("class", function (d) {
var labels = "startmarker"
if ('flux' in d.notes.map_info) {
if (d.notes.map_info.flux == 0) {
labels = labels.concat(" inactive");
}
}
return labels;
})
.append("path")
.attr("d", "M 10,10 0,5 10,0 Z");

dummy arrowheads get added everywhere, and then I selectively show them based on some logic here

function plot_reverse_arrowhead(rxn) {
return (((Math.abs(rxn.notes.map_info.flux) < 1E-8) || isNaN(rxn.notes.map_info.flux))
&& rxn.notes.map_info.reversibility);
}

You'd probably need to code in some logic about scaling the reverse arrowheads to be some fraction of the forward direction's size? That would involve changing how the markers are scaled, since I do them all at once here. Not sure why I don't just scale them in the code above when they're created...

svg.selectAll("marker")
.attr("markerWidth", markerscale)
.attr("markerHeight", markerscale)
.select("path")
.attr("fill", get_flux_stroke);

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

No branches or pull requests

2 participants