本文整理汇总了C++中BamAlignment::EditTag方法的典型用法代码示例。如果您正苦于以下问题:C++ BamAlignment::EditTag方法的具体用法?C++ BamAlignment::EditTag怎么用?C++ BamAlignment::EditTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BamAlignment
的用法示例。
在下文中一共展示了BamAlignment::EditTag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main ( int argc, char *argv[] ) {
struct parameters *param = 0;
param = interface(param, argc, argv);
//bam input and generate index if not yet
//-------------------------------------------------------------------------------------------------------+
// BAM input (file or filenames?) |
//-------------------------------------------------------------------------------------------------------+
char *fof = param->mapping_f;
FILE *IN=NULL;
char linefof[5000];
int filecount=0;
vector <string> fnames;
if (strchr(fof,' ')!=NULL) {
char *ptr;
ptr=strtok(fof," ");
while (ptr!=NULL) {
fnames.push_back(ptr);
filecount++;
ptr=strtok(NULL," ");
}
} else {
IN=fopen(fof,"rt");
if (IN!=NULL) {
long linecount=0;
while (fgets(linefof,5000-1,IN)!=NULL) {
linecount++;
if (linefof[0]!='#' && linefof[0]!='\n') {
char *ptr=strchr(linefof,'\n');
if (ptr!=NULL && ptr[0]=='\n') {
ptr[0]='\0';
}
FILE *dummy=NULL;
dummy=fopen(linefof,"rt");
if (dummy!=NULL) { // seems to be a file of filenames...
fclose(dummy);
fnames.push_back(linefof);
filecount++;
} else if (filecount==0 || linecount>=1000-1) { // seems to be a single file
fnames.push_back(fof);
filecount++;
break;
}
}
}
fclose(IN);
}
} //file or file name decided and stored in vector "fnames"
cerr << "the input mapping files are:" << endl;
vector <string>::iterator fit = fnames.begin();
for(; fit != fnames.end(); fit++) {
cerr << *fit << endl;
}
//-------------------------------------------------------------------------------------------------------+
// end of file or filenames |
//-------------------------------------------------------------------------------------------------------+
// open the BAM file(s)
BamMultiReader reader;
reader.Open(fnames);
// get header & reference information
string header = reader.GetHeaderText();
RefVector refs = reader.GetReferenceData();
// attempt to open BamWriter
BamWriter writer;
string outputBam = param->writer;
if ( outputBam != "" ) {
if ( !writer.Open(param->writer, header, refs) ) {
cerr << "Could not open output BAM file" << endl;
exit(0);
}
}
BamAlignment bam;
while (reader.GetNextAlignment(bam)) { //change RG
string rg = "RG";
string rgType = "Z";
string rgValue = "1";
bam.EditTag(rg,rgType,rgValue);
writer.SaveAlignment(bam);
} // read a bam
return 0;
} //main
示例2: main
//.........这里部分代码省略.........
logf << '\n';
}
modified_alignment_readcounter++;
}
else
{
if (logf.is_open ())
{
logf << alignment.Name << '\t' << alignment.IsReverseStrand() << '\t' << alignment.RefID << '\t' << setfill ('0') << setw (8) << orig_position << '\t' << "UNMOD";
if (clipfail)
logf << " NOCLIP";
logf << '\n';
}
}
if (aligner.verbose_){
cout << alignment.Name << endl;
cout << "------------------------------------------" << endl;
// Wait for input to continue or quit program
if (input.size() == 0)
input = 'x';
else if (input[0] != 'c' and input[0] != 'C')
getline(cin, input);
if (input.size()>0){
if (input[0] == 'q' or input[0] == 'Q')
return 1;
else if (input[0] == 's' or input[0] == 'S')
aligner.verbose_ = false;
}
}
// Finally update alignment information
alignment.CigarData = new_cigar_data;
alignment.EditTag("MD", "Z" , new_md_tag);
} // end of CreateRef else if
else {
switch (aligner.GetCreateRefError ())
{
case Realigner::CR_ERR_RECREATE_REF:
if (logf.is_open ())
logf << alignment.Name << '\t' << alignment.IsReverseStrand() << '\t' << alignment.RefID << '\t' << setfill ('0') << setw (8) << orig_position << '\t' << "RECRERR" << '\n';
error_recreate_ref_readcount++;
break;
case Realigner::CR_ERR_CLIP_ANCHOR:
if (logf.is_open ())
logf << alignment.Name << '\t' << alignment.IsReverseStrand() << '\t' << alignment.RefID << '\t' << setfill ('0') << setw (8) << orig_position << '\t' << "CLIPERR" << '\n';
error_clip_anchor_readcount++;
break;
default:
// On a good run this writes way too many reads to the log file - don't want to create a too large txt file
// if (logf.is_open ())
//logf << alignment.Name << '\t' << alignment.IsReverseStrand() << '\t' << alignment.RefID << '\t' << setfill ('0') << setw (8) << orig_position << '\t' << "PERFECT" << '\n';
already_perfect_readcount++;
break;
}
if (aligner.verbose_) {
cout << alignment.Name << endl;
cout << "------------------------------------------" << endl;
// Wait for input to continue or quit program
if (input.size() == 0)
input = 'x';
else if (input[0] != 'c' and input[0] != 'C')
getline(cin, input);
if (input.size()>0){