Skip to main content

Python implementation of stream library

Project description

Python implementation of stream library for parsing all files encoded by stream and writing protobuf instances into the file by using the same encoding.

Installation

You can install pyStream using pip:

pip install pystream-protobuf

Examples

Here’s a sample code using the Stream class to read a file (so-called GAM file) containing a set of VG’s Alignment objects (defined here). It yields the protobuf objects stored in the file:

import stream
import vg_pb2

alns_list = []
with stream.open("test.gam", "rb") as istream:
    for data in istream:
        aln = vg_pb2.Alignment()
        aln.ParseFromString(data)
        alns_list.append(aln)

Or

import stream
import vg_pb2

alns_list = []
istream = stream.open("test.gam", "rb")
for data in istream:
    aln = vg_pb2.Alignment()
    aln.ParseFromString(data)
    alns_list.append(aln)
istream.close()

And here is another sample code for writing multiple protobuf objects into a file (here a GAM file):

import stream

with stream.open("test.gam", "wb") as ostream:
    ostream.write(*objects_list)
    ostream.write(*another_objects_list)

Or

import stream

ostream = stream.open("test.gam", "wb")
ostream.write(*objects_list)
ostream.write(*another_objects_list)
ostream.close()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pystream-protobuf-1.1.2.tar.gz (9.7 kB view details)

Uploaded Source

File details

Details for the file pystream-protobuf-1.1.2.tar.gz.

File metadata

File hashes

Hashes for pystream-protobuf-1.1.2.tar.gz
Algorithm Hash digest
SHA256 101a9a25f6b89ab0ea5cb7cdf1d4bfc252ccc1756eff2bf9be3fb06c56551916
MD5 a02ef462d4e6266f682d107eee4080c5
BLAKE2b-256 aae3d02c910b8f80537a5d74c6aa136a6e2ecbdd06d2a0c9174736a80a71c9c4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page