Skip to content

Adding new SNP formats

haraldgrove edited this page Jun 4, 2014 · 4 revisions

How to add support for new formats.

  1. Make a new file called io.py in the convmods folder

  2. Add the following code and expand where needed:

    class Geno(object): """ The class name must be 'Geno' """

     def __init__(self, ped=None, mark=None):
         """ Storing the provided pedigree and marker is only required if the
             file format requires it.
         """
         self.ped = ped # Contains information about the pedigree
         # ped = {}
         # ped[sample] = {'father':'','mother':'','family':[],'sex':'','phe':'','pos':0,'children':[],'pedlist':[]}
         self.mark = mark # Contains information about the markers
         # mark = {}
         # mark[SNP] = {'chrom':'','pos':0,'a1':'','a1x':0,'a2':'','a2x':0,'rank':0,'marklist':[]}
    
     def updateped(self):
         """ This is called before starting to read/write,
             use it to format the pedigree information before output, if required.
             For instance, adding family information to the samples.
         """
    
     def updatemark(self):
         """ This is called before starting to read/write,
             use it to format the marker information before output, if required.
             For instance, changing alleles representation from 'ACGT' to '1234'.
         """
    
     def translate(self,line):
         """ Convert the line just read from the input file to a list,
             containing the sample name and then genotypes as 0/1/2, with unknown as 'nan'.
             ex. ['Sample1','0','0','1','0','nan','2']
             Comment lines should not be returned.
         """
    
     def write(self,fout,glist):
         """ Prints out the genotypes in the provided list
             The format of the list is the same as mentioned under 'translate'
             Pedigree and marker information should be in the self.ped and self.mark dicts
         """
    
Clone this wiki locally