Changeset 1105


Ignore:
Timestamp:
03/13/21 00:46:26 (3 years ago)
Author:
Maciej Komosinski
Message:

Using the "framsfiles" module to write genotypes to a file instead of an ad-hoc code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • framspy/FramsticksCLI.py

    r1092 r1105  
    77import argparse
    88import numpy as np
    9 import framsreader  # only needed for mutation: https://pypi.org/project/framsreader
     9from framsfiles import reader as framsreader
     10from framsfiles import writer as framswriter
    1011
    1112
     
    3637        GETSIMPLEST_CMD = "getsimplest"
    3738        GETSIMPLEST_FILE = "simplest.gen"
    38         EVALUATE_CMD = "evaluate eval-allcriteria.sim" # the .sim file must be compatible with the standard-eval expdef
     39        EVALUATE_CMD = "evaluate eval-allcriteria.sim"  # the .sim file must be compatible with the standard-eval expdef
    3940        EVALUATE_FILE = "genos_eval.json"
    4041        CROSSOVER_CMD = "crossover"
     
    127128                                outfile.write(genotype)
    128129                        else:
    129                                 outfile.write("org:\n")
    130                                 outfile.write("genotype:~\n")
    131                                 outfile.write(genotype + "~\n\n")  # TODO proper quoting of special characters in genotype...
     130                                outfile.write(framswriter.from_collection({"_classname": "org", "genotype": genotype}))
     131                                outfile.write("\n")
    132132                        outfile.close()
    133133                return relname, absname
     
    304304        # - "vectorize" crossover so that many genotypes is handled in one call. Even better, use .so/.dll direct communication to CLI
    305305        # - use threads for non-blocking reading from frams' stdout and thus not relying on specific strings printed by frams
    306         # - a pool of binaries running simultaneously, balance load - in particular evaluation
    307         # - if we read genotypes in "org:" format anywhere: import https://pypi.org/project/framsreader and use it if successful,
    308         #    if not then print a message "framsreader not available, using simple internal method to save a genotype" and proceed as it is now.
    309         #    We should use the proper writer to handle all special cases like quoting special characters etc.
     306        # - a pool of binaries running simultaneously, balance load - in particular, evaluation
    310307
    311308        parsed_args = parseArguments()
Note: See TracChangeset for help on using the changeset viewer.