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