示例#1
0
def reference_remove_sequence():
    try:
        data = flask.request.json
        scala_object(Env.hail().variant,
                     'ReferenceGenome').removeSequence(data['name'])
        return '', 204
    except FatalError as e:
        return flask.jsonify({'message': e.args[0]}), 400
示例#2
0
文件: types.py 项目: danking/hail
 def _convert_to_j(self, annotation):
     if annotation is not None:
         return scala_object(Env.hail().annotations, 'Annotation').fromSeq(
             Env.jutils().arrayListToISeq(
                 [t._convert_to_j(annotation.get(f)) for f, t in self.items()]))
     else:
         return None
示例#3
0
def create_backward_compatibility_files():
    import os

    all_values_table, all_values_matrix_table = create_all_values_datasets()

    file_version = Env.hail().expr.ir.FileFormat.version().toString()
    supported_codecs = scala_object(Env.hail().io, 'BufferSpec').specs()

    table_dir = resource(
        os.path.join('backward_compatability', str(file_version), 'table'))
    if not os.path.exists(table_dir):
        os.makedirs(table_dir)

    matrix_table_dir = resource(
        os.path.join('backward_compatability', str(file_version),
                     'matrix_table'))
    if not os.path.exists(matrix_table_dir):
        os.makedirs(matrix_table_dir)

    i = 0
    for codec in supported_codecs:
        all_values_table.write(os.path.join(table_dir, f'{i}.ht'),
                               overwrite=True,
                               _codec_spec=codec.toString())
        all_values_matrix_table.write(os.path.join(matrix_table_dir,
                                                   f'{i}.hmt'),
                                      overwrite=True,
                                      _codec_spec=codec.toString())
        i += 1
示例#4
0
文件: types.py 项目: dujm/hail
 def __init__(self, key_type, value_type, required=False):
     jtype = scala_object(Env.hail().expr,
                          'TDict').apply(key_type._jtype, value_type._jtype,
                                         required)
     self.key_type = key_type
     self.value_type = value_type
     super(TDict, self).__init__(jtype)
示例#5
0
 def _convert_to_j(self, annotation):
     if annotation is not None:
         return scala_object(Env.hail().annotations, 'Annotation').fromSeq(
             Env.jutils().arrayListToISeq(
                 [t._convert_to_j(annotation.get(f)) for f, t in self.items()]))
     else:
         return None
示例#6
0
 def random(rows, cols, block_size):
     hc = Env.hc()
     return BlockMatrix(
         hc,
         scala_object(Env.hail().distributedmatrix,
                      'BlockMatrix').random(hc._jhc, rows, cols,
                                            block_size))
示例#7
0
文件: types.py 项目: dujm/hail
 def __init__(self, element_type, required=False):
     """
     :param :class:`.Type` element_type: Hail type of set element
     """
     jtype = scala_object(Env.hail().expr,
                          'TSet').apply(element_type._jtype, required)
     self.element_type = element_type
     super(TSet, self).__init__(jtype)
示例#8
0
文件: types.py 项目: dujm/hail
 def _convert_to_j(self, annotation):
     if annotation is not None:
         return scala_object(Env.hail().annotations, 'Annotation').fromSeq(
             Env.jutils().arrayListToISeq([
                 f.typ._convert_to_j(annotation.get(f.name))
                 for f in self.fields
             ]))
     else:
         return None
示例#9
0
 def test_codecs_table(self):
     from hail.utils.java import Env, scala_object
     codecs = scala_object(Env.hail().io, 'CodecSpec').codecSpecs()
     rt = self.get_vds().rows()
     temp = new_temp_file(suffix='ht')
     for codec in codecs:
         rt.write(temp, overwrite=True, _codec_spec=codec.toString())
         rt2 = hl.read_table(temp)
         self.assertTrue(rt._same(rt2))
