Loading...
Searching...
No Matches
FilterTest Class Reference

## Public Types

enum | FileType { SAM , BAM }

## Static Public Member Functions

static void | testFilter (FileType inputType)

## Detailed Description

Definition at line 21 of file TestFilter.h.

## Member Enumeration Documentation

## FileType

enum FilterTest::FileType

Definition at line 24 of file TestFilter.h.

{SAM, BAM};

## Member Function Documentation

## testFilter()

void FilterTest::testFilter | ( | FileType | inputType | ) |

static

Definition at line 34 of file TestFilter.cpp.

{
SamFile inSam;
if(inputType == SAM)
{
assert(inSam.OpenForRead("testFiles/testSam.sam"));
}
else
{
assert(inSam.OpenForRead("testFiles/testBam.bam"));
}
// Read the SAM Header.
SamFileHeader samHeader;
assert(inSam.ReadHeader(samHeader));
validateHeader(samHeader);
SamRecord samRecord;
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead1(samRecord);
// Clip the read, 2 from the front and 2 from the back, which causes 2D to
// be dropped.
assert(SamFilter::softClip(samRecord, 2, 2) == SamFilter::CLIPPED);
assert(samRecord.get0BasedPosition() == TestValidate::READ1_POS + 2);
std::string expectedCigar = "2S1M2S";
assert(samRecord.getCigar() == expectedCigar);
assert(samRecord.getSequence() == TestValidate::READ1_SEQ);
assert(samRecord.getQuality() == TestValidate::READ1_QUAL);
// Only 1 base, so the end is the same as start
assert(samRecord.get0BasedAlignmentEnd() == TestValidate::READ1_POS + 2);
assert(samRecord.getAlignmentLength() == 1);
assert(samRecord.get0BasedUnclippedStart() == TestValidate::READ1_UNCLIP_START);
// The new unclipped end is not the same as the original end because the
// 2 deletions are lost.
assert(samRecord.get0BasedUnclippedEnd() == TestValidate::READ1_UNCLIP_END - 2);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead2(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead3(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead4(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead5(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead6(samRecord);
// Clip the read 2 more from the front and 2 from the back.
assert(SamFilter::softClip(samRecord, 5, 2) == SamFilter::CLIPPED);
assert(samRecord.get0BasedPosition() == TestValidate::READ6_POS + 2);
expectedCigar = "2H5S1M2S";
assert(samRecord.getCigar() == expectedCigar);
assert(samRecord.getSequence() == TestValidate::READ6_SEQ);
assert(samRecord.getQuality() == TestValidate::READ6_QUAL);
// Only 1 base, so the end is the same as start
assert(samRecord.get0BasedAlignmentEnd() == TestValidate::READ6_POS + 2);
assert(samRecord.getAlignmentLength() == 1);
assert(samRecord.get0BasedUnclippedStart() == TestValidate::READ6_UNCLIP_START);
assert(samRecord.get0BasedUnclippedEnd() == TestValidate::READ6_UNCLIP_END);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead7(samRecord);
// Clip the read 2 more from the front and 2 morefrom the back.
assert(SamFilter::softClip(samRecord, 5, 3) == SamFilter::CLIPPED);
assert(samRecord.get0BasedPosition() == TestValidate::READ7_POS + 2);
expectedCigar = "5S1M3S3H";
assert(samRecord.getCigar() == expectedCigar);
assert(samRecord.getSequence() == TestValidate::READ7_SEQ);
assert(samRecord.getQuality() == TestValidate::READ7_QUAL);
// Only 1 base, so the end is the same as start
assert(samRecord.get0BasedAlignmentEnd() == TestValidate::READ7_POS + 2);
assert(samRecord.getAlignmentLength() == 1);
assert(samRecord.get0BasedUnclippedStart() == TestValidate::READ7_UNCLIP_START);
assert(samRecord.get0BasedUnclippedEnd() == TestValidate::READ7_UNCLIP_END);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead8(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead9(samRecord);
assert(inSam.ReadRecord(samHeader, samRecord) == true);
validateRead10(samRecord);
}
SamFile::ReadHeader
bool ReadHeader(SamFileHeader &header)
Reads the header section from the file and stores it in the passed in header.
Definition SamFile.cpp:450
SamFile::ReadRecord
bool ReadRecord(SamFileHeader &header, SamRecord &record)
Reads the next record from the file & stores it in the passed in record.
Definition SamFile.cpp:514
SamFile::OpenForRead
bool OpenForRead(const char *filename, SamFileHeader *header=NULL)
Open a sam/bam file for reading with the specified filename, determing the type of file and SAM/BAM b...
Definition SamFile.cpp:93
SamFilter::CLIPPED
@ CLIPPED
Filtering clipped the read.
Definition SamFilter.h:31
SamFilter::softClip
static FilterStatus softClip(SamRecord &record, int32_t numFrontClips, int32_t numBackClips)
Soft clip the record from the front and/or the back.
Definition SamFilter.cpp:155
SamRecord::getAlignmentLength
int32_t getAlignmentLength()
Returns the length of the clipped sequence, returning 0 if the cigar is '*'.
Definition SamRecord.cpp:1493
SamRecord::get0BasedUnclippedEnd
int32_t get0BasedUnclippedEnd()
Returns the 0-based inclusive right-most position adjusted for clipped bases.
Definition SamRecord.cpp:1526
SamRecord::get0BasedUnclippedStart
int32_t get0BasedUnclippedStart()
Returns the 0-based inclusive left-most position adjusted for clipped bases.
Definition SamRecord.cpp:1506
SamRecord::get0BasedAlignmentEnd
int32_t get0BasedAlignmentEnd()
Returns the 0-based inclusive rightmost position of the clipped sequence.
Definition SamRecord.cpp:1467
SamRecord::get0BasedPosition
int32_t get0BasedPosition()
Get the 0-based(BAM) leftmost position of the record.
Definition SamRecord.cpp:1319
SamRecord::getCigar
const char * getCigar()
Returns the SAM formatted CIGAR string.
Definition SamRecord.cpp:1555
SamRecord::getQuality
const char * getQuality()
Returns the SAM formatted quality string (QUAL).
Definition SamRecord.cpp:1638
SamRecord::getSequence
const char * getSequence()
Returns the SAM formatted sequence string (SEQ), translating the base as specified by setSequenceTran...
Definition SamRecord.cpp:1568

The documentation for this class was generated from the following files:

- bam/test/TestFilter.h
- bam/test/TestFilter.cpp