Commit 69ca7e90 authored by Neil Kindlon's avatar Neil Kindlon
Browse files

Changed vector copies to references

parent 9724fbbe
......@@ -40,7 +40,7 @@ void BedSort::SortBed() {
for (masterBedMapNoBin::iterator m = _bed->bedMapNoBin.begin(); m != _bed->bedMapNoBin.end(); ++m) {
// bedList is already sorted by start position.
vector<BED> bedList = m->second;
const vector<BED> &bedList = m->second;
for (unsigned int i = 0; i < bedList.size(); ++i) {
_bed->reportBedNewLine(bedList[i]);
......@@ -105,7 +105,7 @@ void BedSort::SortBedOnFaidx()
if( m == _bed->bedMapNoBin.end() ) continue; //this chromosome is not present in BED
// bedList is already sorted by start position.
vector<BED> bedList = m->second;
const vector<BED> &bedList = m->second;
for (unsigned int i = 0; i < bedList.size(); ++i) {
_bed->reportBedNewLine(bedList[i]);
......@@ -124,11 +124,11 @@ void BedSort::SortBedBySizeAsc() {
for (masterBedMapNoBin::iterator m = _bed->bedMapNoBin.begin(); m != _bed->bedMapNoBin.end(); ++m) {
// bedList is already sorted by start position.
vector<BED> bedList = m->second;
const vector<BED> &bedList = m->second;
// add the entries from this chromosome to the current list
for (unsigned int i = 0; i < m->second.size(); ++i) {
masterList.push_back(m->second[i]);
for (unsigned int i = 0; i < bedList.size(); ++i) {
masterList.push_back(bedList[i]);
}
}
......@@ -151,11 +151,11 @@ void BedSort::SortBedBySizeDesc() {
for (masterBedMapNoBin::iterator m = _bed->bedMapNoBin.begin(); m != _bed->bedMapNoBin.end(); ++m) {
// bedList is already sorted by start position.
vector<BED> bedList = m->second;
const vector<BED> &bedList = m->second;
// add the entries from this chromosome to the current list
for (unsigned int i = 0; i < m->second.size(); ++i) {
masterList.push_back(m->second[i]);
for (unsigned int i = 0; i < bedList.size(); ++i) {
masterList.push_back(bedList[i]);
}
}
......@@ -174,7 +174,7 @@ void BedSort::SortBedByChromThenSizeAsc() {
for (masterBedMapNoBin::iterator m = _bed->bedMapNoBin.begin(); m != _bed->bedMapNoBin.end(); ++m) {
// bedList is already sorted by start position.
vector<BED> bedList = m->second;
vector<BED> &bedList = m->second;
sort(bedList.begin(), bedList.end(), sortBySizeAsc);
for (unsigned int i = 0; i < bedList.size(); ++i) {
......@@ -190,7 +190,7 @@ void BedSort::SortBedByChromThenSizeDesc() {
for (masterBedMapNoBin::iterator m = _bed->bedMapNoBin.begin(); m != _bed->bedMapNoBin.end(); ++m) {
// bedList is already sorted by start position.
vector<BED> bedList = m->second;
vector<BED> &bedList = m->second;
sort(bedList.begin(), bedList.end(), sortBySizeDesc);
......@@ -208,7 +208,7 @@ void BedSort::SortBedByChromThenScoreAsc() {
for (masterBedMapNoBin::iterator m = _bed->bedMapNoBin.begin(); m != _bed->bedMapNoBin.end(); ++m) {
// bedList is already sorted by start position.
vector<BED> bedList = m->second;
vector<BED> &bedList = m->second;
sort(bedList.begin(), bedList.end(), sortByScoreAsc);
for (unsigned int i = 0; i < bedList.size(); ++i) {
......@@ -230,7 +230,7 @@ void BedSort::SortBedByChromThenScoreDesc() {
for (masterBedMapNoBin::iterator m = _bed->bedMapNoBin.begin(); m != _bed->bedMapNoBin.end(); ++m) {
// bedList is already sorted by start position.
vector<BED> bedList = m->second;
vector<BED> &bedList = m->second;
sort(bedList.begin(), bedList.end(), sortByScoreDesc);
for (unsigned int i = 0; i < bedList.size(); ++i) {
......
#Header line for a.bed
chr7 240 560 x 86 -
chr7 210 525 d 21 +
chr7 2100 2310 e 32 +
chr3 40 260 p 41 -
chr3 10 220 f 12 +
chr3 100 320 g 96 -
chr9 140 160 z 05 +
chr9 110 120 a 81 -
chr9 1100 1120 b 12 +
chr9
chr3
chr7
BT=${BT-../../bin/bedtools}
check()
{
if diff $1 $2; then
echo ok
else
echo fail
fi
}
###########################################################
# Test default
############################################################
echo " intersect.t01...\c"
echo \
"chr3 10 220 f 12 +
chr3 40 260 p 41 -
chr3 100 320 g 96 -
chr7 210 525 d 21 +
chr7 240 560 x 86 -
chr7 2100 2310 e 32 +
chr9 110 120 a 81 -
chr9 140 160 z 05 +
chr9 1100 1120 b 12 +" > exp
$BT sort -i a.bed > obs
check obs exp
rm obs exp
###########################################################
# Test sizeA
############################################################
echo " intersect.t02...\c"
echo \
"chr9 110 120 a 81 -
chr9 140 160 z 05 +
chr9 1100 1120 b 12 +
chr3 10 220 f 12 +
chr7 2100 2310 e 32 +
chr3 40 260 p 41 -
chr3 100 320 g 96 -
chr7 210 525 d 21 +
chr7 240 560 x 86 -" > exp
$BT sort -i a.bed -sizeA > obs
check obs exp
rm obs exp
###########################################################
# Test sizeD
############################################################
echo " intersect.t03...\c"
echo \
"chr7 240 560 x 86 -
chr7 210 525 d 21 +
chr3 40 260 p 41 -
chr3 100 320 g 96 -
chr3 10 220 f 12 +
chr7 2100 2310 e 32 +
chr9 140 160 z 05 +
chr9 1100 1120 b 12 +
chr9 110 120 a 81 -" > exp
$BT sort -i a.bed -sizeD > obs
check obs exp
rm obs exp
###########################################################
# Test chrThenSizeA
############################################################
echo " intersect.t04...\c"
echo \
"chr3 10 220 f 12 +
chr3 40 260 p 41 -
chr3 100 320 g 96 -
chr7 2100 2310 e 32 +
chr7 210 525 d 21 +
chr7 240 560 x 86 -
chr9 110 120 a 81 -
chr9 140 160 z 05 +
chr9 1100 1120 b 12 +" > exp
$BT sort -i a.bed -chrThenSizeA > obs
check obs exp
rm obs exp
###########################################################
# Test chrThenSizeD
############################################################
echo " intersect.t05...\c"
echo \
"chr3 40 260 p 41 -
chr3 100 320 g 96 -
chr3 10 220 f 12 +
chr7 240 560 x 86 -
chr7 210 525 d 21 +
chr7 2100 2310 e 32 +
chr9 140 160 z 05 +
chr9 1100 1120 b 12 +
chr9 110 120 a 81 -" > exp
$BT sort -i a.bed -chrThenSizeD > obs
check obs exp
rm obs exp
###########################################################
# Test chrThenScoreA
############################################################
echo " intersect.t06...\c"
echo \
"chr3 10 220 f 12 +
chr3 40 260 p 41 -
chr3 100 320 g 96 -
chr7 210 525 d 21 +
chr7 2100 2310 e 32 +
chr7 240 560 x 86 -
chr9 140 160 z 05 +
chr9 1100 1120 b 12 +
chr9 110 120 a 81 -" > exp
$BT sort -i a.bed -chrThenScoreA > obs
check obs exp
rm obs exp
###########################################################
# Test chrThenScoreD
############################################################
echo " intersect.t07...\c"
echo \
"chr3 100 320 g 96 -
chr3 40 260 p 41 -
chr3 10 220 f 12 +
chr7 240 560 x 86 -
chr7 2100 2310 e 32 +
chr7 210 525 d 21 +
chr9 110 120 a 81 -
chr9 1100 1120 b 12 +
chr9 140 160 z 05 +" > exp
$BT sort -i a.bed -chrThenScoreD > obs
check obs exp
rm obs exp
###########################################################
# Test faidx
############################################################
echo " intersect.t08...\c"
echo \
"chr9 110 120 a 81 -
chr9 140 160 z 05 +
chr9 1100 1120 b 12 +
chr3 10 220 f 12 +
chr3 40 260 p 41 -
chr3 100 320 g 96 -
chr7 210 525 d 21 +
chr7 240 560 x 86 -
chr7 2100 2310 e 32 +" > exp
$BT sort -i a.bed -faidx names.txt > obs
check obs exp
rm obs exp
###########################################################
# Test header
############################################################
echo " intersect.t09...\c"
echo \
"#Header line for a.bed
chr3 10 220 f 12 +
chr3 40 260 p 41 -
chr3 100 320 g 96 -
chr7 210 525 d 21 +
chr7 240 560 x 86 -
chr7 2100 2310 e 32 +
chr9 110 120 a 81 -
chr9 140 160 z 05 +
chr9 1100 1120 b 12 +" > exp
$BT sort -i a.bed -header > obs
check obs exp
rm obs exp
......@@ -52,6 +52,9 @@ cd reldist; bash test-reldist.sh; cd ..
echo " Testing bedtools slop:"
cd slop; bash test-slop.sh; cd ..
echo " Testing bedtools sort:"
cd slop; bash test-sort.sh; cd ..
echo " Testing bedtools shuffle:"
cd shuffle; bash test-shuffle.sh; cd ..
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment