-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
692d54a
commit 4bdb528
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
def vcfExtract(vcf): | ||
import allel | ||
vcfInfo = allel.vcf_to_dataframe(vcf, ['variants/CHROM', 'variants/POS', 'variants/REF', 'variants/ALT'], alt_number=1) | ||
return vcfInfo | ||
#extract information from vcf to a df | ||
|
||
def vcfDFtoList(vcfdf): | ||
vcfList = vcfdf.values.tolist() | ||
return vcfList | ||
#convert df to a list | ||
|
||
def snvINDELlists(snvList, indelList, variantsList): | ||
for variant in variantsList: | ||
ref = len(str(variant[2])) | ||
alt = len(str(variant[3])) | ||
if (ref > 1 or alt > 1): | ||
indelList.append(variant) | ||
else: | ||
snvList.append(variant) | ||
#separate SNVs and INDELs into separate lists | ||
#this function takes (1) two empty SNV and INDEL lists and (2) a list with variants, and separates the variants according to size (SNVs and INDELs) | ||
|
||
def variantCalls(truth, query): | ||
TPs = [x for x in query if x in truth] | ||
FPs = [x for x in query if x not in truth] | ||
FNs = [x for x in truth if x not in query] | ||
return TPs, FPs, FNs |