Skip to content

Commit 8950c94

Browse files
committed
Clang format
1 parent f25d92d commit 8950c94

28 files changed

+267
-298
lines changed

src/abundance.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#include "abundance.h"
2-
#include "pimpl.h"
3-
#include <fmt/format.h>
42

3+
#include <fmt/format.h>
54
#include <transcript_abundance.h>
5+
66
#include <cstdlib>
77
#include <string>
88

99
#include "module.h"
10+
#include "pimpl.h"
1011
#include "python_runner.h"
1112
#include "util.h"
1213

src/fasta.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,3 @@ read_fasta_fast(const string& fasta_path) {
5959
return contig2seq;
6060
}
6161
#endif
62-

src/filter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,3 @@ class Filter_module::impl : public tksm_module {
231231
};
232232

233233
MODULE_IMPLEMENT_PIMPL_CLASS(Filter_module);
234-

src/fusion.cpp

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,23 @@
22

33
#include <cgranges/IITree.h>
44

5+
#include <algorithm>
56
#include <cxxopts.hpp>
7+
#include <fstream>
68
#include <optional>
79
#include <random>
810
#include <ranges>
911
#include <set>
1012
#include <string>
1113
#include <variant>
1214
#include <vector>
13-
#include <fstream>
14-
#include <algorithm>
15-
1615

1716
#include "gtf.h"
1817
#include "interval.h"
1918
#include "mdf.h"
2019
#include "module.h"
2120
#include "util.h"
2221

23-
2422
using std::set;
2523
using std::string;
2624
using std::unordered_map;
@@ -108,31 +106,31 @@ event_type_to_string(EventType type) -> string {
108106
}
109107
}
110108

