from pathlib import Path
import pkg_resources

from libsbml_draw.model.sbml_layout import SBMLlayout

model_file_name = "model.xml"

model_file = Path(pkg_resources.resource_filename(
        "libsbml_draw", "model/data/" + model_file_name))


sl = SBMLlayout(str(model_file))

fr_alg = sl.getLayoutAlgorithmOptions()


def test_fr_alg_options_defaults():

    assert fr_alg.k == 20
    assert fr_alg.gravity == 0
    assert fr_alg.baryx == 500
    assert fr_alg.baryy == 500
    assert fr_alg.autobary == 1
    assert fr_alg.padding == 20


sl2 = SBMLlayout(str(model_file))

sl2.setLayoutAlgorithm_k(15)
sl2.setLayoutAlgorithm_gravity(20)
sl2.setLayoutAlgorithm_baryx(100)
model_file_name = "glycolysis_BIOMD176.xml"

model_file = Path(
    pkg_resources.resource_filename("libsbml_draw",
                                    "model/data/" + model_file_name))

sl = SBMLlayout(str(model_file))

sl._describeModel()

sl.drawNetwork()

sl.aliasNode("ATP")
sl.aliasNode("ADP")
sl.drawNetwork()

sl.regenerateLayout()

sl.drawNetwork()

loo = sl.getLayoutAlgorithmOptions()

print(loo.k)

#sl.setLayoutAlgorithm_grav()

#sl.drawNetwork("glycolysis_bm12.png")

#sl.drawNetwork("glycolysis_bm12.pdf")