Skip to content

Commit 7919349

Browse files
committed
Added low memory usage option
1 parent ad33edb commit 7919349

File tree

5 files changed

+82
-12
lines changed

5 files changed

+82
-12
lines changed

Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ CFLAGS+= -g -Wall -O2 -UNDEBUG -march=native -Wno-deprecated
3535
CXXFLAGS+= ${CFLAGS}
3636
LIBS = -l boost_graph
3737

38+
.PHONY: low_mem
39+
low_mem: CXXFLAGS=${CFLAGS} -D LOW_MEM_USG
40+
low_mem: all
41+
3842
.PHONY: all
3943
all:action read_input
4044

@@ -54,7 +58,7 @@ read_input_OBJS= \
5458
${OBJ_DIR}/build_chains.o \
5559
${OBJ_DIR}/read_fasta.o \
5660
${OBJ_DIR}/table_entry.o \
57-
${OBJ_DIR}/RNA_seq.o \
61+
#${OBJ_DIR}/RNA_seq.o \
5862
5963
${BIN_DIR}/build_RNA_seq_graph: ${read_input_OBJS}
6064
@echo 'Linking $@'; \

src/graph_refinement.cpp

+28-8
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,14 @@ void linking_refinement(::std::vector<table_entry*> & links, map<unsigned long l
431431
CharString l_part = chains[chain_it->first];
432432
string new_link = seqan::toCString(seqan::suffix(l_part,length(l_part) - len));
433433
unsigned long long f_l = fingerprint(new_link);
434-
//NEW_OPT new_link.append(head);
434+
#if defined(LOW_MEM_USG)
435435
table_entry* t_new = new table_entry(f_l,fingerprint(head));
436-
//NEW_OPT table_entry* t_new = new table_entry(new_link,f_l,fingerprint(head));
436+
#endif
437+
438+
#if !defined(LOW_MEM_USG)
439+
new_link.append(head);
440+
table_entry* t_new = new table_entry(new_link,f_l,fingerprint(head));
441+
#endif
437442
t_new->push_D_link(chain_it->first);
438443
t_new->push_A_link(fingerprint(head));
439444
links.push_back(t_new);
@@ -495,9 +500,14 @@ void linking_refinement(::std::vector<table_entry*> & links, map<unsigned long l
495500
CharString l_part = chains[chain_it->first];
496501
string new_link = seqan::toCString(seqan::suffix(l_part,length(l_part) - len));
497502
unsigned long long f_l = fingerprint(new_link);
498-
//NEW_OPT new_link.append(head);
503+
#if defined(LOW_MEM_USG)
499504
table_entry* t_new = new table_entry(f_l,fingerprint(head));
500-
//NEW_OPT table_entry* t_new = new table_entry(new_link,f_l,fingerprint(head));
505+
#endif
506+
507+
#if !defined(LOW_MEM_USG)
508+
new_link.append(head);
509+
table_entry* t_new = new table_entry(new_link,f_l,fingerprint(head));
510+
#endif
501511
t_new->push_D_link(chain_it->first);
502512
t_new->push_A_link(fingerprint(head));
503513
links.push_back(t_new);
@@ -630,9 +640,14 @@ void check_overlapping_nodes(std::vector<table_entry*> & links, map<unsigned lon
630640
string first_half;
631641
assign(first_half,prefix(chains[short_blocks[i].frag_links.D_chain],len));
632642
string new_link_1 = first_half;
633-
//NEW_OPT new_link_1.append(ch);
643+
#if defined(LOW_MEM_USG)
634644
table_entry* link_1 = new table_entry(fingerprint(first_half),fingerprint(ch));
635-
//NEW_OPT table_entry* link_1 = new table_entry(new_link_1,fingerprint(first_half),fingerprint(ch));
645+
#endif
646+
647+
#if !defined(LOW_MEM_USG)
648+
new_link_1.append(ch);
649+
table_entry* link_1 = new table_entry(new_link_1,fingerprint(first_half),fingerprint(ch));
650+
#endif
636651
link_1->push_D_link(short_blocks[i].frag_links.D_chain);
637652
link_1->push_A_link(short_blocks[i].frag_links.A_chain);
638653
links.push_back(link_1);
@@ -654,9 +669,14 @@ void check_overlapping_nodes(std::vector<table_entry*> & links, map<unsigned lon
654669
string second_half;
655670
assign(first_half,prefix(chains[short_blocks[i].other_links[j].D_chain],len));
656671
string new_link_2 = second_half;
657-
//NEW_OPT new_link_2.append(ch);
672+
#if defined(LOW_MEM_USG)
658673
table_entry* link_2 = new table_entry(fingerprint(second_half),fingerprint(ch));
659-
//NEW_OPT table_entry* link_2 = new table_entry(new_link_2,fingerprint(second_half),fingerprint(ch));
674+
#endif
675+
676+
#if !defined(LOW_MEM_USG)
677+
new_link_2.append(ch);
678+
table_entry* link_2 = new table_entry(new_link_2,fingerprint(second_half),fingerprint(ch));
679+
#endif
660680
link_2->push_D_link(short_blocks[i].other_links[j].D_chain);
661681
link_2->push_A_link(short_blocks[i].other_links[j].A_chain);
662682
links.push_back(link_1);

src/read_fasta.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,13 @@ table_entry* build_entry(String<Dna5> seq){
5252
assign(left_seq,prefix(seq,length(seq)/2));
5353
string right_seq;
5454
assign(right_seq,suffix(seq,length(seq)/2));
55+
#if defined(LOW_MEM_USG)
5556
el = new table_entry(fingerprint(left_seq),fingerprint(right_seq));
56-
//NEW_OPT el = new table_entry(seq,fingerprint(left_seq),fingerprint(right_seq));
57+
#endif
58+
59+
#if !defined(LOW_MEM_USG)
60+
el = new table_entry(seq,fingerprint(left_seq),fingerprint(right_seq));
61+
#endif
5762
return el;
5863
}
5964
/*
@@ -336,8 +341,11 @@ int read_fasta(char* file_name, tables &t){
336341
::std::fstream fstrm;
337342
fstrm.open(file_name, ::std::ios_base::in | ::std::ios_base::binary);
338343
if(fstrm.is_open()){
344+
#if defined(LOW_MEM_USG)
345+
std::cerr << "Memory optimized process stared" << std::endl;
346+
#endif
339347
clock_t tStart = clock();
340-
::std::cerr << "Processing RNA-seq file..." << ::std::endl;
348+
std::cerr << "Processing RNA-seq file..." << std::endl;
341349
String<char> fasta_tag;
342350
String<Dna5> fasta_seq;
343351
int c = 0;

src/table_entry.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ unsigned long long fingerprint(const string& seq){
5959

6060

6161
//Constructors
62+
#if defined(LOW_MEM_USG)
6263
table_entry::table_entry(unsigned long long left_f, unsigned long long right_f){
6364

6465
this->l_next = NULL;
@@ -72,6 +73,26 @@ table_entry::table_entry(unsigned long long left_f, unsigned long long right_f){
7273
this->chain_prev = NULL;
7374
this->frequency = 1;
7475
}
76+
#endif
77+
78+
#if !defined(LOW_MEM_USG)
79+
table_entry::table_entry(String<Dna5>seq, unsigned long long left_f, unsigned long long right_f){
80+
seqan::assign(short_read,seq);
81+
this->l_next = NULL;
82+
this->l_prev = NULL;
83+
this->r_next = NULL;
84+
this->r_prev = NULL;
85+
86+
this->left_fingerprint = left_f;
87+
this->right_fingerprint = right_f;
88+
//this->junction_offset = 0;
89+
this->chain_next = NULL;
90+
this->chain_prev = NULL;
91+
this->frequency = 1;
92+
}
93+
#endif
94+
95+
7596
/* NEW_OPT
7697
table_entry::table_entry(String<Dna5> seq,
7798
unsigned long long left_f, unsigned long long right_f){

src/table_entry.h

+18-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ using namespace std;
4343

4444
class table_entry{
4545
private:
46+
#if !defined(LOW_MEM_USG)
47+
string short_read;
48+
#endif
4649
// NEW_OPT RNA_seq* short_read;
4750
//Table List
4851
table_entry* r_next;
@@ -65,8 +68,13 @@ class table_entry{
6568
std::vector<unsigned long long> D_delta;
6669
std::vector<unsigned long long> A_delta;
6770
//Constructors
71+
#if defined(LOW_MEM_USG)
6872
table_entry(unsigned long long, unsigned long long);
69-
//NEW_OPT table_entry(String<Dna5>, unsigned long long, unsigned long long);
73+
#endif
74+
75+
#if !defined(LOW_MEM_USG)
76+
table_entry(String<Dna5>, unsigned long long, unsigned long long);
77+
#endif
7078
//table_entry(String<Dna5>, string, string, unsigned long long, unsigned long long);
7179
//table_entry(String<Dna5>, string, string, int, unsigned long long, unsigned long long);
7280
//table_entry(String<Dna5>, string, string, int, int, long, int, unsigned long long, unsigned long long);
@@ -88,6 +96,7 @@ class table_entry{
8896
void set_chain_prev(table_entry*);
8997

9098
//Get Methods
99+
#if defined(LOW_MEM_USG)
91100
string get_RNA_seq_sequence() const{
92101
static const char* alph= "ACGT";
93102
unsigned long long f1=left_fingerprint;
@@ -109,6 +118,14 @@ class table_entry{
109118
}
110119
return seq;
111120
}
121+
#endif
122+
123+
#if !defined(LOW_MEM_USG)
124+
string get_RNA_seq_sequence() const{
125+
return short_read;
126+
}
127+
#endif
128+
112129
//NEW_OPT RNA_seq* get_short_read() const;
113130
table_entry* get_l_next() const;
114131
table_entry* get_l_prev() const;

0 commit comments

Comments
 (0)