Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show all descriptions and alignments with maximum score #38

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions hits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ long obvious;

long opt_descriptions;
long opt_alignments;
long opt_show_best;

/* parameters for bit scores and expect values */

Expand Down Expand Up @@ -189,7 +190,26 @@ void hits_enter(long seqno, long score, long qstrand, long qframe,
((score == hits_list[place-1].score) &&
(seqno > hits_list[place-1].seqno))))
place--;


long Nbest = 1;
if (place > 0)
{
if (score < hits_list[place-1].score)
Nbest++;

for (long j=(place-1); j>0; j--)
{
if (hits_list[j].score < hits_list[j-1].score)
Nbest++;
}
}

if (Nbest > opt_show_best)
{
pthread_mutex_unlock(&hitsmutex);
return;
}

// move entries down

long move = (hits_count < keephits ? hits_count : keephits - 1) - place;
Expand Down Expand Up @@ -280,10 +300,11 @@ void hits_enter_align_string(long i, char * align, long align_len)
// hits_list[i].alignment[align_len] = 0;
}

void hits_init(long descriptions, long alignments, long minscore, long maxscore, double minexpect, double expect, int show_nostats)
void hits_init(long descriptions, long alignments, long show_best, long minscore, long maxscore, double minexpect, double expect, int show_nostats)
{
opt_descriptions = descriptions;
opt_alignments = alignments;
opt_show_best = show_best;
keephits = descriptions > alignments ? descriptions : alignments;

long maxhits = db_getseqcount_masked();
Expand Down Expand Up @@ -2002,7 +2023,26 @@ void hits_show(long view, long show_gis)
showalignments = hits_count;
else
showalignments = opt_alignments;

long Nbest = 1;
long place = 1;
while (place < hits_count)
{
if (hits_list[place-1].score > hits_list[place].score)
Nbest++;

if (Nbest <= opt_show_best)
place++;
else
break;
}

if (showhits > place)
showhits = place;

if (showalignments > place)
showalignments = place;

struct db_thread_s * t = db_thread_create();

if(view == 0)
Expand Down
24 changes: 19 additions & 5 deletions swipe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
/* ARGUMENTS AND THEIR DEFAULTS */

#define DEFAULT_MAXMATCHES 250
#define DEFAULT_SHOW_BEST 250
#define DEFAULT_ALIGNMENTS 100
#define DEFAULT_MINSCORE 1
#define DEFAULT_MAXSCORE (LONG_MAX)
Expand Down Expand Up @@ -64,6 +65,7 @@ double expect;
double minexpect;
long minscore;
long maxscore;
long show_best;
long alignments;
long maxmatches;
long gapopen;
Expand Down Expand Up @@ -739,6 +741,7 @@ void args_show()
fprintf(out, "Min score shown: %ld\n", minscore);
fprintf(out, "Max matches shown: %ld\n", maxmatches);
fprintf(out, "Alignments shown: %ld\n", alignments);
fprintf(out, "Best scores shown: %ld\n", show_best);
fprintf(out, "Show gi's: %ld\n", show_gis);
fprintf(out, "Show taxid's: %ld\n", show_taxid);
fprintf(out, "Threads: %ld\n", threads);
Expand Down Expand Up @@ -796,6 +799,7 @@ void args_usage()
fprintf(out, " -G, --gapopen=NUM gap open penalty (11)\n");
fprintf(out, " -E, --gapextend=NUM gap extension penalty (1)\n");
fprintf(out, " -v, --num_descriptions=NUM sequence descriptions to show (250)\n");
fprintf(out, " -B, --show_best=NUM number of different scoring sequences to show (250)\n");
fprintf(out, " -b, --num_alignments=NUM sequence alignments to show (100)\n");
fprintf(out, " -e, --evalue=REAL maximum expect value of sequences to show (10.0)\n");
fprintf(out, " -k, --minevalue=REAL minimum expect value of sequences to show (0.0)\n");
Expand Down Expand Up @@ -836,6 +840,7 @@ void args_init(int argc, char **argv)
maxscore = DEFAULT_MAXSCORE;
maxmatches = DEFAULT_MAXMATCHES;
alignments = DEFAULT_ALIGNMENTS;
show_best = DEFAULT_SHOW_BEST;
threads = DEFAULT_THREADS;
view = DEFAULT_VIEW;
symtype = DEFAULT_SYMTYPE;
Expand All @@ -856,7 +861,7 @@ void args_init(int argc, char **argv)
progname = argv[0];

opterr = 1;
char short_options[] = "d:i:M:q:r:G:E:S:v:b:c:u:e:k:a:m:p:x:C:Q:D:F:K:N:o:z:IHh";
char short_options[] = "d:i:M:q:r:G:E:S:v:B:b:c:u:e:k:a:m:p:x:C:Q:D:F:K:N:o:z:IHh";

static struct option long_options[] =
{
Expand All @@ -869,6 +874,7 @@ void args_init(int argc, char **argv)
{"gapextend", required_argument, NULL, 'E' },
{"strand", required_argument, NULL, 'S' },
{"num_descriptions", required_argument, NULL, 'v' },
{"show_best", required_argument, NULL, 'B' },
{"num_alignments", required_argument, NULL, 'b' },
{"min_score", required_argument, NULL, 'c' },
{"max_score", required_argument, NULL, 'u' },
Expand Down Expand Up @@ -907,7 +913,12 @@ void args_init(int argc, char **argv)
/* threads */
threads = atol(optarg);
break;


case 'B':
/* show best */
show_best = atol(optarg);
break;

case 'b':
/* alignments */
alignments = atol(optarg);
Expand Down Expand Up @@ -1157,6 +1168,9 @@ void args_init(int argc, char **argv)

if ((dump<0) || (dump>2))
fatal("Illegal dump mode.");

if (maxmatches < show_best)
maxmatches = show_best;

translate_init(query_gencode, db_gencode);
}
Expand Down Expand Up @@ -1845,7 +1859,7 @@ void master(int size)

/* init */

hits_init(maxmatches, alignments, minscore, maxscore, minexpect, expect, view==0);
hits_init(maxmatches, alignments, show_best, minscore, maxscore, minexpect, expect, view==0);

prepare_search(size-1);

Expand Down Expand Up @@ -2179,7 +2193,7 @@ void slave(int rank, int size)
// fprintf(out, "Node %d: SSE2: %ld SSSE3: %ld\n", rank, cpu_feature_sse2, cpu_feature_ssse3);
// fprintf(out, "This is slave no %d.\n", rank);

hits_init(maxmatches, alignments, minscore, maxscore, minexpect, expect, 0);
hits_init(maxmatches, alignments, show_best, minscore, maxscore, minexpect, expect, 0);

prepare_search(size-1);

Expand Down Expand Up @@ -2436,7 +2450,7 @@ void slave(int rank, int size)
void work()
{
args_show();
hits_init(maxmatches, alignments, minscore, maxscore, minexpect, expect, view==0);
hits_init(maxmatches, alignments, show_best, minscore, maxscore, minexpect, expect, view==0);

compute7 = 0;
compute16 = 0;
Expand Down
3 changes: 2 additions & 1 deletion swipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ extern long maxmatches;
extern long threads;
extern const char * databasename;
extern long alignments;
extern long show_best;
extern long queryno;
extern long compute7;
extern long show_taxid;
Expand Down Expand Up @@ -346,7 +347,7 @@ void db_getsequence(struct db_thread_s * t, long seqno, long strand, long frame,
void db_getheader(struct db_thread_s * t, long seqno, char ** address,
long * length);

void hits_init(long descriptions, long alignments, long minscore,
void hits_init(long descriptions, long alignments, long show_best, long minscore,
long maxscore, double minexpect, double expect, int show_nostats);
void hits_enter(long seqno, long score, long qstrand, long qframe,
long dstrand, long dframe, long align_hint, long bestq);
Expand Down