From 46af928f59d1d132489151112632af151b5918b8 Mon Sep 17 00:00:00 2001 From: sepro Date: Fri, 1 Dec 2017 13:49:49 +0100 Subject: [PATCH] adding additional documentation to the code --- conekt/controllers/graph_comparison.py | 6 ++--- conekt/helpers/cytoscape.py | 12 +++++++++- .../relationships/sequence_sequence_ecc.py | 22 +++++++++++++++++-- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/conekt/controllers/graph_comparison.py b/conekt/controllers/graph_comparison.py index 3c7bb40..903ce77 100644 --- a/conekt/controllers/graph_comparison.py +++ b/conekt/controllers/graph_comparison.py @@ -12,9 +12,9 @@ # TODO placeholder for the search function -@graph_comparison.route('/') -def graph_comparison_overview(): - return "TEST" +# @graph_comparison.route('/') +# def graph_comparison_overview(): +# return "TEST" @graph_comparison.route('/cluster//') diff --git a/conekt/helpers/cytoscape.py b/conekt/helpers/cytoscape.py index 2bd50cc..769ed45 100644 --- a/conekt/helpers/cytoscape.py +++ b/conekt/helpers/cytoscape.py @@ -254,6 +254,14 @@ def add_depth_data_nodes(network): @staticmethod def connect_homologs(network): + """ + Connects homologous (or orthologous) genes using a dashed edge. Requires a cytoscape.js compatible network as + input and will return a network with homologs connected. Note that gene families need to be present in the + network *before* applying this function. (e.g. using add_family_data_nodes in this class) + + :param network: + :return: + """ connected_network = deepcopy(network) """ Add edges between homologous genes from different targets, family_id needs to be specified ! @@ -411,7 +419,9 @@ def add_depth_data_edges(network): @staticmethod def prune_unique_lc(network): """ - Remove genes from network that have an lc that occurs only once + Remove genes from network that have a unique label (label co-occ.). Requires a Cytoscape.js compatible network + and will return a purned copy in the same format. Note that label co-occ. need to be present in the + network *before* applying this function. (e.g. using add_lc_data_nodes in this class) :param network: dict containing the network :return: Cytoscape.js compatible network with the pruned network diff --git a/conekt/models/relationships/sequence_sequence_ecc.py b/conekt/models/relationships/sequence_sequence_ecc.py index cb89793..4fcdcac 100644 --- a/conekt/models/relationships/sequence_sequence_ecc.py +++ b/conekt/models/relationships/sequence_sequence_ecc.py @@ -46,6 +46,15 @@ class SequenceSequenceECCAssociation(db.Model): @staticmethod def get_ecc_network(sequence, network, family): + """ + Get network connecting a specific sequence to all genes with significant Expression Context Conservation. + + + :param sequence: internal ID of sequence + :param network: network method ID to consider + :param family: kind of gene families used to detect ECC + :return: network dict (can be made compatible using CytoscapeHelper) + """ data = SequenceSequenceECCAssociation.query.filter(and_( SequenceSequenceECCAssociation.query_id == sequence, SequenceSequenceECCAssociation.query_network_method_id == network, @@ -112,8 +121,8 @@ def get_ecc_network(sequence, network, family): @staticmethod def get_ecc_pair_network(ecc_id): """ - Get all data for an SequenceSequenceECCAssociation to make a ECC graph - + Get all data for an SequenceSequenceECCAssociation to make a ECC graph, similar to the pairwise comparisons in + Movahedi et al. :param ecc_id: interal id of the SequenceSequenceECCAssociation :return: ecc pair with neighborhood as graph dict @@ -203,6 +212,15 @@ def get_ecc_pair_network(ecc_id): @staticmethod def get_ecc_multi_network(gf_method_id, sequence_ids): + """ + Creates an ECC network for multiple genes, the resulting network will contain all ECC partners of the input + genes. Pruning this network keeping only genes with non-unique label co-occurances is recommended ! + + + :param gf_method_id: gene family method used to detect ECC + :param sequence_ids: sequences to include as the core of the network + :return: network dict + """ associations = SequenceSequenceECCAssociation.query.\ filter(SequenceSequenceECCAssociation.gene_family_method_id == gf_method_id).\ filter(and_(SequenceSequenceECCAssociation.query_id.in_(sequence_ids),