libPoMo.main

This library contains functions that are used by PoMo.

libPoMo.main.a(n)[source]

Calculate the Watterson’s Theta coefficient.

libPoMo.main.binom(s, p, n)[source]

Binomial Distribution

Calculate the binomial sampling probability (not very efficient, but not much effieciency is needed with small samples).

libPoMo.main.dsRatio(dsR)[source]

Downsampling ratio type for argparse.

libPoMo.main.get_data_from_cf_line(cfStr)[source]

Read in the data of a single counts format line.

The return type is a list with the number of samples and a two dimensional array of the form data[species][nucleotide], where species is the index of the species and nucleotide is the index of the nucleotide (0,1,2 or 3 for a,c,g and t, respectively).

Parameters:CFStream (cfStr) – The CFStream pointing to the line to be read in.
Return type:([int] n_samples, [[int]] data)
libPoMo.main.get_species_from_cf_headerline(line)[source]

Get the number of species and the names fom a counts format header line.

Parameters:line (str) – The header line.
Return type:(int n_species, [str] sp_names)
libPoMo.main.is_number(s)[source]

Determine if value is an integer.

libPoMo.main.mutModel(mm)[source]

Mutation model type for argparse.

libPoMo.main.probability_matrix(n)[source]

Create probability matrices for the HyPhy batch file.

libPoMo.main.read_data_write_HyPhy_input(fn, N, thresh, path_bf, muts, mutgamma, sels, selgamma, PoModatafile, PoModatafile_cons, theta=None, vb=None)[source]

Read the count data and write the HyPhy input file.

The provided filename has to point to a data file in counts format (cf. cf). The data will be downsampled if necessary and the HyPhy batch and input files will be written. The number of species, the species names, the number of species samples and the theta value (usr_def) will be returned in a tuple.

Parameters:
  • fn (str) – Counts format file name.
  • N (int) – Virtual population size.
  • thresh (float) – Trheshold of data discard for downsampling.
  • path_bf (str) – Path to the HyPhy batch files
  • muts (str) – Mutation model (mutModel()).
  • mutgamma (str) – Gamma of the mutation model (setGM()).
  • sels (str) – Selection model (selModel()).
  • selgamma (str) – Gamma of selection model (setGS()).
  • PoModatafile (str) – Path to HyPhy input file.
  • PoModatafile_cons (str) – Path to HyPhy input file.
  • vb (Boolean) – Verbosity.
Return type:

(int n_species, [str] sp_names, [str] sp_samples, Boolean all_one, float usr_def)

libPoMo.main.selModel(sm)[source]

Selection model type for argparse.

libPoMo.main.setGM(gm)[source]

Set variable mutation rate, if gm is given.

libPoMo.main.setGS(gs)[source]

Set fixation bias, if gs is given.

libPoMo.main.timeStr()[source]

Time in human readable format.