ConsDB 1.0 Tool for creating consensus genomes from variant databases.

Classes | Public Member Functions | Public Attributes | List of all members
RSEntry.RSEntry Class Reference

## Classes
class | RSVar

## Public Member Functions
def | __init__ (self, chrom, rsid, pos=None)
def | __add__ (self, rse)
def | __eq__ (self, rse)
def | __getitem__ (self, key)
def | __iadd__ (self, rse)
def | __len__ (self)
def | __repr__ (self)
def | __str__ (self)
def | add_var (self, var)
def | add_var_from_args (self, pos, ref, var, major=0, minor=0, clin=[], afs=[], var_type='', pop_afs={})
def | all_vars_empty (self)
def | get_major_alleles (self)
def | get_major_alleles_pop (self, pop)
def | pick_major_allele (self, var_list)
def | to_vcf (self, pop=None, cons=False, is_maj=False)

## Public Attributes
| chrom
| rsid
| pos
| vars

## Detailed Description

    A class to hold all variants at a given position.

    Attributes
    --------------------
    chrom : str
        Which chromosome the entry is on (1-22, X, Y)
    rsid : int
        The RefSNP ID number for the entry
    pos : int
        Base position of the entry (1-indexed)
    vars : dict
        Dictionary that maps variant code strings to RSVariant objects

    Methods
    --------------------
    add_var(var)
        Add a RSVariant object to the RSEntry
    add_var_from_args(pos, ref, var, major=0, minor=0, clin=[], afs=[],
        var_type='', pop_afs={})
        Add a variant to the RSEntry based on the given arguments
    all_vars_empty()
        Check if all variants in the RSEntry are empty
    get_major_alleles()
        Return a list of major RSVariants
    get_major_alleles_pop(pop)
        Return a list of major RSVariants for a given population
    pick_major_allele(var_list)
        Reproducibly choose a representative variant
    to_vcf(pop=None, cons=False, is_maj=False)
        Create a VCF record from variants

## Constructor & Destructor Documentation

## ◆ __init__()

def RSEntry.RSEntry.__init__ | ( |  | self,
|  |  | chrom,
|  |  | rsid,
|  |  | pos = `None`
| ) |  |

    Initialize an instance of the RSEntry class. Requires a chromosome and
    a RSID number. Base position is optional, and if not passed will be
    inferred from the first added variant.

    Parameters:
    chrom: Chromosome of the entry
    rsid: RefSNP ID number of the entry
    pos: Position of the entry

## Member Function Documentation

## ◆ __add__()

def RSEntry.RSEntry.__add__ | ( |  | self,
|  |  | rse
| ) |  |

    Implement addition for two RSEntry objects.

## ◆ __eq__()

def RSEntry.RSEntry.__eq__ | ( |  | self,
|  |  | rse
| ) |  |

    Implement equality checking for two RSEntry objects.

## ◆ __getitem__()

def RSEntry.RSEntry.__getitem__ | ( |  | self,
|  |  | key
| ) |  |

    Allow access to variants via the [] operator.

## ◆ __iadd__()

def RSEntry.RSEntry.__iadd__ | ( |  | self,
|  |  | rse
| ) |  |

    Implement incremental addition.

## ◆ __len__()

def RSEntry.RSEntry.__len__ | ( |  | self | ) |

    Implement len operator.

## ◆ __repr__()

def RSEntry.RSEntry.__repr__ | ( |  | self | ) |

    Implement repr operator.

## ◆ __str__()

def RSEntry.RSEntry.__str__ | ( |  | self | ) |

    Implement str operator.

## ◆ add_var()

def RSEntry.RSEntry.add_var | ( |  | self,
|  |  | var
| ) |  |

    Add a variant by passing an RSVariant object. Note that this creates a
    new RSVar object and doesn't use the passed object.

    Parameters:
    var: RSVar object to add

## ◆ add_var_from_args()

def RSEntry.RSEntry.add_var_from_args | ( |  | self,
|  |  | pos,
|  |  | ref,
|  |  | var,
|  |  | major = `0`,
|  |  | minor = `0`,
|  |  | clin = `[]`,
|  |  | afs = `[]`,
|  |  | var_type = `''`,
|  |  | pop_afs = `{}`
| ) |  |

    Add a variant by passing all necessary information.

    Parameters:
    pos: Variant position
    ref: Reference sequence at the variant position
    var: Variant sequence
    major: Number of studies in dbSNP listing this variant as major
    minor: Number of studies in dbSNP listing this variant as minor
    clin: Clinical significance of this variant
    afs: Allele frequency of this allele
    var_type: Variant type (SNP or indel) of this allele
    pop_afs: Population allele frequencies

## ◆ all_vars_empty()

def RSEntry.RSEntry.all_vars_empty | ( |  | self | ) |

    Check if all variants are empty.

## ◆ get_major_alleles()

def RSEntry.RSEntry.get_major_alleles | ( |  | self | ) |

    Get a list of variants representing a major allele (AF >= 0.5).

## ◆ get_major_alleles_pop()

def RSEntry.RSEntry.get_major_alleles_pop | ( |  | self,
|  |  | pop
| ) |  |

    Get a list of variants representing a major allele (AF >= 0.5) for the
    given population.

    Parameters:
    pop: Population to use

## ◆ pick_major_allele()

def RSEntry.RSEntry.pick_major_allele | ( |  | self,
|  |  | var_list
| ) |  |

    Reproducibly choose a representative variant.

    Parameters:
    var_list: List of RSVar objects to pick from

## ◆ to_vcf()

def RSEntry.RSEntry.to_vcf | ( |  | self,
|  |  | pop = `None`,
|  |  | cons = `False`,
|  |  | is_maj = `False`
| ) |  |

    Create a VCF record from variants. If preparing a consensus VCF
    file, makes sure that there is only one alternate allele per line.

    Parameters:
    pop: Population to use
    cons: If this VCF file is a consensus VCF
    is_maj: If this RSCollection object already contains only major alleles

The documentation for this class was generated from the following file:

- RSEntry.py