示例#1
0
 def _from_java(jtt):
     return tmatrix(dtype(jtt.globalType().toString()),
                    dtype(jtt.colType().toString()),
                    jiterable_to_list(jtt.colKey()),
                    dtype(jtt.rowType().toString()),
                    jiterable_to_list(jtt.rowKey()),
                    dtype(jtt.entryType().toString()))
示例#2
0
 def _from_java(jtt):
     return tmatrix(
         dtype(jtt.globalType().toString()),
         dtype(jtt.colType().toString()),
         jiterable_to_list(jtt.colKey()),
         dtype(jtt.rowType().toString()),
         jiterable_to_list(jtt.rowKey()),
         dtype(jtt.entryType().toString()))
示例#3
0
文件: matrix_type.py 项目: zscu/hail
 def _from_json(json):
     return tmatrix(
         dtype(json['global']),
         dtype(json['col']),
         json['col_key'],
         dtype(json['row']),
         json['row_key'],
         dtype(json['entry']))
示例#4
0
def register_reference_genome_functions(rg):
    from hail.expr.types import dtype

    register_session_function(f"isValidContig({rg})", (dtype("str"),), dtype("bool"))
    register_session_function(f"isValidLocus({rg})", (dtype("str"),dtype("int32"),), dtype("bool"))

    register_session_function(f"contigLength({rg})", (dtype("str"),), dtype("int32"))

    register_session_function(f"getReferenceSequenceFromValidLocus({rg})", (dtype("str"),dtype("int32"),dtype("int32"),dtype("int32"),), dtype("str"))
    register_session_function(f"getReferenceSequence({rg})", (dtype("str"),dtype("int32"),dtype("int32"),dtype("int32"),), dtype("str"))
示例#5
0
文件: table_ir.py 项目: vedasha/hail
def regression_test_type(test):
    glm_fit_schema = dtype('struct{n_iterations:int32,converged:bool,exploded:bool}')
    if test == 'wald':
        return dtype(f'struct{{beta:float64,standard_error:float64,z_stat:float64,p_value:float64,fit:{glm_fit_schema}}}')
    elif test == 'lrt':
        return dtype(f'struct{{beta:float64,chi_sq_stat:float64,p_value:float64,fit:{glm_fit_schema}}}')
    elif test == 'score':
        return dtype('struct{chi_sq_stat:float64,p_value:float64}')
    else:
        assert test == 'firth', test
        return dtype(f'struct{{beta:float64,chi_sq_stat:float64,p_value:float64,fit:{glm_fit_schema}}}')
示例#6
0
文件: table_ir.py 项目: jigold/hail
def regression_test_type(test):
    glm_fit_schema = dtype('struct{n_iterations:int32,converged:bool,exploded:bool}')
    if test == 'wald':
        return dtype(
            f'struct{{beta:float64,standard_error:float64,z_stat:float64,p_value:float64,fit:{glm_fit_schema}}}')
    elif test == 'lrt':
        return dtype(f'struct{{beta:float64,chi_sq_stat:float64,p_value:float64,fit:{glm_fit_schema}}}')
    elif test == 'score':
        return dtype('struct{chi_sq_stat:float64,p_value:float64}')
    else:
        assert test == 'firth', test
        return dtype(f'struct{{beta:float64,chi_sq_stat:float64,p_value:float64,fit:{glm_fit_schema}}}')
示例#7
0
文件: table_ir.py 项目: vedasha/hail
 def _compute_type(self):
     name = self.config['name']
     child_typ = self.child.typ
     if name == 'LinearRegressionRowsChained':
         pass_through = self.config['passThrough']
         chained_schema = hl.dtype('struct{n:array<int32>,sum_x:array<float64>,y_transpose_x:array<array<float64>>,beta:array<array<float64>>,standard_error:array<array<float64>>,t_stat:array<array<float64>>,p_value:array<array<float64>>}')
         self._type = hl.ttable(
             child_typ.global_type,
             (child_typ.row_key_type
              ._insert_fields(**{f: child_typ.row_type[f] for f in pass_through})
              ._concat(chained_schema)),
             child_typ.row_key)
     elif name == 'LinearRegressionRowsSingle':
         pass_through = self.config['passThrough']
         chained_schema = hl.dtype('struct{n:int32,sum_x:float64,y_transpose_x:array<float64>,beta:array<float64>,standard_error:array<float64>,t_stat:array<float64>,p_value:array<float64>}')
         self._type = hl.ttable(
             child_typ.global_type,
             (child_typ.row_key_type
              ._insert_fields(**{f: child_typ.row_type[f] for f in pass_through})
              ._concat(chained_schema)),
             child_typ.row_key)
     elif name == 'LogisticRegression':
         pass_through = self.config['passThrough']
         logreg_type = hl.tstruct(logistic_regression=hl.tarray(regression_test_type(self.config['test'])))
         self._type = hl.ttable(
             child_typ.global_type,
             (child_typ.row_key_type
              ._insert_fields(**{f: child_typ.row_type[f] for f in pass_through})
              ._concat(logreg_type)),
             child_typ.row_key)
     elif name == 'PoissonRegression':
         pass_through = self.config['passThrough']
         poisreg_type = regression_test_type(self.config['test'])
         self._type = hl.ttable(
             child_typ.global_type,
             (child_typ.row_key_type
              ._insert_fields(**{f: child_typ.row_type[f] for f in pass_through})
              ._concat(poisreg_type)),
             child_typ.row_key)
     elif name == 'Skat':
         key_field = self.config['keyField']
         key_type = child_typ.row_type[key_field]
         skat_type = hl.dtype(f'struct{{id:{key_type},size:int32,q_stat:float64,p_value:float64,fault:int32}}')
         self._type = hl.ttable(
             hl.tstruct(),
             skat_type,
             ['id'])
     elif name == 'PCA':
         self._type = hl.ttable(
             hl.tstruct(eigenvalues=hl.tarray(hl.tfloat64),
                        scores=hl.tarray(child_typ.col_key_type._insert_field('scores', hl.tarray(hl.tfloat64)))),
             child_typ.row_key_type._insert_field('loadings', dtype('array<float64>')),
             child_typ.row_key)
     else:
         assert name == 'LocalLDPrune', name
         self._type = hl.ttable(
             hl.tstruct(),
             child_typ.row_key_type._insert_fields(mean=hl.tfloat64, centered_length_rec=hl.tfloat64),
             list(child_typ.row_key))
示例#8
0
    async def _async_value_type(self, ir):
        async def inputs(infile, _):
            await write_int(infile, ServiceBackend.VALUE_TYPE)
            await write_str(infile, tmp_dir())
            await write_str(infile, self.billing_project)
            await write_str(infile, self.remote_tmpdir)
            await write_str(infile, self.render(ir))

        _, resp, _ = await self._rpc('value_type(...)', inputs)
        return dtype(resp)
示例#9
0
    def execute(self, ir):
        code = self._render(ir)
        resp = requests.post(f'{self.url}/execute', json=code)
        resp.raise_for_status()

        resp_json = resp.json()

        typ = dtype(resp_json['type'])
        result = resp_json['value']

        return typ._from_json(result)
    async def _async_execute_untimed(self, ir):
        token = secret_alnum_string()
        with TemporaryDirectory(ensure_exists=False) as dir:
            async def create_inputs():
                with self.fs.open(dir + '/in', 'wb') as infile:
                    write_int(infile, ServiceBackend.EXECUTE)
                    write_str(infile, tmp_dir())
                    write_str(infile, self.billing_project)
                    write_str(infile, self.bucket)
                    write_str(infile, self.render(ir))
                    write_str(infile, token)

            async def create_batch():
                batch_attributes = self.batch_attributes
                if 'name' not in batch_attributes:
                    batch_attributes = {**batch_attributes, 'name': 'execute(...)'}
                bb = self.async_bc.create_batch(token=token, attributes=batch_attributes)

                j = bb.create_jvm_job([
                    'is.hail.backend.service.ServiceBackendSocketAPI2',
                    os.environ['HAIL_SHA'],
                    os.environ['HAIL_JAR_URL'],
                    batch_attributes['name'],
                    dir + '/in',
                    dir + '/out',
                ], mount_tokens=True)
                return (j, await bb.submit(disable_progress_bar=self.disable_progress_bar))

            _, (j, b) = await asyncio.gather(create_inputs(), create_batch())

            status = await b.wait(disable_progress_bar=self.disable_progress_bar)
            if status['n_succeeded'] != 1:
                raise ValueError(f'batch failed {status} {await j.log()}')


            with self.fs.open(dir + '/out', 'rb') as outfile:
                success = read_bool(outfile)
                if success:
                    s = read_str(outfile)
                    try:
                        resp = json.loads(s)
                    except json.decoder.JSONDecodeError as err:
                        raise ValueError(f'could not decode {s}') from err
                else:
                    jstacktrace = read_str(outfile)
                    raise FatalError(jstacktrace)

        typ = dtype(resp['type'])
        if typ == tvoid:
            x = None
        else:
            x = typ._convert_from_json_na(resp['value'])

        return x
示例#11
0
文件: backend.py 项目: tpoterba/hail
 def execute(self, ir):
     code = self._render(ir)
     resp = requests.post(f'{self.url}/execute', json=code)
     if resp.status_code == 400:
         resp_json = resp.json()
         raise FatalError(resp_json['message'])
     resp.raise_for_status()
     
     resp_json = resp.json()
     typ = dtype(resp_json['type'])
     result = resp_json['value']
     return typ._from_json(result)
示例#12
0
    def execute(self, ir, timed=False):
        resp = self.socket.request('execute',
                                   code=self._render(ir),
                                   billing_project=self._billing_project,
                                   bucket=self._bucket)
        typ = dtype(resp['type'])
        if typ == tvoid:
            value = None
        else:
            value = typ._convert_from_json_na(resp['value'])
        # FIXME put back timings

        return (value, None) if timed else value
示例#13
0
文件: backend.py 项目: bcajes/hail
 def execute(self, ir):
     r = Renderer(stop_at_jir=True)
     code = r(ir)
     assert len(r.jirs) == 0
     
     resp = requests.post(f'http://hail-apiserver:5000/execute', json=code)
     resp.raise_for_status()
     
     resp_json = resp.json()
     
     typ = dtype(resp_json['type'])
     result = resp_json['value']
     
     return typ._from_json(result)
示例#14
0
文件: backend.py 项目: datnoor/hail
    def execute(self, ir):
        r = Renderer(stop_at_jir=True)
        code = r(ir)
        assert len(r.jirs) == 0

        resp = requests.post(f'http://hail-apiserver:5000/execute', json=code)
        resp.raise_for_status()

        resp_json = resp.json()

        typ = dtype(resp_json['type'])
        result = resp_json['value']

        return typ._from_json(result)
