Genetic Algorithm for multi-component fit

class Gamma.GA[source]

A class used for implementing the Genetic Algorithm (GA).

get_ga_pool(assembly, pop_size, max_trans, vq_vec_list, quat_vec)[source]

Method used to generate initial population for running GA.

Arguments:
assembly
Instance of a Assembly object.
pop_size
Number of members in the population.
max_trans
Set the translation offset range (in Angstrom) applied to each of the components position generated in the initial population pool.
vq_vec_list
List of Vector objects used to represent initial point configuration which is used to generate initial populatons of fits.
quat_vec
List of Quaternion vectors (in the form of [w,x,y,z]) used for the purpose of applying rotation operation to the components in the assembly.
Return:
Return an instance of a Population object.
run(runs, no_of_gen, pop_size, selection_method, gof, w_gof, w_clash, prot, ncomp, emmap, resolution, logfile, gasnap, vq_vec_list, mrate, crate, moffset, ncpu=1)[source]

Main method to initiate GA cycle.

Arguments:
runs
Number of GA solution to generate.
no_of_gen
Number of GA generations to generate.
pop_size
Number of members in the GA population.
selection_method
Selection method used to pick members in the population for the purpose of generating new population. Currently should be set to 1 for tournament selection.
gof
Option to specify the Goodness-of-fit function to use. Set it to 1 for Mutual information score or 2 for Cross Correlation Coefficient score.
w_gof
Weighting used for Goodness-of-fit score contribution to the GA fitness score.
w_clash
Weighting used for clash penalty score contribution to the GA fitness score.
prot
Instance of a Structure_BioPy object that contain multiple chains used as an input for building Assembly object
ncomp
Number of component in the assembly.
emmap
Instance of a map object.
resolution
Resolution of the map.
logfile
Name of the output logfile.
gasnap
Option used to control the PDB files written during the GA run. Set it to 1 for writing each individual member in the population (fit) in the every GA generation. Default is set to ‘dummy’ which will not write each individual member in the population in every GA generation.
vq_vec_list
List of Vector objects used to represent initial point configuration which is used to generate initial populatons of fits.
mrate
Mutation rate for the mutation operator.
crate
Crossover rate for the mutation operator.
moffset
Set the translation offset range (in Angstrom) applied to each of the components position generated in the initial population pool.
ncpu
Number of cpus to use in parallel through Parallel Python.
Return:
The function return the following items. An instance of the Population object of the final generation. A Structure_BioPy object corresponding to the fittest member in the final genaration and its respective simulated map object. A string containing the best fitness score, Min, Max, Avg, Std and total fitness score of all fits in the final genetation.
score_population(pop, pop_size, gof, w_gof, w_clash, cpu_avil, jobserver, scorer, assembly, emmap, ncomp, cvol, template_grid, apix)[source]

Method used to score memeber in the population.

Arguments:
pop
Instance of the Population object.
pop_size
Number of members in the population.
gof
Option to specify the Goodness-of-fit function to use. Set it to 1 for Mutual information score or 2 for Cross Correlation Coefficient score.
w_gof
Selection method used to pick members in the population for the purpose of generating new population. Currently should be set to 1 for tournament selection.
gof
Option to specify the Goodness-of-fit function to use. Set it to 1 for Mutual information score or 2 for Cross Correlation Coefficient score.
w_gof
Weighting used for Goodness-of-fit score contribution to the GA fitness score.
w_clash
Weighting used for clash penalty score contribution to the GA fitness score.
cpu_avil
Number of cpus to use in parallel through Parallel Python.
jobserver
Instance of the Jobserver object used by Parallel Python.
scorer
Instance of the ScoringFunction object.
assembly
Instance of a Assembly object.
emmap
Instance of a map object.
ncomp
Number of component in the assembly.
cvol
List containing the volume values of the individual components. Used in the calculation of the clash score.
template_grid
Map instance to be used as a template for the purpose of calculating the clash score.
apix
voxel size of the grid
Return:
Return an instance of a Population object with all its member’s fitness been score.
class Gamma.Genotype(gene_types)[source]

A class to store a collection of VectorGene and QuaternionGene that is used to represent the state of the components in the assembly.

breed(otherGenotype, mutationRate, crossRate)[source]

Generate a child genotype after applying crossover and mutation operation using two selected genotypes.

Arguments:
otherGenotype
An instance of Genotype object.
mutationRate
Rate of mutation used.
crossRate
Rate of crossover used.
Return:
Return a child genotype object.
copy()[source]

Randomly select two genes (VectorGene and QuaternionGene) of two component in a genotype and swap them

Return:
Return a copy of the genotype.
get_fitness()[source]

Returns the fitness value of the genotype.

swap()[source]

Randomly select two genes (VectorGene and QuaternionGene) of two component in a genotype and swap them

Return:
Return an instance of a genotype after swapping.
uniform_crossover(otherGenotype, mutationRate, crossRate)[source]

Apply uniform crossover operation between two selected genotype.

Arguments:
otherGenotype
An instance of Genotype object.
mutationRate
Rate of mutation used.
crossRate
Rate of crossover used.
Return:
Return a child genotype object.
class Gamma.Population[source]

A class to store a collection of Genotype objects.

addGenotype(genotype)[source]

Method to append a genotype object to the population.

avg_fitness()[source]

Returns the average fittness score of the genotypes in the population

breedNewPop(no_of_iters, curr_iter, mutation_const, crossRate, sel_method, sel_par)[source]

Returns a population object after performing a series of breeding opetation on the genotype in the current population

breed_1child(mutation_const, crossRate, sel_method, sel_par)[source]

