本文整理汇总了C++中BamReader::CreateIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ BamReader::CreateIndex方法的具体用法?C++ BamReader::CreateIndex怎么用?C++ BamReader::CreateIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BamReader
的用法示例。
在下文中一共展示了BamReader::CreateIndex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadIndex
bool BamParse::loadIndex(BamReader& reader)
{
bool bsignal = reader.OpenIndex(this->filename_index);
if(bsignal==false)
{
cerr << "Index file not found, now create it!!!"<<endl;
bool bci=reader.CreateIndex();
if(bci==false)
{
cerr << "Index file cannot be created!!!"<<endl;
return false;
}
else
{
bool blct=reader.LocateIndex();
if(blct==false)
{
cerr << "Index file cannot be located!!!"<<endl;
return false;
}
}
}
return true;
}
示例2: CreateIndexes
// creates index files for BAM files that don't have them
bool BamMultiReaderPrivate::CreateIndexes(const BamIndex::IndexType& type)
{
bool errorsEncountered = false;
m_errorString.clear();
// iterate over readers
std::vector<MergeItem>::iterator itemIter = m_readers.begin();
std::vector<MergeItem>::iterator itemEnd = m_readers.end();
for (; itemIter != itemEnd; ++itemIter) {
MergeItem& item = (*itemIter);
BamReader* reader = item.Reader;
if (reader == 0) continue;
// if reader doesn't have an index, create one
if (!reader->HasIndex()) {
if (!reader->CreateIndex(type)) {
m_errorString.append(1, '\t');
m_errorString.append(reader->GetErrorString());
m_errorString.append(1, '\n');
errorsEncountered = true;
}
}
}
// check for errors encountered before returning success/fail
if (errorsEncountered) {
const std::string currentError = m_errorString;
const std::string message =
std::string("error while creating index files: \n") + currentError;
SetErrorString("BamMultiReader::CreateIndexes", message);
return false;
} else
return true;
}
示例3: CreateIndexes
// saves index data to BAM index files (".bai"/".bti") where necessary, returns success/fail
bool BamMultiReader::CreateIndexes(bool useStandardIndex) {
bool result = true;
for (vector<pair<BamReader*, BamAlignment*> >::iterator it = readers.begin(); it != readers.end(); ++it) {
BamReader* reader = it->first;
result &= reader->CreateIndex(useStandardIndex);
}
return result;
}
示例4: Run
int IndexTool::Run(int argc, char* argv[]) {
// parse command line arguments
Options::Parse(argc, argv, 1);
// open our BAM reader
BamReader reader;
reader.Open(m_settings->InputBamFilename);
// create index for BAM file
bool useDefaultIndex = !m_settings->IsUsingBamtoolsIndex;
reader.CreateIndex(useDefaultIndex);
// clean & exit
reader.Close();
return 0;
}
示例5: main
//.........这里部分代码省略.........
//Check for Reference Fasta sequence
if (!has_ref)
{
cerr << "no FASTA reference provided, cannot realign" << endl;
exit(1);
}
////Check for reader
BamReader reader;
if (STdin == true)
{
if (!reader.Open("stdin"))
{
cerr << "could not open stdin bam for reading" << endl;
cerr << reader.GetErrorString() << endl;
reader.Close();
printSummary(argv);
}
}
else
{
if (has_bamfile == true)
{
if (!reader.Open(bamfile))
{
cerr << "ERROR: could not open bam files from stdin ... Aborting" << endl;
cerr << reader.GetErrorString() << endl;
reader.Close();
printSummary(argv);
}
if ( !reader.LocateIndex() )
reader.CreateIndex();
}
else
{
cerr << "--bam flag is set but no bamfile is provided... Aborting" << endl;
reader.Close();
printSummary(argv);
}
}
//// Check Region Tags
if ( (has_regionFile == true) && (has_region == true) )
{
cerr << "ERROR: You provide both region and has provide a Set Region List... Aborting" << endl;
exit(1);
}
//// store the names of all the reference sequences in the BAM file
vector<RefData> referencedata = reader.GetReferenceData();
//// Store Region LIST
vector<BamRegion> regionlist;
if (has_region == true)
{
BamRegion region;
ParseRegionString(regionstr, reader, region);
regionlist.push_back(region);
}
else if (has_regionFile == true)
{
ifstream RG(RegionFile.c_str(), ios_base::in);
string line;
while(getline(RG,line))