コード例 #1
0
ファイル: filterBAM.cpp プロジェクト: avilella/sga
// Read an alignment pair from the BamReader.
// Returns false if the read fails
bool readAlignmentPair(BamTools::BamReader* pReader, 
                       BamTools::BamAlignment& record1,
                       BamTools::BamAlignment& record2)
{
    // Read a pair from the BAM
    // Read record 1. Skip secondary alignments of the previous pair
    do
    {
        if(!pReader->GetNextAlignment(record1))
            return false;
    } while(!record1.IsPrimaryAlignment());

    // Read record 2.
    do
    {
        if(!pReader->GetNextAlignment(record2))
            return false;
    } while(!record2.IsPrimaryAlignment());
    return true;
}
コード例 #2
0
	uint32_t BamAlignmentReader::GetReadLength(const std::string& bamPath)
	{
		uint32_t bamReadLength = 300;
		BamTools::BamReader bamReader;
		if (!bamReader.Open(bamPath))
		{
			throw "Unable to open bam file";
		}
		BamTools::BamAlignment bamAlignment;
		while(bamReader.GetNextAlignment(bamAlignment))
		{
			if (bamAlignment.IsPrimaryAlignment())
			{
				bamReadLength = bamAlignment.QueryBases.size();
				break;
			}
		}
		bamReader.Close();
		return bamReadLength;
	}