Пример #1
0
 def setup():
     global rvmf, rvmc, rvnrows
     bs.munmap_binfile(rvmf)
     inputfile = os.path.realpath(
         os.path.dirname(os.path.realpath(__file__)) +
         "/../../c/test/data/rsvk.10.bin")
     rvmf, rvmc, rvnrows = bs.mmap_rsvk_file(inputfile, [4, 8])
     if rvnrows <= 0:
         assert False, "Unable to open the rsvk.10.bin file"
     global vrmf, vrmc, vrnrows
     bs.munmap_binfile(vrmf)
     inputfile = os.path.realpath(
         os.path.dirname(os.path.realpath(__file__)) +
         "/../../c/test/data/vkrs.10.bin")
     vrmf, vrmc, vrnrows = bs.mmap_vkrs_file(inputfile, [8, 4])
     if vrnrows <= 0:
         assert False, "Unable to open the vkrs.10.bin file"
Пример #2
0
# This example uses the "c/test/data/rsvk.m.10.bin".
mf, mc, nrows = vk.mmap_rsvk_file('rsvk.m.10.bin', [])
if nrows <= 0:
    assert False, "Unable to open the rsvk.m.10.bin file"

vk.find_all_rv_variantkey_by_rsid(mc, 0, nrows, 0x00000003)
# [9223656209074749440, 9223656316446408704, 9223656367992733696]

vk.munmap_binfile(mf)

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Load the lookup table for VariantKey ro rsID
# The input binary file can be generated using the resources/tools/vkrs.sh script.
# This example uses the "c/test/data/vkrs.10.bin".
mf, mc, nrows = vk.mmap_vkrs_file('vkrs.10.bin', [])
if nrows <= 0:
    assert False, "Unable to open the vkrs.10.bin file"

vk.find_vr_rsid_by_variantkey(mc, 0, nrows, vk=0X80010274003A0000)
# (97, 3)

vk.get_next_vr_rsid_by_variantkey(mc, 2, nrows, vk=0X80010274003A0000)
# (97, 3)

vk.find_all_vr_rsid_by_variantkey(mc, 0, nrows, vk=0X80010274003A0000)
# [97]

vk.find_vr_chrompos_range(mc, 0, nrows, 0X14, 0X000256C5, 0X000256CB)
# (9973, 7, 9)
Пример #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))