示例#15
0
    async def _async_execute(self, ir, timed=False):
        async def inputs(infile, token):
            await write_int(infile, ServiceBackend.EXECUTE)
            await write_str(infile, tmp_dir())
            await write_str(infile, self.billing_project)
            await write_str(infile, self.remote_tmpdir)
            await write_str(infile, self.render(ir))
            await write_str(infile, token)

        _, resp, timings = await self._rpc('execute(...)', inputs)
        typ = dtype(resp['type'])
        converted_value = typ._convert_from_json_na(resp['value'])
        if timed:
            return converted_value, timings
        return converted_value
示例#16
0
文件: backend.py 项目: jigold/hail
    def execute(self, ir, timed=False):
        code = self._render(ir)
        resp = requests.post(f'{self.url}/execute', json=code, cookies=self.cookies)
        if resp.status_code == 400:
            resp_json = resp.json()
            raise FatalError(resp_json['message'])
        resp.raise_for_status()

        resp_json = resp.json()
        typ = dtype(resp_json['type'])
        result = json.loads(resp_json['result'])
        value = typ._from_json(result['value'])
        timings = result['timings']

        return (value, timings) if timed else value
示例#17
0
    def execute(self, ir, timed=False):
        code = self._render(ir)
        resp = retry_response_returning_functions(requests.post,
                                                  f'{self.url}/execute',
                                                  json=code,
                                                  headers=self.headers)
        if resp.status_code == 400 or resp.status_code == 500:
            raise FatalError(resp.text)
        resp.raise_for_status()
        resp_json = resp.json()
        typ = dtype(resp_json['type'])
        value = typ._convert_from_json_na(resp_json['value'])
        # FIXME put back timings

        return (value, None) if timed else value
示例#18
0
文件: backend.py 项目: shutianxu/hail
    def execute(self, ir, timed=False):
        code = self._render(ir)
        resp = requests.post(f'{self.url}/execute', json=code, cookies=self.cookies)
        if resp.status_code == 400:
            resp_json = resp.json()
            raise FatalError(resp_json['message'])
        resp.raise_for_status()

        resp_json = resp.json()
        typ = dtype(resp_json['type'])
        result = json.loads(resp_json['result'])
        value = typ._from_json(result['value'])
        timings = result['timings']

        return (value, timings) if timed else value
示例#19
0
def register_liftover_functions(rg, dest_rg):
    from hail.expr.types import dtype

    register_session_function(
        f"liftoverLocus({rg})({dest_rg})", (
            dtype(f"locus<{rg}>"),
            dtype('float64'),
        ), dtype(f"struct{{result:locus<{dest_rg}>,is_negative_strand:bool}}"))
    register_session_function(
        f"liftoverLocusInterval({rg})({dest_rg})", (
            dtype(f"interval<locus<{rg}>>"),
            dtype('float64'),
        ),
        dtype(
            f"struct{{result:interval<locus<{dest_rg}>>,is_negative_strand:bool}}"
        ))
    def value_type(self, ir):
        token = secret_alnum_string()
        with TemporaryDirectory(ensure_exists=False) as dir:
            with self.fs.open(dir + '/in', 'wb') as infile:
                write_int(infile, ServiceBackend.VALUE_TYPE)
                write_str(infile, tmp_dir())
                write_str(infile, self.render(ir))

            batch_attributes = self.batch_attributes
            if 'name' not in batch_attributes:
                batch_attributes = {**batch_attributes, 'name': 'value_type(...)'}
            bb = self.bc.create_batch(token=token, attributes=batch_attributes)

            j = bb.create_jvm_job([
                'is.hail.backend.service.ServiceBackendSocketAPI2',
                os.environ['HAIL_SHA'],
                os.environ['HAIL_JAR_URL'],
                batch_attributes['name'],
                dir + '/in',
                dir + '/out',
            ], mount_tokens=True)
            b = bb.submit(disable_progress_bar=self.disable_progress_bar)
            status = b.wait(disable_progress_bar=self.disable_progress_bar)
            if status['n_succeeded'] != 1:
                raise ValueError(f'batch failed {status} {j.log()}')


            with self.fs.open(dir + '/out', 'rb') as outfile:
                success = read_bool(outfile)
                if success:
                    s = read_str(outfile)
                    try:
                        return dtype(json.loads(s))
                    except json.decoder.JSONDecodeError as err:
                        raise ValueError(f'could not decode {s}') from err
                else:
                    jstacktrace = read_str(outfile)
                    raise FatalError(jstacktrace)
示例#21
0
def register_liftover_functions(rg, dest_rg):
    from hail.expr.types import dtype
    
    register_function(f"liftoverLocus({rg})({dest_rg})", (dtype(f"locus<{rg}>"), dtype('float64'),), dtype(f"struct{{result:locus<{dest_rg}>,is_negative_strand:bool}}"))
    register_function(f"liftoverLocusInterval({rg})({dest_rg})", (dtype(f"interval<locus<{rg}>>"), dtype('float64'),), dtype(f"struct{{result:interval<locus<{dest_rg}>>,is_negative_strand:bool}}"))
示例#22
0
文件: table_ir.py 项目: jigold/hail
 def _compute_type(self):
     name = self.config['name']
     child_typ = self.child.typ
     if name == 'LinearRegressionRowsChained':
         pass_through = self.config['passThrough']
         chained_schema = hl.dtype(
             'struct{n:array<int32>,sum_x:array<float64>,y_transpose_x:array<array<float64>>,beta:array<array<float64>>,standard_error:array<array<float64>>,t_stat:array<array<float64>>,p_value:array<array<float64>>}')
         self._type = hl.ttable(
             child_typ.global_type,
             (child_typ.row_key_type
              ._insert_fields(**{f: child_typ.row_type[f] for f in pass_through})
              ._concat(chained_schema)),
             child_typ.row_key)
     elif name == 'LinearRegressionRowsSingle':
         pass_through = self.config['passThrough']
         chained_schema = hl.dtype(
             'struct{n:int32,sum_x:float64,y_transpose_x:array<float64>,beta:array<float64>,standard_error:array<float64>,t_stat:array<float64>,p_value:array<float64>}')
         self._type = hl.ttable(
             child_typ.global_type,
             (child_typ.row_key_type
              ._insert_fields(**{f: child_typ.row_type[f] for f in pass_through})
              ._concat(chained_schema)),
             child_typ.row_key)
     elif name == 'LogisticRegression':
         pass_through = self.config['passThrough']
         logreg_type = hl.tstruct(logistic_regression=hl.tarray(regression_test_type(self.config['test'])))
         self._type = hl.ttable(
             child_typ.global_type,
             (child_typ.row_key_type
              ._insert_fields(**{f: child_typ.row_type[f] for f in pass_through})
              ._concat(logreg_type)),
             child_typ.row_key)
     elif name == 'PoissonRegression':
         pass_through = self.config['passThrough']
         poisreg_type = regression_test_type(self.config['test'])
         self._type = hl.ttable(
             child_typ.global_type,
             (child_typ.row_key_type
              ._insert_fields(**{f: child_typ.row_type[f] for f in pass_through})
              ._concat(poisreg_type)),
             child_typ.row_key)
     elif name == 'Skat':
         key_field = self.config['keyField']
         key_type = child_typ.row_type[key_field]
         skat_type = hl.dtype(f'struct{{id:{key_type},size:int32,q_stat:float64,p_value:float64,fault:int32}}')
         self._type = hl.ttable(
             hl.tstruct(),
             skat_type,
             ['id'])
     elif name == 'PCA':
         self._type = hl.ttable(
             hl.tstruct(eigenvalues=hl.tarray(hl.tfloat64),
                        scores=hl.tarray(child_typ.col_key_type._insert_field('scores', hl.tarray(hl.tfloat64)))),
             child_typ.row_key_type._insert_field('loadings', dtype('array<float64>')),
             child_typ.row_key)
     else:
         assert name == 'LocalLDPrune', name
         self._type = hl.ttable(
             hl.tstruct(),
             child_typ.row_key_type._insert_fields(mean=hl.tfloat64, centered_length_rec=hl.tfloat64),
             list(child_typ.row_key))
