Skip to content

Commit

Permalink
links to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Zsailer committed Jan 10, 2017
1 parent 7925b70 commit e069f00
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

#Python API for analyzing and manipulating genotype-phenotype maps


[![Join the chat at https://gitter.im/harmslab/gpmap](https://badges.gitter.im/harmslab/gpmap.svg)](https://gitter.im/harmslab/gpmap?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Documentation Status](https://readthedocs.org/projects/gpmap/badge/?version=latest)](http://gpmap.readthedocs.io/en/latest/?badge=latest)

This package defines a standard data-structure for genotype-phenotype (GP) map data.
Useful for creating network graphs (via NetworkX) from GP data. Subset, manipulate,
extend, etc. GP maps. Calculate statistics, model evolutionary trajectories, predict
Expand Down
2 changes: 1 addition & 1 deletion docs/_pages/gpm.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GenotypePhenotypeMap
====================

The ``GenotypePhenotypeMap`` class is the primary tool provided by the ``seqspace`` package.
The ``GenotypePhenotypeMap`` class is the primary tool provided by the ``gpmap`` package.
It creates intuitive and useful mapping on the fly. It appends methods and attributes
to make analyzing genotype-phenotype data easy. We've create other packages that
easily interact with the ``GenotypePhenotypeMap``.
Expand Down
2 changes: 1 addition & 1 deletion docs/_pages/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ To begin using this package, import the base class of the package, `GenotypePhen

.. code-block:: python
import GenotypePhenotypeMap
from gpmap import GenotypePhenotypeMap
There a few ways you initialize a GenotypePhenotypeMap object. First, you can pass
the data into the object directly:
Expand Down
42 changes: 42 additions & 0 deletions gpmap/simulate/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import random
import numpy as np
from gpmap import utils
from gpmap.gpm import GenotypePhenotypeMap

def random_mutation_set(length, alphabet_size=2):
"""Generate a random mutations dictionary for simulations.
Expand All @@ -20,3 +22,43 @@ def random_mutation_set(length, alphabet_size=2):
alphabet = utils.AMINO_ACIDS[:size]
mutations = dict([(i, alphabet[i])for i in range(length)])
return mutations

class GenotypePhenotypeSimulation(GenotypePhenotypeMap):
""" Build a simulated GenotypePhenotypeMap. Generates random phenotypes.
"""
def __init__(self, wildtype, mutations, range=(0,1), *args, **kwargs):
# build genotypes
genotypes = utils.mutations_to_genotypes(wildtype, mutations)
phenotypes = np.empty(len(genotypes), dtype=float)
super(GenotypePhenotypeSimulation, self).__init__(wildtype, genotypes,
phenotypes,
*args,
**kwargs,
)
self.set_random(range=range)

def set_random(self, range=(0,1)):
""" Get a set of random
"""
self.phenotypes = np.random.random(range[0], range[1], size=self.n)

@classmethod
def from_length(cls, length, alphabet_size=2, *args, **kwargs):
""" Create a simulate genotype-phenotype map from a given genotype length.
Parameters
----------
length : int
length of genotypes
alphabet_size : int (optional)
alphabet size
Returns
-------
self : GenotypePhenotypeSimulation
"""
mutations = random_mutations_set(lengths, alphabet_size=alphabet_size)
wildtype = ".join"([m[0] for m in mutations.values()])
self = cls(wildtype, mutations, *args, **kwargs)
return self

0 comments on commit e069f00

Please sign in to comment.