Example #1
0
    def dec(self, n=1):
        """
		The function dec takes as input a number n which is defaulted to
		1. It deletes one monomer from an assembly that it chooses -
		where the probability is proportional to the surface area of the
		assembly.
		"""
        weights = [(a, a.monomers_at_surface) for a in self.assemblies
                   if a.number >= n]
        asmb = stats.weighted_choice(
            weights)  # Choose assembly by surface area
        # Decrement
        '''diff is the number of monomers in the assembly minus the number
		you want to remove from the assembly'''
        diff = asmb.number - n
        '''diff must be greater than or equal to 0 because you can't
		remove more than the number of monomers that compose the
		assembly.'''
        assert (diff >= 0)
        '''If the number you want to remove = the number of monomers in
		the assembly...'''
        if diff == 0:
            self.removeAssembly(asmb)  #Just remove the assembly.
        elif diff == 1:  #If there is only one monomer in the assembly,
            #put the monomer back in solution and...
            self.monomers.inc(1)
            self.removeAssembly(asmb)  #just remove the assembly
        else:
            asmb.dec(n)  #Otherwise, decrease number of monomers by 1.
Example #2
0
    def dec(self, n=1):
        """
		The function dec takes as input a number n which is defaulted to
		1. It deletes one monomer from an assembly that it chooses -
		where the probability is proportional to the surface area of the
		assembly.
		"""
        weights = [(a, a.monomers_at_surface) for a in self.assemblies if a.number >= n]
        asmb = stats.weighted_choice(weights)  # Choose assembly by surface area
        # Decrement
        """diff is the number of monomers in the assembly minus the number
		you want to remove from the assembly"""
        diff = asmb.number - n

        """diff must be greater than or equal to 0 because you can't
		remove more than the number of monomers that compose the
		assembly."""
        assert diff >= 0

        """If the number you want to remove = the number of monomers in
		the assembly..."""
        if diff == 0:
            self.removeAssembly(asmb)  # Just remove the assembly.
        elif diff == 1:  # If there is only one monomer in the assembly,
            # put the monomer back in solution and...
            self.monomers.inc(1)
            self.removeAssembly(asmb)  # just remove the assembly
        else:
            asmb.dec(n)  # Otherwise, decrease number of monomers by 1.
Example #3
0
    def inc(self, n=1):
        """
		The function inc takes as input a number n which is defaulted to 1.
		It adds one monomer to an assembly that it chooses - where the
		probability of being chosen is proportional to the surface area of
		the assembly.
		"""
        # Choose assembly by surface area
        weights = [(a, a.monomers_at_surface) for a in self.assemblies]
        asmb = stats.weighted_choice(weights)
        # Increment
        asmb.inc(n)
Example #4
0
    def inc(self, n=1):
        """
		The function inc takes as input a number n which is defaulted to 1.
		It adds one monomer to an assembly that it chooses - where the
		probability of being chosen is proportional to the surface area of
		the assembly.
		"""
        # Choose assembly by surface area
        weights = [(a, a.monomers_at_surface) for a in self.assemblies]
        asmb = stats.weighted_choice(weights)
        # Increment
        asmb.inc(n)
Example #5
0
	def dec(self,n=1):
		# Choose assembly by surface area
		weights = [(a, a.monomers_at_surface) for a in self.assemblies if a.number >= n]
		asmb = stats.weighted_choice(weights)
		# Decrement
		diff = asmb.number-n
		assert(diff>=0)
		if diff == 0:
			self.removeAssembly(asmb)
		elif diff == 1:
			# Return to monomer pool
			self.monomers.inc(1)
			self.removeAssembly(asmb)
		else:
			asmb.dec(n)
Example #6
0
 def dec(self, n=1):
     # Choose assembly by surface area
     weights = [(a, a.monomers_at_surface) for a in self.assemblies
                if a.number >= n]
     asmb = stats.weighted_choice(weights)
     # Decrement
     diff = asmb.number - n
     assert (diff >= 0)
     if diff == 0:
         self.removeAssembly(asmb)
     elif diff == 1:
         # Return to monomer pool
         self.monomers.inc(1)
         self.removeAssembly(asmb)
     else:
         asmb.dec(n)
Example #7
0
        data_outs.write("# Parameters:\n")
        optdict = vars(options)
        for (k, v) in optdict.items():
            data_outs.write("#\t{k}: {v}\n".format(k=k, v=v))
        data_outs.write("# Window size = {}\n".format(window_size))

        n_samples = 0
        scores = []
        min_ent = 1e6
        min_seq = None
        max_ent = 0
        max_seq = None
        quant = gelscore.EntropyQuant()
        while n_samples < options.num_samples:
            # Pick sequence at random
            seq = stats.weighted_choice(seq_weights)
            if len(seq) >= window_size:
                # Pick a subsequence within sequence at random
                startpos = random.randint(0, len(seq) - window_size)
                subseq = seq[startpos:(startpos + window_size)]
                if not '*' in subseq:
                    score = quant.quant(subseq, base=options.logarithm_base)
                    if score < min_ent:
                        min_ent = score
                        min_seq = subseq
                    if score > max_ent:
                        max_ent = score
                        max_seq = subseq
                    scores.append(score)
                    n_samples += 1
Example #8
0
	def inc(self,n=1):
		# Choose assembly by surface area
		weights = [(a, a.monomers_at_surface) for a in self.assemblies]
		asmb = stats.weighted_choice(weights)
		# Increment
		asmb.inc(n)
Example #9
0
		data_outs.write("# Parameters:\n")
		optdict = vars(options)
		for (k,v) in optdict.items():
			data_outs.write("#\t{k}: {v}\n".format(k=k, v=v))
		data_outs.write("# Window size = {}\n".format(window_size))
	
		n_samples = 0
		scores = []
		min_ent = 1e6
		min_seq = None
		max_ent = 0
		max_seq = None
		quant = gelscore.EntropyQuant()
		while n_samples < options.num_samples:
			# Pick sequence at random
			seq = stats.weighted_choice(seq_weights)
			if len(seq) >= window_size:
				# Pick a subsequence within sequence at random
				startpos = random.randint(0, len(seq)-window_size)
				subseq = seq[startpos:(startpos+window_size)]
				if not '*' in subseq:
					score = quant.quant(subseq, base=options.logarithm_base)
					if score < min_ent:
						min_ent = score
						min_seq = subseq
					if score > max_ent:
						max_ent = score
						max_seq = subseq
					scores.append(score)
					n_samples += 1
Example #10
0
 def inc(self, n=1):
     # Choose assembly by surface area
     weights = [(a, a.monomers_at_surface) for a in self.assemblies]
     asmb = stats.weighted_choice(weights)
     # Increment
     asmb.inc(n)