Example #1
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
Example #2
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
Example #3
0
File: expr.py Project: 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
Example #4
0
File: expr.py Project: 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
Example #5
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
        ]
Example #6
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)
Example #7
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)
Example #8
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
Example #9
0
File: expr.py Project: 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
Example #10
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
Example #11
0
File: expr.py Project: 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
Example #12
0
File: typ.py Project: 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)
Example #13
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
Example #14
0
 def __init__(self, path):
     self._jfile = Env.jutils().writeFile(path, Env.hc()._jhc)
     super(HadoopWriter, self).__init__()
Example #15
0
File: expr.py Project: Fedja/hail
 def _convert_to_j(self, annotation):
     if annotation:
         return Env.jutils().makeInt(annotation)
     else:
         return annotation
Example #16
0
 def __init__(self, path):
     self._jfile = Env.jutils().readFile(path, Env.hc()._jhc)
     super(HadoopReader, self).__init__()
Example #17
0
File: expr.py Project: 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]
Example #18
0
 def __init__(self, path):
     self._jfile = Env.jutils().writeFile(path, Env.hc()._jhc)
     super(HadoopWriter, self).__init__()
Example #19
0
 def __init__(self, path):
     self._jfile = Env.jutils().readFile(path, Env.hc()._jhc)
     super(HadoopReader, self).__init__()
Example #20
0
 def _convert_to_j(self, annotation):
     if annotation:
         return Env.jutils().makeInt(annotation)
     else:
         return annotation
Example #21
0
File: expr.py Project: 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