Coder Social home page Coder Social logo

pyvg's Introduction

Build Status codecov

pyvg

pyvg is a lightweight Python package intended for making it easier to import and work with vg graphs and mapped reads in Python. It relies on vg graphs being converted to JSON, since importing proto-graphs is slow compared to JSON.

Installation

pyvg requires Python3 and Pip in order to be installed.

git clone [email protected]:uio-bmi/pyvg.git
cd pyvg
pip3 install -e .

Alternatively use pip install -e . if your pip command installs Python 3 packages.

Usage

Graphs

Make sure your vg graph is in json-format. You can easily convert by doing:

vg view -jV graph.vg > graph.json

The graph can then be read into a Python Graph object by doing:

from pyvg import Graph
graph = Graph.from_file("graph.json")
# Convert to OffsetBasedGraph
obgraph = graph.get_offset_based_graph()

When working with huge graphs (millions of nodes), reading and converting will be faster if using the numpy backend of OffsetBasedGraphs, bypassing the Pyvg Graph object:

from pyvg.conversion import json_file_to_obg_numpy_graph
ob_graph = json_file_to_obg_numpy_graph("graph.json")

# Write ob graph to a compact numpy file:
ob_graph.to_numpy_file("graph.npy")

Mappings

pyvg read vg mappings into an IntervalCollection. If you have a vg gam file, convert it to json first:

vg view -aj mappings.gam > mappings.json

Now, these can be read by pyvg:

from pyvg.conversion import vg_json_file_to_intervals
intervals = vg_json_file_to_intervals("mappings.json", ob_graph)

# Intervals is now a generator
for interval in intervals:
    print(interval)

Development

pyvg only supports Python 3. Run tests from the root directory using py.test: py.test. Pull-requests are welcome!

pyvg's People

Contributors

ivargr avatar knutdrand avatar

Stargazers

 avatar Colin Davenport avatar Chunyu Zhao avatar  avatar slp avatar Byron J. Smith avatar Danang Crysnanto avatar Adam Novak avatar Eric T. Dawson avatar Erik Garrison avatar

Watchers

James Cloos avatar Lex Nederbragt avatar sandve avatar  avatar  avatar

Forkers

khodor14

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.