示例#10
0
 def test_codecs_table(self):
     from hail.utils.java import scala_object
     codecs = scala_object(Env.hail().io, 'CodecSpec').codecSpecs()
     rt = self.get_vds().rows()
     temp = new_temp_file(suffix='ht')
     for codec in codecs:
         rt.write(temp, overwrite=True, _codec_spec=codec.toString())
         rt2 = hl.read_table(temp)
         self.assertTrue(rt._same(rt2))
示例#11
0
 def test_codecs_matrix(self):
     from hail.utils.java import Env, scala_object
     codecs = scala_object(Env.hail().io, 'CodecSpec').codecSpecs()
     ds = self.get_vds()
     temp = new_temp_file(suffix='hmt')
     for codec in codecs:
         ds.write(temp, overwrite=True, _codec_spec=codec.toString())
         ds2 = hl.read_matrix_table(temp)
         self.assertTrue(ds._same(ds2))
示例#12
0
文件: types.py 项目: danking/hail
    def __init__(self, **field_types):
        self._field_types = field_types
        self._fields = tuple(field_types)

        self._get_jtype = lambda: scala_object(Env.hail().expr.types.virtual, 'TStruct').apply(
            list(self._fields),
            [t._jtype for f, t in self._field_types.items()],
            False)

        super(tstruct, self).__init__()
示例#13
0
文件: types.py 项目: ahiduchick/hail
    def __init__(self, **field_types):
        self._field_types = field_types
        self._fields = tuple(field_types)

        self._get_jtype = lambda: scala_object(Env.hail(
        ).expr.types, 'TStruct').apply(list(
            self._fields), [t._jtype
                            for f, t in self._field_types.items()], False)

        super(tstruct, self).__init__()
示例#14
0
 def __init__(self, contig, position, reference_genome=None):
     if isinstance(contig, int):
         contig = str(contig)
     jrep = scala_object(Env.hail().variant,
                         'Locus').apply(contig, position)
     self._init_from_java(jrep)
     self._contig = contig
     self._position = position
     self._rg = reference_genome if reference_genome else Env.hc(
     ).default_reference
示例#15
0
文件: locus.py 项目: bcajes/hail
    def __init__(self, contig, position, reference_genome='default'):
        if isinstance(contig, int):
            contig = str(contig)

        self._rg = reference_genome

        jrep = scala_object(Env.hail().variant, 'Locus').apply(contig, position, self._rg._jrep)
        self._init_from_java(jrep)
        self._contig = contig
        self._position = position
示例#16
0
 def __init__(self, contig, start, ref, alts, reference_genome=None):
     if isinstance(contig, int):
         contig = str(contig)
     jrep = scala_object(Env.hail().variant,
                         'Variant').apply(contig, start, ref, alts)
     self._init_from_java(jrep)
     self._contig = contig
     self._start = start
     self._ref = ref
     self._rg = reference_genome if reference_genome else Env.hc(
     ).default_reference
示例#17
0
文件: locus.py 项目: shulik7/hail
    def __init__(self, contig, position, reference_genome='default'):
        if isinstance(contig, int):
            contig = str(contig)

        self._rg = reference_genome

        jrep = scala_object(Env.hail().variant,
                            'Locus').apply(contig, position, self._rg._jrep)
        self._init_from_java(jrep)
        self._contig = contig
        self._position = position
示例#18
0
文件: types.py 项目: dujm/hail
    def __init__(self, names, types, required=False):

        if len(names) != len(types):
            raise ValueError('length of names and types not equal: %d and %d' %
                             (len(names), len(types)))
        jtype = scala_object(Env.hail().expr,
                             'TStruct').apply(names,
                                              map(lambda t: t._jtype, types),
                                              required)
        self.fields = [Field(names[i], types[i]) for i in range(len(names))]

        super(TStruct, self).__init__(jtype)
