-
Notifications
You must be signed in to change notification settings - Fork 5
Home
LRez is a project that provides both a standalone toolkit and a C++ API allowing to work with barcoded linked-reads.
The documentation of the various modules and of their corresponding functions is available at https://morispi.github.io/LRez/files.html.
LRez can easily be integrated to existing projects, and should be compiled using -llrez_bamtools -llrez -L/path/to/LRez/lib/
.
We provide a few examples on how to use the different functionalities of the API below.
string bamFile = "bamFile.bam";
bool onlyIndexPrimary = false;
unsigned minQuality = 0;
BarcodesOffsetsIndex index = indexBarcodesOffsetsFromBam(bamFile, onlyIndexPrimary, minQuality);
vector<BamAlignment> alignments;
string barcode = "ACGTTGCGATGGTCTG";
alignments = retrieveAlignmentsWithBarcode(bamFile, index, barcode);
Alternatively, if the index needs to be queried with multiple barcodes, the BAM file can be opened a single time
string bamFile = "bamFile.bam";
BamReader reader;
reader.Open(bamFile);
// Check if the BAM file was properly opened
vector<BamAlignment> alignments;
string barcode = "ACGTTGCGATGGTCTG";
alignments = retrieveAlignmentsWithBarcode_BamReader(reader, index, barcode);
barcode = "TTGCTAGCTAGGTAGT";
alignments = retrieveAlignmentsWithBarcode_BamReader(reader, index, barcode);
reader.Close();
string bamFile = "bamFile.bam";
string region = "chr:beg-end";
robin_hood::unordered_set<string> barcodes;
barcodes = extractBarcodesSeqsFromRegion(bamFile, region);
Alternatively, if the index needs to be queried with multiple barcodes, the BAM file can be opened a single time
string bamFile = "bamFile.bam";
BamReader reader;
reader.Open(bamFile);
// Check if the BAM file was properly opened
robin_hood::unordered_set<string> barcodes;
string region = "chr:beg-end";
barcodes = extractBarcodesSeqsFromRegion_BamReader(reader, region);
region = "chr2:beg-end";
barcodes = extractBarcodesSeqsFromRegion_BamReader(reader, region);
reader.Close();
Compute the number of common barcodes between the ends of a given contig, and the ends of all other contigs
string bamFile = "bamFile.bam";
bool onlyIndexPrimary = false;
unsigned minQuality = 0;
BarcodesOffsetsIndex index = indexBarcodesOffsetsFromBam(bamFile, onlyIndexPrimary, minQuality);
unsigned endSize = 1000;
string contig = "chr12";
robin_hood::unordered_map<pair<string, string>, unsigned, hashPairs> commonBarcodes;
commonBarcodes = compareContig(bamFile, index, contig, endSize);
string fastqFile = "fastqFile.fastq";
BarcodesIndex index = indexBarcodesFromFastq(fastqFile);
Alternatively, if the FASTQ file is gzipped
string fastqFile = "fastqFile.fastq";
BarcodesIndex index = indexBarcodesFromFastqGz(fastqFile);
vector<string> reads;
string barcode = "ACGTTGCGATGGTCTG";
alignments = retrieveReadsWithBarcode(fastqFile, index, barcode);
Alternatively, if the index needs to be queried with multiple barcodes, the FASTQ file can be opened a single time
string fastqFile = "fastqFile.fastq";
ifstream if;
if.open(fastqFile);
// Check if the FASTQ file was properly opened
vector<string> reads;
string barcode = "ACGTTGCGATGGTCTG";
reads = retrieveReadsWithBarcodes_Stream(if, index, barcode);
barcode = "TTGCTAGCTAGGTAGT";
reads = retrieveReadsWithBarcodes_Stream(if, index, barcode);
if.close();
vector<string> reads;
string barcode = "ACGTTGCGATGGTCTG";
reads = retrieveReadsWithBarcode_Gzip(fastqFile, index, barcode);
Alternatively, if the index needs to be queried with multiple barcodes, the FASTQ file can be opened a single time
string fastqFile = "fastqFile.fastq";
FILE* if;
if = fopen(fastqFile.c_str(), "rb");
// Check if the FASTQ file was properly opened
struct access* gzIndex = NULL;
gzIndex = deserializeGzIndex(gzIndex, fastqFile + "i");
vector<string> reads;
string barcode = "ACGTTGCGATGGTCTG";
reads = retrieveReadsWithBarcode_Gzip_Stream_Index(if, gzIndex, index, barcode);
barcode = "TTGCTAGCTAGGTAGT";
reads = retrieveReadsWithBarcode_Gzip_Stream_Index(if, gzIndex, index, barcode);
fclose(if);
freeGzIndex(gzIndex);