From f24bfab09ead0244dbd87199d8ba6ce2b4e7e467 Mon Sep 17 00:00:00 2001 From: ASLeonard Date: Wed, 17 Apr 2019 15:16:11 +0100 Subject: [PATCH] tweaks --- .travis.yml | 21 +++------------------ README.md | 10 ++++++++-- scripts/interface_analysis.py | 23 +++++++++++++++-------- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0850181..3b0679b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,6 @@ env: python: '3.6.7' matrix: include: - - env: COMPILER=clang++ - os: osx - osx_image: xcode10.2 - - env: COMPILER=clang++-7 addons: &clang70 apt: @@ -29,27 +25,16 @@ matrix: packages: g++-7 sources: - ubuntu-toolchain-r-test - allow_failures: - - os: osx before_install: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then python3 get-pip.py --user; fi - + - curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py" + - python3 get-pip.py --user - pip3 install numpy --user - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-apple-darwin.tar.xz; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then tar -xf clang+llvm-8.0.0-x86_64-apple-darwin.tar.xz; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export LLVM_DIR=${TRAVIS_BUILD_DIR}/clang+llvm-8.0.0-x86_64-apple-darwin; fi - install: - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export CXX=${TRAVIS_BUILD_DIR}/clang+llvm-8.0.0-x86_64-apple-darwin/bin/${COMPILER}; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH=${TRAVIS_BUILD_DIR}/clang+llvm-8.0.0-x86_64-apple-darwin/bin:$PATH; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export LD_LIBRARY_PATH=${TRAVIS_BUILD_DIR}/clang+llvm-8.0.0-x86_64-apple-darwin/lib:$LD_LIBRARY_PATH; fi - - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CXX=${COMPILER}; fi + - export CXX=${COMPILER} script: - echo $CXX diff --git a/README.md b/README.md index 40992d1..d8df350 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,20 @@ git clone --recurse-submodules https://github.com/ASLeonard/polyomino_interfaces cd polyomino_interfaces make ``` +At which point the simulation program is in `/bin/ProteinEvolution`. Errors at this stage probably indicate the compiler (or the CXX environment variable) is not modern enough. +Several compiler flags can be added depenending on what is available on the user's system if desired, like g++ has support for multi-threading (-fopenmp) and link-time optimization (-flto). + #### Python requirements The analysis and plotting has been tested with the following versions, although many older/newer versions are likely to work. These are common packages, but not always installed by default. -+ python (3.65) -+ SciPy (1.2.1) ++ python (3.6.5) + Numpy (1.16.2) + Matplotlib (3.03) ++ SciPy (1.2.1) (only necessary for scripts within **polyomino_core**, not used by default) + +#### Testing +The install, c++, and python can be tested after making, by calling `make test`. This will run an evolution simulation with default parameters, analyse the generated files, save the analysis, and then erase all the generated files and analysis. #### Directory layout The main folders of interest are bin/ and scripts/, although a more curious user can modify the c++ in the other folders. diff --git a/scripts/interface_analysis.py b/scripts/interface_analysis.py index bfa58dd..3c68c41 100644 --- a/scripts/interface_analysis.py +++ b/scripts/interface_analysis.py @@ -136,7 +136,7 @@ def __growDescendentTree(tree,max_depth=float('inf')): def __valid_descendent(gen_idx,kid): return (np.array_equal(phenotypes_in[gen_idx+1,kid],tree.pID) and interactions[gen_idx+1,kid].bonds==tree.bonds) - ##iterate down tree while possible + ##iterate down tree while possible, up to a max_depth if set while gen_val<(max_gen-1): new_descendents=[child for descendent in descendents for child in np.where(selections[gen_val]==descendent)[0] if __valid_descendent(gen_val,child)] @@ -192,21 +192,24 @@ def __addBranch(): ##iterate backwards through tree finding new branches while g_idx>0: - ##if parent is null, has been found already + ##if parent is null, this tree has been found already if np.array_equal(phenotypes[g_idx-1,p_idx],null_pid): + ##the phenotypes of parent and child are the same, but bonds aren't, discard it if np.array_equal(phenotypes_in[g_idx-1,p_idx],pid_ref): temp_forest.append((False,Tree(pid_ref,bond_ref,(-1,-1),g_idx,[[c_idx]]))) + ##found a new transition to add as a branch else: if not __addBranch(): return None break - ##if not equal, found a transition, add branch at this point + + ##if not equal, found a new transition, add branch at this point elif not np.array_equal(phenotypes[g_idx-1,p_idx],pid_ref): if not __addBranch(): return None bond_ref=interactions[g_idx-1,p_idx].bonds pid_ref=phenotypes[g_idx-1,p_idx] - + ##tree has not been found already, but different bonds, so discard it elif interactions[g_idx-1,p_idx].bonds !=bond_ref: temp_forest.append((False,Tree(pid_ref,bond_ref,(-1,-1),g_idx,[[c_idx]]))) bond_ref=interactions[g_idx-1,p_idx].bonds @@ -215,9 +218,11 @@ def __addBranch(): g_idx-=1 c_idx=p_idx p_idx=selections[g_idx-1,p_idx] + ##loop has finished, add last generation else: if not np.array_equal(pid_ref,init_pid) and not __addBranch(): return None + ##look back at roots of new branches and extend them if valid while temp_forest: (alive,tree)=temp_forest.pop() @@ -248,7 +253,7 @@ def __addBranch(): return (forest,dict(transitions),dict(failed_jumps)) -##calculate strengths of each part of the tree +##calculate strengths of each bond at each leaf of a tree def treeBondStrengths(KAG,interactions): bond_data=defaultdict(list) for tree in KAG: @@ -260,7 +265,8 @@ def treeBondStrengths(KAG,interactions): break max_pop=max(max_pop,len(populations)) inner_bond_maps=defaultdict(list) - ##find strengths for all bonds, and get bond topology + + ##find strengths for all bonds, and store results by bond topology for species in populations: all_bonds=interactions[generation,species].bonds new_bond_type=getBondType(tree.new_bond,all_bonds) @@ -333,7 +339,7 @@ def runEvolutionSequence(): ##defaults for dynamic fitness landscape #default_parameters={'file_path' : 'bin/', 'N' : 2, 'P' : 100, 'K' : 600, 'B' : 150, 'X': 0, 'F': 1, 'A' : 2, 'D' : 1, 'J': 1, 'M': 1, 'Y' : .6875, 'T': 25, 'O' : 200, 'G' : 10} - + ##helper method to stringify parameters def generateParameterString(): prm_str='' for param,value in default_parameters.items(): @@ -358,7 +364,7 @@ def generateParameterString(): collateByMode(default_parameters['A'],range(default_parameters['D']),fname_params) - +##run analysis type, either for static landscapes or dynamic landscapes with single assembly graph def analysisByMode(mode,run, params): file_base='Mu{2}Y{0}T{1}F{3}O{4}'.format(*(params+(run,))) if mode < 2: @@ -371,6 +377,7 @@ def analysisByMode(mode,run, params): else: print('unknown mode request, set parameter \'A\'') +##after all analyses are finished, go back and collect all the results and averages into a single file def collateByMode(mode,run_range, params): file_base='Y{}T{}Mu{}F{}'.format(*params) if mode < 2: