Net Module : Getting started
This module provides various functions to upload data and interact with the MorphoNet database.
The detail of all all accessible functions can be found in the API Documentation.
We provide here some basic examples to interact with the MorphoNet Database.
Connect to the MorphoNet Database
First you have to connect with the API to the morphonet database using your credentials.
[8]:
import morphonet
mn=morphonet.Net("user","password")
--> Invalid Credentials
Interact with your datasets
Create your dataset
You can simply create a dataset using this function.
[ ]:
mn.create_dataset("test set",minTime=1,maxTime=150)
(more parameters are accessible in the documentation)
List your datasets
To display the datasets you own, you can use :
[ ]:
mn.list_my_dataset()
It will display all your datasets like this
(id_set) set_name is data_type created by set_owner the creation_dateTo display a dataset you can access (even if you’re not its owner) :
[ ]:
mn.list_dataset()
Select a dataset
You can either select a dataset by name or by id using
[ ]:
mn.select_dataset_by_name(thenameofmydataset)
#or
mn.select_dataset_by_id(thenIDofmydataset)
These 2 functions will bind the selected dataset to active dataset attached to the session, being able to use other functions to modify/share the dataset.
Access to a user or a group.
In order to have access to the id for a user or a group, you can use these two functions
[ ]:
mn.get_guy_by_name('Surname name')
mn.get_group_by_name("group_name")
that both return the id of the corresponding group/user.
For the user one, it’s really important to add a space between name and surname !
As an example :
[ ]:
mn.share_dataset_with_group(mn.getGroupByName("testgroup"),0)
Update a dataset
You can update a dataset using this function :
[ ]:
update_dataSet(name,minTime,maxTime,id_NCBI,id_type)
You can fill only a portion of the parameters, the missing ones will keep the old dataset values.
In order to change the dataset description you can use this function :
[ ]:
upload_description(newdescription)
Delete a dataset
There is 2 ways do delete a dataset, you can :
Delete all data from server (including set itself and sharings) using :
[ ]:
delete_dataset()
Or clear data from server (only meshes and properties) with
[ ]:
clear_dataset()
Manage Meshes
Morphological data must be uploaded to MorphoNet server under the form of surface meshes.
More specifically, we employ the most common format to represent meshes, i.e., the obj format In order to have access to all MorphoNet features please follow the format procedure.
Notice that for all theses functions , you first have to create or select a dataset.
Upload a new mesh
You can start by the upload of mesh at a specific time step using this function :
[ ]:
upload_mesh_at(t,obj,quality,channel,link,texture,material,ttype)
Access to a mesh
You can get your mesh using this function
[ ]:
get_mesh_at(self,t,quality,channel)
Delete a specific mesh
You can delete your uploaded mesh from the server using this function
[ ]:
clear_mesh_at(self,t,quality,channel)
Manage Properties
In order to fully exploit the interdisciplinary networking structure of our morphological browser, you can upload your own morphological properties.
Please follow first this format help in order to get the correct format for your additional properties.
Note that for all theses functions , you first have to create or select a dataset.
Display the Properties format
You can have access to a simple reminder on the property, format type using
[ ]:
show_properties_type()
Upload a new property
In order to upload your property you can use this function
[ ]:
upload_property(name, field)
where field represents the content of the property (text data respecting the corresponding format).
List properties of a selected dataset
You can list all properties associated to your dataset using
[ ]:
get_properties()
Get the property .
You can get the details of any property from the server in 2 ways:
with the property ID (int) using
[ ]:
get_property_by_id(id_property)
with the property name (text) using
[ ]:
get_property_by_name(name)
both will return the property data that is parsed by the viewer to display it.
Delete any property
In the same way you can delete a property using
[ ]:
delete_property_by_id(id_property)
#or
delete_property_by_name(name)
Manage primitives
In case of multiple repetition of the same pattern you can use the primitive concept. it is based on repeating a single object several times with different parameters (such as position, rotation and scaling), instead of having several copies of the same object in a single mesh, and allows for lighter datasets in some cases.
You just have to upload first the object which you want to “repeat” and reference it in your different mesh files.
Notice that primitives are always associated to one dataset only.
Upload a primitive
In order to first upload a primitive use this function
[ ]:
upload_primitive(name,obj)
where obj represente the primitive in the classical meshes format.
Upload a Mesh which contains primitives
Associated to your dataset, you can nowupload your meshes with primitives using
[ ]:
upload_mesh_with_primitive_at(t,obj,quality=0,channel=0)
Delete a specitic primitive
In order to delete delete a previously uploaded primitive from the database, use
[ ]:
delete_primitive(name)
Clear all primitives
To clear all primitives associated to a dataset from the database, use
[ ]:
clear_primitive()