示例#19
0
文件: types.py 项目: dujm/hail
    def from_fields(cls, fields, required=False):
        """Creates a new TStruct from field objects.

        :param fields: The TStruct fields.
        :type fields: list of :class:`.Field`

        :param bool required: Flag for whether the struct can be missing.

        :return: TStruct from input fields
        :rtype: :class:`.TStruct`
        """

        struct = TStruct.__new__(cls)
        struct.fields = fields
        jfields = [
            scala_object(Env.hail().expr,
                         'Field').apply(f.name, f.typ._jtype, i)
            for i, f in enumerate(fields)
        ]
        jtype = scala_object(Env.hail().expr,
                             'TStruct').apply(jindexed_seq(jfields), required)
        return TStruct._from_java(jtype)
示例#20
0
文件: locus.py 项目: bcajes/hail
    def parse(cls, string, reference_genome='default'):
        """Parses a locus object from a CHR:POS string.

        **Examples**

        >>> l1 = hl.Locus.parse('1:101230')
        >>> l2 = hl.Locus.parse('X:4201230')

        :param str string: String to parse.
        :param reference_genome: Reference genome to use. Default is :func:`~hail.default_reference`.
        :type reference_genome: :obj:`str` or :class:`.ReferenceGenome`

        :rtype: :class:`.Locus`
        """

        return Locus._from_java(scala_object(Env.hail().variant, 'Locus').parse(string, reference_genome._jrep), reference_genome)
示例#21
0
    def parse(cls, string, reference_genome=None):
        """Parses a locus object from a CHR:POS string.

        **Examples**

        >>> l1 = Locus.parse('1:101230')
        >>> l2 = Locus.parse('X:4201230')

        :param str string: String to parse.
        :param reference_genome: Reference genome to use. Default is :py:meth:`hail.api1.HailContext.default_reference`.
        :type reference_genome: :class:`.GenomeReference`

        :rtype: :class:`.Locus`
        """
        rg = reference_genome if reference_genome else Env.hc(
        ).default_reference
        return Locus._from_java(
            scala_object(Env.hail().variant, 'Locus').parse(string), rg)
示例#22
0
文件: locus.py 项目: shulik7/hail
    def parse(cls, string, reference_genome='default'):
        """Parses a locus object from a CHR:POS string.

        **Examples**

        >>> l1 = hl.Locus.parse('1:101230')
        >>> l2 = hl.Locus.parse('X:4201230')

        :param str string: String to parse.
        :param reference_genome: Reference genome to use. Default is :func:`~hail.default_reference`.
        :type reference_genome: :obj:`str` or :class:`.ReferenceGenome`

        :rtype: :class:`.Locus`
        """

        return Locus._from_java(
            scala_object(Env.hail().variant,
                         'Locus').parse(string, reference_genome._jrep),
            reference_genome)
示例#23
0
    def parse(cls, string, reference_genome=None):
        """Parses a variant object from a string.

        There are two acceptable formats: CHR:POS:REF:ALT, and
        CHR:POS:REF:ALT1,ALT2,...ALTN.  Below is an example of
        each:

        >>> v_biallelic = Variant.parse('16:20012:A:TT')
        >>> v_multiallelic = Variant.parse('16:12311:T:C,TTT,A')

        :param str string: String to parse.
        :param reference_genome: Reference genome to use. Default is :py:meth:`hail.api1.HailContext.default_reference`.
        :type reference_genome: :class:`.GenomeReference`

        :rtype: :class:`.Variant`
        """
        rg = reference_genome if reference_genome else Env.hc(
        ).default_reference
        jrep = scala_object(Env.hail().variant, 'Variant').parse(string)
        return Variant._from_java(jrep, rg)
示例#24
0
文件: test_api.py 项目: shulik7/hail
def create_backward_compatibility_files():
    import os

    all_values_table, all_values_matrix_table = create_all_values_datasets()

    file_version = Env.hail().variant.FileFormat.version().toString()
    supported_codecs = scala_object(Env.hail().io, 'CodecSpec').supportedCodecSpecs()

    table_dir = 'backward_compatability/{}/table'.format(file_version)
    if not os.path.exists(table_dir):
        os.makedirs(table_dir)

    matrix_table_dir = 'backward_compatability/{}/matrix_table'.format(file_version)
    if not os.path.exists(matrix_table_dir):
        os.makedirs(matrix_table_dir)

    i = 0
    for codec in supported_codecs:
        all_values_table.write('{}/{}.ht'.format(table_dir, i), overwrite=True, _codec_spec=codec.toString())
        all_values_matrix_table.write('{}/{}.hmt'.format(matrix_table_dir, i), overwrite=True, _codec_spec=codec.toString())
        i += 1
