dwhswenson / contact_map

Contact map analysis for biomolecules; based on MDTraj
GNU Lesser General Public License v2.1
42 stars 18 forks source link

ContactCount.to_networkx #90

Closed dwhswenson closed 3 years ago

dwhswenson commented 4 years ago

A sparse matrix (such as a contact map) can be considered equivalent to a network. This PR adds a direct function to make a NetworkX graph from a ContactCount.

This constructor allows you to also add our graph to an existing graph by specifying the graph keyword. Additionally, you can select whether you want the graph to use the indices as nodes or the topology objects.

Another way to create a NetworkX graph from a ContactCount would be:

g = nx.from_scipy_sparse(contact_count.sparse_matrix)

There are options possible with nx.from_scipy_sparse that are not possible with ContactCount.to_networkx. See NetworkX docs on it.

codecov[bot] commented 3 years ago

Codecov Report

Merging #90 (73cca8d) into master (ae5deca) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #90   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           13        13           
  Lines         1140      1153   +13     
=========================================
+ Hits          1140      1153   +13     
Impacted Files Coverage Δ
contact_map/contact_count.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ae5deca...73cca8d. Read the comment docs.

dwhswenson commented 3 years ago

This is ready for review. Includes: