def paths_ratios(self, repertoire): # Get the dominant genotype network for the repertoire giant = self.caller.dominant_network(repertoire) # 'PathAnalyzer' object path_analyzer = PathAnalyzer(giant, self.netBuilder, self.deltaDict[repertoire]) # Run shortest paths calculation for all paths; regardless of path length. # This sets the 'max_path_length' value. path_analyzer.getAccessiblePaths() # Length of the longest path in the network max_path_length = path_analyzer.max_path_length # Compute the ratio of accessible paths for all path lengths in range: # [2, max_path_length]. # Set dict {path_length : ratio} giant["Ratio_of_accessible_mutational_paths"] = { i: path_analyzer.getAccessiblePaths(i) for i in xrange(2, max_path_length + 1) }
def __init__(self, network, netUtils, seqToEscrDict, delta, bitManip) : # Store reference to the network object self.network = network # Store reference to the netUtils object self.netUtils = netUtils # Create the peak analyzer self.peakAnalyzer = PeakAnalyzer(network, netUtils, delta) # Create the path analyzer self.pathAnalyzer = PathAnalyzer(network, netUtils, delta) # Create the epistasis analyzer self.epiAnalyzer = EpistasisAnalyzer(network, netUtils, seqToEscrDict, delta, bitManip) # Get a reference to the BitSeqManipulator in use self.bitManip = self.netUtils.bitManip
class Landscape : # Constructor def __init__(self, network, netUtils, seqToEscrDict, delta, bitManip) : # Store reference to the network object self.network = network # Store reference to the netUtils object self.netUtils = netUtils # Create the peak analyzer self.peakAnalyzer = PeakAnalyzer(network, netUtils, delta) # Create the path analyzer self.pathAnalyzer = PathAnalyzer(network, netUtils, delta) # Create the epistasis analyzer self.epiAnalyzer = EpistasisAnalyzer(network, netUtils, seqToEscrDict, delta, bitManip) # Get a reference to the BitSeqManipulator in use self.bitManip = self.netUtils.bitManip # ---------------------------------------------------------------- # Peak analysis methods # ---------------------------------------------------------------- def getPeaks(self, recompute) : return self.peakAnalyzer.getPeaks(recompute) # ---------------------------------------------------------------- # Path analysis methods # ---------------------------------------------------------------- def getAccessiblePaths(self, pathLength=0): return self.pathAnalyzer.getAccessiblePaths(pathLength) # ---------------------------------------------------------------- # Epistasis analysis methods # ---------------------------------------------------------------- def getEpistasis(self) : return self.epiAnalyzer.getEpiAll() # ---------------------------------------------------------------- # Calculate mutational distances from summit for all vertices # ---------------------------------------------------------------- def populateDistsToSummit(self) : # Convenient handle for bitManip bm = self.bitManip # Get the summit sequence summit = Utils.getSeqWithMaxScore(self.network, self.bitManip.seqLength) # Get vertex that represents summit trgtVrtx = self.netUtils.getVertex(summit, self.network) # Reference to the list of sequences in the network vertices = [ self.netUtils.getVertex(seq, self.network) \ for seq in self.network.vs["sequences"] ] self.network.vs["Distance from Summit"] = \ [ len(self.network.get_shortest_paths(srcVrtx, to=trgtVrtx, \ weights=None, mode=igraph.OUT, output="epath")[0]) \ for srcVrtx in vertices ]