MorphoNet.Net Documentation
Docstring for the net.py module.
This API is used to directly interact with your data on MorphoNet
For any information for the installation go on https://pypi.org/project/morphonet/
- class morphonet.net.Net(login='', passwd='', new_url=None, new_port=-1, token=None, id_user=-1)
Bases:
object
Connect to the MorphoNet server.
Use your credentials to connect to MorphoNet
- Parameters:
login (string) – your login in MorphoNet
passwd (string) – your password in MorphoNet
new_url (string, optional) – for developmental purpose, you can specify a new server that will be used to compute API request and get/upload MorphoNet data.
new_port (int, optional) – for developmental purpose, you can specify an other port
- Returns:
return an object of morphonet which will allow you to upload or download data
- Return type:
MorphoConnection
Examples
>>> import morphonet >>> mn=morphonet.Net("yourlogin","yourpassword")
- change_dataset_owner(new_owner_id)
Update the dataset on the server
- Parameters:
new_owner_id (int) – Identifiant of the new owner
- change_property_owner(id_property, new_owner_id)
Update the property on the server
- Parameters:
id_property (int) – property to transfer
new_owner_id (int) – Identifiant of the new owner
- clear_dataset()
Remove the 3D data and all properties for the selected dataset
Examples
>>> mn.clear_dataset()
- clear_mesh_at(t, quality=-1, channel=-1)
Remove the 3D data for the selected dataset at a specified time point, for a quality and channel
- Parameters:
t (int) – The time point to clear 3D data from
quality (int) – The quality of the 3D data
channel (int) – Wich channel of the object
Examples
>>> mn.clear_mesh_at(1,0,0)
- create_dataset(name, minTime=0, maxTime=0, id_NCBI=0, id_type=0, spf=-1, dt=-1, serveradress=None)
To create a data in the MorphoNet database
- Parameters:
name (string) – the given name of the dataset
minTime (int, optional) – the time first time point for 3D (or 2D) + t dataset, default: 0
maxTime (int, optional) – the last first time point for 3D (or 2D) + t dataset, default: 0
id_NCBI (int, optional) – the NCBI id attribute to the dataset
id_type (int, optional) –
- the tType of dataset :
0 : Observed
1 : Simulated
2 : Drawed
spf (int , optional) – the second post fertilization for the first time point
dt (int , optional) – the delta time in seconds between two consecutive time points
serveradress (string , optional) – you own server adress
Examples
>>> mn.create_dataset("test set",minTime=1,maxTime=150)
- delete_dataset()
Remove the selected dataset from the server
Examples
>>> mn.delete_dataset()
- delete_dataset_by_id(id_dataset)
Remove the selected dataset from the server using its id
Examples
>>> mn.delete_dataset()
- delete_image_at(t, channel=0)
Remove the raw image of the 3D dataset on the server, but only for a specific time point and channel
- Parameters:
t (int) – The time point to delete raw images
channel (int, optional) – Which channel of the dataset
mn.delete_image_at(0) (>>>) –
- delete_images()
Remove all the raw images from the server for the specified dataset
- delete_primitive(name)
Delete a specific primitive (specified by its name) for the selected dataset
- Parameters:
name (string) – Name of the primitive
Examples
>>> mn.delete_primitive("primitive to delete")
- delete_primitives()
Clear all primitives existing for the selected dataset
- delete_property_by_id(id_property)
Delete an property specified by its id on the server
- Parameters:
id_property (string) – id of the property
Examples
>>> mn.delete_property_by_id("1")
- delete_property_by_name(name)
Delete an property specified by its name on the server
- Parameters:
name (string) – Name of the property
Examples
>>> mn.delete_property_by_name("property name")
- get_annotation_by_id(id_property)
Retrieve the annotations for a property from MorphoNet
- Parameters:
id_property (int) – ID of the property
- Returns:
file – The annotation txt file for this property
- Return type:
string
Examples
>>> data = mn.get_annotation_by_id(1)
- get_cells_by_gene(gene_id)
Retrieve the list of cells (with their expression value) for the gene passed in argument (gene id is the id inside the database) return a dictionnary with database id as key as value tuple containing (cell,stage,value)
- get_cells_by_gene_by_stage(gene_id, stage_id)
Retrieve the list of cells (with their expression value) for the gene and the stage passed in argument (gene id and stage id are the id inside the database) return a dictionnary with database id as key as value tuple containing (cell,value)
- get_developmental_table()
Retrieve the corresponding developmental table of the specie of the dataset (avaible only for Ascidian ) return the list of developmentale table property (id,id_datasettype,period,stage,developmentaltstage,description,hpf)
- get_genes()
Retrieve the list of genes for this specie return a list with (id,Gene Model, Gene Name, Unique Gene id)
- get_genes_by_cell(cell_name)
Retrieve the list of genes (with their expression value) for the cell name in argument return a dictionnary with database id as key as value tuple containing (stage,gene,value)
- get_genes_by_cell_by_stage(cell_name, stage_id)
Retrieve the list of genes (with their expression value) for the cell name and stage id in argument return a dictionnary with database id as key as value tuple containing (gene,value)
- get_genes_by_stage(stage_id)
Retrieve the list of genes (with their expression value) for the stage id in argument return a dictionnary with database id as key as value tuple containing (gene,cell,value)
- get_group_by_name(name)
Return the group corresponding to a specific name
- Parameters:
name (string) – the name of the group
- Returns:
the id corresponding to the group, -1 if the group does not exist
- Return type:
id_group
Examples
>>> mn.get_group_by_name("The ascidians")
- get_guy_by_id(id_guy)
Return the person corresponding to an id
- Parameters:
id_guy (int) – the id of the person you are looking for
- Returns:
name , surname and login
- Return type:
object
Examples
>>> mn.get_guy_by_id(1)
- get_guy_by_name(name)
Return the person corresponding to a specific name and surname
- Parameters:
name (string) – the name and surname separated by a space
- Returns:
the id corresponding to the person, -1 if the person does not exist
- Return type:
id_guy
Examples
>>> mn.get_guy_by_name("Faure Emmanuel")
- get_image_at(t, channel=0)
Return the raw images (as a Numpy Matrix in uint8) from the server for the specified dataset :param t: The time point to upload raw images :type t: int :param channel: For which channel of the dataset :type channel: int, optional
- Returns:
mat – the numpy matrix of the rawimage in uint8
- Return type:
numpy
Examples
>>> mat=mn.get_image(1)
- get_image_size(id_rawimage)
Get the dimensions as JSON in format ‘(x,y,z)’ of rawimage with given id
- Parameters:
id (int) – ID of the RawImage (the same as the file name).
- Returns:
dims – The dimensions as JSON in format ‘(x,y,z)’ of the rawimage. None if ID does not exist or there is an error
- Return type:
string
- get_mesh_at(t, quality=0, channel=0)
Retrieve the mesh on the server for the specified time, quality and channel
- Parameters:
t (int) – The time point to get 3D data from
quality (int, optional) – Which quality of the dataset
channel (int, optional) – Which channel of the dataset
- Returns:
obj – The 3D data for the mesh
- Return type:
string
Examples
>>> data = mn.get_mesh_at(1)
- get_number_of_mesh_at(t, quality=-1, channel=-1)
Get the number of 3D data mesh for the selected dataset at a specifid time point, for a quality and a channel
- Parameters:
t (int) – The time point to get the number of 3D data from
quality (int) – The quality of the 3D data
channel (int) – Wich channel of the object
- Returns:
count – the number of the 3D meshes for the specified configuration
- Return type:
int
Examples
>>> mn.get_number_of_mesh_at(1,0,0)
- get_objects_from_property_by_id(id_property)
Get the list of object of an property specified by its id
- Parameters:
id_property (int) – ID of the property
- Returns:
objects – List of key/value corresponding to a split to the property data
- Return type:
list
Examples
>>> objetcs = mn.get_objects_from_property_by_id(1)
- get_objects_from_property_by_name(name)
Get the list of object of an property specified by its name
- Parameters:
name (string) – name of the property
- Returns:
objects – List of key/value corresponding to a split to the property data
- Return type:
list
Examples
>>> objetcs = mn.get_objects_from_property_by_name("property name")
- get_properties()
List all properties for the selected dataset
- Returns:
data – The list of properties
- Return type:
list
- get_property_annotated_by_id(id_property)
Retrieve directly the property annotated from MorphoNet
- Parameters:
id_property (int) – ID of the property
- Returns:
file – The property with the last annotation as a txt file in the MorphoNet Format
- Return type:
string
Examples
>>> data = mn.get_property_annotated_by_id(1)
- get_property_by_id(id_property)
Get the data of the property specified by its id
- Parameters:
id_property (int) – ID of the property
- Returns:
propertys – The data stored on the server
- Return type:
bytes
Examples
>>> mn.get_property_by_id("property name")
- get_property_by_name(name)
Get the data of the property specified by its name
- Parameters:
name (string) – Name of the property
- Returns:
property – The data stored on the server
- Return type:
bytes
Examples
>>> mn.get_property_by_name("property name")
- get_stages()
Retrieve the list of stages for this specie FROM “anissed all stages” return a dictionnary with stage database id as key and (Stage) as value
- is_image_at(t, channel=0)
Test is the raw images from the server for the specified dataset :param t: The time point to upload raw images :type t: int :param channel: For which channel of the dataset :type channel: int, optional
- Returns:
is – True if the raw image exist on the server
- Return type:
bool
Examples
>>> mn.is_image_at(1)
- list_dataset()
To display dataset you can access (even if you re not owner)
Examples
>>> mn.list_dataset()
It will display all your datasets like this >>> (id_set) set_name is data_type created by set_owner the creation_date
- list_my_dataset()
To display the datasets you own
Examples
>>> mn.list_my_dataset()
Notes
It will display all your datasets like this >>> (id_set) set_name is data_type created by set_owner the creation_date
- read_mesh(filename)
Read the mesh inside the given filename
- Parameters:
filename (string) – the mesh file name
- Returns:
obj – the mesh
- Return type:
string
Examples
>>> mn.read_mesh("path/to/myfile.obj")
- select_dataset_by_id(ids)
Select a dataset using an id
- Parameters:
ids (int) – The dataset id to select
Examples
>>> mn.select_dataset_by_id(1)
- select_dataset_by_name(name)
Select a dataset using is name
- Parameters:
name (string) – The dataset name to select
Examples
>>> mn.select_dataset_by_name("The name")
To share the current dataset with a specific group
- Parameters:
id_group (int) – the id of the group
role (int) – the role (Manager : 1, Reader : 0 ) which will be attribute to the group
Examples
>>> mn.share_dataset_with_group(1,0)
To share the current dataset with a specific user
- Parameters:
id_user (int) – the id of the user
role (int) – the role (Manager : 1, Reader : 0 ) which will be attribute to the user
Examples
>>> mn.share_dataset_with_user(1,0)
The property specified by its id become accessible to everyone you shared it (or public if you shared the property with public)
- Parameters:
id_property (int) – ID of the property
Examples
>>> objetcs = mn.share_property_by_id(1)
- show_properties_type()
Display all properties type storing fomats
To unshare the current dataset with a specific group
- Parameters:
id_group (int) – the id of the group
Examples
>>> mn.unshare_dataset_with_group(1)
To unshare the current dataset with a specific user
- Parameters:
id_user (int) – the id of the user
Examples
>>> mn.unshare_dataset_with_user(1)
The property specified by its id become unaccessible to everyone you shared it (or public if you shared the property with public)
- Parameters:
id_property (int) –
property (ID of the) –
Examples
>>> objetcs = mn.unshare_property_by_id(1)
- update_dataset(dataset_name='', minTime=-1, maxTime=-1, id_NCBI=-1, id_type=-1)
Change specified values for the selected dataset
- Parameters:
dataset_name (string, optional) – New name of the dataset
minTime (int, optional) – New minimal time point
maxTime (int, optional) – New maximum time point
id_NCBI (int, optional) – New taxonomy category id
id_type (int, optional) – New dataset stored type
Examples
>>> mn.update_dataset("Changing name only")
or
>>> mn.update_dataset("new name",1,1,1000,1)
- update_rawimage_link(id_rawimage, link)
Updates the link of a Rawimage with given id
- Parameters:
id (int) – ID of the RawImage (the same as the file name).
link (string) – new link to replace the previous one with
- upload_description(description)
Change description of the selected dataset on the server
- Parameters:
description (string) – New description to upload
Examples
>>> mn.upload_description("The new description attached")
- upload_image_at(t, rawdata, voxel_size='1,1,1', channel=0, scale=1)
Upload the dataset raw images with a scale value for a specified time, channel, It will erase any previous uploaded rawimages at this time point :param t: The time point to upload raw images :type t: int :param rawdata: The numpy array of the raw images of the dataset :type rawdata: uint8 :param channel: For which channel of the dataset :type channel: int, optional :param scale: Scale the raw images during the display to match the 3D data :type scale: float, optional
- Returns:
id – The id of the raw image created on the server
- Return type:
int
Examples
>>> im = imread(filepath) #Read your image >>> factor=2 #specify the rescale Factor >>> im=np.uint8(255*np.float32(im[::factor,::factor,::factor])/im.max()) #Convert it in 8 bits >>> mn.upload_image_at(1,im,scale=factor)
- upload_mesh_at(t, obj, quality=0, channel=0, link='null', texture=None, material=None, ttype='bmp', center=None)
Upload a new mesh (3D data) to a specific time point, for a quality and channel given. You can upload a texture by giving a texture and a material, specifying the texture format In order to add mutliple meshes at the same time point, you can call mutliple times the upload_mesh function :param t: The time point to set 3D data :type t: int :param obj: The content of the 3D data :type obj: bytes :param quality: Which quality of the dataset :type quality: int, optional :param channel: Which channel of the dataset :type channel: int, optional :param link: Do not specify this one if you don’t know what you are doing !! If bundle already exist for this mesh on the server, specify it :type link: string, optional :param texture: The texture data content that will be applied to the mesh :type texture: bytes, optional :param material: If texture is set, the name of the material that will be applied after applying the texure :type material: string, optional :param ttype: If texture is set, the file format for the texture
- Returns:
id – The id of the mesh created on the server
- Return type:
int
Examples
>>> #Specify a file on the hard drive by path, with rights >>> f = open(filepath,"r+") >>> #load content of file inside variable >>> content = f.read() >>> mn.upload_mesh_at(1,content,0,0) >>> f.close()
- upload_mesh_with_primitive_at(t, obj, quality=0, channel=0)
Upload a new mesh (3D data) to a specific time point, for a quality and channel given but using a primitive object
- Parameters:
t (int) – The time point to store 3D data
obj (string) – The mesh of the 3D data
quality (int, optional) – Which quality of the dataset
channel (int, optional) – Which channel of the dataset
- Returns:
id – The id of the mesh created on the server
- Return type:
int
Examples
>>> >>> with open('mymesh.obj','r') as f: #Specify a file on the hard drive by path, with rights >>> obj = f.read() #load mesh of the file inside variable >>> mn.upload_mesh_with_primitive_at(1,obj)
- upload_primitive(name, obj)
Create a reusable 3D format instance in the database
- Parameters:
name (string) – Name of the primitive
obj (bytes) – The content of the primitive (3D Data)
- Returns:
id – The id of the primitive created on the server
- Return type:
int
Examples
>>> with open('myprimitive.obj','r') as f: #Specify a file on the hard drive by path, with rights >>> obj = f.read() #load mesh of the file inside variable >>> mn.upload_primitive("a new primitive",obj)
- upload_property(name, field)
Create a new property in the database
- Parameters:
name (string) – Name of the property
field (bytes) – The content of the property (text Data respecting the corresponding format)
- Returns:
id (int) – The id of the property created on the server
Examples_get_objects
——–
>>> #Specify a file on the hard drive by path, with rights
>>> file = open(filepath,”r+”)
>>> #load content of file inside variable
>>> content = f.read()
>>> mn.upload_property(“a new property”,content)