INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Export a numpy array to a png file.
def save(filename, numpy_data): """ Export a numpy array to a png file. Arguments: filename (str): A filename to which to save the png data numpy_data (numpy.ndarray OR str): The numpy array to save to png. OR a string: If a string is provded, it should be a binary png str ...
Export a numpy array to a set of png files with each Z - index 2D array as its own 2D file.
def save_collection(png_filename_base, numpy_data, start_layers_at=1): """ Export a numpy array to a set of png files, with each Z-index 2D array as its own 2D file. Arguments: png_filename_base: A filename template, such as "my-image-*.png" which will lead t...
Import all files matching the filename base given with png_filename_base. Images are ordered by alphabetical order which means that you * MUST * 0 - pad your numbers if they span a power of ten ( e. g. 0999 - 1000 or 09 - 10 ). This is handled automatically by its complementary function png. save_collection. Also look ...
def load_collection(png_filename_base): """ Import all files matching the filename base given with `png_filename_base`. Images are ordered by alphabetical order, which means that you *MUST* 0-pad your numbers if they span a power of ten (e.g. 0999-1000 or 09-10). This is handled automatically by its...
Print workspace status.
def print_workspace(self, name): """Print workspace status.""" path_list = find_path(name, self.config) if len(path_list) == 0: self.logger.error("No matches for `%s`" % name) return False for name, path in path_list.items(): self.print_status(name, ...
Print repository status.
def print_status(self, repo_name, repo_path): """Print repository status.""" color = Color() self.logger.info(color.colored( "=> [%s] %s" % (repo_name, repo_path), "green")) try: repo = Repository(repo_path) repo.status() except RepositoryError...
Gets the block - size for a given token at a given resolution.
def get_block_size(self, token, resolution=None): """ Gets the block-size for a given token at a given resolution. Arguments: token (str): The token to inspect resolution (int : None): The resolution at which to inspect data. If none is specified, uses th...
Return a binary - encoded decompressed 2d image. You should specify a token and channel pair. For image data users should use the channel image.
def get_xy_slice(self, token, channel, x_start, x_stop, y_start, y_stop, z_index, resolution=0): """ Return a binary-encoded, decompressed 2d image. You should specify a 'token' and 'channel' pair. For image dat...
Get a RAMONVolume volumetric cutout from the neurodata server.
def get_volume(self, token, channel, x_start, x_stop, y_start, y_stop, z_start, z_stop, resolution=1, block_size=DEFAULT_BLOCK_SIZE, neariso=False): """ Get a RAMONVolume volumetric cutout f...
Get volumetric cutout data from the neurodata server.
def get_cutout(self, token, channel, x_start, x_stop, y_start, y_stop, z_start, z_stop, t_start=0, t_stop=1, resolution=1, block_size=DEFAULT_BLOCK_SIZE, neariso=False): """ ...
Post a cutout to the server.
def post_cutout(self, token, channel, x_start, y_start, z_start, data, resolution=0): """ Post a cutout to the server. Arguments: token (str) channel (str) x_s...
Accepts data in zyx. !!!
def _post_cutout_no_chunking_blosc(self, token, channel, x_start, y_start, z_start, data, resolution): """ Accepts data in zyx. !!! """ data = numpy.expand_dims(data, axis=0) blosc_data = blosc.pack_arr...
Import a TIFF file into a numpy array.
def load(tiff_filename): """ Import a TIFF file into a numpy array. Arguments: tiff_filename: A string filename of a TIFF datafile Returns: A numpy array with data from the TIFF file """ # Expand filename to be absolute tiff_filename = os.path.expanduser(tiff_filename) ...
Export a numpy array to a TIFF file.
def save(tiff_filename, numpy_data): """ Export a numpy array to a TIFF file. Arguments: tiff_filename: A filename to which to save the TIFF data numpy_data: The numpy array to save to TIFF Returns: String. The expanded filename that now holds the TIFF data """ # E...
Load a multipage tiff into a single variable in x y z format.
def load_tiff_multipage(tiff_filename, dtype='float32'): """ Load a multipage tiff into a single variable in x,y,z format. Arguments: tiff_filename: Filename of source data dtype: data type to use for the returned tensor Returns: Array containing contents from i...
Write config in configuration file. Data must me a dict.
def write(self): """ Write config in configuration file. Data must me a dict. """ file = open(self.config_file, "w+") file.write(yaml.dump(dict(self), default_flow_style=False)) file.close()
Clone repository from url.
def clone(self, url): """Clone repository from url.""" return self.execute("%s branch %s %s" % (self.executable, url, self.path))
Get version from package resources.
def get_version(): """Get version from package resources.""" requirement = pkg_resources.Requirement.parse("yoda") provider = pkg_resources.get_provider(requirement) return provider.version
Mixing and matching positional args and keyword options.
def mix_and_match(name, greeting='Hello', yell=False): '''Mixing and matching positional args and keyword options.''' say = '%s, %s' % (greeting, name) if yell: print '%s!' % say.upper() else: print '%s.' % say
Same as mix_and_match but using the
def option_decorator(name, greeting, yell): '''Same as mix_and_match, but using the @option decorator.''' # Use the @option decorator when you need more control over the # command line options. say = '%s, %s' % (greeting, name) if yell: print '%s!' % say.upper() else: print '%s.'...
Import a nifti file into a numpy array. TODO: Currently only transfers raw data for compatibility with annotation and ND formats
def load(nifti_filename): """ Import a nifti file into a numpy array. TODO: Currently only transfers raw data for compatibility with annotation and ND formats Arguments: nifti_filename (str): A string filename of a nifti datafile Returns: A numpy array with data from the nifti fi...
Export a numpy array to a nifti file. TODO: currently using dummy headers and identity matrix affine transform. This can be expanded.
def save(nifti_filename, numpy_data): """ Export a numpy array to a nifti file. TODO: currently using dummy headers and identity matrix affine transform. This can be expanded. Arguments: nifti_filename (str): A filename to which to save the nifti data numpy_data (numpy.ndarray): The nu...
Return the status - code of the API ( estimated using the public - tokens lookup page ).
def ping(self, suffix='public_tokens/'): """ Return the status-code of the API (estimated using the public-tokens lookup page). Arguments: suffix (str : 'public_tokens/'): The url endpoint to check Returns: int: status code """ return sel...
Return a constructed URL appending an optional suffix ( uri path ).
def url(self, suffix=""): """ Return a constructed URL, appending an optional suffix (uri path). Arguments: suffix (str : ""): The suffix to append to the end of the URL Returns: str: The complete URL """ return super(neuroRemote, ...
Requests a list of next - available - IDs from the server.
def reserve_ids(self, token, channel, quantity): """ Requests a list of next-available-IDs from the server. Arguments: quantity (int): The number of IDs to reserve Returns: int[quantity]: List of IDs you've been granted """ quantity = str(quantit...
Call the restful endpoint to merge two RAMON objects into one.
def merge_ids(self, token, channel, ids, delete=False): """ Call the restful endpoint to merge two RAMON objects into one. Arguments: token (str): The token to inspect channel (str): The channel to inspect ids (int[]): the list of the IDs to merge ...
Creates channels given a dictionary in new_channels_data dataset name and token ( project ) name.
def create_channels(self, dataset, token, new_channels_data): """ Creates channels given a dictionary in 'new_channels_data' , 'dataset' name, and 'token' (project) name. Arguments: token (str): Token to identify project dataset (str): Dataset name to identify da...
Kick off the propagate function on the remote server.
def propagate(self, token, channel): """ Kick off the propagate function on the remote server. Arguments: token (str): The token to propagate channel (str): The channel to propagate Returns: boolean: Success """ if self.get_propagate_...
Get the propagate status for a token/ channel pair.
def get_propagate_status(self, token, channel): """ Get the propagate status for a token/channel pair. Arguments: token (str): The token to check channel (str): The channel to check Returns: str: The status code """ url = self.url('sd...
Creates a project with the given parameters.
def create_project(self, project_name, dataset_name, hostname, is_public, s3backend=0, kvserver='localhost', kvengine='MySQL', mdengine=...
Lists a set of projects related to a dataset.
def list_projects(self, dataset_name): """ Lists a set of projects related to a dataset. Arguments: dataset_name (str): Dataset name to search projects for Returns: dict: Projects found based on dataset query """ url = self.url() + "/nd/resource/...
Creates a token with the given parameters. Arguments: project_name ( str ): Project name dataset_name ( str ): Dataset name project is based on token_name ( str ): Token name is_public ( int ): 1 is public. 0 is not public Returns: bool: True if project created false if not created.
def create_token(self, token_name, project_name, dataset_name, is_public): """ Creates a token with the given parameters. Arguments: project_name (str): Project name dataset_name (str): Da...
Get a token with the given parameters. Arguments: project_name ( str ): Project name dataset_name ( str ): Dataset name project is based on token_name ( str ): Token name Returns: dict: Token info
def get_token(self, token_name, project_name, dataset_name): """ Get a token with the given parameters. Arguments: project_name (str): Project name dataset_name (str): Dataset name project is based on token...
Delete a token with the given parameters. Arguments: project_name ( str ): Project name dataset_name ( str ): Dataset name project is based on token_name ( str ): Token name channel_name ( str ): Channel name project is based on Returns: bool: True if project deleted false if not deleted.
def delete_token(self, token_name, project_name, dataset_name): """ Delete a token with the given parameters. Arguments: project_name (str): Project name dataset_name (str): Dataset name project is based on ...
Lists a set of tokens that are public in Neurodata. Arguments: Returns: dict: Public tokens found in Neurodata
def list_tokens(self): """ Lists a set of tokens that are public in Neurodata. Arguments: Returns: dict: Public tokens found in Neurodata """ url = self.url() + "/nd/resource/public/token/" req = self.remote_utils.get_url(url) if req.status_co...
Creates a dataset.
def create_dataset(self, name, x_img_size, y_img_size, z_img_size, x_vox_res, y_vox_res, z_vox_res, x_offset=0, y...
Returns info regarding a particular dataset.
def get_dataset(self, name): """ Returns info regarding a particular dataset. Arugments: name (str): Dataset name Returns: dict: Dataset information """ url = self.url() + "/resource/dataset/{}".format(name) req = self.remote_utils.get_ur...
Lists datasets in resources. Setting get_global_public to True will retrieve all public datasets in cloud. False will get user s public datasets.
def list_datasets(self, get_global_public): """ Lists datasets in resources. Setting 'get_global_public' to 'True' will retrieve all public datasets in cloud. 'False' will get user's public datasets. Arguments: get_global_public (bool): True if user wants all public ...
Arguments: name ( str ): Name of dataset to delete
def delete_dataset(self, name): """ Arguments: name (str): Name of dataset to delete Returns: bool: True if dataset deleted, False if not """ url = self.url() + "/resource/dataset/{}".format(name) req = self.remote_utils.delete_url(url) i...
Create a new channel on the Remote using channel_data.
def create_channel(self, channel_name, project_name, dataset_name, channel_type, dtype, startwindow, endwindow, readonly=0, ...
Gets info about a channel given its name name of its project and name of its dataset.
def get_channel(self, channel_name, project_name, dataset_name): """ Gets info about a channel given its name, name of its project , and name of its dataset. Arguments: channel_name (str): Channel name project_name (str): Project name dataset_name (st...
Parse show subcommand.
def parse(self): """Parse show subcommand.""" parser = self.subparser.add_parser( "show", help="Show workspace details", description="Show workspace details.") group = parser.add_mutually_exclusive_group(required=True) group.add_argument('--all', acti...
Execute show subcommand.
def execute(self, args): """Execute show subcommand.""" if args.name is not None: self.show_workspace(slashes2dash(args.name)) elif args.all is not None: self.show_all()
Show specific workspace.
def show_workspace(self, name): """Show specific workspace.""" if not self.workspace.exists(name): raise ValueError("Workspace `%s` doesn't exists." % name) color = Color() workspaces = self.workspace.list() self.logger.info("<== %s workspace ==>" % color.colored(na...
Show details for all workspaces.
def show_all(self): """Show details for all workspaces.""" for ws in self.workspace.list().keys(): self.show_workspace(ws) print("\n\n")
Get the base URL of the Remote.
def url(self, endpoint=''): """ Get the base URL of the Remote. Arguments: None Returns: `str` base URL """ if not endpoint.startswith('/'): endpoint = "/" + endpoint return self.protocol + "://" + self.hostname + endpoint
Ping the server to make sure that you can access the base URL.
def ping(self, endpoint=''): """ Ping the server to make sure that you can access the base URL. Arguments: None Returns: `boolean` Successful access of server (or status code) """ r = requests.get(self.url() + "/" + endpoint) return r.stat...
Converts a dense annotation to a DAE using Marching Cubes ( PyMCubes ).
def export_dae(filename, cutout, level=0): """ Converts a dense annotation to a DAE, using Marching Cubes (PyMCubes). Arguments: filename (str): The filename to write out to cutout (numpy.ndarray): The dense annotation level (int): The level at which to run mcubes Returns: ...
Converts a dense annotation to a obj using Marching Cubes ( PyMCubes ).
def export_obj(filename, cutout, level=0): """ Converts a dense annotation to a obj, using Marching Cubes (PyMCubes). Arguments: filename (str): The filename to write out to cutout (numpy.ndarray): The dense annotation level (int): The level at which to run mcubes Returns: ...
Converts a dense annotation to a. PLY using Marching Cubes ( PyMCubes ).
def export_ply(filename, cutout, level=0): """ Converts a dense annotation to a .PLY, using Marching Cubes (PyMCubes). Arguments: filename (str): The filename to write out to cutout (numpy.ndarray): The dense annotation level (int): The level at which to run mcubes Returns: ...
Guess the appropriate data type from file extension.
def _guess_format_from_extension(ext): """ Guess the appropriate data type from file extension. Arguments: ext: The file extension (period optional) Returns: String. The format (without leading period), or False if none was found or couldn't be guessed """ ...
Reads in a file from disk.
def open(in_file, in_fmt=None): """ Reads in a file from disk. Arguments: in_file: The name of the file to read in in_fmt: The format of in_file, if you want to be explicit Returns: numpy.ndarray """ fmt = in_file.split('.')[-1] if in_fmt: fmt = in_fmt f...
Converts in_file to out_file guessing datatype in the absence of in_fmt and out_fmt.
def convert(in_file, out_file, in_fmt="", out_fmt=""): """ Converts in_file to out_file, guessing datatype in the absence of in_fmt and out_fmt. Arguments: in_file: The name of the (existing) datafile to read out_file: The name of the file to create with converted data in_f...
Builds a graph using the graph - services endpoint.
def build_graph(self, project, site, subject, session, scan, size, email=None, invariants=Invariants.ALL, fiber_file=DEFAULT_FIBER_FILE, atlas_file=None, use_threads=False, callback=None): """ Builds a graph using the graph-services endpoint. ...
Compute invariants from an existing GraphML file using the remote grute graph services.
def compute_invariants(self, graph_file, input_format, invariants=Invariants.ALL, email=None, use_threads=False, callback=None): """ Compute invariants from an existing GraphML file using the remote grute graph services. Arguments: ...
Convert a graph from one GraphFormat to another.
def convert_graph(self, graph_file, input_format, output_formats, email=None, use_threads=False, callback=None): """ Convert a graph from one GraphFormat to another. Arguments: graph_file (str): Filename of the file to convert input_format (str): A ...
Converts a RAMON object list to a JSON - style dictionary. Useful for going from an array of RAMONs to a dictionary indexed by ID.
def to_dict(ramons, flatten=False): """ Converts a RAMON object list to a JSON-style dictionary. Useful for going from an array of RAMONs to a dictionary, indexed by ID. Arguments: ramons (RAMON[]): A list of RAMON objects flatten (boolean: False): Not implemented Returns: ...
Converts RAMON objects into a JSON string which can be directly written out to a. json file. You can pass either a single RAMON or a list. If you pass a single RAMON it will still be exported with the ID as the key. In other words:
def to_json(ramons, flatten=False): """ Converts RAMON objects into a JSON string which can be directly written out to a .json file. You can pass either a single RAMON or a list. If you pass a single RAMON, it will still be exported with the ID as the key. In other words: type(from_json(to_...
Converts JSON to a python list of RAMON objects. if cutout is provided the cutout attribute of the RAMON object is populated. Otherwise it s left empty. json should be an ID - level dictionary like so:
def from_json(json, cutout=None): """ Converts JSON to a python list of RAMON objects. if `cutout` is provided, the `cutout` attribute of the RAMON object is populated. Otherwise, it's left empty. `json` should be an ID-level dictionary, like so: { 16: { type: "segme...
Converts an HDF5 file to a RAMON object. Returns an object that is a child - - class of RAMON ( though it s determined at run - time what type is returned ).
def from_hdf5(hdf5, anno_id=None): """ Converts an HDF5 file to a RAMON object. Returns an object that is a child- -class of RAMON (though it's determined at run-time what type is returned). Accessing multiple IDs from the same file is not supported, because it's not dramatically faster to access e...
Exports a RAMON object to an HDF5 file object.
def to_hdf5(ramon, hdf5=None): """ Exports a RAMON object to an HDF5 file object. Arguments: ramon (RAMON): A subclass of RAMONBase hdf5 (str): Export filename Returns: hdf5.File Raises: InvalidRAMONError: if you pass a non-RAMON object """ if issubclass(ty...
Takes str or int returns class type
def RAMON(typ): """ Takes str or int, returns class type """ if six.PY2: lookup = [str, unicode] elif six.PY3: lookup = [str] if type(typ) is int: return _ramon_types[typ] elif type(typ) in lookup: return _ramon_typ...
Return a binary - encoded decompressed 2d image. You should specify a token and channel pair. For image data users should use the channel image.
def get_xy_slice(self, token, channel, x_start, x_stop, y_start, y_stop, z_index, resolution=0): """ Return a binary-encoded, decompressed 2d image. You should specify a 'token' and 'channel' pair. For image dat...
Get a RAMONVolume volumetric cutout from the neurodata server.
def get_volume(self, token, channel, x_start, x_stop, y_start, y_stop, z_start, z_stop, resolution=1, block_size=DEFAULT_BLOCK_SIZE, neariso=False): """ Get a RAMONVolume volumetric cutout f...
Get volumetric cutout data from the neurodata server.
def get_cutout(self, token, channel, x_start, x_stop, y_start, y_stop, z_start, z_stop, t_start=0, t_stop=1, resolution=1, block_size=DEFAULT_BLOCK_SIZE, neariso=False): """ ...
Post a cutout to the server.
def post_cutout(self, token, channel, x_start, y_start, z_start, data, resolution=0): """ Post a cutout to the server. Arguments: token (str) channel (str) x_s...
Creates a project with the given parameters.
def create_project(self, project_name, dataset_name, hostname, is_public, s3backend=0, kvserver='localhost', kvengine='MySQL', mdengine=...
Creates a token with the given parameters. Arguments: project_name ( str ): Project name dataset_name ( str ): Dataset name project is based on token_name ( str ): Token name is_public ( int ): 1 is public. 0 is not public Returns: bool: True if project created false if not created.
def create_token(self, token_name, project_name, dataset_name, is_public): """ Creates a token with the given parameters. Arguments: project_name (str): Project name dataset_name (str): Da...
Get a token with the given parameters. Arguments: project_name ( str ): Project name dataset_name ( str ): Dataset name project is based on token_name ( str ): Token name Returns: dict: Token info
def get_token(self, token_name, project_name, dataset_name): """ Get a token with the given parameters. Arguments: project_name (str): Project name dataset_name (str): Dataset name project is based on token...
Delete a token with the given parameters. Arguments: project_name ( str ): Project name dataset_name ( str ): Dataset name project is based on token_name ( str ): Token name channel_name ( str ): Channel name project is based on Returns: bool: True if project deleted false if not deleted.
def delete_token(self, token_name, project_name, dataset_name): """ Delete a token with the given parameters. Arguments: project_name (str): Project name dataset_name (str): Dataset name project is based on ...
Creates a dataset.
def create_dataset(self, name, x_img_size, y_img_size, z_img_size, x_vox_res, y_vox_res, z_vox_res, x_offset=0, y...
Create a new channel on the Remote using channel_data.
def create_channel(self, channel_name, project_name, dataset_name, channel_type, dtype, startwindow, endwindow, readonly=0, ...
Gets info about a channel given its name name of its project and name of its dataset.
def get_channel(self, channel_name, project_name, dataset_name): """ Gets info about a channel given its name, name of its project , and name of its dataset. Arguments: channel_name (str): Channel name project_name (str): Project name dataset_name (st...
Deletes a channel given its name name of its project and name of its dataset.
def delete_channel(self, channel_name, project_name, dataset_name): """ Deletes a channel given its name, name of its project , and name of its dataset. Arguments: channel_name (str): Channel name project_name (str): Project name dataset_name (str): D...
Arguments: channel_name ( str ): Channel Name is the specific name of a specific series of data. Standard naming convention is to do ImageTypeIterationNumber or NameSubProjectName. datatype ( str ): The data type is the storage method of data in the channel. It can be uint8 uint16 uint32 uint64 or float32. channel_type...
def add_channel(self, channel_name, datatype, channel_type, data_url, file_format, file_type, exceptions=None, resolution=None, windowrange=None, readonly=None): """ Arguments: channel_name (str): Channel Name is the specific name of a ...
Arguments: project_name ( str ): Project name is the specific project within a dataset s name. If there is only one project associated with a dataset then standard convention is to name the project the same as its associated dataset. token_name ( str ): The token name is the default token. If you do not wish to specify...
def add_project(self, project_name, token_name=None, public=None): """ Arguments: project_name (str): Project name is the specific project within a dataset's name. If there is only one project associated with a dataset then standard convention is to name the ...
Add a new dataset to the ingest.
def add_dataset(self, dataset_name, imagesize, voxelres, offset=None, timerange=None, scalinglevels=None, scaling=None): """ Add a new dataset to the ingest. Arguments: dataset_name (str): Dataset Name is the overarching name of the research effor...
Genarate ND json object.
def nd_json(self, dataset, project, channel_list, metadata): """ Genarate ND json object. """ nd_dict = {} nd_dict['dataset'] = self.dataset_dict(*dataset) nd_dict['project'] = self.project_dict(*project) nd_dict['metadata'] = metadata nd_dict['channels'] ...
Generate the dataset dictionary
def dataset_dict( self, dataset_name, imagesize, voxelres, offset, timerange, scalinglevels, scaling): """Generate the dataset dictionary""" dataset_dict = {} dataset_dict['dataset_name'] = dataset_name dataset_dict['imagesize'] = imagesize dataset_dict['voxel...
Generate the project dictionary.
def channel_dict(self, channel_name, datatype, channel_type, data_url, file_format, file_type, exceptions, resolution, windowrange, readonly): """ Generate the project dictionary. """ channel_dict = {} channel_dict['channel_name'] = chann...
Genarate the project dictionary.
def project_dict(self, project_name, token_name, public): """ Genarate the project dictionary. """ project_dict = {} project_dict['project_name'] = project_name if token_name is not None: if token_name == '': project_dict['token_name'] = projec...
Identify the image size using the data location and other parameters
def identify_imagesize(self, image_type, image_path='/tmp/img.'): """ Identify the image size using the data location and other parameters """ dims = () try: if (image_type.lower() == 'png'): dims = np.shape(ndpng.load('{}{}'.format( ...
Verify the path supplied.
def verify_path(self, data, verifytype): """ Verify the path supplied. """ # Insert try and catch blocks try: token_name = data["project"]["token_name"] except: token_name = data["project"]["project_name"] channel_names = list(data["channe...
Try to post data to the server.
def put_data(self, data): """ Try to post data to the server. """ URLPath = self.oo.url("autoIngest/") # URLPath = 'https://{}/ca/autoIngest/'.format(self.oo.site_host) try: response = requests.post(URLPath, data=json.dumps(data), ...
Arguments: file_name ( str ): The file name of the json file to post ( optional ). If this is left unspecified it is assumed the data is in the AutoIngest object. dev ( bool ): If pushing to a microns dev branch server set this to True if not leave False. verifytype ( enum ): Set http verification type by checking the ...
def post_data(self, file_name=None, legacy=False, verifytype=VERIFY_BY_SLICE): """ Arguments: file_name (str): The file name of the json file to post (optional). If this is left unspecified it is assumed the data is in the AutoIngest object. ...
Arguments: file_name ( str:/ tmp/ ND. json ): The file name to store the json to
def output_json(self, file_name='/tmp/ND.json'): """ Arguments: file_name(str : '/tmp/ND.json'): The file name to store the json to Returns: None """ complete_example = ( self.dataset, self.project, self.channels, self.metadata) data =...
Find path for given workspace and|or repository.
def find_path(name, config, wsonly=False): """Find path for given workspace and|or repository.""" workspace = Workspace(config) config = config["workspaces"] path_list = {} if name.find('/') != -1: wsonly = False try: ws, repo = name.split('/') except ValueError...
Get a list of public tokens available on this server.
def get_public_tokens(self): """ Get a list of public tokens available on this server. Arguments: None Returns: str[]: list of public tokens """ r = self.remote_utils.get_url(self.url() + "public_tokens/") return r.json()
NOTE: VERY SLOW! Get a dictionary relating key: dataset to value: [ tokens ] that rely on that dataset.
def get_public_datasets_and_tokens(self): """ NOTE: VERY SLOW! Get a dictionary relating key:dataset to value:[tokens] that rely on that dataset. Arguments: None Returns: dict: relating key:dataset to value:[tokens] """ datasets =...
Return the project info for a given token.
def get_proj_info(self, token): """ Return the project info for a given token. Arguments: token (str): Token to return information for Returns: JSON: representation of proj_info """ r = self.remote_utils.get_url(self.url() + "{}/info/".format(tok...
Return the size of the volume ( 3D ). Convenient for when you want to download the entirety of a dataset.
def get_image_size(self, token, resolution=0): """ Return the size of the volume (3D). Convenient for when you want to download the entirety of a dataset. Arguments: token (str): The token for which to find the dataset image bounds resolution (int : 0): The resol...
Insert new metadata into the OCP metadata database.
def set_metadata(self, token, data): """ Insert new metadata into the OCP metadata database. Arguments: token (str): Token of the datum to set data (str): A dictionary to insert as metadata. Include `secret`. Returns: json: Info of the inserted ID (c...
Adds a new subvolume to a token/ channel.
def add_subvolume(self, token, channel, secret, x_start, x_stop, y_start, y_stop, z_start, z_stop, resolution, title, notes): """ Adds a new subvolume to a token/channel. Arguments: token (str): ...
Get a response object for a given url.
def get_url(self, url): """ Get a response object for a given url. Arguments: url (str): The url make a get to token (str): The authentication token Returns: obj: The response object """ try: req = requests.get(url, header...
Returns a post resquest object taking in a url user token and possible json information.
def post_url(self, url, token='', json=None, data=None, headers=None): """ Returns a post resquest object taking in a url, user token, and possible json information. Arguments: url (str): The url to make post to token (str): The authentication token j...
Returns a delete resquest object taking in a url and user token.
def delete_url(self, url, token=''): """ Returns a delete resquest object taking in a url and user token. Arguments: url (str): The url to make post to token (str): The authentication token Returns: obj: Delete request object """ if (...
Ping the server to make sure that you can access the base URL.
def ping(self, url, endpoint=''): """ Ping the server to make sure that you can access the base URL. Arguments: None Returns: `boolean` Successful access of server (or status code) """ r = self.get_url(url + "/" + endpoint) return r.status...
Import a HDF5 file into a numpy array.
def load(hdf5_filename): """ Import a HDF5 file into a numpy array. Arguments: hdf5_filename: A string filename of a HDF5 datafile Returns: A numpy array with data from the HDF5 file """ # Expand filename to be absolute hdf5_filename = os.path.expanduser(hdf5_filename) ...
Export a numpy array to a HDF5 file.
def save(hdf5_filename, array): """ Export a numpy array to a HDF5 file. Arguments: hdf5_filename (str): A filename to which to save the HDF5 data array (numpy.ndarray): The numpy array to save to HDF5 Returns: String. The expanded filename that now holds the HDF5 data """ ...
return values of execute are set as result of the task returned by ensure_future () obtainable via task. result ()
def run(self, job: Job) -> Future[Result]: ''' return values of execute are set as result of the task returned by ensure_future(), obtainable via task.result() ''' if not self.watcher_ready: self.log.error(f'child watcher unattached when executing {job}') job.canc...
Adds a character matrix to DendroPy tree and infers gaps using Fitch s algorithm.
def infer_gaps_in_tree(df_seq, tree, id_col='id', sequence_col='sequence'): """Adds a character matrix to DendroPy tree and infers gaps using Fitch's algorithm. Infer gaps in sequences at ancestral nodes. """ taxa = tree.taxon_namespace # Get alignment as fasta alignment = df_seq.phylo.to_...