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

Added check to fastaFromBed preventing sequences from being

extract beyond the length of a chromosome.
parent b8fcde3a
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
......@@ -73,16 +73,22 @@ void Bed2Fa::ExtractDNA() {
// loop through each BED entry for this chrom and
// print the sequence
for (unsigned int i = 0; i < bedList.size(); i++) {
string dna = currDNA.substr(bedList[i].start, ((bedList[i].end - bedList[i].start)));
unsigned int start = bedList[i].start;
unsigned int end = bedList[i].end;
if ( (start < currDNA.size()) && (end < currDNA.size()) ) {
string dna = currDNA.substr(bedList[i].start, ((bedList[i].end - bedList[i].start)));
if (!(this->useName)) {
faOut << ">" << currChrom << ":"
<< bedList[i].start << "-" << bedList[i].end << endl << dna << endl;
}
else {
faOut << ">" << bedList[i].name << endl << dna << endl;
}
if (!(this->useName)) {
faOut << ">" << currChrom << ":"
<< bedList[i].start << "-" << bedList[i].end << endl << dna << endl;
}
else {
faOut << ">" << bedList[i].name << endl << dna << endl;
}
}
else cerr << "Feature (" << bedList[i].chrom << ":" << start << "-" << end << ") beyond chromosome size. Ignoring." << endl;
}
currDNA = "";
}
......@@ -98,16 +104,22 @@ void Bed2Fa::ExtractDNA() {
// loop through each BED entry for this chrom and
// print the sequence.
for (unsigned int i = 0; i < bedList.size(); i++) {
string dna = currDNA.substr(bedList[i].start, ((bedList[i].end - bedList[i].start)));
unsigned int start = bedList[i].start;
unsigned int end = bedList[i].end;
if ( (start < currDNA.size()) && (end < currDNA.size()) ) {
string dna = currDNA.substr(bedList[i].start, ((bedList[i].end - bedList[i].start)));
if (!(this->useName)) {
faOut << ">" << currChrom << ":"
<< bedList[i].start << "-" << bedList[i].end << endl << dna << endl;
}
else {
faOut << ">" << bedList[i].name << endl << dna << endl;
}
if (!(this->useName)) {
faOut << ">" << currChrom << ":"
<< bedList[i].start << "-" << bedList[i].end << endl << dna << endl;
}
else {
faOut << ">" << bedList[i].name << endl << dna << endl;
}
}
else cerr << "Feature (" << bedList[i].chrom << ":" << start << "-" << end << ") beyond chromosome size. Ignoring." << endl;
}
currDNA = "";
}
......
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