Return the default path for fit data h5 files
340027
def DataPath():
    
    return os.path.abspath('%s/data'%(os.path.dirname( \
        os.path.realpath(__file__))))
168883
function defaults() {
	var fnames,
		fpath,
		stats,
		out,
		len,
		i;

	fnames = fs.readdirSync( __dirname );
	len = fnames.length;

	out = {};
	for ( i = 0; i < len; i++ ) {
		fpath = path.join( __dirname, fnames[ i ] );
		stats = fs.statSync( fpath );
		if ( stats.isDirectory() ) {
			out[ fnames[ i ] ] = require( fpath + '/defaults.json' );
		}
	}
	return out;
}
1111947
def getDefaultItems(self):
        
        return [
            RtiRegItem('HDF-5 file',
                       'argos.repo.rtiplugins.hdf5.H5pyFileRti',
                       extensions=['hdf5', 'h5', 'h5e', 'he5', 'nc']), # hdf extension is for HDF-4

            RtiRegItem('MATLAB file',
                       'argos.repo.rtiplugins.scipyio.MatlabFileRti',
                       extensions=['mat']),

            RtiRegItem('NetCDF file',
                       'argos.repo.rtiplugins.ncdf.NcdfFileRti',
                       #extensions=['nc', 'nc3', 'nc4']),
                       extensions=['nc', 'nc4']),
                       #extensions=[]),

            RtiRegItem('NumPy binary file',
                       'argos.repo.rtiplugins.numpyio.NumpyBinaryFileRti',
                       extensions=['npy']),

            RtiRegItem('NumPy compressed file',
                       'argos.repo.rtiplugins.numpyio.NumpyCompressedFileRti',
                       extensions=['npz']),

            RtiRegItem('NumPy text file',
                       'argos.repo.rtiplugins.numpyio.NumpyTextFileRti',
                       #extensions=['txt', 'text']),
                       extensions=['dat']),

            RtiRegItem('IDL save file',
                       'argos.repo.rtiplugins.scipyio.IdlSaveFileRti',
                       extensions=['sav']),

            RtiRegItem('Pandas CSV file',
                       'argos.repo.rtiplugins.pandasio.PandasCsvFileRti',
                        extensions=['csv']),

            RtiRegItem('Pillow image',
                       'argos.repo.rtiplugins.pillowio.PillowFileRti',
                        extensions=['bmp', 'eps', 'im', 'gif', 'jpg', 'jpeg', 'msp', 'pcx',
                                    'png', 'ppm', 'spi', 'tif', 'tiff', 'xbm', 'xv']),

            RtiRegItem('Wav file',
                       'argos.repo.rtiplugins.scipyio.WavFileRti',
                       extensions=['wav'])]
730656
def load_file_or_hdu(filename):
    
    if isinstance(filename, fits.HDUList):
        hdulist = filename
    else:
        hdulist = fits.open(filename, ignore_missing_end=True)
    return hdulist
142248
def get_default_home_dir():
    
    ding0_dir = str(cfg_ding0.get('config',
                                  'config_dir'))
    return os.path.join(os.path.expanduser('~'), ding0_dir)
345566
def _get_file_paths(self, tax_ids, file_type):
        
        file_paths = dict()
        if file_type not in self.files:
            raise KeyError("file type {} not configured".format(file_type))
        for taxon in tax_ids:
            file_paths[taxon] = {
                'file': "{}.{}".format(taxon, self.files[file_type]['pattern']),
                'url': "{}{}.{}".format(
                    self.files[file_type]['path'], taxon,
                    self.files[file_type]['pattern']),
                'headers': {'User-Agent': USER_AGENT}
            }
        return file_paths
716753
async function getTrueFilePath(p) {
  let fsPathNormalized = p;
  // OSX: HFS+ stores filenames in NFD (decomposed normal form) Unicode format,
  // so we must ensure that the input path is in that format first.
  if (process.platform === 'darwin')
    fsPathNormalized = fsPathNormalized.normalize('NFD');

  // !! Windows: Curiously, the drive component mustn't be part of a glob,
  // !! otherwise glob.sync() will invariably match nothing.
  // !! Thus, we remove the drive component and instead pass it in as the 'cwd'
  // !! (working dir.) property below.
  const pathRoot = parse(fsPathNormalized).root;
  const noDrivePath = fsPathNormalized.slice(Math.max(pathRoot.length - 1, 0));

  // Perform case-insensitive globbing (on Windows, relative to the drive /
  // network share) and return the 1st match, if any.
  // Fortunately, glob() with nocase case-corrects the input even if it is
  // a *literal* path.
  const result = await glob(noDrivePath, { nocase: true, cwd: pathRoot });
  return result[0];
}
1334885
def LoadFits(name):
    
    if name not in fits_collection.keys():
        raise Exception('Invalid fit name : %s'%name)
    else:
        testPath = DataPath() + '/' + fits_collection[name].data_url.split('/')[-1]
        if (not os.path.isfile(testPath)):
            DownloadData(name)
        fit = fits_collection[name].fit_class(name.split('surfinBH')[-1])
        print('Loaded %s fit.'%name)
        return fit
709039
def _get_result_paths(self, data):
        

        result = {}

        # OTU map (mandatory output)
        result['OtuMap'] = ResultPath(Path=self.Parameters['-O'].Value,
                                      IsWritten=True)

        # SumaClust will not produce any output file if the
        # input file was empty, so we create an empty
        # output file
        if not isfile(result['OtuMap'].Path):
            otumap_f = open(result['OtuMap'].Path, 'w')
            otumap_f.close()

        return result
