示例#1
0
文件: expr.py 项目: Fedja/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 annotation
示例#2
0
 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[f.name])
                 for f in self.fields
             ]))
     else:
         return annotation
示例#3
0
 def __init__(self, contig, position):
     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
示例#4
0
    def _init_from_java(self, jtype):

        jfields = Env.jutils().iterableToArrayList(jtype.fields())
        self.fields = [
            Field(f.name(), Type._from_java(f.typ()), dict(f.attrsJava()))
            for f in jfields
        ]
示例#5
0
文件: variant.py 项目: Fedja/hail
    def parse(string):
        """Parses a locus object from a CHR:POS string.

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

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

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

        return Locus._from_java(scala_object(Env.hail().variant, 'Locus').parse(string))
示例#7
0
 def __init__(self, element_type):
     """
     :param :class:`.Type` element_type: Hail type of set element
     """
     jtype = scala_object(Env.hail().expr, 'TSet').apply(element_type._jtype)
     self.element_type = element_type
     super(TSet, self).__init__(jtype)
示例#8
0
 def _convert_to_j(self, annotation):
     if annotation is not None:
         return Env.jutils().javaMapToMap(
             {self.key_type._convert_to_j(k): self.value_type._convert_to_j(v) for k, v in annotation.iteritems()}
         )
     else:
         return annotation
示例#9
0
文件: expr.py 项目: Fedja/hail
 def _convert_to_j(self, annotation):
     if annotation is not None:
         return Env.jutils().javaMapToMap(
             {self.key_type._convert_to_j(k): self.value_type._convert_to_j(v) for k, v in annotation.iteritems()}
         )
     else:
         return annotation
示例#10
0
文件: typ.py 项目: wtsi-hgi/hail
 def __init__(self, element_type, required = False):
     """
     :param :class:`.Type` element_type: Hail type of array element
     """
     jtype = scala_object(Env.hail().expr, 'TAggregable').apply(element_type._jtype, required)
     self.element_type = element_type
     super(TAggregable, self).__init__(jtype)
示例#11
0
文件: variant.py 项目: jbloom22/hail
 def __init__(self, contig, position):
     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
示例#12
0
文件: expr.py 项目: Fedja/hail
 def __init__(self, element_type):
     """
     :param :class:`.Type` element_type: Hail type of set element
     """
     jtype = scala_object(Env.hail().expr, 'TSet').apply(element_type._jtype)
     self.element_type = element_type
     super(TSet, self).__init__(jtype)
示例#13
0
文件: expr.py 项目: Fedja/hail
 def _convert_to_j(self, annotation):
     if annotation is not None:
         return Env.jutils().arrayListToSet(
             [self.element_type._convert_to_j(elt) for elt in annotation]
         )
     else:
         return annotation
示例#14
0
 def _convert_to_j(self, annotation):
     if annotation is not None:
         return Env.jutils().arrayListToISeq(
             [self.element_type._convert_to_j(elt) for elt in annotation]
         )
     else:
         return annotation
示例#15
0
def hadoop_copy(src, dest):
    """Copy a file through the Hadoop filesystem API.
    Supports distributed file systems like hdfs, gs, and s3.
    
    **Examples**
    
    >>> hadoop_copy('gs://hail-common/LCR.interval_list', 'file:///mnt/data/LCR.interval_list') # doctest: +SKIP
    
    **Notes**
    
    The provided source and destination file paths must be URIs
    (uniform resource identifiers).    
    
    :param str src: Source file URI. 
    :param str dest: Destination file URI.
    """
    Env.jutils().copyFile(src, dest, Env.hc()._jhc)
示例#16
0
文件: variant.py 项目: jbloom22/hail
 def __init__(self, contig, start, ref, alts):
     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
示例#17
0
 def __init__(self, contig, start, ref, alts):
     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
示例#18
0
文件: utils.py 项目: jbloom22/hail
def hadoop_copy(src, dest):
    """Copy a file through the Hadoop filesystem API.
    Supports distributed file systems like hdfs, gs, and s3.
    
    **Examples**
    
    >>> hadoop_copy('gs://hail-common/LCR.interval_list', 'file:///mnt/data/LCR.interval_list') # doctest: +SKIP
    
    **Notes**
    
    The provided source and destination file paths must be URIs
    (uniform resource identifiers).    
    
    :param str src: Source file URI. 
    :param str dest: Destination file URI.
    """
    Env.jutils().copyFile(src, dest, Env.hc()._jhc)
示例#19
0
文件: typ.py 项目: wtsi-hgi/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, Env.jutils().javaMapToMap(f.attributes)) 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
 def _convert_to_py(self, annotation):
     if annotation:
         lst = Env.jutils().iterableToArrayList(annotation)
         d = dict()
         for x in lst:
             d[self.key_type._convert_to_py(x._1())] = self.value_type._convert_to_py(x._2())
         return d
     else:
         return annotation
示例#21
0
文件: expr.py 项目: Fedja/hail
 def _convert_to_py(self, annotation):
     if annotation:
         lst = Env.jutils().iterableToArrayList(annotation)
         d = dict()
         for x in lst:
             d[self.key_type._convert_to_py(x._1())] = self.value_type._convert_to_py(x._2())
         return d
     else:
         return annotation
示例#22
0
文件: expr.py 项目: Fedja/hail
    def __init__(self, names, types):
        """
        """

        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))
        self.fields = [Field(names[i], types[i]) for i in xrange(len(names))]

        super(TStruct, self).__init__(jtype)
示例#23
0
    def __init__(self, names, types):
        """
        """

        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))
        self.fields = [Field(names[i], types[i]) for i in xrange(len(names))]

        super(TStruct, self).__init__(jtype)
示例#24
0
文件: history.py 项目: jbloom22/hail
 def formatted(self):
     now = datetime.datetime.now()
     history = "# {}\n# version: {}\n\n".format(now.isoformat(), Env.hc().version)
     history += "from hail import *\n\n"
     for stmt in self.statements:
         history += (stmt + "\n\n")
     history += ("(" + self.expr + ")")
     try:
         import autopep8
         return autopep8.fix_code(history)
     except ImportError:
         return history
示例#25
0
文件: history.py 项目: wtsi-hgi/hail
 def formatted(self):
     now = datetime.datetime.utcnow()
     history = "# {}\n# version: {}\n\n".format(now.isoformat(), Env.hc().version)
     history += "from hail import *\n\n"
     for stmt in self.statements:
         history += (stmt + "\n\n")
     history += ("(" + self.expr + ")")
     try:
         import autopep8
         return autopep8.fix_code(history)
     except ImportError:
         return history
示例#26
0
文件: variant.py 项目: jbloom22/hail
    def parse(cls, string):
        """Parses a locus object from a CHR:POS string.

        **Examples**

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

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

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

        **Examples**

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

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

        return Locus._from_java(
            scala_object(Env.hail().variant, 'Locus').parse(string))