示例#25
0
def create_backward_compatibility_files():
    import os

    all_values_table, all_values_matrix_table = create_all_values_datasets()

    file_version = Env.hail().variant.FileFormat.version().toString()
    supported_codecs = scala_object(Env.hail().io, 'CodecSpec').supportedCodecSpecs()

    table_dir = resource(os.path.join('backward_compatability', str(file_version), 'table'))
    if not os.path.exists(table_dir):
        os.makedirs(table_dir)

    matrix_table_dir = resource(os.path.join('backward_compatability', str(file_version), 'matrix_table'))
    if not os.path.exists(matrix_table_dir):
        os.makedirs(matrix_table_dir)

    i = 0
    for codec in supported_codecs:
        all_values_table.write(os.path.join(table_dir, f'{i}.ht'), overwrite=True, _codec_spec=codec.toString())
        all_values_matrix_table.write(os.path.join(matrix_table_dir, f'{i}.hmt'), overwrite=True,
                                      _codec_spec=codec.toString())
        i += 1
示例#26
0
文件: types.py 项目: dujm/hail
 def __init__(self, reference_genome=None, required=False):
     self._rg = reference_genome if reference_genome else Env.hc(
     ).default_reference
     jtype = scala_object(Env.hail().expr,
                          'TInterval').apply(self._rg._jrep, required)
     super(TInterval, self).__init__(jtype)
示例#27
0
 def __init__(self, ref, alt):
     jaa = scala_object(Env.hail().variant, 'AltAllele').apply(ref, alt)
     self._init_from_java(jaa)
     self._ref = ref
     self._alt = alt
示例#28
0
文件: types.py 项目: dujm/hail
 def __init__(self, required=False):
     super(TCall, self).__init__(
         scala_object(Env.hail().expr, 'TCall').apply(required))
示例#29
0
 def remove_sequence(self, name):
     scala_object(Env.hail().variant,
                  'ReferenceGenome').removeSequence(name)
示例#30
0
文件: types.py 项目: lfrancioli/hail
 def __init__(self):
     self._get_jtype = lambda: scala_object(Env.hail().expr.types, 'TInt32Optional')
     super(_tint32, self).__init__()
示例#31
0
文件: types.py 项目: lfrancioli/hail
 def __init__(self, element_type):
     self._get_jtype = lambda: scala_object(Env.hail().expr.types, 'TArray').apply(element_type._jtype, False)
     self._element_type = element_type
     super(tarray, self).__init__()
示例#32
0
文件: types.py 项目: lfrancioli/hail
 def __init__(self):
     self._get_jtype = lambda: scala_object(Env.hail().expr.types, 'TStringOptional')
     super(_tstr, self).__init__()
示例#33
0
文件: types.py 项目: dujm/hail
 def __init__(self, required=False):
     super(TInt64, self).__init__(
         scala_object(Env.hail().expr, 'TInt64').apply(required))
     self.required = required
示例#34
0
文件: types.py 项目: danking/hail
 def __init__(self, key_type, value_type):
     self._get_jtype = lambda: scala_object(Env.hail().expr.types.virtual, 'TDict').apply(
         key_type._jtype, value_type._jtype, False)
     self._key_type = key_type
     self._value_type = value_type
     super(tdict, self).__init__()
示例#35
0
文件: types.py 项目: danking/hail
 def __init__(self):
     self._get_jtype = lambda: scala_object(Env.hail().expr.types.virtual, 'TCallOptional')
     super(_tcall, self).__init__()
