Manager¶
This module the database manager of ComPath.
-
class
compath.manager.
Manager
(engine, session)[source]¶ Database manager.
Init ComPath manager.
-
get_all_mappings
() → List[compath.models.PathwayMapping][source]¶ Get all mappings in the database.
-
get_all_accepted_mappings
() → List[compath.models.PathwayMapping][source]¶ Get all accepted mappings in the database.
-
get_mappings_by_type
(mapping_type: str) → List[compath.models.PathwayMapping][source]¶ Get all mappings in the database.
- Parameters
mapping_type – type of the mapping
-
get_vote_by_id
(vote_id: str) → Optional[compath.models.Vote][source]¶ Get a vote by its id.
- Parameters
vote_id – identifier
-
get_vote
(user: compath.models.User, mapping: compath.models.PathwayMapping) → Optional[compath.models.Vote][source]¶ Get a vote.
- Parameters
user – User instance
mapping – Mapping instance
-
get_user_by_email
(email: str) → Optional[compath.models.User][source]¶ Get a user by their email address.
-
get_mapping
(service_1_name, pathway_1_id, pathway_1_name, service_2_name, pathway_2_id, pathway_2_name, mapping_type)[source]¶ Query mapping in the database.
- Parameters
service_1_name (str) – manager name of the service 1
pathway_1_id (str) – pathway 1 id
pathway_1_name (str) – pathway 1 name
service_2_name (str) – manager name of the service 1
pathway_2_id (str) – pathway 2 id
pathway_2_name (str) – pathway 2 name
mapping_type (str) – mapping type (isPartOf or equivalentTo)
- Return type
Optional[Mapping]
-
get_mapping_by_id
(mapping_id: int) → Optional[compath.models.PathwayMapping][source]¶ Get a mapping by its id.
- Parameters
mapping_id – mapping id
-
get_or_create_vote
(user, mapping, vote_type=True)[source]¶ Get or create vote.
- Parameters
user (User) – User instance
mapping (PathwayMapping) – Mapping instance
vote_type (Optional[Vote.type]) – vote type
- Return type
-
get_or_create_mapping
(service_1_name, pathway_1_id, pathway_1_name, service_2_name, pathway_2_id, pathway_2_name, mapping_type, user)[source]¶ Get or create a mapping.
- Parameters
service_1_name (str) – manager name of the service 1
pathway_1_name (str) – pathway 1 name
pathway_1_id (str) – pathway 1 id
service_2_name (str) – manager name of the service 1
pathway_2_name (str) – pathway 2 name
pathway_2_id (str) – pathway 2 id
mapping_type (str) – type of mapping
user (User) – the user
- Returns
PathwayMapping and boolean indicating if the mapping was created or not
- Return type
-
claim_mapping
(mapping, user)[source]¶ Check if user has already established the mapping, if not claims it.
- Parameters
mapping (PathwayMapping) – Mapping instance
user (User) – User
- Return type
- Returns
if mapping was assigned to user
-
accept_mapping
(mapping_id)[source]¶ Accept established mapping (from user or curator consensus).
- Parameters
mapping_id (int) – mapping id
- Return type
- Returns
mapping and boolean that indicates if transaction was made
-
get_mappings_from_pathway_with_relationship
(type, service_name, pathway_id, pathway_name)[source]¶ Get all mappings matching pathway and service name.
-
get_decendents_mappings_from_pathway_with_is_part_of_relationship
(service_name, pathway_id, pathway_name)[source]¶ Get all mappings matching pathway and service name.
-
get_ancestry_mappings_from_pathway_with_is_part_of_relationship
(service_name, pathway_id, pathway_name)[source]¶ Get all mappings matching pathway and service name.
-
get_all_mappings_from_pathway
(service_name, pathway_id, pathway_name)[source]¶ Get all mappings matching pathway and service name.
- Parameters
- Return type
- Returns
-