Skip to content

Commit

Permalink
Running clang-format on all c++ source files
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdavidsmith committed Jun 23, 2024
1 parent 5b9b71f commit 505d18c
Show file tree
Hide file tree
Showing 25 changed files with 1,216 additions and 1,485 deletions.
246 changes: 106 additions & 140 deletions GenomicRegion.cpp

Large diffs are not rendered by default.

291 changes: 141 additions & 150 deletions GenomicRegion.hpp

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions MappedRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@
#include "MappedRead.hpp"
#include "smithlab_utils.hpp"

#include <fstream>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <string>

using std::string;
using std::runtime_error;
using std::string;

MappedRead::MappedRead(const string &line) {
std::istringstream is;
is.rdbuf()->pubsetbuf(const_cast<char*>(line.c_str()), line.size());
is.rdbuf()->pubsetbuf(const_cast<char *>(line.c_str()), line.size());

string chrom, name, tmp;
size_t start = 0ul, end = 0ul;
char strand = '\0';
double score;
if (is >> chrom >> start >> tmp) {
if (find_if(tmp.begin(), tmp.end(),
[](char c) {return !std::isdigit(c);}) == tmp.end()) {
[](char c) { return !std::isdigit(c); }) == tmp.end()) {
end = std::stol(tmp);
if (!(is >> name >> score >> strand >> seq))
throw runtime_error("bad line in MappedRead file: " + line);
Expand All @@ -55,11 +55,11 @@ MappedRead::MappedRead(const string &line) {
r = GenomicRegion(chrom, start, end, name, score, strand);
is >> scr;
}
else throw runtime_error("bad line in MappedRead file: " + line);
else
throw runtime_error("bad line in MappedRead file: " + line);
}

string
MappedRead::tostring() const {
string MappedRead::tostring() const {
std::ostringstream oss;
oss << r; // no chaining for the << of GenomicRegion
oss << '\t' << seq;
Expand Down
6 changes: 2 additions & 4 deletions MappedRead.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,15 @@ struct MappedRead {
std::string tostring() const;
};

template <class T> T&
operator>>(T &the_stream, MappedRead &mr) {
template <class T> T &operator>>(T &the_stream, MappedRead &mr) {
std::string buffer;
if (getline(the_stream, buffer)) {
mr = MappedRead(buffer);
}
return the_stream;
}

template <class T> T&
operator<<(T &the_stream, const MappedRead &mr) {
template <class T> T &operator<<(T &the_stream, const MappedRead &mr) {
the_stream << mr.tostring();
return the_stream;
}
Expand Down
Loading

0 comments on commit 505d18c

Please sign in to comment.