示例#23
0
def register_functions():
    from hail.expr.types import dtype

    register_function("flatten", (dtype("array<array<?T>>"), ),
                      dtype("array<?T>"))
    register_function("difference", (
        dtype("set<?T>"),
        dtype("set<?T>"),
    ), dtype("set<?T>"))
    register_function("median", (dtype("set<?T:numeric>"), ), dtype("?T"))
    register_function("median", (dtype("array<?T:numeric>"), ), dtype("?T"))
    register_function("uniqueMinIndex", (dtype("array<?T>"), ), dtype("int32"))
    register_function("mean", (dtype("set<?T:numeric>"), ), dtype("float64"))
    register_function("mean", (dtype("array<?T:numeric>"), ), dtype("float64"))
    register_function("toFloat32", (dtype("?T:numeric"), ), dtype("float32"))
    register_function("uniqueMaxIndex", (dtype("array<?T>"), ), dtype("int32"))
    register_function("toSet", (dtype("array<?T>"), ), dtype("set<?T>"))

    def array_floating_point_divide(arg_type, ret_type):
        register_function("/", (
            arg_type,
            hl.tarray(arg_type),
        ), hl.tarray(ret_type))
        register_function("/", (hl.tarray(arg_type), arg_type),
                          hl.tarray(ret_type))
        register_function("/", (hl.tarray(arg_type), hl.tarray(arg_type)),
                          hl.tarray(ret_type))

    array_floating_point_divide(hl.tint32, hl.tfloat32)
    array_floating_point_divide(hl.tint64, hl.tfloat32)
    array_floating_point_divide(hl.tfloat32, hl.tfloat32)
    array_floating_point_divide(hl.tfloat64, hl.tfloat64)

    def ndarray_floating_point_divide(arg_type, ret_type):
        register_function("/", (
            arg_type,
            hl.tndarray(arg_type, NatVariable()),
        ), hl.tndarray(ret_type, NatVariable()))
        register_function("/",
                          (hl.tndarray(arg_type, NatVariable()), arg_type),
                          hl.tndarray(ret_type, NatVariable()))
        register_function("/", (hl.tndarray(
            arg_type, NatVariable()), hl.tndarray(arg_type, NatVariable())),
                          hl.tndarray(ret_type, NatVariable()))

    ndarray_floating_point_divide(hl.tint32, hl.tfloat32)
    ndarray_floating_point_divide(hl.tint64, hl.tfloat32)
    ndarray_floating_point_divide(hl.tfloat32, hl.tfloat32)
    ndarray_floating_point_divide(hl.tfloat64, hl.tfloat64)

    register_function("values", (dtype("dict<?key, ?value>"), ),
                      dtype("array<?value>"))
    register_function("[*:]", (
        dtype("array<?T>"),
        dtype("int32"),
    ), dtype("array<?T>"))
    register_function("[*:]", (
        dtype("str"),
        dtype("int32"),
    ), dtype("str"))
    register_function("get", (
        dtype("dict<?key, ?value>"),
        dtype("?key"),
    ), dtype("?value"))
    register_function("get", (
        dtype("dict<?key, ?value>"),
        dtype("?key"),
        dtype("?value"),
    ), dtype("?value"))
    register_function("max", (dtype("array<?T:numeric>"), ), dtype("?T"))
    register_function("nanmax", (dtype("array<?T:numeric>"), ), dtype("?T"))
    register_function("max", (
        dtype("?T"),
        dtype("?T"),
    ), dtype("?T"))
    register_function("nanmax", (
        dtype("?T"),
        dtype("?T"),
    ), dtype("?T"))
    register_function("max_ignore_missing", (
        dtype("?T"),
        dtype("?T"),
    ), dtype("?T"))
    register_function("nanmax_ignore_missing", (
        dtype("?T"),
        dtype("?T"),
    ), dtype("?T"))
    register_function("product", (dtype("set<?T:numeric>"), ), dtype("?T"))
    register_function("product", (dtype("array<?T:numeric>"), ), dtype("?T"))
    register_function("toInt32", (dtype("?T:numeric"), ), dtype("int32"))
    register_function("extend", (
        dtype("array<?T>"),
        dtype("array<?T>"),
    ), dtype("array<?T>"))
    register_function("argmin", (dtype("array<?T>"), ), dtype("int32"))
    register_function("toFloat64", (dtype("?T:numeric"), ), dtype("float64"))
    register_function("sort", (dtype("array<?T>"), ), dtype("array<?T>"))
    register_function("sort", (
        dtype("array<?T>"),
        dtype("bool"),
    ), dtype("array<?T>"))
    register_function("isSubset", (
        dtype("set<?T>"),
        dtype("set<?T>"),
    ), dtype("bool"))
    register_function("[*:*]", (
        dtype("str"),
        dtype("int32"),
        dtype("int32"),
    ), dtype("str"))
    register_function("[*:*]", (
        dtype("array<?T>"),
        dtype("int32"),
        dtype("int32"),
    ), dtype("array<?T>"))
    register_function("+", (
        dtype("array<?T:numeric>"),
        dtype("array<?T>"),
    ), dtype("array<?T>"))
    register_function("+", (
        dtype("array<?T:numeric>"),
        dtype("?T"),
    ), dtype("array<?T>"))
    register_function("+", (
        dtype("?T:numeric"),
        dtype("array<?T>"),
    ), dtype("array<?T>"))
    register_function("+", (
        dtype("ndarray<?T:numeric, ?nat>"),
        dtype("ndarray<?T, ?nat>"),
    ), dtype("ndarray<?T, ?nat>"))
    register_function("+", (
        dtype("ndarray<?T:numeric, ?nat>"),
        dtype("?T"),
    ), dtype("ndarray<?T, ?nat>"))
    register_function("+", (
        dtype("?T:numeric"),
        dtype("ndarray<?T, ?nat>"),
    ), dtype("ndarray<?T, ?nat>"))
    register_function("**", (
        dtype("array<?T:numeric>"),
        dtype("array<?T>"),
    ), dtype("array<float64>"))
    register_function("**", (
        dtype("array<?T:numeric>"),
        dtype("?T"),
    ), dtype("array<float64>"))
    register_function("**", (
        dtype("?T:numeric"),
        dtype("array<?T>"),
    ), dtype("array<float64>"))
    register_function("**", (
        dtype("ndarray<?T:numeric, ?nat>"),
        dtype("ndarray<?T, ?nat>"),
    ), dtype("ndarray<?T, ?nat>"))
    register_function("**", (
        dtype("ndarray<?T:numeric, ?nat>"),
        dtype("?T"),
    ), dtype("ndarray<?T, ?nat>"))
    register_function("**", (
        dtype("?T:numeric"),
        dtype("ndarray<?T, ?nat>"),
    ), dtype("ndarray<?T, ?nat>"))
    register_function("append", (
        dtype("array<?T>"),
        dtype("?T"),
    ), dtype("array<?T>"))
    register_function("[:*]", (
        dtype("str"),
        dtype("int32"),
    ), dtype("str"))
    register_function("[:*]", (
        dtype("array<?T>"),
        dtype("int32"),
    ), dtype("array<?T>"))
    register_function("remove", (
        dtype("set<?T>"),
        dtype("?T"),
    ), dtype("set<?T>"))
    register_function("[]", (
        dtype("str"),
        dtype("int32"),
    ), dtype("str"))
    register_function("indexArray", (
        dtype("array<?T>"),
        dtype("int32"),
    ), dtype("?T"))
    register_function("[]", (
        dtype("dict<?key, ?value>"),
        dtype("?key"),
    ), dtype("?value"))
    register_function("dictToArray", (dtype("dict<?key, ?value>"), ),
                      dtype("array<tuple(?key, ?value)>"))
    register_function("%", (
        dtype("array<?T:numeric>"),
        dtype("array<?T>"),
    ), dtype("array<?T>"))
    register_function("%", (
        dtype("array<?T:numeric>"),
        dtype("?T"),
    ), dtype("array<?T>"))
    register_function("%", (
        dtype("?T:numeric"),
        dtype("array<?T>"),
    ), dtype("array<?T>"))
    register_function("%", (
        dtype("ndarray<?T:numeric, ?nat>"),
        dtype("ndarray<?T, ?nat>"),
    ), dtype("ndarray<?T, ?nat>"))
    register_function("%", (
        dtype("ndarray<?T:numeric, ?nat>"),
        dtype("?T"),
    ), dtype("ndarray<?T, ?nat>"))
    register_function("%", (
        dtype("?T:numeric"),
        dtype("ndarray<?T, ?nat>"),
    ), dtype("ndarray<?T, ?nat>"))
    register_function("dict", (dtype("array<tuple(?key, ?value)>"), ),
                      dtype("dict<?key, ?value>"))
    register_function("dict", (dtype("set<tuple(?key, ?value)>"), ),
                      dtype("dict<?key, ?value>"))
    register_function("keys", (dtype("dict<?key, ?value>"), ),
                      dtype("array<?key>"))
    register_function("min", (dtype("array<?T:numeric>"), ), dtype("?T"))
    register_function("nanmin", (dtype("array<?T:numeric>"), ), dtype("?T"))
    register_function("min", (
        dtype("?T"),
        dtype("?T"),
    ), dtype("?T"))
    register_function("nanmin", (
        dtype("?T"),
        dtype("?T"),
    ), dtype("?T"))
    register_function("min_ignore_missing", (
        dtype("?T"),
        dtype("?T"),
    ), dtype("?T"))
    register_function("nanmin_ignore_missing", (
        dtype("?T"),
        dtype("?T"),
    ), dtype("?T"))
    register_function("sum", (dtype("set<?T:numeric>"), ), dtype("?T"))
    register_function("sum", (dtype("array<?T:numeric>"), ), dtype("?T"))
    register_function("toInt64", (dtype("?T:numeric"), ), dtype("int64"))
    register_function("contains", (
        dtype("dict<?key, ?value>"),
        dtype("?key"),
    ), dtype("bool"))
    register_function("contains", (
        dtype("array<?T>"),
        dtype("?T"),
    ), dtype("bool"))
    register_function("contains", (
        dtype("set<?T>"),
        dtype("?T"),
    ), dtype("bool"))
    register_function("-", (
        dtype("array<?T:numeric>"),
        dtype("?T"),
    ), dtype("array<?T>"))
    register_function("-", (
        dtype("array<?T:numeric>"),
        dtype("array<?T>"),
    ), dtype("array<?T>"))
    register_function("-", (
        dtype("?T:numeric"),
        dtype("array<?T>"),
    ), dtype("array<?T>"))
    register_function("-", (
        dtype("ndarray<?T:numeric, ?nat>"),
        dtype("ndarray<?T, ?nat>"),
    ), dtype("ndarray<?T, ?nat>"))
    register_function("-", (
        dtype("ndarray<?T:numeric, ?nat>"),
        dtype("?T"),
    ), dtype("ndarray<?T, ?nat>"))
    register_function("-", (
        dtype("?T:numeric"),
        dtype("ndarray<?T, ?nat>"),
    ), dtype("ndarray<?T, ?nat>"))
    register_function("addone", (dtype("int32"), ), dtype("int32"))
    register_function("isEmpty", (dtype("dict<?key, ?value>"), ),
                      dtype("bool"))
    register_function("isEmpty", (dtype("array<?T>"), ), dtype("bool"))
    register_function("isEmpty", (dtype("set<?T>"), ), dtype("bool"))
    register_function("[:]", (dtype("array<?T>"), ), dtype("array<?T>"))
    register_function("[:]", (dtype("str"), ), dtype("str"))
    register_function("union", (
        dtype("set<?T>"),
        dtype("set<?T>"),
    ), dtype("set<?T>"))
    register_function("*", (
        dtype("array<?T:numeric>"),
        dtype("array<?T>"),
    ), dtype("array<?T>"))
    register_function("*", (
        dtype("array<?T:numeric>"),
        dtype("?T"),
    ), dtype("array<?T>"))
    register_function("*", (
        dtype("?T:numeric"),
        dtype("array<?T>"),
    ), dtype("array<?T>"))
    register_function("*", (
        dtype("ndarray<?T:numeric, ?nat>"),
        dtype("ndarray<?T, ?nat>"),
    ), dtype("ndarray<?T, ?nat>"))
    register_function("*", (
        dtype("ndarray<?T:numeric, ?nat>"),
        dtype("?T"),
    ), dtype("ndarray<?T, ?nat>"))
    register_function("*", (
        dtype("?T:numeric"),
        dtype("ndarray<?T, ?nat>"),
    ), dtype("ndarray<?T, ?nat>"))
    register_function("intersection", (
        dtype("set<?T>"),
        dtype("set<?T>"),
    ), dtype("set<?T>"))
    register_function("add", (
        dtype("set<?T>"),
        dtype("?T"),
    ), dtype("set<?T>"))
    register_function("argmax", (dtype("array<?T>"), ), dtype("int32"))
    register_function("//", (
        dtype("array<?T:numeric>"),
        dtype("array<?T>"),
    ), dtype("array<?T>"))
    register_function("//", (
        dtype("array<?T:numeric>"),
        dtype("?T"),
    ), dtype("array<?T>"))
    register_function("//", (
        dtype("?T:numeric"),
        dtype("array<?T>"),
    ), dtype("array<?T>"))
    register_function("//", (
        dtype("ndarray<?T:numeric, ?nat>"),
        dtype("ndarray<?T, ?nat>"),
    ), dtype("ndarray<?T, ?nat>"))
    register_function("//", (
        dtype("ndarray<?T:numeric, ?nat>"),
        dtype("?T"),
    ), dtype("ndarray<?T, ?nat>"))
    register_function("//", (
        dtype("?T:numeric"),
        dtype("ndarray<?T, ?nat>"),
    ), dtype("ndarray<?T, ?nat>"))
    register_function("keySet", (dtype("dict<?key, ?value>"), ),
                      dtype("set<?key>"))
    register_function("qnorm", (dtype("float64"), ), dtype("float64"))
    register_function("oneHotAlleles", (
        dtype("call"),
        dtype("int32"),
    ), dtype("array<int32>"))
    register_function("dpois", (
        dtype("float64"),
        dtype("float64"),
        dtype("bool"),
    ), dtype("float64"))
    register_function("dpois", (
        dtype("float64"),
        dtype("float64"),
    ), dtype("float64"))
    register_function("ploidy", (dtype("call"), ), dtype("int32"))
    register_function("||", (
        dtype("bool"),
        dtype("bool"),
    ), dtype("bool"))
    register_function("ppois", (
        dtype("float64"),
        dtype("float64"),
        dtype("bool"),
        dtype("bool"),
    ), dtype("float64"))
    register_function("ppois", (
        dtype("float64"),
        dtype("float64"),
    ), dtype("float64"))
    register_function("log10", (dtype("float64"), ), dtype("float64"))
    register_function("isHet", (dtype("call"), ), dtype("bool"))
    register_function("isAutosomalOrPseudoAutosomal", (dtype("?T:locus"), ),
                      dtype("bool"))
    register_function("testCodeUnification", (
        dtype("?x:numeric"),
        dtype("?x:int32"),
    ), dtype("?x"))
    register_seeded_function("rand_pois", (dtype("float64"), ),
                             dtype("float64"))
    register_seeded_function("rand_pois", (
        dtype("int32"),
        dtype("float64"),
    ), dtype("array<float64>"))
    register_function("toFloat32", (dtype("str"), ), dtype("float32"))
    register_function("toFloat32", (dtype("bool"), ), dtype("float32"))
    register_function("isAutosomal", (dtype("?T:locus"), ), dtype("bool"))
    register_function("isPhased", (dtype("call"), ), dtype("bool"))
    register_function("isHomVar", (dtype("call"), ), dtype("bool"))
    register_function("corr", (
        dtype("array<float64>"),
        dtype("array<float64>"),
    ), dtype("float64"))
    register_function("log", (
        dtype("float64"),
        dtype("float64"),
    ), dtype("float64"))
    register_function("log", (dtype("float64"), ), dtype("float64"))
    register_function("foobar2", (), dtype("int32"))
    register_function("approxEqual", (
        dtype("float64"),
        dtype("float64"),
        dtype("float64"),
        dtype("bool"),
        dtype("bool"),
    ), dtype("bool"))
    register_function("plDosage", (dtype("array<?N:int32>"), ),
                      dtype("float64"))
    register_function("includesEnd", (dtype("interval<?T>"), ), dtype("bool"))
    register_function("position", (dtype("?T:locus"), ), dtype("int32"))
    register_seeded_function("rand_unif", (
        dtype("float64"),
        dtype("float64"),
    ), dtype("float64"))
    register_function("str", (dtype("?T"), ), dtype("str"))
    register_function("valuesSimilar", (
        dtype("?T"),
        dtype("?T"),
        dtype('float64'),
        dtype('bool'),
    ), dtype("bool"))
    register_function("replace", (
        dtype("str"),
        dtype("str"),
        dtype("str"),
    ), dtype("str"))
    register_function("exp", (dtype("float64"), ), dtype("float64"))
    register_function("&&", (
        dtype("bool"),
        dtype("bool"),
    ), dtype("bool"))
    register_function("compare", (
        dtype("int32"),
        dtype("int32"),
    ), dtype("int32"))
    register_function("triangle", (dtype("int32"), ), dtype("int32"))
    register_function("Interval", (
        dtype("?T"),
        dtype("?T"),
        dtype("bool"),
        dtype("bool"),
    ), dtype("interval<?T>"))
    register_function("contig", (dtype("?T:locus"), ), dtype("str"))
    register_function("Call", (dtype("bool"), ), dtype("call"))
    register_function("Call", (dtype("str"), ), dtype("call"))
    register_function("Call", (
        dtype("int32"),
        dtype("bool"),
    ), dtype("call"))
    register_function("Call", (
        dtype("int32"),
        dtype("int32"),
        dtype("bool"),
    ), dtype("call"))
    register_function("Call", (
        dtype("array<int32>"),
        dtype("bool"),
    ), dtype("call"))
    register_function("qchisqtail", (
        dtype("float64"),
        dtype("float64"),
    ), dtype("float64"))
    register_function("binomTest", (
        dtype("int32"),
        dtype("int32"),
        dtype("float64"),
        dtype("int32"),
    ), dtype("float64"))
    register_function("qpois", (
        dtype("float64"),
        dtype("float64"),
    ), dtype("int32"))
    register_function("qpois", (
        dtype("float64"),
        dtype("float64"),
        dtype("bool"),
        dtype("bool"),
    ), dtype("int32"))
    register_function("is_finite", (dtype("float32"), ), dtype("bool"))
    register_function("is_finite", (dtype("float64"), ), dtype("bool"))
    register_function("inYPar", (dtype("?T:locus"), ), dtype("bool"))
    register_function("contingency_table_test", (
        dtype("int32"),
        dtype("int32"),
        dtype("int32"),
        dtype("int32"),
        dtype("int32"),
    ), dtype("struct{p_value: float64, odds_ratio: float64}"))
    register_function("toInt32", (dtype("bool"), ), dtype("int32"))
    register_function("toInt32", (dtype("str"), ), dtype("int32"))
    register_function("foobar1", (), dtype("int32"))
    register_function("toFloat64", (dtype("str"), ), dtype("float64"))
    register_function("toFloat64", (dtype("bool"), ), dtype("float64"))
    register_function("dbeta", (
        dtype("float64"),
        dtype("float64"),
        dtype("float64"),
    ), dtype("float64"))
    register_function("min_rep", (
        dtype("?T:locus"),
        dtype("array<str>"),
    ), dtype("struct{locus: ?T, alleles: array<str>}"))
    register_function("locus_windows_per_contig", (
        dtype("array<array<float64>>"),
        dtype("float64"),
    ), dtype("tuple(array<int32>, array<int32>)"))
    register_function("toBoolean", (dtype("str"), ), dtype("bool"))
    register_seeded_function("rand_bool", (dtype("float64"), ), dtype("bool"))
    register_function("pchisqtail", (
        dtype("float64"),
        dtype("float64"),
    ), dtype("float64"))
    register_seeded_function("rand_cat", (dtype("array<float64>"), ),
                             dtype("int32"))
    register_function("inYNonPar", (dtype("?T:locus"), ), dtype("bool"))
    register_function("+", (
        dtype("str"),
        dtype("str"),
    ), dtype("str"))
    register_function("**", (
        dtype("float32"),
        dtype("float32"),
    ), dtype("float64"))
    register_function("**", (
        dtype("int32"),
        dtype("int32"),
    ), dtype("float64"))
    register_function("**", (
        dtype("int64"),
        dtype("int64"),
    ), dtype("float64"))
    register_function("**", (
        dtype("float64"),
        dtype("float64"),
    ), dtype("float64"))
    register_function("length", (dtype("str"), ), dtype("int32"))
    register_function("slice", (
        dtype("str"),
        dtype("int32"),
        dtype("int32"),
    ), dtype("str"))
    register_function("split", (
        dtype("str"),
        dtype("str"),
        dtype("int32"),
    ), dtype("array<str>"))
    register_function("split", (
        dtype("str"),
        dtype("str"),
    ), dtype("array<str>"))
    register_seeded_function("rand_gamma", (
        dtype("float64"),
        dtype("float64"),
    ), dtype("float64"))
    register_function("UnphasedDiploidGtIndexCall", (dtype("int32"), ),
                      dtype("call"))
    register_function("[]", (
        dtype("call"),
        dtype("int32"),
    ), dtype("int32"))
    register_function("sign", (dtype("int64"), ), dtype("int64"))
    register_function("sign", (dtype("float64"), ), dtype("float64"))
    register_function("sign", (dtype("float32"), ), dtype("float32"))
    register_function("sign", (dtype("int32"), ), dtype("int32"))
    register_function("unphasedDiploidGtIndex", (dtype("call"), ),
                      dtype("int32"))
    register_function("gamma", (dtype("float64"), ), dtype("float64"))
    register_function("%", (
        dtype("float64"),
        dtype("float64"),
    ), dtype("float64"))
    register_function("%", (
        dtype("int64"),
        dtype("int64"),
    ), dtype("int64"))
    register_function("%", (
        dtype("float32"),
        dtype("float32"),
    ), dtype("float32"))
    register_function("%", (
        dtype("int32"),
        dtype("int32"),
    ), dtype("int32"))
    register_function(
        "fisher_exact_test", (
            dtype("int32"),
            dtype("int32"),
            dtype("int32"),
            dtype("int32"),
        ),
        dtype(
            "struct{p_value: float64, odds_ratio: float64, ci_95_lower: float64, ci_95_upper: float64}"
        ))
    register_function("floor", (dtype("float64"), ), dtype("float64"))
    register_function("floor", (dtype("float32"), ), dtype("float32"))
    register_function("isNonRef", (dtype("call"), ), dtype("bool"))
    register_function("includesStart", (dtype("interval<?T>"), ),
                      dtype("bool"))
    register_function("isHetNonRef", (dtype("call"), ), dtype("bool"))
    register_function("hardy_weinberg_test", (
        dtype("int32"),
        dtype("int32"),
        dtype("int32"),
    ), dtype("struct{het_freq_hwe: float64, p_value: float64}"))
    register_function("haplotype_freq_em", (dtype("array<int32>"), ),
                      dtype("array<float64>"))
    register_function("nNonRefAlleles", (dtype("call"), ), dtype("int32"))
    register_function("abs", (dtype("float64"), ), dtype("float64"))
    register_function("abs", (dtype("float32"), ), dtype("float32"))
    register_function("abs", (dtype("int64"), ), dtype("int64"))
    register_function("abs", (dtype("int32"), ), dtype("int32"))
    register_function("endswith", (
        dtype("str"),
        dtype("str"),
    ), dtype("bool"))
    register_function("sqrt", (dtype("float64"), ), dtype("float64"))
    register_function("isnan", (dtype("float32"), ), dtype("bool"))
    register_function("isnan", (dtype("float64"), ), dtype("bool"))
    register_function("lower", (dtype("str"), ), dtype("str"))
    register_seeded_function("rand_beta", (
        dtype("float64"),
        dtype("float64"),
    ), dtype("float64"))
    register_seeded_function("rand_beta", (
        dtype("float64"),
        dtype("float64"),
        dtype("float64"),
        dtype("float64"),
    ), dtype("float64"))
    register_function("toInt64", (dtype("bool"), ), dtype("int64"))
    register_function("toInt64", (dtype("str"), ), dtype("int64"))
    register_function("testCodeUnification2", (dtype("?x"), ), dtype("?x"))
    register_function("contains", (
        dtype("str"),
        dtype("str"),
    ), dtype("bool"))
    register_function("contains", (
        dtype("interval<?T>"),
        dtype("?T"),
    ), dtype("bool"))
    register_function("entropy", (dtype("str"), ), dtype("float64"))
    register_function("filtering_allele_frequency", (
        dtype("int32"),
        dtype("int32"),
        dtype("float64"),
    ), dtype("float64"))
    register_function("gqFromPL", (dtype("array<?N:int32>"), ), dtype("int32"))
    register_function("startswith", (
        dtype("str"),
        dtype("str"),
    ), dtype("bool"))
    register_function("ceil", (dtype("float32"), ), dtype("float32"))
    register_function("ceil", (dtype("float64"), ), dtype("float64"))
    register_function("json", (dtype("?T"), ), dtype("str"))
    register_function("strip", (dtype("str"), ), dtype("str"))
    register_function("firstMatchIn", (
        dtype("str"),
        dtype("str"),
    ), dtype("array<str>"))
    register_function("isEmpty", (dtype("interval<?T>"), ), dtype("bool"))
    register_function("~", (
        dtype("str"),
        dtype("str"),
    ), dtype("bool"))
    register_function("mkString", (
        dtype("set<str>"),
        dtype("str"),
    ), dtype("str"))
    register_function("mkString", (
        dtype("array<str>"),
        dtype("str"),
    ), dtype("str"))
    register_function("dosage", (dtype("array<?N:float64>"), ),
                      dtype("float64"))
    register_function("upper", (dtype("str"), ), dtype("str"))
    register_function("overlaps", (
        dtype("interval<?T>"),
        dtype("interval<?T>"),
    ), dtype("bool"))
    register_function("downcode", (
        dtype("call"),
        dtype("int32"),
    ), dtype("call"))
    register_function("inXPar", (dtype("?T:locus"), ), dtype("bool"))
    register_function("format", (
        dtype("str"),
        dtype("?T:tuple"),
    ), dtype("str"))
    register_function("pnorm", (dtype("float64"), ), dtype("float64"))
    register_function("is_infinite", (dtype("float32"), ), dtype("bool"))
    register_function("is_infinite", (dtype("float64"), ), dtype("bool"))
    register_function("isHetRef", (dtype("call"), ), dtype("bool"))
    register_function("isMitochondrial", (dtype("?T:locus"), ), dtype("bool"))
    register_function("hamming", (
        dtype("str"),
        dtype("str"),
    ), dtype("int32"))
    register_function("end", (dtype("interval<?T>"), ), dtype("?T"))
    register_function("start", (dtype("interval<?T>"), ), dtype("?T"))
    register_function("inXNonPar", (dtype("?T:locus"), ), dtype("bool"))
    register_function("escapeString", (dtype("str"), ), dtype("str"))
    register_function("isHomRef", (dtype("call"), ), dtype("bool"))
    register_seeded_function("rand_norm", (
        dtype("float64"),
        dtype("float64"),
    ), dtype("float64"))
    register_function("chi_squared_test", (
        dtype("int32"),
        dtype("int32"),
        dtype("int32"),
        dtype("int32"),
    ), dtype("struct{p_value: float64, odds_ratio: float64}"))
