Returns a VVR or decompressed CVVR block
19397
def _read_vvr_block(self, offset):
        '''
        
        '''
        with self.file.open('rb') as f:
            f.seek(offset, 0)
            block_size = int.from_bytes(f.read(8), 'big')
            block = f.read(block_size-8)

        section_type = int.from_bytes(block[0:4], 'big')
        if section_type == 13:
            # a CVVR
            compressed_size = int.from_bytes(block[12:16], 'big')
            return gzip.decompress(block[16:16+compressed_size])
        elif section_type == 7:
            # a VVR
            return block[4:]
1080399
def get_frames(self):
        """"""
        frames = super(CalibratedPair, self).get_frames()
        return self.calibration.rectify(frames)
478206
def _variant_vc(checkpoints):
    
    if not checkpoints.get("vc"):
        return [], []
    vc_wf = [s("get_parallel_regions", "batch-split",
               [["batch_rec"]],
               [cwlout(["region_block"], {"type": "array", "items": "string"})],
               "bcbio-vc",
               disk={"files": 2.0}, cores=1),
             s("variantcall_batch_region", "batch-parallel",
               [["batch_rec"], ["region_block"]],
               [cwlout(["vrn_file_region"], ["File", "null"], [".tbi"]),
                cwlout(["region_block"], {"type": "array", "items": "string"})],
               "bcbio-vc", ["bcftools", "bedtools", "freebayes=1.1.0.46",
                            "gatk4", "vqsr_cnn", "deepvariant;env=dv", "sentieon;env=python2",
                            "htslib", "octopus", "picard", "platypus-variant;env=python2", "pythonpy",
                            "samtools", "pysam>=0.13.0", "strelka;env=python2", "vardict", "vardict-java",
                            "varscan", "moreutils", "vcfanno", "vcflib", "vt", "r=3.5.1", "r-base",
                            "perl"],
               disk={"files": 2.0}),
             s("concat_batch_variantcalls", "batch-merge",
               [["batch_rec"], ["region_block"], ["vrn_file_region"]],
               [cwlout(["vrn_file"], "File", [".tbi"])],
               "bcbio-vc", ["bcftools", "htslib", "gatk4"],
               disk={"files": 1.5}, cores=1)]
    if not checkpoints.get("jointvc"):
        vc_wf += [s("postprocess_variants", "batch-single",
                    [["batch_rec"], ["vrn_file"]],
                    [cwlout(["vrn_file"], "File", [".tbi"])],
                    "bcbio-vc", ["snpeff=4.3.1t"], disk={"files": 0.5})]
    vc_rec_exclude = [["align_bam"]]
    if not checkpoints.get("jointvc"):
        vc_rec_exclude.append(["genome_resources", "variation"])
    vc_wf += [s("compare_to_rm", "batch-single",
                [["batch_rec"], ["vrn_file"]],
                [cwlout("vc_rec", "record",
                        fields=[cwlout(["batch_samples"], ["null", {"type": "array", "items": "string"}]),
                                cwlout(["validate", "summary"], ["File", "null"]),
                                cwlout(["validate", "tp"], ["File", "null"], [".tbi"]),
                                cwlout(["validate", "fp"], ["File", "null"], [".tbi"]),
                                cwlout(["validate", "fn"], ["File", "null"], [".tbi"]),
                                cwlout("inherit", exclude=vc_rec_exclude)])],
                "bcbio-vc", ["bcftools", "bedtools", "pythonpy", "gvcf-regions;env=python2",
                             "htslib", "rtg-tools", "vcfanno"],
                disk={"files": 1.5})]
    batch_in = [["analysis"], ["genome_build"], ["align_bam"], ["vrn_file"],
                ["metadata", "batch"], ["metadata", "phenotype"],
                ["config", "algorithm", "callable_regions"], ["regions", "sample_callable"],
                ["config", "algorithm", "variantcaller"],
                ["config", "algorithm", "ensemble"],
                ["config", "algorithm", "vcfanno"],
                ["config", "algorithm", "coverage_interval"],
                ["config", "algorithm", "effects"],
                ["config", "algorithm", "min_allele_fraction"],
                ["config", "algorithm", "exclude_regions"],
                ["config", "algorithm", "variant_regions"],
                ["config", "algorithm", "variant_regions_merged"],
                ["config", "algorithm", "validate"], ["config", "algorithm", "validate_regions"],
                ["config", "algorithm", "tools_on"],
                ["config", "algorithm", "tools_off"],
                ["reference", "fasta", "base"],
                ["reference", "rtg"], ["reference", "genome_context"],
                ["genome_resources", "variation", "clinvar"],
                ["genome_resources", "variation", "cosmic"], ["genome_resources", "variation", "dbsnp"],
                ["genome_resources", "variation", "esp"], ["genome_resources", "variation", "exac"],
                ["genome_resources", "variation", "gnomad_exome"],
                ["genome_resources", "variation", "1000g"],
                ["genome_resources", "variation", "lcr"], ["genome_resources", "variation", "polyx"],
                ["genome_resources", "variation", "encode_blacklist"],
                ["genome_resources", "aliases", "ensembl"], ["genome_resources", "aliases", "human"],
                ["genome_resources", "aliases", "snpeff"], ["reference", "snpeff", "genome_build"]]
    if checkpoints.get("umi"):
        batch_in.append(["config", "algorithm", "umi_type"])
    if checkpoints.get("rnaseq"):
        batch_in += [["genome_resources", "variation", "editing"]]
    else:
        batch_in += [["genome_resources", "variation", "train_hapmap"],
                     ["genome_resources", "variation", "train_indels"]]
    vc = [s("batch_for_variantcall", "multi-batch", batch_in,
            [cwlout("batch_rec", "record",
                    fields=[cwlout(["config", "algorithm", "variantcaller_order"], "int"),
                            cwlout("inherit")])],
            "bcbio-vc",
            disk={"files": 2.0}, cores=1,
            unlist=[["config", "algorithm", "variantcaller"]], no_files=True),
          w("variantcall", "multi-parallel", vc_wf,
            [["region"], ["region_block"], ["vrn_file_region"], ["vrn_file"], ["validate", "summary"]])]
    if checkpoints.get("jointvc"):
        vc += _variant_jointvc()
    if checkpoints.get("ensemble"):
        vc += _variant_ensemble(checkpoints)
    summarize_in = [["jointvc_rec" if checkpoints.get("jointvc") else "vc_rec"]]
    if checkpoints.get("ensemble"):
        summarize_in += [["ensemble_rec"]]
    vc += [s("summarize_vc", "multi-combined", summarize_in,
             [cwlout(["variants", "calls"], {"type": "array", "items": ["File", "null"]}),
              cwlout(["variants", "gvcf"], ["null", {"type": "array", "items": ["File", "null"]}]),
              cwlout(["variants", "samples"], {"type": "array", "items": {"type": "array",
                                                                          "items": ["File", "null"]}}),
              cwlout(["validate", "grading_summary"], ["File", "null"]),
              cwlout(["validate", "grading_plots"], {"type": "array", "items": ["File", "null"]})],
             "bcbio-vc",
             disk={"files": 2.0}, cores=1)]
    return vc, [["validate", "grading_summary"], ["variants", "calls"], ["variants", "gvcf"]]
