예제 #1
0
 def setUpClass(cls):
     global mf, mc, nrows
     inputfile = os.path.realpath(
         os.path.dirname(os.path.realpath(__file__)) +
         "/../../c/test/data/nrvk.10.bin")
     mf, mc, nrows = bs.mmap_nrvk_file(inputfile)
     if nrows <= 0:
         assert False, "Unable to open the nrvk.10.bin file"
예제 #2
0
# (7493989787586955617, 48)

vk.munmap_binfile(mf)


# /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\


# NRVK
# ----

# Load the lookup table for non-reversible variantkeys.
# The input binary files can be generated from a normalized VCF file using the resources/tools/nrvk.sh script.
# The VCF file can be normalized using the `resources/tools/vcfnorm.sh` script.
# This example uses the "c/test/data/nrvk.10.bin".
mf, mc, nrows = vk.mmap_nrvk_file('nrvk.10.bin')
if nrows <= 0:
    assert False, "Unable to open the nrvk.10.bin file"

vk.find_ref_alt_by_variantkey(mc, vk=0x2000c3521f1c15ab)
# (b'ACGTACGT', b'ACGT', 8, 4, 12)
# Return values are: REF, ALT, REF length, ALT length, REF+ALT length

# Reverse all VariantKeys, including the ones that are not directly reversible by using a lookup table.
vk.reverse_variantkey(mc, vk=0x2000c3521f1c15ab)
# (b'4', 100004, b'ACGTACGT', b'ACGT', 8, 4, 12)
# Return values are: CHROM, POS, REF, ALT, REF length, ALT length, REF+ALT length

vk.get_variantkey_ref_length(mc, vk=0x2000c3521f1c15ab)
# 8
예제 #3
0
    def __init__(self,
                 genoref_file=None,
                 nrvk_file=None,
                 rsvk_file=None,
                 vkrs_file=None):
        """Instantiate a new VariantKey object.
        Load the support files if specified.

        Parameters
        ----------
        genoref_file : string
            Name and path of the binary file containing the genome reference (fasta.bin).
            This file can be generated from a FASTA file using the resources/tools/fastabin.sh script.
        nrvk_file : string
            Name and path of the binary file containing the non-reversible-VariantKey mapping (nrvk.bin).
            This file can be generated from a normalized VCF file using the resources/tools/nrvk.sh script.
        rsvk_file : string
            Name and path of the binary file containing the rsID to VariantKey mapping (rsvk.bin).
            This file can be generated using the resources/tools/rsvk.sh script.
        vkrs_file : string
            Name and path of the binary file containing the VariantKey to rsID mapping (vkrs.bin).
            This file can be generated using the resources/tools/vkrs.sh script.
        """

        self.genoref_mf = None
        self.genoref_size = 0
        self.nrvk_mf = None
        self.nrvk_mc = None
        self.nrvk_nrows = 0
        self.rsvk_mf = None
        self.rsvk_mc = None
        self.rsvk_nrows = 0
        self.vkrs_mf = None
        self.vkrs_mc = None
        self.vkrs_nrows = 0

        if genoref_file is not None:
            # Load the reference genome binary file.
            self.genoref_mf, self.genoref_size = pvk.mmap_genoref_file(
                genoref_file)
            if self.genoref_size <= 0:
                raise Exception('Unable to load the GENOREF file: {0}'.format(
                    genoref_file))

        if nrvk_file is not None:
            # Load the lookup table for non-reversible variantkeys.
            self.nrvk_mf, self.nrvk_mc, self.nrvk_nrows = pvk.mmap_nrvk_file(
                nrvk_file)
            if self.nrvk_nrows <= 0:
                raise Exception(
                    'Unable to load the NRVK file: {0}'.format(nrvk_file))

        if rsvk_file is not None:
            # Load the lookup table for rsID to VariantKey.
            self.rsvk_mf, self.rsvk_mc, self.rsvk_nrows = pvk.mmap_rsvk_file(
                rsvk_file, [4, 8])
            if self.rsvk_nrows <= 0:
                raise Exception(
                    'Unable to load the RSVK file: {0}'.format(rsvk_file))

        if vkrs_file is not None:
            # Load the lookup table for VariantKey ro rsID
            self.vkrs_mf, self.vkrs_mc, self.vkrs_nrows = pvk.mmap_vkrs_file(
                vkrs_file, [8, 4])
            if self.vkrs_nrows <= 0:
                raise Exception(
                    'Unable to load the VKRS file: {0}'.format(vkrs_file))