示例#28
0
    def parse(string):
        """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')

        :rtype: :class:`.Variant`
        """
        jrep = scala_object(Env.hail().variant, 'Variant').parse(string)
        return Variant._from_java(jrep)
示例#29
0
文件: variant.py 项目: jbloom22/hail
    def parse(cls, string):
        """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')

        :rtype: :class:`.Variant`
        """
        jrep = scala_object(Env.hail().variant, 'Variant').parse(string)
        return Variant._from_java(jrep)
示例#30
0
文件: expr.py 项目: Fedja/hail
 def __init__(self):
     super(TLocus, self).__init__(scala_object(Env.hail().expr, 'TLocus'))
示例#31
0
文件: expr.py 项目: Fedja/hail
 def __init__(self):
     super(TCall, self).__init__(scala_object(Env.hail().expr, 'TCall'))
示例#32
0
文件: expr.py 项目: Fedja/hail
 def __init__(self):
     super(TGenotype, self).__init__(scala_object(Env.hail().expr, 'TGenotype'))
示例#33
0
 def __init__(self):
     super(TInt, self).__init__(scala_object(Env.hail().expr, 'TInt'))
示例#34
0
 def _convert_to_py(self, annotation):
     if annotation:
         lst = Env.jutils().iterableToArrayList(annotation)
         return set([self.element_type._convert_to_py(x) for x in lst])
     else:
         return annotation
示例#35
0
 def __init__(self):
     super(TString, self).__init__(scala_object(Env.hail().expr, 'TString'))
示例#36
0
文件: stats.py 项目: jbloom22/hail
 def _jrep(self):
     return Env.hail().stats.BetaDist.apply(float(self.a), float(self.b))
示例#37
0
文件: stats.py 项目: jbloom22/hail
 def _jrep(self):
     return Env.hail().stats.UniformDist.apply(float(self.minVal), float(self.maxVal))
