const string POSITION_PROPERTY = "position";
const string QUERYBASES_PROPERTY = "queryBases";
const string REFERENCE_PROPERTY = "reference";
+const string CIGAR_PROPERTY = "cigar";
// boolalpha
const string TRUE_STR = "true";
const string& refName = filterToolReferences.at(al.RefID).RefName;
keepAlignment &= valueFilter.check(refName);
}
+ else if ( propertyName == CIGAR_PROPERTY ) {
+ stringstream cigarSs;
+ const vector<CigarOp>& cigarData = al.CigarData;
+ if ( !cigarData.empty() ) {
+ vector<CigarOp>::const_iterator cigarBegin = cigarData.begin();
+ vector<CigarOp>::const_iterator cigarIter = cigarBegin;
+ vector<CigarOp>::const_iterator cigarEnd = cigarData.end();
+ for ( ; cigarIter != cigarEnd; ++cigarIter ) {
+ const CigarOp& op = (*cigarIter);
+ cigarSs << op.Length << op.Type;
+ }
+ keepAlignment &= valueFilter.check(cigarSs.str());
+ }
+ }
else BAMTOOLS_ASSERT_UNREACHABLE;
// if alignment fails at ANY point, just quit and return false
else if ( propertyName == MATEREFERENCE_PROPERTY ||
propertyName == NAME_PROPERTY ||
propertyName == QUERYBASES_PROPERTY ||
- propertyName == REFERENCE_PROPERTY
+ propertyName == REFERENCE_PROPERTY ||
+ propertyName == CIGAR_PROPERTY
)
{
m_filterEngine.parseToken(token, stringValue, type);
m_propertyNames.push_back(POSITION_PROPERTY);
m_propertyNames.push_back(QUERYBASES_PROPERTY);
m_propertyNames.push_back(REFERENCE_PROPERTY);
+ m_propertyNames.push_back(CIGAR_PROPERTY);
// add vector contents to FilterEngine<BamAlignmentChecker>
vector<string>::const_iterator propertyNameIter = m_propertyNames.begin();
// open reader without index
BamMultiReader reader;
- reader.Open(m_settings->InputFiles, false, true);
+ if (!reader.Open(m_settings->InputFiles, false, true)) {
+ cerr << "Could not open input files for reading." << endl;
+ return false;
+ }
const string headerText = reader.GetHeaderText();
filterToolReferences = reader.GetReferenceData();
// open writer
BamWriter writer;
bool writeUncompressed = ( m_settings->OutputFilename == Options::StandardOut() && !m_settings->IsForceCompression );
- writer.Open(m_settings->OutputFilename, headerText, filterToolReferences, writeUncompressed);
+ if (!writer.Open(m_settings->OutputFilename, headerText, filterToolReferences, writeUncompressed)) {
+ cerr << "Could not open " << m_settings->OutputFilename << " for writing." << endl;
+ return false;
+ }
BamAlignment al;