[go: nahoru, domu]

Skip to content

Commit

Permalink
moved variantSeparation class to fun.py
Browse files Browse the repository at this point in the history
  • Loading branch information
LindoNkambule committed Dec 2, 2019
1 parent d25048e commit ffa7a6d
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 54 deletions.
56 changes: 2 additions & 54 deletions src/python/VCFCompare.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,7 @@
import os
import argparse
import csv
from fun import infoExtract, createLists, concordance


class variantSeparation:
def __init__(self, truth, query):
self.truth = truth
self.query = query


def SNVs(self):
snv = []
# Truth and Query
tsnv = createLists(self.truth).snvList()
truthSNVs = len(tsnv)
qsnv = createLists(self.query).snvList()
querySNVs = len(qsnv)

# Calls, Recall, and Precision
stp, sfp, sfn = concordance(tsnv, qsnv).variantCalls()
lenstp = len(stp)
lensfp = len(sfp)
lensfn = len(sfn)

try:
snvRecall = lenstp/(lenstp+lensfn)
snvPrecision = lenstp/(lenstp+lensfp)
snv.extend(('SNV', truthSNVs, lenstp, lensfp, lensfn, querySNVs, snvRecall, snvPrecision))
except Exception:
pass
return snv


def INDELs(self):
indel = []
# Truth and Query
tindel = createLists(self.truth).indelList()
truthINDELs = len(tindel)
qindel = createLists(self.query).indelList()
queryINDELs = len(qindel)

# Calls, Recall, and Precision
itp, ifp, ifn = concordance(tindel, qindel).variantCalls()
lenitp = len(itp)
lenifp = len(ifp)
lenifn = len(ifn)

try:
indelRecall = lenitp/(lenitp+lenifn)
indelPrecision = lenitp/(lenitp+lenifp)
indel.extend(('INDEL', truthINDELs, lenitp, lenifn, lenifn, queryINDELs, indelRecall, indelPrecision))
except Exception:
pass
return indel
from fun import infoExtract, createLists, concordance, variantSeparation


def main():
Expand All @@ -77,7 +25,7 @@ def main():

truth_list = infoExtract(args.truth).alleles()
query_list = infoExtract(args.query).alleles()


# Totals
Truth_Total = len(truth_list)
Expand Down
53 changes: 53 additions & 0 deletions src/python/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,59 @@ def snvINDELlists(self):
snvList.append(variant)
return snvList, indelList


class variantSeparation:
def __init__(self, truth, query):
self.truth = truth
self.query = query


def SNVs(self):
snv = []
# Truth and Query
tsnv = createLists(self.truth).snvList()
truthSNVs = len(tsnv)
qsnv = createLists(self.query).snvList()
querySNVs = len(qsnv)

# Calls, Recall, and Precision
stp, sfp, sfn = concordance(tsnv, qsnv).variantCalls()
lenstp = len(stp)
lensfp = len(sfp)
lensfn = len(sfn)

try:
snvRecall = lenstp/(lenstp+lensfn)
snvPrecision = lenstp/(lenstp+lensfp)
snv.extend(('SNV', truthSNVs, lenstp, lensfp, lensfn, querySNVs, snvRecall, snvPrecision))
except Exception:
pass
return snv


def INDELs(self):
indel = []
# Truth and Query
tindel = createLists(self.truth).indelList()
truthINDELs = len(tindel)
qindel = createLists(self.query).indelList()
queryINDELs = len(qindel)

# Calls, Recall, and Precision
itp, ifp, ifn = concordance(tindel, qindel).variantCalls()
lenitp = len(itp)
lenifp = len(ifp)
lenifn = len(ifn)

try:
indelRecall = lenitp/(lenitp+lenifn)
indelPrecision = lenitp/(lenitp+lenifp)
indel.extend(('INDEL', truthINDELs, lenitp, lenifn, lenifn, queryINDELs, indelRecall, indelPrecision))
except Exception:
pass
return indel


class concordance():
def __init__(self, truth, query):
self.truth = truth
Expand Down

0 comments on commit ffa7a6d

Please sign in to comment.