projects
/
htsworkflow.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
909ef50
)
Small change to handle the odd case when no alignment is performed.
author
Tim Reddy Tim
<treddy@hudsonalpha.org>
Tue, 25 Nov 2008 20:26:28 +0000
(20:26 +0000)
committer
Tim Reddy Tim
<treddy@hudsonalpha.org>
Tue, 25 Nov 2008 20:26:28 +0000
(20:26 +0000)
htswanalysis/src/complexity_count.cpp
patch
|
blob
|
history
diff --git
a/htswanalysis/src/complexity_count.cpp
b/htswanalysis/src/complexity_count.cpp
index 28e42953c6a8490e3cfdc3166002953fe7805830..22975ee6eecdec9f7e3284d23c74a2143eea49e9 100644
(file)
--- a/
htswanalysis/src/complexity_count.cpp
+++ b/
htswanalysis/src/complexity_count.cpp
@@
-59,10
+59,11
@@
void read_align_file(char* filename, Hits& features) {
string line_str(line);
vector<string> fields;
split(line_str, delim, fields);
string line_str(line);
vector<string> fields;
split(line_str, delim, fields);
- if(fields.size() <=
3
) { continue; }
+ if(fields.size() <=
4
) { continue; }
vector<string> location; split(fields[3], location_delim, location);
vector<string> location; split(fields[3], location_delim, location);
+ if(location.size() != 2) { continue; }
int chr = chromstr_to_int(location[0]);
int chr = chromstr_to_int(location[0]);
- if(chr
== -1
) { continue; }
+ if(chr
< 0
) { continue; }
int pos = atoi(location[1].c_str());
bool strand = ((fields[4].c_str())[0] == 'F')?0:1;
int pos = atoi(location[1].c_str());
bool strand = ((fields[4].c_str())[0] == 'F')?0:1;
@@
-90,12
+91,13
@@
void print_features(Hits& hits, string filename, unsigned int size_1, unsigned i
}
unsigned int count_complexity(Hits& data) {
}
unsigned int count_complexity(Hits& data) {
- int chrom = -1;
+ unsigned int num_hits = data.size();
unsigned int n_island = 0;
unsigned int island_size = 0;
unsigned int n_island = 0;
unsigned int island_size = 0;
+ int chrom = data.begin()->chr;
for(Hits::iterator i = data.begin()+1; i != data.end()-1 && i != data.end(); ++i) {
for(Hits::iterator i = data.begin()+1; i != data.end()-1 && i != data.end(); ++i) {
- if(
chrom == -1 ||
i->chr != chrom) {
+ if(i->chr != chrom) {
chrom = i->chr;
} else if( (i+1)->chr != chrom ) { continue; }
int prev = (i-1)->start;
chrom = i->chr;
} else if( (i+1)->chr != chrom ) { continue; }
int prev = (i-1)->start;
@@
-117,8
+119,9
@@
int main(int argc, char** argv) {
char label1[128]; strcpy(label1,argv[1]);
Hits align1; read_align_file(argv[2], align1);
char label1[128]; strcpy(label1,argv[1]);
Hits align1; read_align_file(argv[2], align1);
- int complexity;
- if(align1.size() == 0) complexity = 0; else complexity = count_complexity(align1);
+ if(align1.size() <= 1) { cerr << "No alignment\n"; exit(0); }
+
+ int complexity = count_complexity(align1);
cout << label1 << "\t" << complexity << "\t" << align1.size()/1000000 << "M\t" << (double)complexity/(double)align1.size() << endl;
}
cout << label1 << "\t" << complexity << "\t" << align1.size()/1000000 << "M\t" << (double)complexity/(double)align1.size() << endl;
}