Class BedStream
High-level BED I/O class.

Defined in <seqan/bed_io.h>
Signature class BedStream;

Member Function Overview

Interface Function Overview

Member Variable Overview

Detailed Description

Examples

The following example demonstrates reading a BED file and printing the annotation locations.

#include <seqan/basic.h>
#include <seqan/bed_io.h>

using namespace seqan;

// USAGE: bed_stream_read IN.bed
//
// Read BED file and print the positions (reference, position) to stdout.
//
// We only read BED 3 here but the example can be easily adjusted to more complex examples.

int main(int argc, char ** argv)
{
    if (argc != 2)
    {
        std::cerr << "USAGE: " << argv[1] << " IN.bed\n";
        return 1;
    }

    BedStream bedIn(argv[1]);
    if (!isGood(bedIn))
    {
        std::cerr << "ERROR: Could not open " << argv[1] << " for reading!\n";
        return 1;
    }

    BedRecord<Bed3> record;
    while (!atEnd(bedIn))
    {
        if (readRecord(record, bedIn) != 0)
        {
            std::cerr << "ERROR: Problem reading from " << argv[1] << "\n";
            return 1;
        }

        std::cout << record.ref << "\t" << record.beginPos << "\n";
    }
    
    return 0;
}

See Also

Member Functions Detail

BedStream::BedStream(); BedStream::BedStream(fileName[, mode = READ]);

Constructor.

Parameters

mode The open mode (BedStream::Mode).
fileName The path to the file to open (char const *).

See Also

Interface Functions Detail

void addSequenceName(bedStream, seqName);

Add the name of a sequence to a BedStream.

Parameters

bedStream The BedStream to add the name to.
seqName The name of the sequence to append.

bool atEnd(bedStream);

Query a BedStream for being at the end of the file.

Parameters

bedStream The BedStream to query.

Returns

bool true if stream is at the end, false otherwise.

int close(bedStream);

Closes a BedStream

Parameters

bedStream The BedStream to close.

Returns

int A status code, 0 on success, different value on failure.

int flush(bedStream);

Flush to a BedStream

Parameters

bedStream The BedStream to flush.

Returns

int Status code, 0 on success, other value on failure.

bool isGood(bedStream);

Query a BedStream for errors.

Parameters

bedStream The BedStream to query.

Returns

TReturn true if stream is good, false otherwise.

See Also

bool open(bedStream, fileName[, mode = READ]);

Open a BedStream.

Parameters

bedStream The BedStream to open. Types: BedStream
fileName The path to the file to open, char const 8
mode The open mode, type is BedStream::Mode.

Returns

bool true on success, false on failure.

See Also

int readRecord(record, bedStream);

Read a record from a BedStream.

Parameters

record The BedRecord to read into.
bedStream The BedStream to read from.

Returns

int A status code, 0 on success, different value on failure.

int writeRecord(bedStream, record);

Write a record to a BedStream

Parameters

bedStream The BedStream to write to.
record The BedRecord to write.

Returns

int A status code, 0 on success, different value on failure.

Member Variables Detail

TCharStringSet BedStream::sequenceNames

The names of the sequences (StringSet of CharString)

The string set is updated when new sequences are seen in BED file.