示例#38
0
 def types_rst(self, file_name):
     Env.hail().utils.FunctionDocumentation.makeTypesDocs(file_name)
示例#39
0
文件: expr.py 项目: Fedja/hail
 def __init__(self, key_type, value_type):
     jtype = scala_object(Env.hail().expr, 'TDict').apply(key_type._jtype, value_type._jtype)
     self.key_type = key_type
     self.value_type = value_type
     super(TDict, self).__init__(jtype)
示例#40
0
文件: variant.py 项目: jbloom22/hail
 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
示例#41
0
文件: expr.py 项目: Fedja/hail
 def _convert_to_py(self, annotation):
     if annotation:
         lst = Env.jutils().iterableToArrayList(annotation)
         return set([self.element_type._convert_to_py(x) for x in lst])
     else:
         return annotation
示例#42
0
 def __init__(self):
     super(TAltAllele,
           self).__init__(scala_object(Env.hail().expr, 'TAltAllele'))
示例#43
0
文件: expr.py 项目: Fedja/hail
 def __init__(self):
     super(TInt, self).__init__(scala_object(Env.hail().expr, 'TInt'))
示例#44
0
 def _to_java(self):
     """Convert to Java TextTableConfiguration object."""
     return Env.hail().utils.TextTableConfiguration.apply(
         self.types, self.comment, self.delimiter, self.missing,
         self.noheader, self.impute)
示例#45
0
文件: expr.py 项目: Fedja/hail
 def _convert_to_j(self, annotation):
     if annotation:
         return Env.jutils().makeInt(annotation)
     else:
         return annotation
示例#46
0
文件: expr.py 项目: Fedja/hail
    def _init_from_java(self, jtype):

        jfields = Env.jutils().iterableToArrayList(jtype.fields())
        self.fields = [Field(f.name(), Type._from_java(f.typ()), dict(f.attrsJava())) for f in jfields]
示例#47
0
 def __init__(self):
     super(TDouble, self).__init__(scala_object(Env.hail().expr, 'TDouble'))
示例#48
0
文件: utils.py 项目: jbloom22/hail
 def functions_rst(self, file_name):
     Env.hail().utils.FunctionDocumentation.makeFunctionsDocs(file_name)
示例#49
0
 def __init__(self):
     super(TBoolean,
           self).__init__(scala_object(Env.hail().expr, 'TBoolean'))
示例#50
0
文件: expr.py 项目: Fedja/hail
 def __init__(self):
     super(TAltAllele, self).__init__(scala_object(Env.hail().expr, 'TAltAllele'))
示例#51
0
 def __init__(self, key_type, value_type):
     jtype = scala_object(Env.hail().expr,
                          'TDict').apply(key_type._jtype, value_type._jtype)
     self.key_type = key_type
     self.value_type = value_type
     super(TDict, self).__init__(jtype)
示例#52
0
 def __init__(self):
     super(TCall, self).__init__(scala_object(Env.hail().expr, 'TCall'))
示例#53
0
 def functions_rst(self, file_name):
     Env.hail().utils.FunctionDocumentation.makeFunctionsDocs(file_name)
示例#54
0
文件: stats.py 项目: jbloom22/hail
 def _jrep(self):
     return Env.hail().stats.TruncatedBetaDist.apply(float(self.a), float(self.b), float(self.minVal), float(self.maxVal))
示例#55
0
 def __init__(self):
     super(TGenotype,
           self).__init__(scala_object(Env.hail().expr, 'TGenotype'))
示例#56
0
文件: expr.py 项目: Fedja/hail
 def __init__(self):
     super(TDouble, self).__init__(scala_object(Env.hail().expr, 'TDouble'))
示例#57
0
 def __init__(self):
     super(TLocus, self).__init__(scala_object(Env.hail().expr, 'TLocus'))
示例#58
0
文件: expr.py 项目: Fedja/hail
 def __init__(self):
     super(TString, self).__init__(scala_object(Env.hail().expr, 'TString'))
示例#59
0
 def _convert_to_j(self, annotation):
     if annotation:
         return Env.jutils().makeInt(annotation)
     else:
         return annotation
示例#60
0
文件: expr.py 项目: Fedja/hail
 def __init__(self):
     super(TBoolean, self).__init__(scala_object(Env.hail().expr, 'TBoolean'))