Skip to content
Snippets Groups Projects
Commit b8fcde3a authored by Aaron's avatar Aaron
Browse files

Added support to BEDPE to allow optional fields at the end.

parent 19c4838c
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
No preview for this file type
chr1 10 20 chr1 19 120 a1 1 - - chr1 10 20 chr1 19 120 a1 1 + -
...@@ -134,6 +134,18 @@ void BedFilePE::reportBedPETab(const BEDPE &a) { ...@@ -134,6 +134,18 @@ void BedFilePE::reportBedPETab(const BEDPE &a) {
a.chrom2.c_str(), a.start2, a.end2, a.chrom2.c_str(), a.start2, a.end2,
a.name.c_str(), a.score.c_str(), a.strand1.c_str(), a.strand2.c_str()); a.name.c_str(), a.score.c_str(), a.strand1.c_str(), a.strand2.c_str());
} }
else if (this->bedType > 10) {
printf("%s\t%d\t%d\t%s\t%d\t%d\t%s\t%s\t%s\t%s\t", a.chrom1.c_str(), a.start1, a.end1,
a.chrom2.c_str(), a.start2, a.end2,
a.name.c_str(), a.score.c_str(), a.strand1.c_str(), a.strand2.c_str());
vector<string>::const_iterator othIt = a.otherFields.begin();
vector<string>::const_iterator othEnd = a.otherFields.end();
for ( ; othIt != othEnd; ++othIt) {
printf("%s\t", othIt->c_str());
}
printf("\t");
}
} }
...@@ -165,6 +177,18 @@ void BedFilePE::reportBedPENewLine(const BEDPE &a) { ...@@ -165,6 +177,18 @@ void BedFilePE::reportBedPENewLine(const BEDPE &a) {
a.chrom2.c_str(), a.start2, a.end2, a.chrom2.c_str(), a.start2, a.end2,
a.name.c_str(), a.score.c_str(), a.strand1.c_str(), a.strand2.c_str()); a.name.c_str(), a.score.c_str(), a.strand1.c_str(), a.strand2.c_str());
} }
else if (this->bedType > 10) {
printf("%s\t%d\t%d\t%s\t%d\t%d\t%s\t%s\t%s\t%s\t", a.chrom1.c_str(), a.start1, a.end1,
a.chrom2.c_str(), a.start2, a.end2,
a.name.c_str(), a.score.c_str(), a.strand1.c_str(), a.strand2.c_str());
vector<string>::const_iterator othIt = a.otherFields.begin();
vector<string>::const_iterator othEnd = a.otherFields.end();
for ( ; othIt != othEnd; ++othIt) {
printf("%s\t", othIt->c_str());
}
printf("\n");
}
} }
...@@ -228,6 +252,26 @@ bool BedFilePE::parseBedPELine (BEDPE &bed, const vector<string> &lineVector, co ...@@ -228,6 +252,26 @@ bool BedFilePE::parseBedPELine (BEDPE &bed, const vector<string> &lineVector, co
return true; return true;
} }
else if (this->bedType > 10) {
bed.chrom1 = lineVector[0];
bed.start1 = atoi(lineVector[1].c_str());
bed.end1 = atoi(lineVector[2].c_str());
bed.chrom2 = lineVector[3];
bed.start2 = atoi(lineVector[4].c_str());
bed.end2 = atoi(lineVector[5].c_str());
bed.name = lineVector[6];
bed.score = lineVector[7].c_str();
bed.strand1 = lineVector[8];
bed.strand2 = lineVector[9];
for (unsigned int i = 6; i < lineVector.size(); ++i) {
bed.otherFields.push_back(lineVector[i]);
}
return true;
}
else { else {
cerr << "Unexpected number of fields: " << lineNum << ". Verify that your files are TAB-delimited and that your BEDPE file has 6,7,8 or 10 fields. Exiting..." << endl; cerr << "Unexpected number of fields: " << lineNum << ". Verify that your files are TAB-delimited and that your BEDPE file has 6,7,8 or 10 fields. Exiting..." << endl;
exit(1); exit(1);
...@@ -301,6 +345,26 @@ bool BedFilePE::parseBedPELine (BEDPE &bed, const vector<string> &lineVector, co ...@@ -301,6 +345,26 @@ bool BedFilePE::parseBedPELine (BEDPE &bed, const vector<string> &lineVector, co
return true; return true;
} }
else if (this->bedType > 10) {
bed.chrom1 = lineVector[0];
bed.start1 = atoi(lineVector[1].c_str());
bed.end1 = atoi(lineVector[2].c_str());
bed.chrom2 = lineVector[3];
bed.start2 = atoi(lineVector[4].c_str());
bed.end2 = atoi(lineVector[5].c_str());
bed.name = lineVector[6];
bed.score = lineVector[7].c_str();
bed.strand1 = lineVector[8];
bed.strand2 = lineVector[9];
for (unsigned int i = 6; i < lineVector.size(); ++i) {
bed.otherFields.push_back(lineVector[i]);
}
return true;
}
else { else {
cerr << "Unexpected number of fields: " << lineNum << ". Verify that your files are TAB-delimited and that your BEDPE file has 6,7,8 or 10 fields. Exiting..." << endl; cerr << "Unexpected number of fields: " << lineNum << ". Verify that your files are TAB-delimited and that your BEDPE file has 6,7,8 or 10 fields. Exiting..." << endl;
exit(1); exit(1);
......
...@@ -34,6 +34,8 @@ struct BEDPE { ...@@ -34,6 +34,8 @@ struct BEDPE {
string strand1; string strand1;
string strand2; string strand2;
vector<string> otherFields;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment