Exemplo n.º 1
0
def annotate(options, titleRow, evidence):
    '''Annotate variants which appear in a sample of a family member'''
    annotateFilename = options.annotations
    with open(annotateFilename,'w') as annotateFile:
        csvWriter = csv.writer(annotateFile, delimiter='\t', quotechar='|')
        if titleRow:
            csvWriter.writerow(titleRow)
        inFamily = []
        notInFamily = []
        # sort the variants by coordinate
        # XXX does this include the variant multiple times?
#        for key,info in sortByCoord(evidence):
#            for readCount,depth in info.counts:
#                if readCount > 0:
#                    inFamily.append(info.inputRow)
#                else:
#                    notInFamily.append(info.inputRow)
        for key,info in sortByCoord(evidence):
           countSum = sum([readCount for (readCount,depth) in info.counts])
           if countSum > 0:
              inFamily.append(info.inputRow)
           else:
              notInFamily.append(info.inputRow)
        for row in inFamily:
             csvWriter.writerow(row + ['IN RELATIVE'])
        for row in notInFamily:
             csvWriter.writerow(row + ['NOT IN RELATIVE'])
    print('Annotated reads saved into file: %s' % annotateFilename)
Exemplo n.º 2
0
def filter(options, evidence):
    '''Decide which variants to keep and which to bin.'''
    binFilename = options.bin
    keepFilename = options.keep
    logFilename = options.log
    with open(logFilename, 'w') as logFile:
        with open(binFilename, 'w') as binFile:
            with open(keepFilename, 'wb') as keepFile:
                csvWriter = csv.writer(keepFile, delimiter='\t', quotechar='|')
                # sort the variants by coordinate
                for key, info in sortByCoord(evidence):
                    classification = classify(options, info.counts)
                    # record the classification of this variant in the logfile
                    logFile.write(
                        "%s: %s: %s\n" %
                        (key, classification.action, classification.reason))
                    if classification.action == 'bin':
                        # bin the variant
                        binFile.write('%s\n' % key)
                        for readCount, depth in info.counts:
                            binFile.write('    <vars/coverage: %d/%d>\n' %
                                          (readCount, depth))
                    elif classification.action == 'keep':
                        # keep the variant
                        csvWriter.writerow(info.inputRow)
Exemplo n.º 3
0
def filter(options, evidence):
    '''Decide which variants to keep and which to bin.'''
    binFilename =  options.bin
    keepFilename = options.keep
    logFilename = options.log
    with open (logFilename,'w') as logFile:
        with open(binFilename,'w') as binFile:
            with open(keepFilename,'wb') as keepFile:
                csvWriter = csv.writer(keepFile, delimiter='\t', quotechar='|')
                # sort the variants by coordinate
                for key,info in sortByCoord(evidence):
                    classification = classify(options, info.counts)
                    # record the classification of this variant in the logfile
                    logFile.write("%s: %s: %s\n" % (key, classification.action, classification.reason))
                    if classification.action == 'bin':
                        # bin the variant
                        binFile.write('%s\n' % key)
                        for readCount,depth in info.counts:
                            binFile.write('    <vars/coverage: %d/%d>\n' % (readCount,depth))
                    elif classification.action == 'keep':
                        # keep the variant
                        csvWriter.writerow(info.inputRow)