示例#24
0
文件: backend.py 项目: tpoterba/hail
 def value_type(self, ir):
     resp = self._request_type(ir, 'value')
     return dtype(resp)
示例#25
0
def register_aggregators():
    from hail.expr.types import dtype

    register_aggregator('ApproxCDF', (dtype('int32'),), (dtype('int32'),),
                        dtype('struct{values:array<int32>,ranks:array<int64>,_compaction_counts:array<int32>}'))
    register_aggregator('ApproxCDF', (dtype('int32'),), (dtype('int64'),),
                        dtype('struct{values:array<int64>,ranks:array<int64>,_compaction_counts:array<int32>}'))
    register_aggregator('ApproxCDF', (dtype('int32'),), (dtype('float32'),),
                        dtype('struct{values:array<float32>,ranks:array<int64>,_compaction_counts:array<int32>}'))
    register_aggregator('ApproxCDF', (dtype('int32'),), (dtype('float64'),),
                        dtype('struct{values:array<float64>,ranks:array<int64>,_compaction_counts:array<int32>}'))

    register_aggregator('Collect', (), (dtype("?in"),), dtype('array<?in>'))

    info_score_aggregator_type = dtype('struct{score:float64,n_included:tint32}')
    register_aggregator('InfoScore', (), (dtype('array<float64>'),), info_score_aggregator_type)

    register_aggregator('Sum', (), (dtype('int64'),), dtype('int64'))
    register_aggregator('Sum', (), (dtype('float64'),), dtype('float64'))

    register_aggregator('Sum', (), (dtype('array<int64>'),), dtype('array<int64>'))
    register_aggregator('Sum', (), (dtype('array<float64>'),), dtype('array<float64>'))

    register_aggregator('CollectAsSet', (), (dtype("?in"),), dtype('set<?in>'))

    register_aggregator('Product', (), (dtype('int64'),), dtype('int64'))
    register_aggregator('Product', (), (dtype('float64'),), dtype('float64'))

    hwe_aggregator_type = dtype('struct { het_freq_hwe: float64, p_value: float64 }')
    register_aggregator('HardyWeinberg', (), (dtype('call'),), hwe_aggregator_type)

    register_aggregator('Max', (), (dtype('bool'),), dtype('bool'))
    register_aggregator('Max', (), (dtype('int32'),), dtype('int32'))
    register_aggregator('Max', (), (dtype('int64'),), dtype('int64'))
    register_aggregator('Max', (), (dtype('float32'),), dtype('float32'))
    register_aggregator('Max', (), (dtype('float64'),), dtype('float64'))

    register_aggregator('Min', (), (dtype('bool'),), dtype('bool'))
    register_aggregator('Min', (), (dtype('int32'),), dtype('int32'))
    register_aggregator('Min', (), (dtype('int64'),), dtype('int64'))
    register_aggregator('Min', (), (dtype('float32'),), dtype('float32'))
    register_aggregator('Min', (), (dtype('float64'),), dtype('float64'))

    register_aggregator('Count', (), (), dtype('int64'))

    register_aggregator('Counter', (), (dtype('?in'),), dtype('dict<?in, int64>'))

    register_aggregator('Take', (dtype('int32'),), (dtype('?in'),), dtype('array<?in>'))

    register_aggregator('TakeBy', (dtype('int32'),), (dtype('?in'), dtype('?key'),), dtype('array<?in>'))

    downsample_aggregator_type = dtype('array<tuple(float64, float64, array<str>)>')
    register_aggregator('Downsample', (dtype('int32'),), (dtype('float64'), dtype('float64'), dtype('array<?T>'),), downsample_aggregator_type)

    call_stats_aggregator_type = dtype('struct{AC: array<int32>,AF:array<float64>,AN:int32,homozygote_count:array<int32>}')
    register_aggregator('CallStats', (dtype('int32'),), (dtype('call'),), call_stats_aggregator_type)

    inbreeding_aggregator_type = dtype('struct{f_stat:float64,n_called:int64,expected_homs:float64,observed_homs:int64}')
    register_aggregator('Inbreeding', (), (dtype('call'), dtype('float64'),), inbreeding_aggregator_type)

    linreg_aggregator_type = dtype('struct{xty:array<float64>,beta:array<float64>,diag_inv:array<float64>,beta0:array<float64>}')
    register_aggregator('LinearRegression', (dtype('int32'), dtype('int32'),), (dtype('float64'), dtype('array<float64>'),), linreg_aggregator_type)

    register_aggregator('PrevNonnull', (), (dtype('?in'),), dtype('?in'))