458177
def get_capture_dimensions(capture):
    """"""
    width = int(capture.get(cv2.CAP_PROP_FRAME_WIDTH))
    height = int(capture.get(cv2.CAP_PROP_FRAME_HEIGHT))
    return width, height
1333140
def _decompose(net, wv_map, mems, block_out):
    

    def arg(x, i):
        # return the mapped wire vector for argument x, wire number i
        return wv_map[(net.args[x], i)]

    def destlen():
        # return iterator over length of the destination in bits
        return range(len(net.dests[0]))

    def assign_dest(i, v):
        # assign v to the wiremap for dest[0], wire i
        wv_map[(net.dests[0], i)] <<= v

    one_var_ops = {
        'w': lambda w: w,
        '~': lambda w: ~w,
    }
    c_two_var_ops = {
        '&': lambda l, r: l & r,
        '|': lambda l, r: l | r,
        '^': lambda l, r: l ^ r,
        'n': lambda l, r: l.nand(r),
    }

    if net.op in one_var_ops:
        for i in destlen():
            assign_dest(i, one_var_ops[net.op](arg(0, i)))
    elif net.op in c_two_var_ops:
        for i in destlen():
            assign_dest(i, c_two_var_ops[net.op](arg(0, i), arg(1, i)))
    elif net.op == 's':
        for i in destlen():
            selected_bit = arg(0, net.op_param[i])
            assign_dest(i, selected_bit)
    elif net.op == 'c':
        arg_wirelist = []
        # generate list of wires for vectors being concatenated
        for arg_vector in net.args:
            arg_vector_as_list = [wv_map[(arg_vector, i)] for i in range(len(arg_vector))]
            arg_wirelist = arg_vector_as_list + arg_wirelist
        for i in destlen():
            assign_dest(i, arg_wirelist[i])
    elif net.op == 'r':
        for i in destlen():
            args = (arg(0, i),)
            dests = (wv_map[(net.dests[0], i)],)
            new_net = LogicNet('r', None, args=args, dests=dests)
            block_out.add_net(new_net)
    elif net.op == 'm':
        arg0list = [arg(0, i) for i in range(len(net.args[0]))]
        addr = concat_list(arg0list)
        new_mem = _get_new_block_mem_instance(net.op_param, mems, block_out)[1]
        data = as_wires(new_mem[addr])
        for i in destlen():
            assign_dest(i, data[i])
    elif net.op == '@':
        addrlist = [arg(0, i) for i in range(len(net.args[0]))]
        addr = concat_list(addrlist)
        datalist = [arg(1, i) for i in range(len(net.args[1]))]
        data = concat_list(datalist)
        enable = arg(2, 0)
        new_mem = _get_new_block_mem_instance(net.op_param, mems, block_out)[1]
        new_mem[addr] <<= MemBlock.EnabledWrite(data=data, enable=enable)
    else:
        raise PyrtlInternalError('Unable to synthesize the following net '
                                 'due to unimplemented op :\n%s' % str(net))
    return