1023330
def fitNullTraitByTrait(self, verbose=False, cache=False, out_dir='./cache', fname=None, rewrite=False):
        
        read_from_file = False
        if cache:
            assert fname is not None, 'MultiTraitSetTest:: specify fname'
            if not os.path.exists(out_dir): os.makedirs(out_dir)
            out_file = os.path.join(out_dir,fname)
            read_from_file = os.path.exists(out_file) and not rewrite

        RV = {}
        if read_from_file:
            f = h5py.File(out_file,'r')
            for p in range(self.P):
                trait_id = self.traitID[p]
                g = f[trait_id]
                RV[trait_id] = {}
                for key in list(g.keys()):
                    RV[trait_id][key] = g[key][:]
            f.close()
            self.nullST=RV
        else:
            """ create stSet and fit null column by column returns all info """
            if self.stSet is None:
                y = sp.zeros((self.N,1))
                self.stSet = MTSet(Y=y, S_R=self.S_R, U_R=self.U_R, F=self.F)
            RV = {}
            for p in range(self.P):
                trait_id = self.traitID[p]
                self.stSet.Y = self.Y[:,p:p+1]
                RV[trait_id] = self.stSet.fitNull()
            self.nullST = RV
            if cache:
                f = h5py.File(out_file,'w')
                smartDumpDictHdf5(RV,f)
                f.close()
        return RV
1061729
def default(self):
        """"""

        import ambry.bundle.default_files as df
        import os

        path = os.path.join(os.path.dirname(df.__file__), self.file_name)

        if six.PY2:
            with open(path, 'rb') as f:
                return f.read()
        else:
            # py3
            with open(path, 'rt', encoding='utf-8') as f:
                return f.read()
487772
def _load_vector_fit(self, fit_key, h5file):
        
        vector_fit = []
        for i in range(len(h5file[fit_key].keys())):
            fit_data = self._read_dict(h5file[fit_key]['comp_%d'%i])
            vector_fit.append(self._load_scalar_fit(fit_data=fit_data))
        return vector_fit
792956
def tseries(self):
        
        if self._stagdat['tseries'] is UNDETERMINED:
            timefile = self.filename('TimeSeries.h5')
            self._stagdat['tseries'] = stagyyparsers.time_series_h5(
                timefile, list(phyvars.TIME.keys()))
            if self._stagdat['tseries'] is not None:
                return self._stagdat['tseries']
            timefile = self.filename('time.dat')
            if self.hdf5 and not timefile.is_file():
                # check legacy folder as well
                timefile = self.filename('time.dat', force_legacy=True)
            self._stagdat['tseries'] = stagyyparsers.time_series(
                timefile, list(phyvars.TIME.keys()))
        return self._stagdat['tseries']
520984
def data_directory():
    """"""
    package_directory = os.path.abspath(os.path.dirname(__file__))
    return os.path.join(package_directory, "data")
924478
def _get_result_paths(self, data):
        

        result = {}

        # get the file extension of the reads file (sortmerna
        # internally outputs all results with this extension)
        fileExtension = splitext(self.Parameters['--reads'].Value)[1]

        # at this point the parameter --aligned should be set as
        # sortmerna will not run without it
        if self.Parameters['--aligned'].isOff():
            raise ValueError("Error: the --aligned parameter must be set.")

        # file base name for aligned reads
        output_base = self.Parameters['--aligned'].Value

        # Blast alignments
        result['BlastAlignments'] =\
            ResultPath(Path=output_base + '.blast',
                       IsWritten=self.Parameters['--blast'].isOn())

        # SAM alignments
        result['SAMAlignments'] =\
            ResultPath(Path=output_base + '.sam',
                       IsWritten=self.Parameters['--sam'].isOn())

        # OTU map (mandatory output)
        result['OtuMap'] =\
            ResultPath(Path=output_base + '_otus.txt',
                       IsWritten=self.Parameters['--otu_map'].isOn())

        # FASTA file of sequences in the OTU map (madatory output)
        result['FastaMatches'] =\
            ResultPath(Path=output_base + fileExtension,
                       IsWritten=self.Parameters['--fastx'].isOn())

        # FASTA file of sequences not in the OTU map (mandatory output)
        result['FastaForDenovo'] =\
            ResultPath(Path=output_base + '_denovo' +
                       fileExtension,
                       IsWritten=self.Parameters['--de_novo_otu'].isOn())
        # Log file
        result['LogFile'] =\
            ResultPath(Path=output_base + '.log',
                       IsWritten=self.Parameters['--log'].isOn())

        return result
156689
def _get_raw_data(self, name):
        """"""
        # try legacy first, then hdf5
        filestem = ''
        for filestem, list_fvar in self._files.items():
            if name in list_fvar:
                break
        fieldfile = self.step.sdat.filename(filestem, self.step.isnap,
                                            force_legacy=True)
        if not fieldfile.is_file():
            fieldfile = self.step.sdat.filename(filestem, self.step.isnap)
        parsed_data = None
        if fieldfile.is_file():
            parsed_data = stagyyparsers.fields(fieldfile)
        elif self.step.sdat.hdf5 and self._filesh5:
            for filestem, list_fvar in self._filesh5.items():
                if name in list_fvar:
                    break
            parsed_data = stagyyparsers.read_field_h5(
                self.step.sdat.hdf5 / 'Data.xmf', filestem, self.step.isnap)
        return list_fvar, parsed_data
1053422
def data_dir(default='data'):
    
    if 'OPENSHIFT_DATA_DIR' in os.environ:
        return os.environ['OPENSHIFT_DATA_DIR']
    if 'GONDOR_DATA_DIR' in os.environ:
        return os.environ['GONDOR_DATA_DIR']
    if provider.detect() == provider.DOTCLOUD:
        return os.path.expanduser('~/data')
    return default