示例#36
0
文件: types.py 项目: danking/hail
 def __init__(self, *types):
     self._get_jtype = lambda: scala_object(Env.hail().expr.types.virtual, 'TTuple').apply(map(lambda t: t._jtype, types),
                                                                                   False)
     self._types = types
     super(ttuple, self).__init__()
示例#37
0
文件: types.py 项目: ahiduchick/hail
 def __init__(self, key_type, value_type):
     self._get_jtype = lambda: scala_object(Env.hail(
     ).expr.types, 'TDict').apply(key_type._jtype, value_type._jtype, False)
     self._key_type = key_type
     self._value_type = value_type
     super(tdict, self).__init__()
示例#38
0
文件: types.py 项目: ahiduchick/hail
 def __init__(self, *types):
     self._get_jtype = lambda: scala_object(Env.hail(
     ).expr.types, 'TTuple').apply(map(lambda t: t._jtype, types), False)
     self._types = types
     super(ttuple, self).__init__()
示例#39
0
文件: types.py 项目: ahiduchick/hail
 def __init__(self):
     self._get_jtype = lambda: scala_object(Env.hail().expr.types,
                                            'TCallOptional')
     super(_tcall, self).__init__()
示例#40
0
 def remove_sequence(self, name):
     scala_object(self._hail_package.variant,
                  'ReferenceGenome').removeSequence(name)
示例#41
0
文件: types.py 项目: danking/hail
 def __init__(self, element_type):
     self._get_jtype = lambda: scala_object(Env.hail().expr.types.virtual, 'TSet').apply(element_type._jtype, False)
     self._element_type = element_type
     super(tset, self).__init__()
示例#42
0
 def remove_liftover(self, name, dest_reference_genome):
     scala_object(self._hail_package.variant,
                  'ReferenceGenome').referenceRemoveLiftover(
                      name, dest_reference_genome)
示例#43
0
文件: types.py 项目: danking/hail
 def __init__(self):
     self._get_jtype = lambda: scala_object(Env.hail().expr.types, 'TVoid')
     super(_tvoid, self).__init__()
示例#44
0
文件: types.py 项目: lfrancioli/hail
 def __init__(self):
     self._get_jtype = lambda: scala_object(Env.hail().expr.types, 'TBooleanOptional')
     super(_tbool, self).__init__()
示例#45
0
文件: types.py 项目: danking/hail
 def __init__(self, point_type):
     self._get_jtype = lambda: scala_object(Env.hail().expr.types.virtual, 'TInterval').apply(self.point_type._jtype, False)
     self._point_type = point_type
     super(tinterval, self).__init__()
示例#46
0
文件: types.py 项目: lfrancioli/hail
 def __init__(self):
     self._get_jtype = lambda: scala_object(Env.hail().expr.types, 'TFloat64Optional')
     super(_tfloat64, self).__init__()
示例#47
0
文件: types.py 项目: danking/hail
 def __init__(self, reference_genome='default'):
     self._rg = reference_genome
     self._get_jtype = lambda: scala_object(Env.hail().expr.types.virtual, 'TLocus').apply(self._rg._jrep,
                                                                                   False)
     super(tlocus, self).__init__()
示例#48
0
 def remove_liftover(self, name, dest_reference_genome):
     scala_object(Env.hail().variant,
                  'ReferenceGenome').referenceRemoveLiftover(
                      name, dest_reference_genome)
示例#49
0
文件: types.py 项目: dujm/hail
 def __init__(self, required=False):
     super(TAltAllele, self).__init__(
         scala_object(Env.hail().expr, 'TAltAllele').apply(required))
示例#50
0
文件: apiserver.py 项目: jigold/hail
def blocking_reference_add_sequence(data):
    scala_object(Env.hail().variant, 'ReferenceGenome').addSequence(
        data['name'], data['fasta_file'], data['index_file'])
示例#51
0
文件: apiserver.py 项目: jigold/hail
def blocking_reference_remove_sequence(data):
    scala_object(
        Env.hail().variant, 'ReferenceGenome').removeSequence(data['name'])