-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdata_manager.h
1080 lines (539 loc) · 21.7 KB
/
data_manager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//***************DATA_MANAGER.H************************
//
//Main class that controls the input/output and handles data storage and data conversions
//
//
//Author: Rong She
//Date: April 2007
//***********************************************
#ifndef DATA_MANAGER_H /* DATA_MANAGER_H */
#define DATA_MANAGER_H
//#define DEBUG_VERSION
//#define VERBOSE
#define COMMAND_WITH_BLAST //run it in command line mode (with blast integrated)
#define PERFORMANCE //record performance numbers in perform.txt
//#define TIMING
//GENEWISE_COMMAND no longer used in #define
//#define GENEWISE_COMMAND //run genewise from command line, requires target sequence file to be prepared from genBlastA result (one gene at a time!)
//#define GENEWISE_PERFORMANCE //record genewise command running time
#define GENBLASTG //do we need to run gblastg?
//#define GENBLASTG_NEED_PID //do we need to compute gblastg final alignment pid? (GENBLASTG must be defined)
//now replace GENBLASTG_NO_REPAIR by REPAIR_HSP_AFTER_EXON!
//#define GENBLASTG_NO_REPAIR //try this for EvsE set (when target genome is the same as query) (turn off REPAIR_HSP_AFTER_EXON)
//the following define is for evaluating against other predictions (not real truth), we compare their alignment PID
//#define GENEWISE //do we need to compute genewise final alignment pid?
//#define WORMBASE //do we need to compute wormbase final alignment pid?
//#define OTHERS_FINAL_ALIGN_KEEP_STOP //do we compute genewise/wormbase pid with internal stops kept?
//#define EVAL_ON_TRUE_EXONS //this is the case for EvsE wormbase exons (wormbase annotations are supposed to be REAL TRUTH)
//#define SKIP_VERSION
//#define DEBUG
//#define USE_CHAR_ARR_IN_STORE_SEQ
#define V23_EXTRA_IS_GAP
#define PID_BEFORE_SCORE
//#define USE_LAST_HSP_WHEN_HAS_STOP
//#define V23_ALL_HSP_GAP_SPLICE_SEGMENT
//#define COMPUT_EXON_FULL_STEP_BACK
#define MEMORY_LIMIT_SW 81920000 //80M, this roughly translates to 80M*4(sizeof(int))*3(num_of_arrays) ~ 960M memory, so about 1G memory is needed
#include "edge.h"
#include "scores.h"
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <list>
#include <numeric>
#include <sstream>
using namespace std;
#if defined(__GNUC__)
#if defined(__APPLE__) && defined(__MACH__) /*mac os X*/
#define IMPLICIT_LFS_64
typedef fpos_t file_pos64; /*Mac does implicit large file support*/
#else
typedef fpos64_t file_pos64;
#endif
#elif defined(_MSC_VER) || defined(__BORLANDC__)
#define IMPLICIT_LFS_64
typedef __int64 file_pos64;
#else
#error This compiler is not supported (need GNU CC, MSC, or BORLANDC).
#endif
//=================================================================================//
/* the basic struct that stores HSPs */
struct HSP_Gene_Pair
{
int ID;
// string chr;
int gene_start;
int gene_end;
int HSP_start;
int HSP_end;
float pid;
HSP_node* node; //used for deleting the nodes
bool hasOverlap; //used for AddSkipEdge()
HSP_Gene_Pair() { node = 0; }
HSP_Gene_Pair(int i, int gstart, int gend, int hstart, int hend, float pid): ID(i),
gene_start(gstart), gene_end(gend), HSP_start(hstart), HSP_end(hend), pid(pid), node(0) {
hasOverlap = false;
}
//check whether two HSPs overlap
bool Overlap(HSP_Gene_Pair* prev_HSP, int& gOL_start, int& gOL_end,
int& hOL_start, int& hOL_end, bool& g_align, bool& h_align);
bool FitWithNeighborHSPs(HSP_Gene_Pair* neighborHSP, bool isPosStrand);
bool HSPInRegion(int region_start, int region_end);
bool operator<(const HSP_Gene_Pair& h) const
{ return HSP_start < h.HSP_start || (HSP_start == h.HSP_start && HSP_end < h.HSP_end); }
friend ostream& operator<<(ostream& os, const HSP_Gene_Pair& h)
{
os << "HSP_ID["<< h.ID << "]:(" << h.HSP_start << "-" << h.HSP_end << ");" << "query:(" << h.gene_start << "-" << h.gene_end << "); pid: " << h.pid
<< "\n";
return os;
}
};
//=================================================================================//
/* stores computed HSP groups, for output purposes (used in DataManager) */
struct Group_Info
{
float score;
int HSP_start;
int HSP_end;
int gene_cover_len;
int chr_index;
bool isPosStrand;
Group_Info(float s, int h_start, int h_end, int gene_cover, int chr, bool isPos): score(s), HSP_start(h_start), HSP_end(h_end),
gene_cover_len(gene_cover), chr_index(chr), isPosStrand(isPos) { }
bool operator<(const Group_Info& g) const
{ return score > g.score || (score == g.score && chr_index < g.chr_index )
|| (score == g.score && chr_index == g.chr_index && HSP_start < g.HSP_start);
}
friend ostream& operator<<(ostream& os, const Group_Info& info)
{
os << "score: " << info.score << "; region: " << info.HSP_start << "-" << info.HSP_end
<< "; gene cover: " << info.gene_cover_len << "\n";
return os;
}
};
/*struct Group_Rank_Count
{
//int group_index;
int count; //absolute position of the current group in all groups, start from 1
int rank;
Group_Rank_Count(int r, int c): rank(r), count(c) {}
};*/
struct Group_RegEnd_Count
{
int region_end;
vector<int> group_count;
Group_RegEnd_Count(int e, vector<int>& v)
{
region_end = e;
group_count = v;
}
};
//struct Group_Rank_Count
struct Group_Count_RegStart_RegEnd
{
//int group_index;
int count; //absolute position of the current group in all groups, start from 1
//int rank;
int region_start;
int region_end;
//Group_Rank_Count(int r, int c): rank(r), count(c) {}
Group_Count_RegStart_RegEnd(int c, int s, int e): count(c), region_start(s), region_end(e) {}
bool operator<(const Group_Count_RegStart_RegEnd& g) const
{
return (region_start < g.region_start) || (region_start == g.region_start && region_end < g.region_end)
|| (region_start == g.region_start && region_end == g.region_end && count < g.count);
}
};
//=================================================================================//
/* stores input alignments from ".align" file */
struct Input_Alignment
{
string query_align;
string target_align;
string match_align;
Input_Alignment() {}
Input_Alignment(string s1, string s2, string match): query_align(s1), target_align(s2), match_align(match) {}
Input_Alignment(const Input_Alignment& align)
{
query_align = align.query_align;
target_align = align.target_align;
match_align = align.match_align;
}
int GetAlignmentScore(int start_index, int end_index)
{
int score = 0;
bool opengap = false;
bool opengap_cur = false;
for (int i=start_index; i<end_index; i++)
{
score += similarity_score(query_align[i], target_align[i], opengap, opengap_cur);
opengap = opengap_cur;
}
return score;
}
friend ostream& operator<<(ostream& os, const Input_Alignment& align)
{
os << "query:" << align.query_align << "\n";
os << "match:" << align.match_align << "\n";
os << "targt:" << align.target_align << "\n";
return os;
}
};
//******************************************************************//
struct align_compare {
int align_score;
float align_pid;
align_compare(): align_score(0), align_pid(0) {}
align_compare(int score, float pid): align_score(score), align_pid(pid) {}
bool operator==(const align_compare& ac) const {return align_pid == ac.align_pid && align_score == ac.align_score; }
#ifdef PID_BEFORE_SCORE //DOESN'T WORK, this is defined in data_manager.h, which hasn't be defined yet! OUCH, darn circular declarations!
bool operator>(const align_compare& ac) const {
return align_pid > ac.align_pid || ((align_pid == ac.align_pid) && (align_score > ac.align_score));
}
#else
bool operator>(const align_compare& ac) const {
return (align_score > ac.align_score) || ((align_score == ac.align_score) && (align_pid > ac.align_pid));
}
#endif
friend ostream& operator<<(ostream& os, const align_compare& ac)
{
os << "align_score:" << ac.align_score << "; align_pid:" << ac.align_pid << ";";
return os;
}
};
struct RankAlignment
{
//float pid;
align_compare pid;
int len;
int match_minus_gap_mismatch;
// float pid_optimal;
//Updated: this source_len ranking doesn't seem to be correct, so not used any more
// int source_len; //the total length of original alignments (donor_alignment and acceptor_alignment) (before splice align)
//RankAlignment(float p, int l, int m)//, int sl)
RankAlignment(align_compare p, int l, int m)
{
pid = p;
len = l;
match_minus_gap_mismatch = m;
// source_len = sl;
}
bool operator==(const RankAlignment& ra) const
{
return pid == ra.pid && len == ra.len && match_minus_gap_mismatch == ra.match_minus_gap_mismatch;
//&& source_len == ra.source_len;
}
bool operator<(const RankAlignment& ra) const
{
// return match_minus_gap_mismatch > ra.match_minus_gap_mismatch ||
// (match_minus_gap_mismatch == ra.match_minus_gap_mismatch && pid > ra.pid) ||
// (match_minus_gap_mismatch == ra.match_minus_gap_mismatch && pid == ra.pid && len < ra.len);
return pid > ra.pid || (pid == ra.pid && match_minus_gap_mismatch > ra.match_minus_gap_mismatch) ||
(pid == ra.pid && match_minus_gap_mismatch == ra.match_minus_gap_mismatch && len < ra.len); // ||
//(pid == ra.pid && match_minus_gap_mismatch == ra.match_minus_gap_mismatch && len == ra.len && source_len < ra.source_len);
}
friend ostream& operator<<(ostream& os, const RankAlignment& ra)
{
os << "pid:" << ra.pid << "; align_len:" << ra.len << "; match-gap/mismatch:" << ra.match_minus_gap_mismatch;
//<< "; source_len:" << ra.source_len;
return os;
}
};
//=================================================================================//
/* stores splice sites for each strand of each chromosome */
/* positive strand use positive integers, negative strand use negative integers */
struct Splice_Sites
{
vector<int> acceptors;
vector<int> donors;
Splice_Sites()
{
acceptors.clear();
donors.clear();
}
void LoadSite(int site, bool isAcceptor)
{
if (isAcceptor)
acceptors.push_back(site);
else
donors.push_back(site);
}
};
//=================================================================================//
struct PairExonSiteInfo
{
ExonSiteInfo prev_exon_start;
ExonSiteInfo prev_exon_end;
ExonSiteInfo cur_exon_start;
ExonSiteInfo cur_exon_end;
PairExonSiteInfo(ExonSiteInfo& p_exon_start, ExonSiteInfo& p_exon_end, ExonSiteInfo& c_exon_start, ExonSiteInfo& c_exon_end)
{
prev_exon_start = p_exon_start;
prev_exon_end = p_exon_end;
cur_exon_start = c_exon_start;
cur_exon_end = c_exon_end;
}
bool operator==(const PairExonSiteInfo& pair_info) const
{
return prev_exon_start == pair_info.prev_exon_start && prev_exon_end == pair_info.prev_exon_end
&& cur_exon_start == pair_info.cur_exon_start && cur_exon_end == pair_info.cur_exon_end;
}
bool operator<(const PairExonSiteInfo& pair_info) const
{
return prev_exon_start < pair_info.prev_exon_start ||
(prev_exon_start == pair_info.prev_exon_start && prev_exon_end < pair_info.prev_exon_end) ||
(prev_exon_start == pair_info.prev_exon_start && prev_exon_end == pair_info.prev_exon_end && cur_exon_start < pair_info.cur_exon_start) ||
(prev_exon_start == pair_info.prev_exon_start && prev_exon_end == pair_info.prev_exon_end && cur_exon_start == pair_info.cur_exon_start
&& cur_exon_end < pair_info.cur_exon_end);
}
};
struct InfoAfterRepair
{
bool need_pop;
vector<ExonSiteInfo> temp_sites;
vector<HSP_Gene_Pair> temp_HSPs;
InfoAfterRepair(bool pop, vector<ExonSiteInfo>& t_sites, vector<HSP_Gene_Pair>& t_HSPs)
{
need_pop = pop;
int i;
for (i=0; i<t_sites.size(); i++)
temp_sites.push_back(t_sites[i]);
for (i=0; i<t_HSPs.size(); i++)
temp_HSPs.push_back(t_HSPs[i]);
}
};
//=================================================================================//
/* THE MAIN CLASS THAT HANDLES ALL DATA INPUT/OUTPUT/CONVERSIONS(PREPARATIONS) */
class DataManager
{
private:
/*******************Data Members*************************/
//map<int, vector<int> > gene_start_end_map; //used to compute query fragment scores
map<int, vector<pair<float, int> > > gene_start_end_map; //used to compute query fragment scores
/*******************Methods*************************/
//void ReadOneGeneSegment(int, int, int);
void ReadOneGeneSegment(int, int, float);
//void GetFragmentScores(vector<HSP_Gene_Pair>& curHSPs);
void GetFragmentScores();
void ProcHSPs(vector<HSP_Gene_Pair>& curHSPs, bool);
void PrepareMaps(vector<HSP_Gene_Pair>& curHSPs, bool);
void CompRegion(multimap<Group_Info, vector<HSP_Gene_Pair*> >::iterator groupIt, int& region_start, int& region_end);
void UpdateGroupRegEnd(map<int, Group_RegEnd_Count>& cur_map, int region_start, int region_end, int group_count);
void GetRegionSeq(vector<string>& seq,
//char* seq, int& seq_len
char* line, int cur_line_start_pos, int cur_len);
void StoreGroupSeq(vector<string>& seq,
//char* seq, int seq_len,
vector<int>& group, int reg_start_pos, int seq_count);
bool GetRegion(int cur_pos, int reg_start_pos, int reg_end_pos,
vector<string>& seq,
//char* seq, int& seq_len,
char* line, int line_len,
bool& reg_start_found, bool& reg_end_found);
public:
/*******************Data Members*************************/
string inputFile; //*.report (blast report)
string outputFile;
string alignFile; //*.align (blast alignment)
string chrSeqFile; //chromosome (target) sequence file (FASTA format) (ONE big file for all chromosomes!)
string spliceFile; //result of genesplicer (result file header)
string queryFile; //query protein sequence
ifstream inputFile_is;
int headerIndex[9];
bool inputFile_Open;
bool cur_gene_start;
bool inputFile_Finish;
string next_query_gene;
ifstream alignFile_is;
bool alignFile_Open;
bool cur_align_start;
// bool alignFile_Finish;
ofstream outFile;
ofstream gff_os;
ostringstream gff_gene_str;
ostringstream gff_str;
ostringstream gff_geneinfo_str;
ofstream cDNA_os;
ofstream pred_protein_os;
string query_gene;
int query_len;
int chr_shortest_hsp_len; //use the shortest candidate gene length as reference for output
int chr_longest_cand_len;
int scale;
multimap<Group_Info, vector<HSP_Gene_Pair*> > groups; //computed HSP groups
//MODIFIED: finish all groups on the same chromosome, then move on to next chromosome
//map<string, vector<Group_Rank_Count> > chr_groups;//keep track of the correpondence between chromosome name and groups, so only load one chromosome at a time
//vector<string> chromosomes; //keep track of the processing order of chromosomes
//MODIFIED: get all DNA regions for all groups at once
map<int, pair<int, int> > group_start_seqno;
vector< vector<string> > group_dna_regions;
//vector<pair<int, char*> > group_dna_regions;
map<string, file_pos64> chr_seq_map; //only load once for a target DNA fasta file
string cur_chr_name; //used only to store the chromosome name of current HSP group (current gene)
char cur_gene_id[MAX_CHAR_NAME]; //used only to store geneid (ID=gene*, * is rank), for GFF3 format output
map<string, vector<string> > chr_name_seq; //map of <chromosome_name, chromosome_nucleotide_sequence>
map<int, Input_Alignment> input_alignments; // <HSP_realID, alignment> (sorted by HSP_ID)
map<int, Input_Alignment> input_alignments_HSPs_dup;
map<string, Splice_Sites> chr_splice_sites;
vector<string> HSP_chr; //chr info (header info)
vector< vector<HSP_Gene_Pair> > HSP_gene; //on positive strand
vector< vector<HSP_Gene_Pair> > HSP_neg_gene; //on negative strand
map<int, float> fragment_score_map; //<frag_start, frag_score>
multimap<int, int> gene_start_HSP_num_map; //<gene_start, HSP_num> (pos) <gene_end, HSP_num> (neg)
map<string, string> query_gene_seq;
/*******************Methods*************************/
void Reset()
{
gene_start_end_map.clear();
query_len = 0;
chr_shortest_hsp_len = INT_MAX;
chr_longest_cand_len = 0;
groups.clear();
//chr_name_seq.clear();
input_alignments.clear();
chr_splice_sites.clear();
HSP_chr.clear();
HSP_gene.clear();
HSP_neg_gene.clear();
fragment_score_map.clear();
gene_start_HSP_num_map.clear();
gff_str.str(""); //clear gff_str content
gff_gene_str.str("");
gff_geneinfo_str.str("");
}
void ResetChrSeq()
{
chr_name_seq.clear();
group_start_seqno.clear();
for (int i = 0; i<group_dna_regions.size(); i++)
//delete [] group_dna_regions[i].second;
group_dna_regions[i].clear();
group_dna_regions.clear();
}
DataManager(const string* fileNames, const char* outFilename, bool phase1_only) { //user can specify output filename
inputFile = fileNames[0];
chrSeqFile = fileNames[1];//chrFileName;
alignFile = fileNames[2];//alignFileName;
//spliceFile = spliceFileName;
//queryFile = queryFileName;
outputFile = outFilename;
char buffer[256];
if (SPLICE_SEGMENT_VERSION == 1)
{
sprintf(buffer, "_%s%s_%s_s%d_%d_%d_%d", PHASE1_VERSION.c_str(), PHASE1_OUTPUT.c_str(),
PHASE2_VERSION.c_str(), SPLICE_SEGMENT_VERSION, REPAIR_HSP_MIN_INIT_SCORE, REPAIR_HSP_EXTEND_SCORE_DROP,
REPAIR_HSP_AFTER_EXON);
}
else
{
if (EXTEND_HSP_BY_SCORE)
sprintf(buffer, "_%s%s_%s_s%d_tdshift%d_tddis%d_tcls%.1f_m%d_score_i%d_d%d_%d", PHASE1_VERSION.c_str(), PHASE1_OUTPUT.c_str(),
PHASE2_VERSION.c_str(), SPLICE_SEGMENT_VERSION, TREE_DATA_SHIFT, TREE_DATA_DISTORT, TREE_CLS_THRESHOLD, MINOBJS,
REPAIR_HSP_MIN_INIT_SCORE, REPAIR_HSP_EXTEND_SCORE_DROP, REPAIR_HSP_AFTER_EXON);
else
sprintf(buffer, "_%s%s_%s_s%d_tdshift%d_tddis%d_tcls%.1f_m%d_pid_i%d_d%d_%d", PHASE1_VERSION.c_str(), PHASE1_OUTPUT.c_str(),
PHASE2_VERSION.c_str(), SPLICE_SEGMENT_VERSION, TREE_DATA_SHIFT, TREE_DATA_DISTORT, TREE_CLS_THRESHOLD, MINOBJS,
REPAIR_HSP_MIN_INIT_SCORE, REPAIR_HSP_EXTEND_SCORE_DROP, REPAIR_HSP_AFTER_EXON);
}
outputFile += buffer;
outFile.open(outputFile.c_str());
if (!outFile.is_open())
cout << "output file open error!" << "\n";
//if (hasGFF) //hasGFF is not used any more
if (OUTPUT_GFF)
{
string gff_filename = outputFile;
gff_filename += ".gff";
gff_os.open(gff_filename.c_str());
if (!gff_os.is_open())
cout << gff_filename << " file open error!" << "\n";
else
gff_os << "##gff-version 3\n";
if (!phase1_only)
{
if (OUTPUT_cDNA)
{
gff_filename = outputFile;
gff_filename += ".DNA";
cDNA_os.open(gff_filename.c_str());
if (!cDNA_os.is_open())
cout << gff_filename << " file open error!" << "\n";
}
if (OUTPUT_Protein)
{
gff_filename = outputFile;
gff_filename += ".pro";
pred_protein_os.open(gff_filename.c_str());
if (!pred_protein_os.is_open())
cout << gff_filename << " file open error!" << "\n";
}
}
}
query_len = 0; //query gene length, initialized to 0, used only to compute the percentage of gene_cover in output
query_gene = "";
next_query_gene = "";
chr_shortest_hsp_len = INT_MAX;
chr_longest_cand_len = 0;
inputFile_Open = false;
cur_gene_start = false;
inputFile_Finish = false;
alignFile_Open = false;
// cur_align_start = false;
// alignFile_Finish = false;
}
~DataManager()
{
if (outFile.is_open())
outFile.close();
if (gff_os.is_open())
gff_os.close();
if (cDNA_os.is_open())
cDNA_os.close();
if (pred_protein_os.is_open())
pred_protein_os.close();
}
bool ReadFile();
bool ReadFile_Skip(); //for debug skip
void PrepareData(bool isPosStrand, int chr_index);
void PrintHSPs(int chr_index) //for debug
{
cout << "pos HSPs: " << "\n";
int i, j;
j = HSP_gene[chr_index].size();
for (i=0; i<j; i++)
cout << HSP_gene[chr_index][i];
cout << "neg HSPs: " << "\n";
j = HSP_neg_gene[chr_index].size();
for (i=0; i<j; i++)
cout << HSP_neg_gene[chr_index][i];
}
void PrintGroups(bool printOverview);