1239593
def _rlfunc(rl,lz,pot):
    """"""
    thisvcirc= vcirc(pot,rl,use_physical=False)
    return rl*thisvcirc-lz
216042
def subseparable_conv_block(inputs, filters, dilation_rates_and_kernel_sizes,
                            **kwargs):
  """"""
  return conv_block_internal(subseparable_conv, inputs, filters,
                             dilation_rates_and_kernel_sizes, **kwargs)
527561
def md2tvd(self, kind='linear'):
        
        if self.position is None:
            return lambda x: x
        return interp1d(self.md, self.tvd,
                        kind=kind,
                        assume_sorted=True,
                        fill_value="extrapolate",
                        bounds_error=False)
354899
def get_vq_codebook(codebook_size, hidden_size):
  """"""
  with tf.variable_scope("vq", reuse=tf.AUTO_REUSE):
    means = tf.get_variable(
        name="means",
        shape=[codebook_size, hidden_size],
        initializer=tf.uniform_unit_scaling_initializer())

    ema_count = tf.get_variable(
        name="ema_count",
        shape=[codebook_size],
        initializer=tf.constant_initializer(0),
        trainable=False)

    with tf.colocate_with(means):
      ema_means = tf.get_variable(
          name="ema_means",
          initializer=means.initialized_value(),
          trainable=False)

  return means, ema_means, ema_count
586280
def libvlc_video_get_adjust_float(p_mi, option):
    '''
    '''
    f = _Cfunctions.get('libvlc_video_get_adjust_float', None) or \
        _Cfunction('libvlc_video_get_adjust_float', ((1,), (1,),), None,
                    ctypes.c_float, MediaPlayer, ctypes.c_uint)
    return f(p_mi, option)
532509
def getVC(self):
        
        _Cr = decompose_GxE(self.fr['Cr'])
        RV = {}
        for key in list(_Cr.keys()):
            RV['var_%s' % key] = sp.array([var_CoXX(_Cr[key], self.Xr)])
        RV['var_g'] = sp.array([var_CoXX(self.fr['Cg'], self.XXh)])
        RV['var_n'] = sp.array([var_CoXX(self.fr['Cn'], sp.eye(self.XXh.shape[0]))])
        return RV
155324
def frame(x):
    
    x = stypes.toDoubleVector(x)
    y = stypes.emptyDoubleVector(3)
    z = stypes.emptyDoubleVector(3)
    libspice.frame_c(x, y, z)
    return stypes.cVectorToPython(x), stypes.cVectorToPython(y), stypes.cVectorToPython(
            z)
645902
def key_CV(key, kcv_length=6):
    
    cipher = DES3.new(B2raw(key), DES3.MODE_ECB)
    encrypted = raw2B(cipher.encrypt(B2raw(b'00000000000000000000000000000000')))

    return encrypted[:kcv_length]
876753
def getVulkanDeviceExtensionsRequired(self, pchValue, unBufferSize):
        

        fn = self.function_table.getVulkanDeviceExtensionsRequired
        pPhysicalDevice = VkPhysicalDevice_T()
        result = fn(byref(pPhysicalDevice), pchValue, unBufferSize)
        return result, pPhysicalDevice