Returns a child genotype after applying crossover and mutation operation

copy()[source]

Returns a copy of the population object.

getBestScores()[source]

Returns a string containing the best fittest value in the pop and its corresponding components of the score (gof,clashscore)

max_fitness()[source]

Returns the best fittness score of the genotype in the population

min_fitness()[source]

Returns the worst fittness score of the genotype in the population

pickBest()[source]

Returns the fittest genotype in the population.

pickSetOfBest(noOfBestGenotypes)[source]

Returns an instance of a population object containing n fittest genotypes.

Arguments:
noOfBestGenotype
Number of fittest genotypes to pick.
pickSetOfWorst(noOfBestGenotypes)[source]

Returns an instance of a population object containing n worst fittest genotypes.

Arguments:
noOfBestGenotype
Number of worst fittest genotypes to pick.
pickWorst()[source]

Returns the worst fittness score of the genotype in the population

size()[source]

Returns the number of genotypes in the population.

std_fitness()[source]

Returns the standard deviation of the fittness values of the genotypes in the population

totalFitnessScore()[source]

Returns a string containing the total, average and the standard deviation of the fitness values in the population.

class Gamma.QuaternionGene(ul_list, w, x, y, z)[source]

A class used to represent the rotational state a component in the assembly and to apply mutation and crossover genetic operators on the component.

check_for_mutations(mutationRate)[source]

Method to apply mutation operator on QuaternionGene based on mutationRate.

Arguments:
mutationRate
Rate of mutation used to decide an application of the mutation operation.
copy()[source]

Returns a copy of a QuaternionGene object.

crossover(otherquat, crossRate)[source]

Method returns a QuaternionGene object among two QuaternionGene based on crossover rate.

Arguments:
otherquat
An instance of a QuaternionGene object.
dot_product(q_param)[source]

Performs the dot product between two quaternion and returns the product in the form of a list of type [w,x,y,z].

Arguments:
q_param
A list of type [w,x,y,z] used to represent a quaternion.
get_interpolated_quat(q2_param)[source]

Return an interpolated QuaternionGene found between two different QuaternionGene.

Arguments:
q2_param
A list of type [w,x,y,z] used of the purpose of finding an interpolated quaternion between two quaternions.
muate()[source]

Mutation operator to set a new value for self.param by randomly picking from the list of precomputed quaternion.

to_rotation_matrix()[source]

Method to convert a quaternion to a rotation matrix.

Return:
A rotation matrix
class Gamma.Selection[source]

A class to implement the selection procedure used to select two genotype for the purpose of creating a child genotype.

roulette_wheel(pop)[source]

Return an instance of a Genotype object selected from the current population using Roulette wheel selection

Arguments:
pop
Instance of a Population object.
tournament(pop, tourn_size=2)[source]

Return an instance of a Genotype object selected from the current population using Tournament selection

Arguments:
pop
Instance of a Population object.
tour_size
Size of the tournament selection.
class Gamma.VectorGene(ul_list, x, y, z)[source]

A class used to record the three dimensional position of a component in the assembly and to apply mutation and crossover genetic operators on them.

check_for_mutations(mutationRate)[source]

Method to apply mutation operator on VectorGene based on mutationRate.

Arguments:
mutationRate
Rate of mutation used to decide an application of the mutation operation.
copy()[source]

Returns a copy of a VectorGene object.

crossover(otherGene, crossRate)[source]

Method to apply crossover operator on VectorGene based on crossover rate.

Arguments:
crossRate
Rate of crossover used to decide an application of the crossover operation.
get_gene_list()[source]

Returns a list of x,y,z coordinates of the vector gene.

mutate()[source]

Mutation operator that modify the x, y, and z coordinates of the VectorGene.

Gamma.move_struct_quat(g, assembly)[source]

Method used to apply the translation and rotation opetations on the individual componets using the information in a given genotype.

Arguments:
g
An instance of a Genotype object.
assembly
An instance of the Assembly object.
Gamma.score_pop_segment_CCC(pop_seg, scorer, assembly, emmap, ncomp, cvol, template_grid, apix)[source]

Method used to score the genotypes (fits) in the population.

Arguments:
pop_seg
An instance of a Population object.
scorer
An instance of the ScoringFunction object.
assembly
An instance of the Assembly object.
emmap
An instance of the map object.
ncomp
Number of components in the assembly.
cvol
List containing the volume values of the individual components. Used in the calculation of the clash score.
template_grid
Map instance to be used as a template for the purpose of calculating the clash score.
apix
voxel size of the grid
w_gof
Weighting used for Goodness-of-fit score contribution to the GA fitness score.
w_clash
Weighting used for clash penalty score contribution to the GA fitness score.
Return:
Return an instance of a Population object with all its member’s fitness been score.
Gamma.score_pop_segment_MI(pop_seg, scorer, assembly, emmap, ncomp, cvol, template_grid, apix, w_gof, w_clash)[source]

Method used to score the genotypes (fits) in the population.

Arguments:
pop_seg
An instance of a Population object.
scorer
An instance of the ScoringFunction object.
assembly
An instance of the Assembly object.
emmap
An instance of the map object.
ncomp
Number of components in the assembly.
cvol
List containing the volume values of the individual components. Used in the calculation of the clash score.
template_grid
Map instance to be used as a template for the purpose of calculating the clash score.
apix
voxel size of the grid
w_gof
Weighting used for Goodness-of-fit score contribution to the GA fitness score.
w_clash
Weighting used for clash penalty score contribution to the GA fitness score.
Return:
Return an instance of a Population object with all its member’s fitness been score.