File: lists.c

package info (click to toggle)
sift 6.2.1-2
  • links: PTS, VCS
  • area: non-free
  • in suites: sid
  • size: 4,784 kB
  • sloc: ansic: 18,272; perl: 219; csh: 164; makefile: 152
file content (165 lines) | stat: -rwxr-xr-x 3,714 bytes parent folder | download | duplicates (5)
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
/* (C) Copyright 1993-7, Fred Hutchinson Cancer Research Center */
/* Use, modification or distribution of these programs is subject to */
/* the terms of the non-commercial licensing agreement in license.h. */

/* lists.c: definitions and functions for various ordered lists */
/* Written by: Bill Alford */
/* Change log information is at the end of the file. */

/*	system headers not in global.h  */
/*	blimps library headers not in global.h */
#include <global.h>
#include <blocks.h>	/* includes sequences.h  */
#ifndef NO_MATRIX
#include <matrix.h>	/* includes pattern.h */
#endif
/*	headers in current directory */
#include "lists.h"
#include "blimps.h"
#ifndef NO_SCORES
#include "scores.h"
#endif


/*
 * Exported variables and data structures
 */

ScoreList    Scores;
ScoreList    PrintScores;
MatrixList   Matrices;
BlockList    Blocks;
SequenceList Sequences;

int MinScoreOfList = -1;	/* the minimum score of the score list */


/*
 * Local variables and data structures
 */


/*
 * Function definitions
 */


/* 
 * initialize_lists
 *   initializes the lists.
 *   Parameters: none
 *   Error codes:
 */

void initialize_lists()
{
#ifndef NO_SCORES
  Scores      = NewSL(score_comparison,     free_score, ALLOW_DUPLICATES);
  PrintScores = NewSL(neg_score_comparison, free_score, ALLOW_DUPLICATES);
#endif
#ifndef NO_MATRIX
  Matrices   = NewSL(matrix_comparison,    NULL, ALLOW_DUPLICATES);
#endif
  Blocks      = NewSL(block_comparison,     NULL, ALLOW_DUPLICATES);
  Sequences   = NewSL(sequence_comparison,  NULL, ALLOW_DUPLICATES);
}




/*
 * Score List functions
 *
 */
#ifndef NO_SCORES

/*
 * insert_in_score_list
 *   Inserts the score entry into the score list and makes sure that the 
 *   number of elements n the list are fewer than the NumberToReport if there
 *   is a limit.
 *   Parameters:
 *     Score score: the score entry.
 *   Return codes: the same as InsertSL.
 *   Error codes: none
 */

int insert_in_score_list(score)
     Score *score;
{
  int ret_value;

  ret_value = InsertSL(Scores, score);
  if (NumberToReport >= 0) {
    DoForSL(Scores, limit_Scores_list_size, NULL);
  }
  return ret_value;
}


/* 
 * limit_Scores_list_size
 *   Used in insert_in_score_list to limit the size of the score list.
 *   Parameters: 
 *     Score *score: the score list entry
 *     void *arg: unused, here to match the procedure call in DoForSL
 *   Return codes: SL_DELETE if the list is too big, SL_QUIT otherwise.
 *   Error codes: none
 */

int limit_Scores_list_size(score, arg)
     Score *score;
     void *arg;  /* not used */
{
/*>>> Seems to cause memory problems?
  if (NumInSL(Scores) > NumberToReport &&
      SavedScoresFlag && score->score > 1000 && NumberToReport < 4990)
  {		NumberToReport += 10;    }
*/

  if (NumInSL(Scores) > NumberToReport) {
    return SL_DELETE;
  }
  else {
    MinScoreOfList = score->score;
    return SL_QUIT; /* done limiting size, stop the DoForSL */
  }
}


/* 
 * enter_score_into_print_scores
 *   Places the score from Scores into PrintScores.  PrintScores is a reverse
 *   ordered list so that the printing comes out with the largest score
 *   first.
 *   Parameters:
 *     Score *score: the score list entry
 *     void *arg: unused, here to match the procedure call in DoForSL
 *   Return code: SL_CONTINUE always.
 *   Error codes: none
 */

int enter_score_into_print_scores(score, arg)
     Score *score;
     void *arg;
{
  InsertSL(PrintScores, score);
  return SL_CONTINUE;
}

#endif








/* Change log information follows. */
/* 
 Changes since version 3.2.5:
 3/3/99 Corrected spelling of Matrices.
        Note: SavedScoresFlag changes to limit_Scores_list_size() were removed,
	      see comments there.
 */