示例#26
0
 def _from_json(json):
     return tblockmatrix(dtype(json['elementType']), json['shape'],
                         json['blockSize'], json['dimsPartitioned'])
示例#27
0
文件: backend.py 项目: shutianxu/hail
 def value_type(self, ir):
     jir = self._to_java_ir(ir)
     return dtype(jir.typ().toString())
示例#28
0
文件: backend.py 项目: shutianxu/hail
 def value_type(self, ir):
     resp = self._request_type(ir, 'value')
     return dtype(resp)
示例#29
0
 def _from_java(jtbm):
     return tblockmatrix(
         dtype(jtbm.elementType().toString()),
         jiterable_to_list(jtbm.shape()),
         jtbm.isRowVector(),
         jtbm.blockSize())
示例#30
0
 def _from_json(json):
     return ttable(
         dtype(json['global']),
         dtype(json['row']),
         json['row_key'])
示例#31
0
 def _from_java(jtbm):
     return tblockmatrix(dtype(jtbm.elementType().toString()),
                         jiterable_to_list(jtbm.shape()),
                         jtbm.isRowVector(), jtbm.blockSize())
示例#32
0
 def _from_json(json):
     return tblockmatrix(dtype(json['element_type']), json['shape'],
                         json['is_row_vector'], json['block_size'])
示例#33
0
 def _from_json(json):
     return tblockmatrix(dtype(json['element_type']),
                         json['shape'],
                         json['is_row_vector'],
                         json['block_size'])
