def __init__(self, filename, count_A1=None, iid=None, sid=None, pos=None, skip_format_check=False ): #!!!document these new optionals. they are here super(Bed, self).__init__() self._ran_once = False self._file_pointer = None self.filename = filename if count_A1 is None: warnings.warn( "'count_A1' was not set. For now it will default to 'False', but in the future it will default to 'True'", FutureWarning) count_A1 = False self.count_A1 = count_A1 self.skip_format_check = skip_format_check if iid is not None: self._row = PstData._fixup_input( iid, empty_creator=lambda ignore: np.empty([0, 2], dtype=str)) if sid is not None: self._col = PstData._fixup_input( sid, empty_creator=lambda ignore: np.empty([0], dtype=str)) if pos is not None: self._col_property = PstData._fixup_input( pos, count=len(self._col), empty_creator=lambda count: np.array([[np.nan, np.nan, np.nan]] * count))
def _empty_inner(self, row, col, filename, row_property, col_property, order, dtype, val_shape): self._ran_once = True self._dtype = np.dtype(dtype) self._order = order row = PstData._fixup_input(row) col = PstData._fixup_input(col) row_property = PstData._fixup_input(row_property,count=len(row)) col_property = PstData._fixup_input(col_property,count=len(col)) with open(filename,'wb') as fp: np.save(fp, np.array([_magic_number])) np.save(fp, np.array(["pstmemmap"])) #name of file format np.save(fp, np.array([2])) #file format version np.save(fp, row) np.save(fp, col) np.save(fp, row_property) np.save(fp, col_property) np.save(fp, np.array([self._dtype])) np.save(fp, np.array([self._order])) np.save(fp, np.array([val_shape])) self._offset = fp.tell() logging.info("About to start allocating memmap '{0}'".format(filename)) shape = (len(row),len(col)) if val_shape is None else (len(row),len(col),val_shape) val = np.memmap(filename, offset=self._offset, dtype=dtype, mode="r+", order=order, shape=shape) logging.info("Finished allocating memmap '{0}'. Size is {1:,}".format(filename,os.path.getsize(filename))) PstData.__init__(self,row,col,val,row_property,col_property,name="np.memmap('{0}')".format(filename))
def __init__(self, iid, test=None): #!!! add docs and test for test super(Identity, self).__init__() if test is None: test = iid if test is iid: iid = PstData._fixup_input( iid, empty_creator=lambda ignore: np.empty([0, 2], dtype='str'), dtype='str') test = iid else: iid = PstData._fixup_input( iid, empty_creator=lambda ignore: np.empty([0, 2], dtype='str'), dtype='str') test = PstData._fixup_input( test, empty_creator=lambda ignore: np.empty([0, 2], dtype='str'), dtype='str') if len(iid) > 0: self._row0 = iid else: self._row0 = self._empty if len(test) > 0: self._row1 = test else: self._row1 = self._empty
def __init__(self, iid=None, iid0=None, iid1=None, val=None, name=None, parent_string=None, xp=None ): #!!!autodoc doesn't generate good doc for this constructor #We don't have a 'super(KernelData, self).__init__()' here because KernelData takes full responsibility for initializing both its superclasses xp = pstutil.array_module(xp) self._val = None #!!why does SnpData __init__ have a copy_inputs, but KernelData doesn't? assert (iid is None) != ( iid0 is None and iid1 is None ), "Either 'iid' or both 'iid0' 'iid1' must be provided." assert name is None or parent_string is None, "Can't set both 'name' and the deprecated 'parent_string'" if parent_string is not None: warnings.warn("'parent_string' is deprecated. Use 'name'", DeprecationWarning) if iid is not None: self._row = PstData._fixup_input( iid, empty_creator=lambda ignore: np.empty([0, 2], dtype='str'), dtype='str') self._col = self._row else: self._row = PstData._fixup_input( iid0, empty_creator=lambda ignore: np.empty([0, 2], dtype='str'), dtype='str') self._col = PstData._fixup_input( iid1, empty_creator=lambda ignore: np.empty([0, 2], dtype='str'), dtype='str') self._row_property = PstData._fixup_input( None, count=len(self._row), empty_creator=lambda count: np.empty([count, 0], dtype='str'), dtype='str') self._col_property = PstData._fixup_input( None, count=len(self._col), empty_creator=lambda count: np.empty([count, 0], dtype='str'), dtype='str') self._val = PstData._fixup_input_val( val, row_count=len(self._row), col_count=len(self._col), empty_creator=lambda row_count, col_count: xp.empty( [row_count, col_count], dtype=xp.float64), xp=xp) self._assert_iid0_iid1(check_val=True) self._name = name or parent_string or "" self._std_string_list = [] self._xp = xp
def __init__(self, iid, sid, val, pos=None, name=None, parent_string=None, copyinputs_function=None): if parent_string is not None: warnings.warn("'parent_string' is deprecated. Use 'name'", DeprecationWarning) self._row = PstData._fixup_input(iid,empty_creator=lambda ignore:np.empty([0,2],dtype=str)) self._col = PstData._fixup_input(sid,empty_creator=lambda ignore:np.empty([0],dtype=str)) self._row_property = PstData._fixup_input(None,count=len(self._row),empty_creator=lambda count:np.empty([count,0],dtype=str)) self._col_property = PstData._fixup_input(pos,count=len(self._col),empty_creator=lambda count:np.array([[np.nan, np.nan, np.nan]]*count)) self.val = PstData._fixup_input_val(val,row_count=len(self._row),col_count=len(self._col),empty_creator=lambda row_count,col_count:np.empty([row_count,col_count],dtype=np.float64)) self._assert_iid_sid_pos() self._name = name or parent_string or "" self._std_string_list = []
def __init__(self, iid, sid, val, pos=None, name=None, copyinputs_function=None): #We don't have a 'super(DistData, self).__init__()' here because DistData takes full responsibility for initializing both its superclasses self._val = None self._row = PstData._fixup_input(iid,empty_creator=lambda ignore:np.empty([0,2],dtype='str'),dtype='str') self._col = PstData._fixup_input(sid,empty_creator=lambda ignore:np.empty([0],dtype='str'),dtype='str') self._row_property = PstData._fixup_input(None,count=len(self._row),empty_creator=lambda count:np.empty([count,0],dtype='str'),dtype='str') self._col_property = PstData._fixup_input(pos,count=len(self._col),empty_creator=lambda count:np.full([count, 3], np.nan)) self._val = PstData._fixup_input_val(val,row_count=len(self._row),col_count=len(self._col),empty_creator=lambda row_count,col_count:np.empty([row_count,col_count,3],dtype=np.float64))#!!!Replace empty with my FillNA method? self._assert_iid_sid_pos(check_val=True) self._name = name or "" self._std_string_list = []
def __init__(self, iid, sid, val, pos=None, name=None, parent_string=None, copyinputs_function=None): #We don't have a 'super(SnpData, self).__init__()' here because SnpData takes full responsiblity for initializing both its superclasses self.val = None if parent_string is not None: warnings.warn("'parent_string' is deprecated. Use 'name'", DeprecationWarning) self._row = PstData._fixup_input(iid,empty_creator=lambda ignore:np.empty([0,2],dtype='S'),dtype='S') self._col = PstData._fixup_input(sid,empty_creator=lambda ignore:np.empty([0],dtype='S'),dtype='S') self._row_property = PstData._fixup_input(None,count=len(self._row),empty_creator=lambda count:np.empty([count,0],dtype='S'),dtype='S') self._col_property = PstData._fixup_input(pos,count=len(self._col),empty_creator=lambda count:np.array([[np.nan, np.nan, np.nan]]*count)) self.val = PstData._fixup_input_val(val,row_count=len(self._row),col_count=len(self._col),empty_creator=lambda row_count,col_count:np.empty([row_count,col_count],dtype=np.float64)) self._assert_iid_sid_pos() self._name = name or parent_string or "" self._std_string_list = []
def __init__(self, iid, sid, val, pos=None, name=None, parent_string=None, copyinputs_function=None): #We don't have a 'super(SnpData, self).__init__()' here because SnpData takes full responsiblity for initializing both its superclasses self.val = None if parent_string is not None: warnings.warn("'parent_string' is deprecated. Use 'name'", DeprecationWarning) self._row = PstData._fixup_input(iid,empty_creator=lambda ignore:np.empty([0,2],dtype=str)) self._col = PstData._fixup_input(sid,empty_creator=lambda ignore:np.empty([0],dtype=str)) self._row_property = PstData._fixup_input(None,count=len(self._row),empty_creator=lambda count:np.empty([count,0],dtype=str)) self._col_property = PstData._fixup_input(pos,count=len(self._col),empty_creator=lambda count:np.array([[np.nan, np.nan, np.nan]]*count)) self.val = PstData._fixup_input_val(val,row_count=len(self._row),col_count=len(self._col),empty_creator=lambda row_count,col_count:np.empty([row_count,col_count],dtype=np.float64)) self._assert_iid_sid_pos() self._name = name or parent_string or "" self._std_string_list = []
def __init__(self, iid, sid, val, pos=None, name=None, parent_string=None, copyinputs_function=None, xp=None, _require_float32_64=True): #We don't have a 'super(SnpData, self).__init__()' here because SnpData takes full responsibility for initializing both its superclasses xp = pstutil.array_module(xp) self._val = None if parent_string is not None: warnings.warn("'parent_string' is deprecated. Use 'name'", DeprecationWarning) self._row = PstData._fixup_input( iid, empty_creator=lambda ignore: np.empty([0, 2], dtype='str'), dtype='str') self._col = PstData._fixup_input( sid, empty_creator=lambda ignore: np.empty([0], dtype='str'), dtype='str') self._row_property = PstData._fixup_input( None, count=len(self._row), empty_creator=lambda count: np.empty([count, 0], dtype='str'), dtype='str') self._col_property = PstData._fixup_input( pos, count=len(self._col), empty_creator=lambda count: np.full([count, 3], np.nan)) self._val = PstData._fixup_input_val( val, row_count=len(self._row), col_count=len(self._col), empty_creator=lambda row_count, col_count: np.empty( [row_count, col_count], dtype=np.float64), _require_float32_64=_require_float32_64, xp=xp) self._assert_iid_sid_pos(check_val=True) self._name = name or parent_string or "" self._std_string_list = [] self._xp = xp
def __init__(self, filename, count_A1=None, iid=None, sid=None, pos=None, skip_format_check=False): #!!!document these new optionals. they are here super(Bed, self).__init__() self._ran_once = False self._file_pointer = None self.filename = filename if count_A1 is None: warnings.warn("'count_A1' was not set. For now it will default to 'False', but in the future it will default to 'True'", FutureWarning) count_A1 = False self.count_A1 =count_A1 self.skip_format_check = skip_format_check if iid is not None: self._row = PstData._fixup_input(iid,empty_creator=lambda ignore:np.empty([0,2],dtype='S'),dtype='S') if sid is not None: self._col = PstData._fixup_input(sid,empty_creator=lambda ignore:np.empty([0],dtype='S'),dtype='S') if pos is not None: self._col_property = PstData._fixup_input(pos,count=len(self._col),empty_creator=lambda count:np.array([[np.nan, np.nan, np.nan]]*count))
def __init__(self, iid=None, iid0=None, iid1=None, val=None, name=None, parent_string=None): #!!!autodoc doesn't generate good doc for this constructor #!!why does SnpData __init__ have a copy_inputs, but KernelData doesn't? assert (iid is None) != (iid0 is None and iid1 is None), "Either 'iid' or both 'iid0' 'iid1' must be provided." assert name is None or parent_string is None, "Can't set both 'name' and the deprecated 'parent_string'" if parent_string is not None: warnings.warn("'parent_string' is deprecated. Use 'name'", DeprecationWarning) if iid is not None: self._row = PstData._fixup_input(iid,empty_creator=lambda ignore:np.empty([0,2],dtype=str)) self._col = self._row else: self._row = PstData._fixup_input(iid0,empty_creator=lambda ignore:np.empty([0,2],dtype=str)) self._col = PstData._fixup_input(iid1,empty_creator=lambda ignore:np.empty([0,2],dtype=str)) self._row_property = PstData._fixup_input(None,count=len(self._row),empty_creator=lambda count:np.empty([count,0],dtype=str)) self._col_property = PstData._fixup_input(None,count=len(self._col),empty_creator=lambda count:np.empty([count,0],dtype=str)) self.val = PstData._fixup_input_val(val,row_count=len(self._row),col_count=len(self._col),empty_creator=lambda row_count,col_count:np.empty([row_count,col_count],dtype=np.float64)) self._assert_iid0_iid1() self._name = name or parent_string or "" self._std_string_list = []