Skip to content

Commit

Permalink
test to add PE mode to cd-hit-est-2d
Browse files Browse the repository at this point in the history
  • Loading branch information
Weizhong Li committed Apr 27, 2017
1 parent e051b28 commit af7fd63
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cdhit-common.c++
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ bool Options::SetOption2D( const char *flag, const char *value )
{
if( SetOptionCommon( flag, value ) ) return true;
if (strcmp(flag, "-i2" ) == 0) input2 = value;
else if (strcmp(flag, "-j2" ) == 0) input2_pe = value;
else if (strcmp(flag, "-s2") == 0) diff_cutoff2 = atof(value);
else if (strcmp(flag, "-S2") == 0) diff_cutoff_aa2 = atoi(value);
else return false;
Expand Down Expand Up @@ -376,6 +377,9 @@ void Options::Validate()
if( has2D ){
if ((diff_cutoff2<0) || (diff_cutoff2>1)) bomb_error("invalid value for -s2");
if (diff_cutoff_aa2<0) bomb_error("invalid value for -S2");
if (PE_mode) {
if (input2_pe.size() == 0) bomb_error("no input file for R2 sequences for 2nd db in PE mode");
}
}
if (global_identity == 0) print = 1;
if (short_coverage < long_coverage) short_coverage = long_coverage;
Expand Down
1 change: 1 addition & 0 deletions cdhit-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ struct Options
string input;
string input_pe;
string input2;
string input2_pe;
string output;
string output_pe;

Expand Down
17 changes: 15 additions & 2 deletions cdhit-est-2d.c++
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ int main(int argc, char **argv)
string db_in;
string db_in2;
string db_out;
string db_in_pe;
string db_in2_pe;
string db_out_pe;


options.cluster_thd = 0.95;
options.NAA = 10;
Expand All @@ -67,8 +71,12 @@ int main(int argc, char **argv)
options.Validate();

db_in = options.input;
db_in_pe = options.input_pe;
db_in2 = options.input2;
db_in2_pe = options.input2_pe;
db_out = options.output;
db_out_pe = options.output_pe;


InitNAA( MAX_UAA );
options.NAAN = NAAN_array[options.NAA];
Expand All @@ -80,10 +88,12 @@ int main(int argc, char **argv)
make_comp_short_word_index(options.NAA, NAAN_array, Comp_AAN_idx);
}

seq_db.Read( db_in.c_str(), options );
if ( options.PE_mode ) {seq_db.Read( db_in.c_str(), db_in_pe.c_str(), options );}
else {seq_db.Read( db_in.c_str(), options );}
cout << "total seq in db1: " << seq_db.sequences.size() << endl;

seq_db2.Read( db_in2.c_str(), options );
if ( options.PE_mode ) { seq_db2.Read( db_in2.c_str(), db_in2_pe.c_str(), options );}
else { seq_db2.Read( db_in2.c_str(), options );}
cout << "total seq in db2: " << seq_db2.sequences.size() << endl;

seq_db.SortDivide( options );
Expand All @@ -93,6 +103,9 @@ int main(int argc, char **argv)
cout << "writing non-redundant sequences from db2" << endl;
seq_db2.WriteClusters( db_in2.c_str(), db_out.c_str(), options );

if ( options.PE_mode ) { seq_db2.WriteClusters( db_in2.c_str(), db_in2_pe.c_str(), db_out.c_str(), db_out_pe.c_str(), options ); }
else { seq_db2.WriteClusters( db_in2.c_str(), db_out.c_str(), options ); }

seq_db2.WriteExtra2D( seq_db, options );
cout << "program completed !" << endl << endl;
end_time = current_time();
Expand Down

0 comments on commit af7fd63

Please sign in to comment.