示例#34
0
def register_aggregators():
    from hail.expr.types import dtype

    register_aggregator('Fraction', (), None, (dtype('bool'), ),
                        dtype('float64'))

    stats_aggregator_type = dtype(
        'struct{mean:float64,stdev:float64,min:float64,max:float64,n:int64,sum:float64}'
    )
    register_aggregator('Statistics', (), None, (dtype('float64'), ),
                        stats_aggregator_type)

    register_aggregator('Collect', (), None, (dtype("?in"), ),
                        dtype('array<?in>'))

    info_score_aggregator_type = dtype(
        'struct{score:float64,n_included:tint32}')
    register_aggregator('InfoScore', (), None, (dtype('array<float64>'), ),
                        info_score_aggregator_type)

    register_aggregator('Sum', (), None, (dtype('int64'), ), dtype('int64'))
    register_aggregator('Sum', (), None, (dtype('float64'), ),
                        dtype('float64'))

    register_aggregator('Sum', (), None, (dtype('array<int64>'), ),
                        dtype('array<int64>'))
    register_aggregator('Sum', (), None, (dtype('array<float64>'), ),
                        dtype('array<float64>'))

    register_aggregator('CollectAsSet', (), None, (dtype("?in"), ),
                        dtype('set<?in>'))

    register_aggregator('Product', (), None, (dtype('int64'), ),
                        dtype('int64'))
    register_aggregator('Product', (), None, (dtype('float64'), ),
                        dtype('float64'))

    hwe_aggregator_type = dtype(
        'struct { het_freq_hwe: float64, p_value: float64 }')
    register_aggregator('HardyWeinberg', (), None, (dtype('call'), ),
                        hwe_aggregator_type)

    register_aggregator('Max', (), None, (dtype('bool'), ), dtype('bool'))
    register_aggregator('Max', (), None, (dtype('int32'), ), dtype('int32'))
    register_aggregator('Max', (), None, (dtype('int64'), ), dtype('int64'))
    register_aggregator('Max', (), None, (dtype('float32'), ),
                        dtype('float32'))
    register_aggregator('Max', (), None, (dtype('float64'), ),
                        dtype('float64'))

    register_aggregator('Min', (), None, (dtype('bool'), ), dtype('bool'))
    register_aggregator('Min', (), None, (dtype('int32'), ), dtype('int32'))
    register_aggregator('Min', (), None, (dtype('int64'), ), dtype('int64'))
    register_aggregator('Min', (), None, (dtype('float32'), ),
                        dtype('float32'))
    register_aggregator('Min', (), None, (dtype('float64'), ),
                        dtype('float64'))

    register_aggregator('Count', (), None, (), dtype('int64'))

    register_aggregator('Counter', (), None, (dtype('?in'), ),
                        dtype('dict<?in, int64>'))

    register_aggregator('Take', (dtype('int32'), ), None, (dtype('?in'), ),
                        dtype('array<?in>'))

    register_aggregator('TakeBy', (dtype('int32'), ), None, (
        dtype('?in'),
        dtype('?key'),
    ), dtype('array<?in>'))

    histogram_aggregator_type = dtype(
        'struct{bin_edges:array<float64>,bin_freq:array<int64>,n_smaller:int64,n_larger:int64}'
    )
    register_aggregator('Histogram', (
        dtype('float64'),
        dtype('float64'),
        dtype('int32'),
    ), None, (dtype('float64'), ), histogram_aggregator_type)

    downsample_aggregator_type = dtype(
        'array<tuple(float64, float64, array<str>)>')
    register_aggregator('Downsample', (dtype('int32'), ), None, (
        dtype('float64'),
        dtype('float64'),
        dtype('array<?T>'),
    ), downsample_aggregator_type)

    call_stats_aggregator_type = dtype(
        'struct{AC: array<int32>,AF:array<float64>,AN:int32,homozygote_count:array<int32>}'
    )
    register_aggregator('CallStats', (), (dtype('int32'), ), (dtype('call'), ),
                        call_stats_aggregator_type)

    inbreeding_aggregator_type = dtype(
        'struct{f_stat:float64,n_called:int64,expected_homs:float64,observed_homs:int64}'
    )
    register_aggregator('Inbreeding', (), None, (
        dtype('call'),
        dtype('float64'),
    ), inbreeding_aggregator_type)

    linreg_aggregator_type = dtype(
        'struct{beta:array<float64>,standard_error:array<float64>,t_stat:array<float64>,p_value:array<float64>,multiple_standard_error:float64,multiple_r_squared:float64,adjusted_r_squared:float64,f_stat:float64,multiple_p_value:float64,n:int64}'
    )
    register_aggregator('LinearRegression', (
        dtype('int32'),
        dtype('int32'),
    ), None, (
        dtype('float64'),
        dtype('array<float64>'),
    ), linreg_aggregator_type)

    register_aggregator('PearsonCorrelation', (), None, (
        dtype('tfloat64'),
        dtype('float64'),
    ), dtype('float64'))

    register_aggregator('PrevNonnull', (), None, (dtype('?in'), ),
                        dtype('?in'))
示例#35
0
文件: backend.py 项目: tpoterba/hail
 def value_type(self, ir):
     jir = self._to_java_ir(ir)
     return dtype(jir.typ().toString())
示例#36
0
def register_aggregators():
    from hail.expr.types import dtype

    register_aggregator('ApproxCDF', (dtype('int32'),), None, (dtype('int32'),),
                        dtype('struct{values:array<int32>,ranks:array<int64>}'))
    register_aggregator('ApproxCDF', (dtype('int32'),), None, (dtype('int64'),),
                        dtype('struct{values:array<int64>,ranks:array<int64>}'))
    register_aggregator('ApproxCDF', (dtype('int32'),), None, (dtype('float32'),),
                        dtype('struct{values:array<float32>,ranks:array<int64>}'))
    register_aggregator('ApproxCDF', (dtype('int32'),), None, (dtype('float64'),),
                        dtype('struct{values:array<float64>,ranks:array<int64>}'))
    register_aggregator('Fraction', (), None, (dtype('bool'),), dtype('float64'))

    stats_aggregator_type = dtype('struct{mean:float64,stdev:float64,min:float64,max:float64,n:int64,sum:float64}')
    register_aggregator('Statistics', (), None, (dtype('float64'),), stats_aggregator_type)

    register_aggregator('Collect', (), None, (dtype("?in"),), dtype('array<?in>'))

    info_score_aggregator_type = dtype('struct{score:float64,n_included:tint32}')
    register_aggregator('InfoScore', (), None, (dtype('array<float64>'),), info_score_aggregator_type)

    register_aggregator('Sum', (), None, (dtype('int64'),), dtype('int64'))
    register_aggregator('Sum', (), None, (dtype('float64'),), dtype('float64'))

    register_aggregator('Sum', (), None, (dtype('array<int64>'),), dtype('array<int64>'))
    register_aggregator('Sum', (), None, (dtype('array<float64>'),), dtype('array<float64>'))

    register_aggregator('CollectAsSet', (), None, (dtype("?in"),), dtype('set<?in>'))

    register_aggregator('Product', (), None, (dtype('int64'),), dtype('int64'))
    register_aggregator('Product', (), None, (dtype('float64'),), dtype('float64'))

    hwe_aggregator_type = dtype('struct { het_freq_hwe: float64, p_value: float64 }')
    register_aggregator('HardyWeinberg', (), None, (dtype('call'),), hwe_aggregator_type)

    register_aggregator('Max', (), None, (dtype('bool'),), dtype('bool'))
    register_aggregator('Max', (), None, (dtype('int32'),), dtype('int32'))
    register_aggregator('Max', (), None, (dtype('int64'),), dtype('int64'))
    register_aggregator('Max', (), None, (dtype('float32'),), dtype('float32'))
    register_aggregator('Max', (), None, (dtype('float64'),), dtype('float64'))

    register_aggregator('Min', (), None, (dtype('bool'),), dtype('bool'))
    register_aggregator('Min', (), None, (dtype('int32'),), dtype('int32'))
    register_aggregator('Min', (), None, (dtype('int64'),), dtype('int64'))
    register_aggregator('Min', (), None, (dtype('float32'),), dtype('float32'))
    register_aggregator('Min', (), None, (dtype('float64'),), dtype('float64'))

    register_aggregator('Count', (), None, (), dtype('int64'))

    register_aggregator('Counter', (), None, (dtype('?in'),), dtype('dict<?in, int64>'))

    register_aggregator('Take', (dtype('int32'),), None, (dtype('?in'),), dtype('array<?in>'))

    register_aggregator('TakeBy', (dtype('int32'),), None, (dtype('?in'), dtype('?key'),), dtype('array<?in>'))

    histogram_aggregator_type = dtype('struct{bin_edges:array<float64>,bin_freq:array<int64>,n_smaller:int64,n_larger:int64}')
    register_aggregator('Histogram', (dtype('float64'), dtype('float64'), dtype('int32'),), None, (dtype('float64'),), histogram_aggregator_type)

    downsample_aggregator_type = dtype('array<tuple(float64, float64, array<str>)>')
    register_aggregator('Downsample', (dtype('int32'),), None, (dtype('float64'), dtype('float64'), dtype('array<?T>'),), downsample_aggregator_type)

    call_stats_aggregator_type = dtype('struct{AC: array<int32>,AF:array<float64>,AN:int32,homozygote_count:array<int32>}')
    register_aggregator('CallStats', (), (dtype('int32'),), (dtype('call'),), call_stats_aggregator_type)

    inbreeding_aggregator_type = dtype('struct{f_stat:float64,n_called:int64,expected_homs:float64,observed_homs:int64}')
    register_aggregator('Inbreeding', (), None, (dtype('call'), dtype('float64'),), inbreeding_aggregator_type)

    linreg_aggregator_type = dtype('struct{beta:array<float64>,standard_error:array<float64>,t_stat:array<float64>,p_value:array<float64>,multiple_standard_error:float64,multiple_r_squared:float64,adjusted_r_squared:float64,f_stat:float64,multiple_p_value:float64,n:int64}')
    register_aggregator('LinearRegression', (dtype('int32'), dtype('int32'),), None, (dtype('float64'), dtype('array<float64>'),), linreg_aggregator_type)

    register_aggregator('PearsonCorrelation', (), None, (dtype('tfloat64'), dtype('float64'),), dtype('float64'))

    register_aggregator('PrevNonnull', (), None, (dtype('?in'),), dtype('?in'))
示例#37
0
def register_reference_genome_functions(rg):
    from hail.expr.types import dtype

    tvariant = dtype(f"struct{{locus:locus<{rg}>,alleles:array<str>}}")
    tinterval = dtype(f"interval<locus<{rg}>>")

    register_session_function(f"Locus({rg})", (dtype("str"), ),
                              dtype(f"locus<{rg}>"))
    register_session_function(f"Locus({rg})", (
        dtype("str"),
        dtype("int32"),
    ), dtype(f"locus<{rg}>"))
    register_session_function(f"LocusAlleles({rg})", (dtype("str"), ),
                              tvariant)
    register_session_function(f"LocusInterval({rg})", (
        dtype("str"),
        dtype("bool"),
    ), tinterval)
    register_session_function(f"LocusInterval({rg})", (
        dtype("str"),
        dtype("int32"),
        dtype("int32"),
        dtype("bool"),
        dtype("bool"),
        dtype("bool"),
    ), tinterval)
    register_session_function(f"isValidContig({rg})", (dtype("str"), ),
                              dtype("bool"))
    register_session_function(f"isValidLocus({rg})", (
        dtype("str"),
        dtype("int32"),
    ), dtype("bool"))

    register_session_function(f"getReferenceSequenceFromValidLocus({rg})", (
        dtype("str"),
        dtype("int32"),
        dtype("int32"),
        dtype("int32"),
    ), dtype("str"))
    register_session_function(f"getReferenceSequence({rg})", (
        dtype("str"),
        dtype("int32"),
        dtype("int32"),
        dtype("int32"),
    ), dtype("str"))

    register_session_function(f"globalPosToLocus({rg})", (dtype("int64"), ),
                              dtype(f"locus<{rg}>"))
    register_session_function(f"locusToGlobalPos({rg})",
                              (dtype(f"locus<{rg}>"), ), dtype("int64"))
示例#38
0
def register_functions():
    from hail.expr.types import dtype

    register_function("flatten", (dtype("array<array<?T>>"),), dtype("array<?T>"))
    register_function("difference", (dtype("set<?T>"),dtype("set<?T>"),), dtype("set<?T>"))
    register_function("median", (dtype("set<?T:numeric>"),), dtype("?T"))
    register_function("median", (dtype("array<?T:numeric>"),), dtype("?T"))
    register_function("uniqueMinIndex", (dtype("array<?T>"),), dtype("int32"))
    register_function("mean", (dtype("set<?T:numeric>"),), dtype("float64"))
    register_function("mean", (dtype("array<?T:numeric>"),), dtype("float64"))
    register_function("toFloat32", (dtype("?T:numeric"),), dtype("float32"))
    register_function("uniqueMaxIndex", (dtype("array<?T>"),), dtype("int32"))
    register_function("toSet", (dtype("array<?T>"),), dtype("set<?T>"))

    def floating_point_divide(arg_type, ret_type):
        register_function("/", (arg_type, hl.tarray(arg_type),), hl.tarray(ret_type))
        register_function("/", (hl.tarray(arg_type),arg_type), hl.tarray(ret_type))
        register_function("/", (hl.tarray(arg_type),hl.tarray(arg_type)), hl.tarray(ret_type))
    floating_point_divide(hl.tint32, hl.tfloat32)
    floating_point_divide(hl.tint64, hl.tfloat32)
    floating_point_divide(hl.tfloat32, hl.tfloat32)
    floating_point_divide(hl.tfloat64, hl.tfloat64)

    register_function("values", (dtype("dict<?key, ?value>"),), dtype("array<?value>"))
    register_function("[*:]", (dtype("array<?T>"),dtype("int32"),), dtype("array<?T>"))
    register_function("[*:]", (dtype("str"),dtype("int32"),), dtype("str"))
    register_function("get", (dtype("dict<?key, ?value>"),dtype("?key"),), dtype("?value"))
    register_function("get", (dtype("dict<?key, ?value>"),dtype("?key"),dtype("?value"),), dtype("?value"))
    register_function("max", (dtype("array<?T:numeric>"),), dtype("?T"))
    register_function("max", (dtype("set<?T:numeric>"),), dtype("?T"))
    register_function("max", (dtype("?T"),dtype("?T"),), dtype("?T"))
    register_function("product", (dtype("set<?T:numeric>"),), dtype("?T"))
    register_function("product", (dtype("array<?T:numeric>"),), dtype("?T"))
    register_function("toInt32", (dtype("?T:numeric"),), dtype("int32"))
    register_function("extend", (dtype("array<?T>"),dtype("array<?T>"),), dtype("array<?T>"))
    register_function("argmin", (dtype("array<?T>"),), dtype("int32"))
    register_function("toFloat64", (dtype("?T:numeric"),), dtype("float64"))
    register_function("sort", (dtype("array<?T>"),), dtype("array<?T>"))
    register_function("sort", (dtype("array<?T>"),dtype("bool"),), dtype("array<?T>"))
    register_function("isSubset", (dtype("set<?T>"),dtype("set<?T>"),), dtype("bool"))
    register_function("[*:*]", (dtype("str"),dtype("int32"),dtype("int32"),), dtype("str"))
    register_function("[*:*]", (dtype("array<?T>"),dtype("int32"),dtype("int32"),), dtype("array<?T>"))
    register_function("+", (dtype("array<?T:numeric>"),dtype("array<?T>"),), dtype("array<?T>"))
    register_function("+", (dtype("array<?T:numeric>"),dtype("?T"),), dtype("array<?T>"))
    register_function("+", (dtype("?T:numeric"),dtype("array<?T>"),), dtype("array<?T>"))
    register_function("**", (dtype("?T:numeric"),dtype("array<?T>"),), dtype("array<float64>"))
    register_function("**", (dtype("array<?T:numeric>"),dtype("array<?T>"),), dtype("array<float64>"))
    register_function("**", (dtype("array<?T:numeric>"),dtype("?T"),), dtype("array<float64>"))
    register_function("append", (dtype("array<?T>"),dtype("?T"),), dtype("array<?T>"))
    register_function("[:*]", (dtype("str"),dtype("int32"),), dtype("str"))
    register_function("[:*]", (dtype("array<?T>"),dtype("int32"),), dtype("array<?T>"))
    register_function("remove", (dtype("set<?T>"),dtype("?T"),), dtype("set<?T>"))
    register_function("[]", (dtype("str"),dtype("int32"),), dtype("str"))
    register_function("indexArray", (dtype("array<?T>"),dtype("int32"),), dtype("?T"))
    register_function("[]", (dtype("dict<?key, ?value>"),dtype("?key"),), dtype("?value"))
    register_function("dictToArray", (dtype("dict<?key, ?value>"),), dtype("array<tuple(?key, ?value)>"))
    register_function("%", (dtype("array<?T:numeric>"),dtype("?T"),), dtype("array<?T>"))
    register_function("%", (dtype("?T:numeric"),dtype("array<?T>"),), dtype("array<?T>"))
    register_function("%", (dtype("array<?T:numeric>"),dtype("array<?T>"),), dtype("array<?T>"))
    register_function("dict", (dtype("array<tuple(?key, ?value)>"),), dtype("dict<?key, ?value>"))
    register_function("dict", (dtype("set<tuple(?key, ?value)>"),), dtype("dict<?key, ?value>"))
    register_function("keys", (dtype("dict<?key, ?value>"),), dtype("array<?key>"))
    register_function("min", (dtype("array<?T:numeric>"),), dtype("?T"))
    register_function("min", (dtype("set<?T:numeric>"),), dtype("?T"))
    register_function("min", (dtype("?T"),dtype("?T"),), dtype("?T"))
    register_function("sum", (dtype("set<?T:numeric>"),), dtype("?T"))
    register_function("sum", (dtype("array<?T:numeric>"),), dtype("?T"))
    register_function("toInt64", (dtype("?T:numeric"),), dtype("int64"))
    register_function("contains", (dtype("dict<?key, ?value>"),dtype("?key"),), dtype("bool"))
    register_function("contains", (dtype("array<?T>"),dtype("?T"),), dtype("bool"))
    register_function("contains", (dtype("set<?T>"),dtype("?T"),), dtype("bool"))
    register_function("-", (dtype("?T:numeric"),dtype("array<?T>"),), dtype("array<?T>"))
    register_function("-", (dtype("array<?T:numeric>"),dtype("?T"),), dtype("array<?T>"))
    register_function("-", (dtype("array<?T:numeric>"),dtype("array<?T>"),), dtype("array<?T>"))
    register_function("addone", (dtype("int32"),), dtype("int32"))
    register_function("isEmpty", (dtype("dict<?key, ?value>"),), dtype("bool"))
    register_function("isEmpty", (dtype("array<?T>"),), dtype("bool"))
    register_function("isEmpty", (dtype("set<?T>"),), dtype("bool"))
    register_function("[:]", (dtype("array<?T>"),), dtype("array<?T>"))
    register_function("[:]", (dtype("str"),), dtype("str"))
    register_function("union", (dtype("set<?T>"),dtype("set<?T>"),), dtype("set<?T>"))
    register_function("*", (dtype("array<?T:numeric>"),dtype("array<?T>"),), dtype("array<?T>"))
    register_function("*", (dtype("?T:numeric"),dtype("array<?T>"),), dtype("array<?T>"))
    register_function("*", (dtype("array<?T:numeric>"),dtype("?T"),), dtype("array<?T>"))
    register_function("intersection", (dtype("set<?T>"),dtype("set<?T>"),), dtype("set<?T>"))
    register_function("add", (dtype("set<?T>"),dtype("?T"),), dtype("set<?T>"))
    register_function("argmax", (dtype("array<?T>"),), dtype("int32"))
    register_function("//", (dtype("array<?T:numeric>"),dtype("array<?T>"),), dtype("array<?T>"))
    register_function("//", (dtype("array<?T:numeric>"),dtype("?T"),), dtype("array<?T>"))
    register_function("//", (dtype("?T:numeric"),dtype("array<?T>"),), dtype("array<?T>"))
    register_function("keySet", (dtype("dict<?key, ?value>"),), dtype("set<?key>"))
    register_function("qnorm", (dtype("float64"),), dtype("float64"))
    register_function("oneHotAlleles", (dtype("call"),dtype("int32"),), dtype("array<int32>"))
    register_function("dpois", (dtype("float64"),dtype("float64"),dtype("bool"),), dtype("float64"))
    register_function("dpois", (dtype("float64"),dtype("float64"),), dtype("float64"))
    register_function("ploidy", (dtype("call"),), dtype("int32"))
    register_function("||", (dtype("bool"),dtype("bool"),), dtype("bool"))
    register_function("ppois", (dtype("float64"),dtype("float64"),dtype("bool"),dtype("bool"),), dtype("float64"))
    register_function("ppois", (dtype("float64"),dtype("float64"),), dtype("float64"))
    register_function("log10", (dtype("float64"),), dtype("float64"))
    register_function("isHet", (dtype("call"),), dtype("bool"))
    register_function("isAutosomalOrPseudoAutosomal", (dtype("?T:locus"),), dtype("bool"))
    register_function("testCodeUnification", (dtype("?x:numeric"),dtype("?x:int32"),), dtype("?x"))
    register_seeded_function("rand_pois", (dtype("float64"),), dtype("float64"))
    register_seeded_function("rand_pois", (dtype("int32"),dtype("float64"),), dtype("array<float64>"))
    register_function("toFloat32", (dtype("str"),), dtype("float32"))
    register_function("toFloat32", (dtype("bool"),), dtype("float32"))
    register_function("isAutosomal", (dtype("?T:locus"),), dtype("bool"))
    register_function("isPhased", (dtype("call"),), dtype("bool"))
    register_function("isHomVar", (dtype("call"),), dtype("bool"))
    register_function("corr", (dtype("array<float64>"),dtype("array<float64>"),), dtype("float64"))
    register_function("log", (dtype("float64"),dtype("float64"),), dtype("float64"))
    register_function("log", (dtype("float64"),), dtype("float64"))
    register_function("foobar2", (), dtype("int32"))
    register_function("approxEqual", (dtype("float64"),dtype("float64"),dtype("float64"),dtype("bool"),dtype("bool"),), dtype("bool"))
    register_function("plDosage", (dtype("array<?N:int32>"),), dtype("float64"))
    register_function("includesEnd", (dtype("interval<?T>"),), dtype("bool"))
    register_function("position", (dtype("?T:locus"),), dtype("int32"))
    register_seeded_function("rand_unif", (dtype("float64"),dtype("float64"),), dtype("float64"))
    register_function("str", (dtype("?T"),), dtype("str"))
    register_function("valuesSimilar", (dtype("?T"),dtype("?T"),dtype('float64'),dtype('bool'),), dtype("bool"))
    register_function("replace", (dtype("str"),dtype("str"),dtype("str"),), dtype("str"))
    register_function("exp", (dtype("float64"),), dtype("float64"))
    register_function("&&", (dtype("bool"),dtype("bool"),), dtype("bool"))
    register_function("compare", (dtype("int32"),dtype("int32"),), dtype("int32"))
    register_function("triangle", (dtype("int32"),), dtype("int32"))
    register_function("Interval", (dtype("?T"),dtype("?T"),dtype("bool"),dtype("bool"),), dtype("interval<?T>"))
    register_function("contig", (dtype("?T:locus"),), dtype("str"))
    register_function("Call", (dtype("bool"),), dtype("call"))
    register_function("Call", (dtype("str"),), dtype("call"))
    register_function("Call", (dtype("int32"),dtype("bool"),), dtype("call"))
    register_function("Call", (dtype("int32"),dtype("int32"),dtype("bool"),), dtype("call"))
    register_function("Call", (dtype("array<int32>"),dtype("bool"),), dtype("call"))
    register_function("qchisqtail", (dtype("float64"),dtype("float64"),), dtype("float64"))
    register_function("binomTest", (dtype("int32"),dtype("int32"),dtype("float64"),dtype("int32"),), dtype("float64"))
    register_function("qpois", (dtype("float64"),dtype("float64"),), dtype("int32"))
    register_function("qpois", (dtype("float64"),dtype("float64"),dtype("bool"),dtype("bool"),), dtype("int32"))
    register_function("is_finite", (dtype("float32"),), dtype("bool"))
    register_function("is_finite", (dtype("float64"),), dtype("bool"))
    register_function("inYPar", (dtype("?T:locus"),), dtype("bool"))
    register_function("contingency_table_test", (dtype("int32"),dtype("int32"),dtype("int32"),dtype("int32"),dtype("int32"),), dtype("struct{p_value: float64, odds_ratio: float64}"))
    register_function("toInt32", (dtype("bool"),), dtype("int32"))
    register_function("toInt32", (dtype("str"),), dtype("int32"))
    register_function("foobar1", (), dtype("int32"))
    register_function("toFloat64", (dtype("str"),), dtype("float64"))
    register_function("toFloat64", (dtype("bool"),), dtype("float64"))
    register_function("dbeta", (dtype("float64"),dtype("float64"),dtype("float64"),), dtype("float64"))
    register_function("min_rep", (dtype("?T:locus"),dtype("array<str>"),), dtype("struct{locus: ?T, alleles: array<str>}"))
    register_function("toBoolean", (dtype("str"),), dtype("bool"))
    register_seeded_function("rand_bool", (dtype("float64"),), dtype("bool"))
    register_function("pchisqtail", (dtype("float64"),dtype("float64"),), dtype("float64"))
    register_seeded_function("rand_cat", (dtype("array<float64>"),), dtype("int32"))
    register_function("inYNonPar", (dtype("?T:locus"),), dtype("bool"))
    register_function("+", (dtype("str"),dtype("str"),), dtype("str"))
    register_function("**", (dtype("float32"),dtype("float32"),), dtype("float64"))
    register_function("**", (dtype("int32"),dtype("int32"),), dtype("float64"))
    register_function("**", (dtype("int64"),dtype("int64"),), dtype("float64"))
    register_function("**", (dtype("float64"),dtype("float64"),), dtype("float64"))
    register_function("length", (dtype("str"),), dtype("int32"))
    register_function("slice", (dtype("str"),dtype("int32"),dtype("int32"),), dtype("str"))
    register_function("split", (dtype("str"),dtype("str"),dtype("int32"),), dtype("array<str>"))
    register_function("split", (dtype("str"),dtype("str"),), dtype("array<str>"))
    register_seeded_function("rand_gamma", (dtype("float64"),dtype("float64"),), dtype("float64"))
    register_function("UnphasedDiploidGtIndexCall", (dtype("int32"),), dtype("call"))
    register_function("[]", (dtype("call"),dtype("int32"),), dtype("int32"))
    register_function("sign", (dtype("int64"),), dtype("int64"))
    register_function("sign", (dtype("float64"),), dtype("float64"))
    register_function("sign", (dtype("float32"),), dtype("float32"))
    register_function("sign", (dtype("int32"),), dtype("int32"))
    register_function("unphasedDiploidGtIndex", (dtype("call"),), dtype("int32"))
    register_function("gamma", (dtype("float64"),), dtype("float64"))
    register_function("%", (dtype("float64"),dtype("float64"),), dtype("float64"))
    register_function("%", (dtype("int64"),dtype("int64"),), dtype("int64"))
    register_function("%", (dtype("float32"),dtype("float32"),), dtype("float32"))
    register_function("%", (dtype("int32"),dtype("int32"),), dtype("int32"))
    register_function("fisher_exact_test", (dtype("int32"),dtype("int32"),dtype("int32"),dtype("int32"),), dtype("struct{p_value: float64, odds_ratio: float64, ci_95_lower: float64, ci_95_upper: float64}"))
    register_function("floor", (dtype("float64"),), dtype("float64"))
    register_function("floor", (dtype("float32"),), dtype("float32"))
    register_function("isNonRef", (dtype("call"),), dtype("bool"))
    register_function("includesStart", (dtype("interval<?T>"),), dtype("bool"))
    register_function("isHetNonRef", (dtype("call"),), dtype("bool"))
    register_function("hardy_weinberg_test", (dtype("int32"),dtype("int32"),dtype("int32"),), dtype("struct{het_freq_hwe: float64, p_value: float64}"))
    register_function("haplotype_freq_em", (dtype("array<int32>"),), dtype("array<float64>"))
    register_function("nNonRefAlleles", (dtype("call"),), dtype("int32"))
    register_function("abs", (dtype("float64"),), dtype("float64"))
    register_function("abs", (dtype("float32"),), dtype("float32"))
    register_function("abs", (dtype("int64"),), dtype("int64"))
    register_function("abs", (dtype("int32"),), dtype("int32"))
    register_function("endswith", (dtype("str"),dtype("str"),), dtype("bool"))
    register_function("sqrt", (dtype("float64"),), dtype("float64"))
    register_function("isnan", (dtype("float32"),), dtype("bool"))
    register_function("isnan", (dtype("float64"),), dtype("bool"))
    register_function("lower", (dtype("str"),), dtype("str"))
    register_seeded_function("rand_beta", (dtype("float64"),dtype("float64"),), dtype("float64"))
    register_seeded_function("rand_beta", (dtype("float64"),dtype("float64"),dtype("float64"),dtype("float64"),), dtype("float64"))
    register_function("toInt64", (dtype("bool"),), dtype("int64"))
    register_function("toInt64", (dtype("str"),), dtype("int64"))
    register_function("testCodeUnification2", (dtype("?x"),), dtype("?x"))
    register_function("contains", (dtype("str"),dtype("str"),), dtype("bool"))
    register_function("contains", (dtype("interval<?T>"),dtype("?T"),), dtype("bool"))
    register_function("entropy", (dtype("str"),), dtype("float64"))
    register_function("filtering_allele_frequency", (dtype("int32"),dtype("int32"),dtype("float64"),), dtype("float64"))
    register_function("gqFromPL", (dtype("array<?N:int32>"),), dtype("int32"))
    register_function("startswith", (dtype("str"),dtype("str"),), dtype("bool"))
    register_function("ceil", (dtype("float32"),), dtype("float32"))
    register_function("ceil", (dtype("float64"),), dtype("float64"))
    register_function("json", (dtype("?T"),), dtype("str"))
    register_function("strip", (dtype("str"),), dtype("str"))
    register_function("firstMatchIn", (dtype("str"),dtype("str"),), dtype("array<str>"))
    register_function("isEmpty", (dtype("interval<?T>"),), dtype("bool"))
    register_function("~", (dtype("str"),dtype("str"),), dtype("bool"))
    register_function("mkString", (dtype("set<str>"),dtype("str"),), dtype("str"))
    register_function("mkString", (dtype("array<str>"),dtype("str"),), dtype("str"))
    register_function("dosage", (dtype("array<?N:float64>"),), dtype("float64"))
    register_function("upper", (dtype("str"),), dtype("str"))
    register_function("overlaps", (dtype("interval<?T>"),dtype("interval<?T>"),), dtype("bool"))
    register_function("downcode", (dtype("call"),dtype("int32"),), dtype("call"))
    register_function("inXPar", (dtype("?T:locus"),), dtype("bool"))
    register_function("format", (dtype("str"),dtype("?T:tuple"),), dtype("str"))
    register_function("pnorm", (dtype("float64"),), dtype("float64"))
    register_function("is_infinite", (dtype("float32"),), dtype("bool"))
    register_function("is_infinite", (dtype("float64"),), dtype("bool"))
    register_function("isHetRef", (dtype("call"),), dtype("bool"))
    register_function("isMitochondrial", (dtype("?T:locus"),), dtype("bool"))
    register_function("hamming", (dtype("str"),dtype("str"),), dtype("int32"))
    register_function("end", (dtype("interval<?T>"),), dtype("?T"))
    register_function("start", (dtype("interval<?T>"),), dtype("?T"))
    register_function("inXNonPar", (dtype("?T:locus"),), dtype("bool"))
    register_function("escapeString", (dtype("str"),), dtype("str"))
    register_function("isHomRef", (dtype("call"),), dtype("bool"))
    register_seeded_function("rand_norm", (dtype("float64"),dtype("float64"),), dtype("float64"))
    register_function("chi_squared_test", (dtype("int32"),dtype("int32"),dtype("int32"),dtype("int32"),), dtype("struct{p_value: float64, odds_ratio: float64}"))
示例#39
0
 def _from_java(jtt):
     return ttable(
         dtype(jtt.globalType().toString()),
         dtype(jtt.rowType().toString()),
         jiterable_to_list(jtt.key()))
示例#40
0
 def _from_java(jtbm):
     return tblockmatrix(dtype(jtbm.elementType().toString()),
                         jiterable_to_list(jtbm.shape()), jtbm.blockSize(),
                         jiterable_to_list(jtbm.dimsPartitioned()))
示例#41
0
def register_reference_genome_functions(rg):
    from hail.expr.types import dtype

    tvariant = dtype(f"struct{{locus:locus<{rg}>,alleles:array<str>}}")
    tinterval = dtype(f"interval<locus<{rg}>>")
    
    register_function(f"Locus({rg})", (dtype("str"),), dtype(f"locus<{rg}>"))
    register_function(f"Locus({rg})", (dtype("str"),dtype("int32"),), dtype(f"locus<{rg}>"))
    register_function(f"LocusAlleles({rg})", (dtype("str"),), tvariant)
    register_function(f"LocusInterval({rg})", (dtype("str"),), tinterval)
    register_function(f"LocusInterval({rg})", (dtype("str"),dtype("int32"),dtype("int32"),dtype("bool"),dtype("bool"),), tinterval)
    register_function(f"isValidContig({rg})", (dtype("str"),), dtype("bool"))
    register_function(f"isValidLocus({rg})", (dtype("str"),dtype("int32"),), dtype("bool"))

    register_function(f"getReferenceSequenceFromValidLocus({rg})", (dtype("str"),dtype("int32"),dtype("int32"),dtype("int32"),), dtype("str"))
    register_function(f"getReferenceSequence({rg})", (dtype("str"),dtype("int32"),dtype("int32"),dtype("int32"),), dtype("str"))

    register_function(f"globalPosToLocus({rg})", (dtype("int64"),), dtype(f"locus<{rg}>"))
    register_function(f"locusToGlobalPos({rg})", (dtype(f"locus<{rg}>"),), dtype("int64"))