Commit e5878aaf authored by Neil Kindlon's avatar Neil Kindlon
Browse files

Merge remote-tracking branch 'upstream/master'

parents 78c266dc 59f252a8
......@@ -51,9 +51,9 @@ copyright = u'2009 - 2014, Aaron R. Quinlan & Neil Kindlon'
# built documents.
#
# The short X.Y version.
version = '2.22.1'
version = '2.23.0'
# The full version, including alpha/beta/rc tags.
release = '2.22.1'
release = '2.23.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......
......@@ -81,6 +81,12 @@ Option Description
**-id** Ignore features in B that are downstream of features in A. This option requires -D and follows its orientation rules for determining what is "downstream".
**-fu** Choose first from features in B that are upstream of features in A.
This option requires -D and follows its orientation rules for determining what is "upstream".
**-fd** Choose first from features in B that are downstream of features in A.
This option requires -D and follows its orientation rules for determining what is "downstream".
**-t** | Specify how ties for closest feature should be handled. This occurs when two features in B have exactly the same "closeness" with A. By default, all such features in B are reported.
| Here are all the options:
| - `all` Report all ties (default).
......@@ -91,6 +97,8 @@ Option Description
| - `each` Report closest records for each database (default).
| - `all` Report closest records among all databases.
**-k** Report the k closest hits. Default is 1. If tieMode = "all", all ties will still be reported.
**-names** When using *multiple databases* (`-b`), provide an alias for each that will appear instead of a fileId when also printing the DB record.
**-filenames** When using *multiple databases* (`-b`), show each complete filename instead of a fileId when also printing the DB record.
......
......@@ -138,6 +138,10 @@ void RecordOutputMgr::printRecord(const Record *record, const QuickString & valu
void RecordOutputMgr::printClosest(RecordKeyVector &keyList, const vector<int> *dists) {
//The first time we print a record is when we print any header, because the header
//hasn't been read from the query file until after the first record has also been read.
checkForHeader();
const ContextClosest *context = static_cast<const ContextClosest *>(_context);
bool deleteBlocks = false;
const Record *keyRec = keyList.getKey();
......@@ -203,6 +207,7 @@ void RecordOutputMgr::printRecord(RecordKeyVector &keyList, RecordKeyVector *blo
if (needsFlush()) {
flush();
}
//The first time we print a record is when we print any header, because the header
//hasn't been read from the query file until after the first record has also been read.
checkForHeader();
......
# This file was auto-generated by running "make setversion VERSION=v2.22.1"
# on Thu Jan 1 20:59:16 EST 2015 .
# This file was auto-generated by running "make setversion VERSION=v2.23.0"
# on Sun Feb 22 17:33:17 EST 2015 .
# Please do not edit or commit this file manually.
#
v2.22.1
v2.23.0
......@@ -11,10 +11,11 @@ Licenced under the GNU General Public License 2.0 license.
******************************************************************************/
#include "windowMaker.h"
WindowMaker::WindowMaker(string &fileName, ID_METHOD id_method, INPUT_FILE_TYPE input_file_type, uint32_t size, uint32_t step)
WindowMaker::WindowMaker(string &fileName, ID_METHOD id_method, INPUT_FILE_TYPE input_file_type, uint32_t size, uint32_t step, bool reverse)
: _size(size)
, _step(step)
, _count(0)
, _reverse(reverse)
, _window_method(FIXED_WINDOW_SIZE)
, _id_method(id_method)
{
......@@ -24,10 +25,11 @@ WindowMaker::WindowMaker(string &fileName, ID_METHOD id_method, INPUT_FILE_TYPE
MakeWindowsFromBED(fileName);
}
WindowMaker::WindowMaker(string &fileName, ID_METHOD id_method, INPUT_FILE_TYPE input_file_type, uint32_t count)
WindowMaker::WindowMaker(string &fileName, ID_METHOD id_method, INPUT_FILE_TYPE input_file_type, uint32_t count, bool reverse)
: _size(0)
, _step(0)
, _count(count)
, _reverse(reverse)
, _window_method(FIXED_WINDOW_COUNT)
, _id_method(id_method)
{
......@@ -76,10 +78,20 @@ void WindowMaker::MakeBEDWindow(const BED& interval)
MakeFixedCountWindow(interval);
}
uint32_t WindowMaker::CalculateWindows(const BED& interval) {
uint32_t num_windows = (interval.end - interval.start) / _step;
if ((interval.end - interval.start) % _step > 0) {
// add 1 to num_windows if the last window is less than _step
num_windows += 1;
}
return num_windows;
}
void WindowMaker::MakeFixedSizeWindow(const BED& interval) {
uint32_t i=1;
uint32_t num_windows = CalculateWindows(interval);
for (uint32_t start = interval.start; start <= interval.end; start += _step, ++i) {
string name = GenerateID(interval,i);
string name = GenerateID(interval, i, num_windows, _reverse);
if ((start + _size) <= interval.end) {
cout << interval.chrom << "\t" << start << "\t" << start + _size << name << endl;
}
......@@ -92,28 +104,39 @@ void WindowMaker::MakeFixedSizeWindow(const BED& interval) {
void WindowMaker::MakeFixedCountWindow(const BED& interval) {
uint32_t interval_size = interval.end - interval.start ;
uint32_t window_size = (interval_size-1)/_count + 1; // integer version of ceil(interval_size/_count)
if (window_size==0 || interval_size==0)
return;
uint32_t i=1;
for (uint32_t start = interval.start; start < interval.end; start += window_size, ++i) {
string name = GenerateID(interval,i);
string name = GenerateID(interval, i, _count, _reverse);
uint32_t end = min(start + window_size,interval.end);
cout << interval.chrom << "\t" << start << "\t" << end << name << endl;
}
}
string WindowMaker::GenerateID(const BED& interval, uint32_t window_index) const {
string WindowMaker::GenerateID(const BED& interval, uint32_t window_index, uint32_t num_windows, bool _reverse) const {
stringstream s;
// cout << "num_windows: " << num_windows << endl;
// cout << "window_index: " << window_index << endl << endl;
switch(_id_method) {
case ID_SOURCE_ID:
s << "\t" << interval.name;
break;
case ID_WINDOW_NUMBER:
s << "\t" << window_index;
if (_reverse == true && num_windows > 0) {
s << "\t" << num_windows - window_index + 1;
} else {
s << "\t" << window_index;
}
break;
case ID_SOURCE_ID_WINDOW_NUMBER:
s << "\t" << interval.name << "_" << window_index;
if (_reverse == true && num_windows > 0) {
s << "\t" << interval.name << "_" << num_windows - window_index + 1;
} else {
s << "\t" << interval.name << "_" << window_index;
}
default:
case ID_NONE:
break;
......
......@@ -37,8 +37,8 @@ public:
};
// constructor
WindowMaker(string &fileName, ID_METHOD id_method, INPUT_FILE_TYPE input_file_type, uint32_t count);
WindowMaker(string &fileName, ID_METHOD id_method, INPUT_FILE_TYPE input_file_type, uint32_t size, uint32_t step);
WindowMaker(string &fileName, ID_METHOD id_method, INPUT_FILE_TYPE input_file_type, uint32_t count, bool reverse);
WindowMaker(string &fileName, ID_METHOD id_method, INPUT_FILE_TYPE input_file_type, uint32_t size, uint32_t step, bool reverse);
// destructor
~WindowMaker(void);
......@@ -50,6 +50,7 @@ private:
uint32_t _size;
uint32_t _step;
uint32_t _count;
bool _reverse; // should window numbering be reversed?
WINDOW_METHOD _window_method;
ID_METHOD _id_method;
......@@ -57,6 +58,7 @@ private:
void MakeFixedSizeWindow(const BED& interval);
void MakeFixedCountWindow(const BED& interval);
uint32_t CalculateWindows(const BED& interval);
string GenerateID(const BED& interval, uint32_t window_index) const;
string GenerateID(const BED& interval, uint32_t window_index, uint32_t num_windows, bool _reverse) const;
};
......@@ -43,6 +43,7 @@ int windowmaker_main(int argc, char* argv[]) {
bool haveBed = false;
bool haveSize = false;
bool haveCount = false;
bool reverse = false;
for(int i = 1; i < argc; i++) {
int parameterLength = (int)strlen(argv[i]);
......@@ -112,6 +113,9 @@ int windowmaker_main(int argc, char* argv[]) {
i++;
}
}
else if(PARAMETER_CHECK("-reverse", 8, parameterLength)) {
reverse = true;
}
else {
cerr << endl << "*****ERROR: Unrecognized parameter: " << argv[i] << " *****" << endl << endl;
showHelp = true;
......@@ -142,9 +146,11 @@ int windowmaker_main(int argc, char* argv[]) {
if (!showHelp) {
WindowMaker *wm = NULL;
if (haveCount)
wm = new WindowMaker(inputFile, idMethod, inputFileType, count);
wm = new WindowMaker(inputFile, idMethod,
inputFileType, count, reverse);
if (haveSize)
wm = new WindowMaker(inputFile, idMethod, inputFileType, size, step);
wm = new WindowMaker(inputFile, idMethod,
inputFileType, size, step, reverse);
delete wm;
}
else {
......@@ -189,6 +195,10 @@ void windowmaker_help(void) {
cerr << "\t\tto fixed number of windows (i.e. same number of windows, with" << endl;
cerr << "\t\tvarying window sizes)." << endl << endl;
cerr << "\t-reverse" << endl;
cerr << "\t\t Reverse numbering of windows in the output, i.e. report " << endl;
cerr << "\t\t windows in decreasing order" << endl << endl;
cerr << "ID Naming Options: " << endl;
cerr << "\t-i src|winnum|srcwinnum" << endl;
cerr << "\t\tThe default output is 3 columns: chrom, start, end ." << endl;
......@@ -276,6 +286,25 @@ void windowmaker_help(void) {
cerr << " ..." << endl;
cerr << endl;
cerr << " # Reverse window numbers: "<< endl;
cerr << " $ cat input.bed" << endl;
cerr << " chr5 60000 70000 AAA" << endl;
cerr << " chr5 73000 90000 BBB" << endl;
cerr << " chr5 100000 101000 CCC" << endl;
cerr << " $ " << PROGRAM_NAME << " -b input.bed -n 3 -i winnum -reverse" << endl;
cerr << " chr5 60000 63334 3" << endl;
cerr << " chr5 63334 66668 2" << endl;
cerr << " chr5 66668 70000 1" << endl;
cerr << " chr5 73000 78667 3" << endl;
cerr << " chr5 78667 84334 2" << endl;
cerr << " chr5 84334 90000 1" << endl;
cerr << " chr5 100000 100334 3" << endl;
cerr << " chr5 100334 100668 2" << endl;
cerr << " chr5 100668 101000 1" << endl;
cerr << " ..." << endl;
cerr << endl;
cerr << " # Add a name column, based on the source ID + window number: "<< endl;
cerr << " $ cat input.bed" << endl;
cerr << " chr5 60000 70000 AAA" << endl;
......
chr5 60000 70000 AAA
chr5 73000 90000 BBB
chr5 100000 101000 CCC
BT=${BT-../../bin/bedtools}
check()
{
if diff $1 $2; then
echo ok
else
echo fail
fi
}
###########################################################
# Test window size / forward window numbering
############################################################
echo " makewindows.t01...\c"
echo \
"chr5 60000 65000 1
chr5 65000 70000 2
chr5 73000 78000 1
chr5 78000 83000 2
chr5 83000 88000 3
chr5 88000 90000 4
chr5 100000 101000 1" > exp
$BT makewindows -b input.bed -w 5000 -i winnum > obs
check obs exp
rm obs exp
###########################################################
# Test window size / reverse window numbering
############################################################
echo " makewindows.t02...\c"
echo \
"chr5 60000 65000 2
chr5 65000 70000 1
chr5 73000 78000 4
chr5 78000 83000 3
chr5 83000 88000 2
chr5 88000 90000 1
chr5 100000 101000 1" > exp
$BT makewindows -b input.bed -reverse -w 5000 -i winnum > obs
check obs exp
rm obs exp
###########################################################
# Test window+step size / forward window numbering
############################################################
echo " makewindows.t03...\c"
echo \
"chr5 60000 65000 1
chr5 62000 67000 2
chr5 64000 69000 3
chr5 66000 70000 4
chr5 68000 70000 5
chr5 73000 78000 1
chr5 75000 80000 2
chr5 77000 82000 3
chr5 79000 84000 4
chr5 81000 86000 5
chr5 83000 88000 6
chr5 85000 90000 7
chr5 87000 90000 8
chr5 89000 90000 9
chr5 100000 101000 1" > exp
$BT makewindows -b input.bed -w 5000 -s 2000 -i winnum > obs
check obs exp
rm obs exp
###########################################################
# Test window size / reverse window numbering
############################################################
echo " makewindows.t04...\c"
echo \
"chr5 60000 65000 5
chr5 62000 67000 4
chr5 64000 69000 3
chr5 66000 70000 2
chr5 68000 70000 1
chr5 73000 78000 9
chr5 75000 80000 8
chr5 77000 82000 7
chr5 79000 84000 6
chr5 81000 86000 5
chr5 83000 88000 4
chr5 85000 90000 3
chr5 87000 90000 2
chr5 89000 90000 1
chr5 100000 101000 1" > exp
$BT makewindows -b input.bed -reverse -w 5000 -s 2000 -i winnum > obs
check obs exp
rm obs exp
###########################################################
# Test fixed size / forward window numbering
############################################################
echo " makewindows.t05...\c"
echo \
"chr5 60000 63334 1
chr5 63334 66668 2
chr5 66668 70000 3
chr5 73000 78667 1
chr5 78667 84334 2
chr5 84334 90000 3
chr5 100000 100334 1
chr5 100334 100668 2
chr5 100668 101000 3" > exp
$BT makewindows -n 3 -b input.bed -i winnum > obs
check obs exp
rm obs exp
###########################################################
# Test fixed size / reverse window numbering
############################################################
echo " makewindows.t06...\c"
echo \
"chr5 60000 63334 3
chr5 63334 66668 2
chr5 66668 70000 1
chr5 73000 78667 3
chr5 78667 84334 2
chr5 84334 90000 1
chr5 100000 100334 3
chr5 100334 100668 2
chr5 100668 101000 1" > exp
$BT makewindows -n 3 -b input.bed -reverse -i winnum > obs
check obs exp
rm obs exp
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