Skip to content

Commit

Permalink
Merge pull request #1 from bioasp/port-to-clasp-3.0.1
Browse files Browse the repository at this point in the history
use pyasp-1.3
  • Loading branch information
sthiele committed Mar 4, 2014
2 parents e939da8 + 9bb4b72 commit f54231a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.4
----------
use pyasp-1.3

1.0 (unreleased)
----------------
Initial release
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def run(self):

setup(cmdclass={'install': install},
name='meneco',
version='1.3.2',
version='1.4',
url='http://pypi.python.org/pypi/meneco/',
license='GPLv3+',
description='Metabolic Network Completion. Compute minimal completions to your draft net with reactions from a repair net.',
Expand All @@ -45,6 +45,6 @@ def run(self):
package_data = {'__meneco__' : ['encodings/*.lp']},
scripts = ['meneco.py'],
install_requires=[
"pyasp >= 1.2.1"
"pyasp == 1.3"
]
)
)
3 changes: 0 additions & 3 deletions src/encodings/card_min_completions_all_targets.lp
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@

% optimizations

ireaction(R) :- ireaction(R,N).

%#maximize [ xreaction(R) : ireaction(R) : not reaction(R,N) : draft(N) : value(R,C) = C].
#minimize [ not false= 0, xreaction(R,N) : ireaction(R,N) ].

#hide.
Expand Down
3 changes: 1 addition & 2 deletions src/encodings/completions_all_targets.lp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

% find minimal set of xreactions such that xscope contains targets in pscope


% what is producible by the original network

dscope(M) :- seed(M).
Expand All @@ -28,7 +29,6 @@
pscope(M) :- reactant(M,R,N), reaction(R,N), reversible(R),
pscope(M2) : product(M2,R,N).


% what are the interesting reactions
% ireactions reactions are now defined in ireactions.lp

Expand All @@ -46,7 +46,6 @@
oreaction(R,N) :- reaction(R,N), not draft(N), xscope(M) : reactant(M,R,N).
oreaction(R,N) :- xscope(M) : product(M,R,N), reaction(R,N), reversible(R), not draft(N).


:- xreaction(R,N), not oreaction(R,N).


Expand Down
9 changes: 7 additions & 2 deletions src/encodings/ireactions.lp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@

% what is producible by the original network

dreaction(R) :- reaction(R,N), draft(N).
samenames(R,N1,N2) :- reaction(R,N1),draft(N1),N1!=N2,reaction(R,N2).
samereactants(R) :- samenames(R,N1,N2), reactant(M2,R,N1): reactant(M2,R,N2).
sameproducts(R) :- samenames(R,N1,N2), products(M2,R,N1): products(M2,R,N2).
same(R):- samenames(R,N1,N2), samereactants(R), sameproducts(R), reversible(R,N1), reversible(R,N2).
same(R):- samenames(R,N1,N2), samereactants(R), sameproducts(R), not reversible(R,N1), not reversible(R,N2).


dscope(M) :- seed(M).

Expand Down Expand Up @@ -51,7 +56,7 @@
bireaction(R,N) :- binteresting(M), reactant(M,R,N), product(M2,R,N), not dscope(M2), reaction(R,N).
bireaction(R,N) :- binteresting(M), product(M,R,N), reactant(M2,R,N), not dscope(M2), reaction(R,N), reversible(R).

ireaction(R,N) :- iireaction(R,N), bireaction(R,N), not dreaction(R).
ireaction(R,N) :- iireaction(R,N), bireaction(R,N), not same(R).
% ireaction(R,N) :- iireaction(R,N), bireaction(R,N), not draft(N).

% iscope(M) :- seed(M).
Expand Down
26 changes: 14 additions & 12 deletions src/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def get_mapping_ireaction(termset):
#print revdict
#quit()
return dict, revdict



def map_reaction_ids(termset, dict):
mapped = TermSet()
for a in termset:
Expand Down Expand Up @@ -95,8 +96,7 @@ def unmap_reaction_ids(termset, revdict):

return unmapped




def get_unproducible(draft, seeds, targets):
draft_f = draft.to_file()
seed_f = seeds.to_file()
Expand All @@ -109,6 +109,7 @@ def get_unproducible(draft, seeds, targets):
os.unlink(target_f)
return models[0]


def compute_ireactions(instance):
instance_f = instance.to_file()
prg = [ ireaction_prg, instance_f]
Expand All @@ -128,17 +129,17 @@ def get_minimal_completion_size(draft, repairnet, seeds, targets):
instance_f= instance.to_file()
#prg = [minimal_completion_prg, heuristic_prg, instance_f]
#co="--heu=domain"
#solver = GringoHClaspOpt(clasp_options=co)
#solver = GringoHClasp(clasp_options=co)
prg = [minimal_completion_prg, instance_f]

solver = GringoUnClasp()
co="--opt-strategy=5"
solver = GringoClasp(clasp_options=co)

optimum = solver.run(prg,collapseTerms=True, collapseAtoms=False)
os.unlink(instance_f)
return optimum



def get_intersection_of_optimal_completions(draft, repairnet, seeds, targets, optimum):
draftfact = String2TermSet('draft("draft")')
ubfact = String2TermSet('ub('+str(optimum)+')')
Expand All @@ -153,8 +154,8 @@ def get_intersection_of_optimal_completions(draft, repairnet, seeds, targets, op
#print revdict
#exit()
prg = [minimal_completion_wb_prg , instance_f ]
#options='-t 2 --enum-mode cautious --opt-all='+str(optimum)
options='--configuration jumpy --enum-mode cautious --opt-all='+str(optimum)
options='--configuration jumpy --enum-mode cautious --opt-mode=optN'

solver = GringoClasp(clasp_options=options)
models = solver.run(prg,nmodels=0,collapseTerms=True, collapseAtoms=False)

Expand All @@ -174,8 +175,8 @@ def get_union_of_optimal_completions(draft, repairnet, seeds, targets, optimum):
instance = map_reaction_ids(instance.union(ireactions), dict)

prg = [minimal_completion_wb_prg , instance.to_file() ]
#options='-t 2 --enum-mode brave --opt-all='+str(optimum)
options='--configuration jumpy --enum-mode brave --opt-all='+str(optimum)
options='--configuration jumpy --enum-mode brave --opt-mode=optN'

solver = GringoClasp(clasp_options=options)
models = solver.run(prg,nmodels=0,collapseTerms=True, collapseAtoms=False)
os.unlink(prg[1])
Expand All @@ -195,7 +196,7 @@ def get_optimal_completions(draft, repairnet, seeds, targets, optimum, nmodels=0
instance = map_reaction_ids(instance.union(ireactions), dict)

prg = [minimal_completion_wb_prg , instance.to_file() ]
options='--configuration jumpy --opt-all='+str(optimum)
options='--configuration jumpy --opt-mode=optN'
solver = GringoClasp(clasp_options=options)
models = solver.run(prg,nmodels,collapseTerms=True, collapseAtoms=False)
os.unlink(prg[1])
Expand All @@ -215,7 +216,8 @@ def get_intersection_of_completions(draft, repairnet, seeds, targets):
instance_f = instance.to_file()

prg = [completion_prg, instance_f]
options='--enum-mode cautious --opt-ignore '
options='--enum-mode cautious --opt-mode=ignore '

solver = GringoClasp(clasp_options=options)
models = solver.run(prg,nmodels=0,collapseTerms=True, collapseAtoms=False)
os.unlink(instance_f)
Expand Down

0 comments on commit f54231a

Please sign in to comment.