111-
inline auto string_to_event_type(const string &st) -> EventType {
109+
inline auto
110+
string_to_event_type(const string &st) -> EventType {
112111
string str{st};
113112
sr::transform(str.begin(), str.end(), str.begin(), ::tolower);
114-
if(str=="INVERSION"){
113+
if (str == "INVERSION") {
115114
return EventType::INVERSION;
116115
}
117-
else if(str=="DELETION"){
116+
else if (str == "DELETION") {
118117
return EventType::DELETION;
119118
}
120-
else if(str=="TRANSLOCATION"){
119+
else if (str == "TRANSLOCATION") {
121120
return EventType::TRANSLOCATION;
122121
}
123-
else if(str=="DUPLICATION"){
122+
else if (str == "DUPLICATION") {
124123
return EventType::DUPLICATION;
125124
}
126-
else if(str=="INSERTION"){
125+
else if (str == "INSERTION") {
127126
return EventType::INSERTION;
128127
}
129-
else if(str=="NONE"){
128+
else if (str == "NONE") {
130129
return EventType::NONE;
131130
}
132-
else{
131+
else {
133132
throw runtime_error("Invalid event type " + str);
134133
}
135-
136134
}
137135

138136
class chimeric_event : public ginterval {
@@ -146,12 +144,26 @@ class chimeric_event : public ginterval {
146144
string orientation2;
147145
int count;
148146
// Event
149-
chimeric_event(EventType event_type) : ginterval{}, event_type{event_type}, event_ratio{0.5}, event_name{"::"}{}
150-
151-
chimeric_event(const string &chr, int start, int end, const string &orientation, const string& orientation2, const string &chr2, EventType event_type, const string &event_name, int count)
152-
: ginterval{chr, start, end, orientation}, event_type{event_type}, event_ratio{0.5}, event_name{event_name}, chr2{chr2}, orientation2{orientation2}, count{count}{}
153-
chimeric_event(const string &chr, int start, int end, const string &orientation, const string& orientation2, const string &chr2, EventType event_type, const string &event_name)
154-
: ginterval{chr, start, end, orientation}, event_type{event_type}, event_ratio{0.5}, event_name{event_name}, chr2{chr2}, orientation2{orientation2}, count{0}{}
147+
chimeric_event(EventType event_type) : ginterval{}, event_type{event_type}, event_ratio{0.5}, event_name{"::"} {}
148+
149+
chimeric_event(const string &chr, int start, int end, const string &orientation, const string &orientation2,
150+
const string &chr2, EventType event_type, const string &event_name, int count)
151+
: ginterval{chr, start, end, orientation},
152+
event_type{event_type},
153+
event_ratio{0.5},
154+
event_name{event_name},
155+
chr2{chr2},
156+
orientation2{orientation2},
157+
count{count} {}
158+
chimeric_event(const string &chr, int start, int end, const string &orientation, const string &orientation2,
159+
const string &chr2, EventType event_type, const string &event_name)
160+
: ginterval{chr, start, end, orientation},
161+
event_type{event_type},
162+
event_ratio{0.5},
163+
event_name{event_name},
164+
chr2{chr2},
165+
orientation2{orientation2},
166+
count{0} {}
155167

156168
chimeric_event(const chimeric_event &other) = default;
157169
auto cut_transcript(const transcript &t, int cut_position, CUT cut) const
@@ -393,7 +405,8 @@ class chimeric_event : public ginterval {
393405
locus get_start(bool strand = true) const { return locus{chr, start, strand}; }
394406
locus get_end(bool strand = true) const { return locus{chr, end, strand}; }
395407
friend ostream &operator<<(ostream &os, const chimeric_event &event) {
396-
os << event.chr << "\t" << event.start << "\t" << event.end << "\t" << event_type_to_string(event.event_type) << "\t" << event.chr2 << "\t" << event.event_name;
408+
os << event.chr << "\t" << event.start << "\t" << event.end << "\t" << event_type_to_string(event.event_type)
409+
<< "\t" << event.chr2 << "\t" << event.event_name;
397410
return os;
398411
}
399412
};
@@ -409,20 +422,22 @@ read_fusions(std::istream &fusion_file) {
409422
string chr1, chr2, orientation1, orientation2, event_name;
410423
int start1, end1;
411424
double count;
412-
iss >> chr1 >> start1 >> end1 >> orientation1 >> orientation2 >> chr2 >> event_name >> count;
425+
iss >> chr1 >> start1 >> end1 >> orientation1 >> orientation2 >> chr2 >> event_name >> count;
413426
std::stringstream oss;
414427
oss << chr1 << ":" << start1 << "-" << end1 << orientation1;
415-
EventType et = [&] () -> EventType {
428+
EventType et = [&]() -> EventType {
416429
if (chr1 == chr2) {
417430
if (orientation1 == orientation2) {
418431
return EventType::DELETION;
419-
} else {
432+
}
433+
else {
420434
return EventType::DUPLICATION;
421435
}
422-
} else {
436+
}
437+
else {
423438
return EventType::TRANSLOCATION;
424439
}
425-
} ();
440+
}();
426441
chimeric_event fusion{chr1, start1, end1, orientation1, orientation2, chr2, et, event_name, count};
427442
fusions.push_back(fusion);
428443
}
@@ -578,8 +593,14 @@ class Fusion_submodule : public tksm_submodule {
578593

579594
locus g1 = generate_random_breakpoint(gene1);
580595
locus g2 = generate_random_breakpoint(gene2);
581-
chimeric_event fusion{g1.get_chr(), g1.get_position(), g2.get_position(),
582-
g1.is_plus_strand() ? "+" : "-",g2.is_plus_strand() ? "+" : "-", g2.get_chr(), event_type, gene1.info.at("gene_name") + "::" + gene2.info.at("gene_name")};
596+
chimeric_event fusion{g1.get_chr(),
597+
g1.get_position(),
598+
g2.get_position(),
599+
g1.is_plus_strand() ? "+" : "-",
600+
g2.is_plus_strand() ? "+" : "-",
601+
g2.get_chr(),
602+
event_type,
603+
gene1.info.at("gene_name") + "::" + gene2.info.at("gene_name")};
583604
logd("Generated fusion: {}, on genes {} and {}", fusion, gene1.info["gene_name"],
584605
gene2.info["gene_name"]);
585606
fusions_so_far.push_back(fusion);
@@ -641,7 +662,7 @@ class Fusion_submodule : public tksm_submodule {
641662

642663
map<string, std::pair<gtf, vector<gtf>>> expressed_genes;
643664
for (const auto &[name, gene] : genes) {
644-
if(gene.first.info.at("gene_biotype") != "protein_coding") continue;
665+
if (gene.first.info.at("gene_biotype") != "protein_coding") continue;
645666
auto iter = expression_map.find(name);
646667
if (iter != expression_map.end() && iter->second > 0) {
647668
expressed_genes[name] = gene;
@@ -756,7 +777,7 @@ class Fusion_submodule : public tksm_submodule {
756777
const auto &genes, auto &gene_expression_map,
757778
const unordered_map<string, unordered_map<string, double>> &tid_to_tpm,
758779
const auto &tid_to_gene, const auto &transcript_templates, const auto &args)
759-
-> generator<std::tuple<chimeric_event, transcript>>{
780+
-> generator<std::tuple<chimeric_event, transcript>> {
760781
bool do_fall_back_to_expression = args.count("expression-fallback") > 0;
761782
auto tpm_dist = [&]() {
762783
if (do_fall_back_to_expression) {
@@ -800,7 +821,7 @@ class Fusion_submodule : public tksm_submodule {
800821
logd("Skipping empty fusion transcript {}", t.info.at("transcript_id"));
801822
continue;
802823
}
803-
co_yield {event, t};
824+
co_yield {event, t};
804825
}
805826
}
806827
}
@@ -829,7 +850,7 @@ class Fusion_submodule : public tksm_submodule {
829850
[[maybe_unused]] double translocation_ratio = args["translocation-ratio"].as<double>();
830851
[[maybe_unused]] bool disable_deletions = args["disable-deletions"].as<bool>();
831852

832-
if(args.count ("fusion-output") == 0) {
853+
if (args.count("fusion-output") == 0) {
833854
loge("No fusion output file specified");
834855
return 1;
835856
}
@@ -859,8 +880,8 @@ class Fusion_submodule : public tksm_submodule {
859880
transcript_id_to_genes, transcript_templates, args)) {
860881
abundances.emplace_back(t.info.at("transcript_id"), t.get_abundance(), t.info.at("CB"));
861882
transcript_templates.emplace(t.info.at("transcript_id"), t);
862-
print_tsv(fusion_out, event, t.info.at("gene_id"), t.info.at("gene_name"), t.info.at("transcript_id"), t.info.at("transcript_name"), t.get_abundance());
863-
883+
print_tsv(fusion_out, event, t.info.at("gene_id"), t.info.at("gene_name"), t.info.at("transcript_id"),
884+
t.info.at("transcript_name"), t.get_abundance());
864885
}
865886
update_expression_of_affected_transcripts(relevant_molecules, abundances);
866887
return 0;
@@ -889,4 +910,3 @@ class Fusion_submodule : public tksm_submodule {
889910
}
890911
}
891912
};
892-

src/fusion.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#ifndef _FUSION_H
22
#define _FUSION_H
33

4-
5-
6-
74
#endif

src/generator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#define GENERATOR_H
33

44
#include <coroutine>
5-
#include <exception>
65
#include <cppcoro/generator.hpp>
6+
#include <exception>
77
using cppcoro::generator;
88

99
#endif // GENERATOR_H

src/head.cpp

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#include "head.h"
2-
#include <iterator>
3-
#include <string>
2+
3+
#include <cxxopts.hpp>
44
#include <fstream>
5+
#include <iterator>
56
#include <random>
7+
#include <string>
68
#include <variant>
79

8-
#include <cxxopts.hpp>
9-
1010
#include "interval.h"
1111
#include "mdf.h"
1212
#include "util.h"
@@ -15,41 +15,37 @@ using std::string;
1515

1616
std::mt19937 rand_gen{std::random_device{}()};
1717

18-
int main(int argc, char **argv){
19-
18+
int
19+
main(int argc, char **argv) {
2020
cxxopts::Options options("tksm head module", "head");
2121

22-
options.add_options()
23-
("n,count", "Number of molecule description", cxxopts::value<int>()->default_value("10"))
24-
("h,help", "Help screen")
25-
;
22+
options.add_options()("n,count", "Number of molecule description", cxxopts::value<int>()->default_value("10"))(
23+
"h,help", "Help screen");
2624
auto args = options.parse(argc, argv);
2725

28-
if(args.count("help") > 0){
26+
if (args.count("help") > 0) {
2927
fmt::print("{}\n", options.help());
3028
return 0;
3129
}
3230
std::vector<string> mandatory = {};
3331

3432
int missing_parameters = 0;
35-
for( string &param : mandatory){
36-
if(args.count(param) == 0){
33+
for (string &param : mandatory) {
34+
if (args.count(param) == 0) {
3735
report_missing_parameter(param);
3836
++missing_parameters;
3937
}
4038
}
4139

42-
if(missing_parameters > 0){
40+
if (missing_parameters > 0) {
4341
std::cerr << options.help() << std::endl;
4442
return 1;
4543
}
4644

47-
48-
4945
int cnt = args["count"].as<int>();
50-
for(const auto &md : stream_mdf(std::cin)){
46+
for (const auto &md : stream_mdf(std::cin)) {
5147
std::cout << md;
52-
if(--cnt == 0){
48+
if (--cnt == 0) {
5349
break;
5450
}
5551
}

src/head.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Head_module : public tksm_module {
4141
describe_program();
4242

4343
int count = args["count"].as<int>();
44-
for(auto &md : stream_mdf(std::cin, true)) {
44+
for (auto &md : stream_mdf(std::cin, true)) {
4545
std::cout << md;
4646
if (--count == 0) {
4747
break;

src/headers.h

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef _HEADERS_H_
22
#define _HEADERS_H_
33

4-
//Include Stable headers for precompilation
4+
// Include Stable headers for precompilation
55

66
// Include fmtlib
77
#include <fmt/format.h>
@@ -19,28 +19,26 @@
1919
#include <Python.h>
2020

2121
// Include stl headers
22+
#include <algorithm>
23+
#include <fstream>
24+
#include <functional>
2225
#include <iostream>
23-
#include <string>
24-
#include <vector>
2526
#include <map>
26-
#include <unordered_map>
27+
#include <memory>
2728
#include <set>
29+
#include <sstream>
30+
#include <string>
31+
#include <unordered_map>
2832
#include <unordered_set>
29-
#include <algorithm>
30-
#include <memory>
3133
#include <utility>
32-
#include <functional>
33-
#include <sstream>
34-
#include <fstream>
34+
#include <vector>
3535

3636
// Include internal stable headers
37-
#include "util.h"
38-
#include "interval.h"
3937
#include "cigar.h"
40-
#include "mdf.h"
4138
#include "gtf.h"
39+
#include "interval.h"
40+
#include "mdf.h"
4241
#include "reverse_complement.h"
43-
44-
42+
#include "util.h"
4543

4644
#endif

0 commit comments

Comments
 (0)