fix: add include
This commit is contained in:
parent
525c9eb122
commit
b2951105ae
144
HGL_SRC/Alloc.c
144
HGL_SRC/Alloc.c
|
@ -1,7 +1,9 @@
|
|||
#include <stdio.h>
|
||||
#include "global_defs.h"
|
||||
#include <ctype.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "global_defs.h"
|
||||
/*
|
||||
* Alloc.c
|
||||
* Memory functions for Harvard Genome Laboratory.
|
||||
|
@ -9,19 +11,16 @@
|
|||
*
|
||||
* Print error message, and die
|
||||
*/
|
||||
void ErrorOut(code,string)
|
||||
int code;
|
||||
void ErrorOut(code, string) int code;
|
||||
char *string;
|
||||
{
|
||||
if (code == 0)
|
||||
{
|
||||
if (code == 0) {
|
||||
fprintf(stderr, "Error:%s\n", string);
|
||||
exit(1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Calloc count*size bytes with memory aligned to size.
|
||||
* Return pointer to new block.
|
||||
|
@ -33,8 +32,7 @@ int count,size;
|
|||
char *temp;
|
||||
temp = calloc(count, (unsigned)size);
|
||||
|
||||
if(count*size == 0)
|
||||
fprintf(stderr,"Allocate ZERO blocks?\n");
|
||||
if (count * size == 0) fprintf(stderr, "Allocate ZERO blocks?\n");
|
||||
ErrorOut(temp, "Cannot allocate memory");
|
||||
return (temp);
|
||||
}
|
||||
|
@ -58,15 +56,12 @@ unsigned size;
|
|||
* Return error code from free().
|
||||
*/
|
||||
|
||||
void Cfree(block)
|
||||
char* block;
|
||||
void Cfree(block) char *block;
|
||||
{
|
||||
extern void Warning();
|
||||
if(block != NULL)
|
||||
{
|
||||
if (block != NULL) {
|
||||
#ifdef SUN4
|
||||
if(free(block) == 0)
|
||||
Warning("Error in Cfree...");
|
||||
if (free(block) == 0) Warning("Error in Cfree...");
|
||||
#endif
|
||||
}
|
||||
/* else
|
||||
|
@ -75,19 +70,15 @@ char* block;
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Print Warning message to stderr.
|
||||
*/
|
||||
void Warning(s)
|
||||
char *s;
|
||||
void Warning(s) char *s;
|
||||
{
|
||||
fprintf(stderr, "Warning:%s\n", s);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get array element from a sequence structure. The index
|
||||
* is relative to the alignment.
|
||||
|
@ -107,8 +98,7 @@ int indx; /*Index relative to the global offset*/
|
|||
* is relative to the alignment.
|
||||
*/
|
||||
|
||||
void ReplaceElem(seq,indx,elem)
|
||||
Sequence *seq; /*Sequence */
|
||||
void ReplaceElem(seq, indx, elem) Sequence *seq; /*Sequence */
|
||||
int indx; /*Position to overwrite (replace) */
|
||||
unsigned char elem; /*Character to replace with */
|
||||
{
|
||||
|
@ -120,13 +110,12 @@ unsigned char elem; /*Character to replace with */
|
|||
* If no c_elem has been allocated yet...
|
||||
*/
|
||||
/* if(index("abcdefghijklmnopqrstuvwxyz-0123456789",elem)==0)
|
||||
fprintf(stderr,"Warning (ReplaceElem) elem = %c\n",elem);
|
||||
fprintf(stderr,"Warning (ReplaceElem) elem =
|
||||
%c\n",elem);
|
||||
*/
|
||||
width = seq->offset - indx;
|
||||
if(seq->seqlen == 0 && elem != '-')
|
||||
{
|
||||
if(seq->seqmaxlen == 0 || seq->c_elem == NULL)
|
||||
{
|
||||
if (seq->seqlen == 0 && elem != '-') {
|
||||
if (seq->seqmaxlen == 0 || seq->c_elem == NULL) {
|
||||
seq->c_elem = Calloc(4, sizeof(char));
|
||||
seq->offset = indx;
|
||||
seq->seqmaxlen = 4;
|
||||
|
@ -138,14 +127,13 @@ unsigned char elem; /*Character to replace with */
|
|||
/*
|
||||
* If inserting before the c_elem (< offset)
|
||||
*/
|
||||
else if((indx<seq->offset) && (elem!='-'))
|
||||
{
|
||||
else if ((indx < seq->offset) && (elem != '-')) {
|
||||
seq->seqmaxlen += width;
|
||||
seq->c_elem = Realloc(seq->c_elem,seq->seqmaxlen*sizeof(char));
|
||||
seq->c_elem =
|
||||
Realloc(seq->c_elem, seq->seqmaxlen * sizeof(char));
|
||||
for (j = seq->seqmaxlen - 1; j >= width; j--)
|
||||
seq->c_elem[j] = seq->c_elem[j - width];
|
||||
for(j=0;j<width;j++)
|
||||
seq->c_elem[j] = '-';
|
||||
for (j = 0; j < width; j++) seq->c_elem[j] = '-';
|
||||
seq->c_elem[0] = elem;
|
||||
seq->seqlen += width;
|
||||
seq->offset = indx;
|
||||
|
@ -153,22 +141,20 @@ unsigned char elem; /*Character to replace with */
|
|||
/*
|
||||
* if inserting after c_elem (indx > offset + seqlen)
|
||||
*/
|
||||
else if((indx>=seq->offset+seq->seqlen) && (elem!='-'))
|
||||
{
|
||||
if(indx-seq->offset >= seq->seqmaxlen)
|
||||
{
|
||||
else if ((indx >= seq->offset + seq->seqlen) && (elem != '-')) {
|
||||
if (indx - seq->offset >= seq->seqmaxlen) {
|
||||
seq->seqmaxlen = indx - seq->offset + 256;
|
||||
seq->c_elem = Realloc(seq->c_elem,seq->seqmaxlen*
|
||||
sizeof(char));
|
||||
seq->c_elem =
|
||||
Realloc(seq->c_elem, seq->seqmaxlen * sizeof(char));
|
||||
}
|
||||
for (j = seq->seqlen; j < seq->seqmaxlen; j++)
|
||||
seq->c_elem[j] = '-';
|
||||
seq->c_elem[indx - seq->offset] = elem;
|
||||
seq->seqlen = indx - seq->offset + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(indx-(seq->offset)>=0 && indx-(seq->offset)<seq->seqlen)
|
||||
else {
|
||||
if (indx - (seq->offset) >= 0 &&
|
||||
indx - (seq->offset) < seq->seqlen)
|
||||
seq->c_elem[indx - (seq->offset)] = elem;
|
||||
else if (elem != '-')
|
||||
fprintf(stderr, "%c better be a -\n", elem);
|
||||
|
@ -176,7 +162,6 @@ unsigned char elem; /*Character to replace with */
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* InsertElem is a modification of InsertElems, and should be
|
||||
* optimized. s.s.5/6/91
|
||||
|
@ -193,32 +178,26 @@ char ch; /*element to insert */
|
|||
return (InsertElems(a, b, c));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Make a copy of Sequence one, place in Sequence two
|
||||
*/
|
||||
void SeqCopy(one,two)
|
||||
Sequence *one,*two;
|
||||
void SeqCopy(one, two) Sequence *one, *two;
|
||||
{
|
||||
int j;
|
||||
*two = *one;
|
||||
if(two->seqmaxlen)
|
||||
two->c_elem = Calloc(one->seqmaxlen,sizeof(char));
|
||||
if (two->seqmaxlen) two->c_elem = Calloc(one->seqmaxlen, sizeof(char));
|
||||
if (two->commentsmaxlen)
|
||||
two->comments = Calloc(one->commentsmaxlen, sizeof(char));
|
||||
for(j=0;j<one->seqlen;j++)
|
||||
two->c_elem[j] = one->c_elem[j];
|
||||
for (j = 0; j < one->seqlen; j++) two->c_elem[j] = one->c_elem[j];
|
||||
for (j = 0; j < one->commentslen; j++)
|
||||
two->comments[j] = one->comments[j];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Normalize seq (remove leading indels in the c_elem;
|
||||
*/
|
||||
void SeqNormal(seq)
|
||||
Sequence *seq;
|
||||
void SeqNormal(seq) Sequence *seq;
|
||||
{
|
||||
int len, j, shift_width, trailer;
|
||||
char *c_elem;
|
||||
|
@ -228,24 +207,25 @@ Sequence *seq;
|
|||
|
||||
if (len == 0) return;
|
||||
|
||||
for(shift_width=0; (shift_width<len) && (c_elem[shift_width] == '-');
|
||||
shift_width++);
|
||||
for (shift_width = 0;
|
||||
(shift_width < len) && (c_elem[shift_width] == '-'); shift_width++)
|
||||
;
|
||||
|
||||
for (j = 0; j < len - shift_width; j++)
|
||||
c_elem[j] = c_elem[j + shift_width];
|
||||
|
||||
seq->seqlen -= shift_width;
|
||||
seq->offset += shift_width;
|
||||
for(trailer=seq->seqlen-1;(c_elem[trailer] =='-' ||
|
||||
c_elem[trailer] == '\0') && trailer>=0;
|
||||
for (trailer = seq->seqlen - 1;
|
||||
(c_elem[trailer] == '-' || c_elem[trailer] == '\0') &&
|
||||
trailer >= 0;
|
||||
trailer--)
|
||||
c_elem[trailer] = '\0';
|
||||
seq->seqlen = trailer + 1;
|
||||
return;
|
||||
}
|
||||
|
||||
void SeqRev(seq,min,max)
|
||||
Sequence *seq;
|
||||
void SeqRev(seq, min, max) Sequence *seq;
|
||||
int min, max;
|
||||
/*
|
||||
SeqRev will reverse a given sequence within a window from
|
||||
|
@ -264,8 +244,7 @@ int min,max;
|
|||
extern char GetElem();
|
||||
extern void ReplaceElem();
|
||||
|
||||
for(j=0;j<= (max-min)/2;j++)
|
||||
{
|
||||
for (j = 0; j <= (max - min) / 2; j++) {
|
||||
temp1 = GetElem(seq, min + j);
|
||||
temp2 = GetElem(seq, max - j);
|
||||
ReplaceElem(seq, min + j, (unsigned char)temp2);
|
||||
|
@ -278,10 +257,8 @@ int min,max;
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
/* sequence complementing. */
|
||||
void SeqComp(seq)
|
||||
Sequence *seq;
|
||||
void SeqComp(seq) Sequence *seq;
|
||||
{
|
||||
int j;
|
||||
unsigned char in, out, case_bit;
|
||||
|
@ -290,31 +267,31 @@ Sequence *seq;
|
|||
't', 'w', 'y', 'h', 'k', 'd', 'b', 'n'};
|
||||
|
||||
static int matr[128] = {
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x00,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0x01,0x0e,0x02,0x0d,0,0,0x04,0x0b,0,0,0x0c,0,0x03,0x0f,0,0x05,0,0x05,0x06,
|
||||
0x08,0x08,0x07,0x09,0x00,0x0a,0,0,0,0,0,0,0,0x01,0x0e,0x02,0x0d,0,0,0x04,
|
||||
0x0b,0,0,0x0c,0,0x03,0x0f,0,0x05,0,0x05,0x06,0x08,0x08,0x07,0x09,0x00,0x0a,
|
||||
0,0,0,0,0x00,0
|
||||
};
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0x00, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01,
|
||||
0x0e, 0x02, 0x0d, 0, 0, 0x04, 0x0b, 0, 0, 0x0c, 0,
|
||||
0x03, 0x0f, 0, 0x05, 0, 0x05, 0x06, 0x08, 0x08, 0x07, 0x09,
|
||||
0x00, 0x0a, 0, 0, 0, 0, 0, 0, 0, 0x01, 0x0e,
|
||||
0x02, 0x0d, 0, 0, 0x04, 0x0b, 0, 0, 0x0c, 0, 0x03,
|
||||
0x0f, 0, 0x05, 0, 0x05, 0x06, 0x08, 0x08, 0x07, 0x09, 0x00,
|
||||
0x0a, 0, 0, 0, 0, 0x00, 0};
|
||||
|
||||
c = seq->c_elem;
|
||||
for(j=0;j<seq->seqlen;j++)
|
||||
{
|
||||
for (j = 0; j < seq->seqlen; j++) {
|
||||
/*
|
||||
* Save Case bit...
|
||||
*/
|
||||
case_bit = c[j] & 32;
|
||||
out = 0;
|
||||
in = matr[c[j]];
|
||||
if(in&1)
|
||||
out|=8;
|
||||
if(in&2)
|
||||
out|=4;
|
||||
if(in&4)
|
||||
out|=2;
|
||||
if(in&8)
|
||||
out|=1;
|
||||
if (in & 1) out |= 8;
|
||||
if (in & 2) out |= 4;
|
||||
if (in & 4) out |= 2;
|
||||
if (in & 8) out |= 1;
|
||||
|
||||
if (case_bit == 0)
|
||||
c[j] = toupper(tmatr[out]);
|
||||
|
@ -323,9 +300,8 @@ Sequence *seq;
|
|||
}
|
||||
|
||||
seq->direction *= -1;
|
||||
seq->strandedness = ( seq->strandedness == 2)?1:
|
||||
( seq->strandedness == 1)?2:
|
||||
0;
|
||||
seq->strandedness = (seq->strandedness == 2) ? 1
|
||||
: (seq->strandedness == 1) ? 2
|
||||
: 0;
|
||||
return;
|
||||
|
||||
}
|
||||
|
|
1700
HGL_SRC/HGLfuncs.c
1700
HGL_SRC/HGLfuncs.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue