Exemple #1
0
    def test_matrix_ir_parses(self):
        matrix_irs = [
            ir.MatrixUnionRows(ir.MatrixRange(5, 5, 1), ir.MatrixRange(5, 5, 1))
        ]

        for x in matrix_irs:
            Env.hail().expr.Parser.parse_matrix_ir(str(x))
Exemple #2
0
    def test_matrix_ir_parses(self):
        hl.index_bgen(resource('example.8bits.bgen'),
                      reference_genome=hail.get_reference('GRCh37'),
                      contig_recoding={'01': '1'})

        collect_sig = ir.AggSignature('Collect', [], None, [hl.tint32])
        collect = ir.MakeStruct([('x',
                                  ir.ApplyAggOp([ir.I32(0)], [], None,
                                                collect_sig,
                                                hl.tarray(hl.tint32)))])

        matrix_read = ir.MatrixRead(
            resource('backward_compatability/1.0.0/matrix_table/0.hmt'), False,
            False)
        table_read = ir.TableRead(
            resource('backward_compatability/1.0.0/table/0.ht'), False, None)

        matrix_irs = [
            ir.MatrixUnionRows(ir.MatrixRange(5, 5, 1),
                               ir.MatrixRange(5, 5, 1)),
            ir.UnlocalizeEntries(ir.LocalizeEntries(matrix_read, '__entries'),
                                 ir.MatrixColsTable(matrix_read), '__entries'),
            ir.MatrixAggregateRowsByKey(matrix_read, collect, collect),
            ir.MatrixAggregateColsByKey(matrix_read, collect, collect),
            ir.MatrixRange(1, 1, 10),
            ir.MatrixImportVCF([resource('sample.vcf')], False, False,
                               None, None, False, ['GT'],
                               hail.get_reference('GRCh37'), {}, True, False),
            ir.MatrixImportBGEN([resource('example.8bits.bgen')], ['GP'],
                                resource('example.sample'), {}, 10, 1,
                                ['varid'], None),
            ir.MatrixFilterRows(matrix_read, ir.FalseIR()),
            ir.MatrixFilterCols(matrix_read, ir.FalseIR()),
            ir.MatrixFilterEntries(matrix_read, ir.FalseIR()),
            ir.MatrixChooseCols(matrix_read, [1, 0]),
            ir.MatrixMapCols(matrix_read, ir.MakeStruct([('x', ir.I64(20))]),
                             ['x']),
            ir.MatrixKeyRowsBy(matrix_read, ['row_i64'], False),
            ir.MatrixMapRows(ir.MatrixKeyRowsBy(matrix_read, []),
                             ir.MakeStruct([('x', ir.I64(20))])),
            ir.MatrixMapEntries(matrix_read,
                                ir.MakeStruct([('x', ir.I64(20))])),
            ir.MatrixMapGlobals(matrix_read,
                                ir.MakeStruct([('x', ir.I64(20))])),
            ir.TableToMatrixTable(table_read, ['f32', 'i64'], ['m', 'astruct'],
                                  ['aset'], ['mset'], 100),
            ir.MatrixCollectColsByKey(matrix_read),
            ir.MatrixExplodeRows(matrix_read, ['row_aset']),
            ir.MatrixExplodeCols(matrix_read, ['col_aset']),
            ir.MatrixAnnotateRowsTable(matrix_read, table_read, '__foo', None),
            ir.MatrixAnnotateColsTable(matrix_read, table_read, '__foo'),
        ]

        for x in matrix_irs:
            try:
                Env.hail().expr.Parser.parse_matrix_ir(str(x))
            except Exception as e:
                raise ValueError(str(x)) from e