621622
def _M2(Xvar, Yvar, mask_X=None, mask_Y=None, xsum=0, xconst=0, ysum=0, yconst=0, weights=None, diag_only=False):
    
    if mask_X is None and mask_Y is None:
        return _M2_dense(Xvar, Yvar, weights=weights, diag_only=diag_only)
    else:
        # Check if one of the masks is not None, modify it and also adjust the constant columns:
        if mask_X is None:
            mask_X = np.ones(Xvar.shape[1], dtype=np.bool)
            xconst = np.ones(0, dtype=float)
        if mask_Y is None:
            mask_Y = np.ones(Yvar.shape[1], dtype=np.bool)
            yconst = np.ones(0, dtype=float)
    if _is_zero(xsum) and _is_zero(ysum) or _is_zero(xconst) and _is_zero(yconst):
        return _M2_sparse(Xvar, mask_X, Yvar, mask_Y, weights=weights)
    else:
        return _M2_const(Xvar, mask_X, xsum[mask_X], xconst, Yvar, mask_Y, ysum[mask_Y], yconst, weights=weights)
231459
def cnvlTcOld(idxPrc,
              aryPrfTcChunk,
              varTr,
              varNumVol,
              queOut):
    
    # Create 'canonical' HRF time course model:
    vecHrf = funcHrf(varNumVol, varTr)

    # adjust the input, if necessary, such that input is 2D, with last dim time
    tplInpShp = aryPrfTcChunk.shape
    aryPrfTcChunk = aryPrfTcChunk.reshape((-1, aryPrfTcChunk.shape[-1]))

    # Prepare an empty array for ouput
    aryConv = np.zeros(np.shape(aryPrfTcChunk))

    # Each time course is convolved with the HRF separately, because the
    # numpy convolution function can only be used on one-dimensional data.
    # Thus, we have to loop through time courses:
    for idxTc, vecTc in enumerate(aryPrfTcChunk):

        # In order to avoid an artefact at the end of the time series, we have
        # to concatenate an empty array to both the design matrix and the HRF
        # model before convolution.
        vecTc = np.append(vecTc, np.zeros(100))
        vecHrf = np.append(vecHrf, np.zeros(100))

        # Convolve design matrix with HRF model:
        aryConv[idxTc, :] = np.convolve(vecTc, vecHrf,
                                        mode='full')[:varNumVol]

    # determine output shape
    tplOutShp = tplInpShp[:-1] + (1, ) + (tplInpShp[-1], )

    # Create list containing the convolved timecourses, and the process ID:
    lstOut = [idxPrc,
              aryConv.reshape(tplOutShp)]

    # Put output to queue:
    queOut.put(lstOut)
705441
def bInit( self, vrModel, vrDiffuseTexture ):
        ""
        # create and bind a VAO to hold state for this model
        self.m_glVertArray = glGenVertexArrays(1)
        glBindVertexArray( self.m_glVertArray )
        # Populate a vertex buffer
        self.m_glVertBuffer = glGenBuffers(1)
        glBindBuffer( GL_ARRAY_BUFFER, self.m_glVertBuffer )
        glBufferData( GL_ARRAY_BUFFER, sizeof( openvr.RenderModel_Vertex_t ) * vrModel.unVertexCount, vrModel.rVertexData, GL_STATIC_DRAW )
        # Identify the components in the vertex buffer
        glEnableVertexAttribArray( 0 )
        glVertexAttribPointer( 0, 3, GL_FLOAT, False, sizeof( openvr.RenderModel_Vertex_t ), openvr.RenderModel_Vertex_t.vPosition.offset )
        glEnableVertexAttribArray( 1 )
        glVertexAttribPointer( 1, 3, GL_FLOAT, False, sizeof( openvr.RenderModel_Vertex_t ), openvr.RenderModel_Vertex_t.vNormal.offset )
        glEnableVertexAttribArray( 2 )
        glVertexAttribPointer( 2, 2, GL_FLOAT, False, sizeof( openvr.RenderModel_Vertex_t ), openvr.RenderModel_Vertex_t.rfTextureCoord.offset )
        # Create and populate the index buffer
        self.m_glIndexBuffer = glGenBuffers(1)
        glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, self.m_glIndexBuffer )
        glBufferData( GL_ELEMENT_ARRAY_BUFFER, sizeof( ctypes.c_uint16 ) * vrModel.unTriangleCount * 3, vrModel.rIndexData, GL_STATIC_DRAW )
        glBindVertexArray( 0 )
        # create and populate the texture
        self.m_glTexture = glGenTextures(1)
        glBindTexture( GL_TEXTURE_2D, self.m_glTexture )
        glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, vrDiffuseTexture.unWidth, vrDiffuseTexture.unHeight,
            0, GL_RGBA, GL_UNSIGNED_BYTE, vrDiffuseTexture.rubTextureMapData )
        # If this renders black ask McJohn what's wrong.
        glGenerateMipmap(GL_TEXTURE_2D)
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE )
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE )
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR )
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR )
        fLargest = glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT )
        glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargest )
        glBindTexture( GL_TEXTURE_2D, 0 )
        self.m_unVertexCount = vrModel.unTriangleCount * 3
        return True