This commit is contained in:
kuoi 2023-04-16 07:33:28 +08:00
commit c9b94ce735
6 changed files with 4431 additions and 0 deletions

111
Makefile Normal file
View File

@ -0,0 +1,111 @@
#
# Unix Makefile for readseq
# to use, command me:
# % make -- or --
# % make CC=your-c-compiler-name
#
# pick an ANSI C compiler (the default Sun CC is not ANSI)
CC=gcc # Gnu C Compiler
#CC=cc # SGI Irix
#CC=vcc # some DEC Ultrix
CFLAGS=
#CFLAGS= -DSMALLCHECKSUM # if you prefer to use a GCG-standard 13 bit checksum
# instead of a full 32 bit checksum. This may enhance compatibility w/ GCG software
SOURCES= readseq.c ureadseq.c ureadseq.h ureadasn.c
DOCS= Readme Readseq.help Formats Stdfiles Makefile Make.com add.gdemenu *.std
# NCBI toolkit support for ASN.1 reader
# this is path to NCBI toolkit, you must set for your system:
NCBI=
#NCBI=/bio/mb/ncbi
#
OTHERLIBS=-lm
LIB1=-lncbi
LIB2=-lncbiobj
LIB3=-lncbicdr
LIB4=-lvibrant
INCPATH=$(NCBI)/include
LIBPATH=$(NCBI)/lib
NCFLAGS=$(CFLAGS) -DNCBI -I$(INCPATH)
NLDFLAGS=-I$(INCPATH) -L$(LIBPATH)
NLIBS=$(LIB1) $(LIB2) $(OTHERLIBS)
all: build test
build: $(SOURCES)
@echo "Compiling readseq..."
$(CC) $(CFLAGS) -o readseq readseq.c ureadseq.c
# if using NCBI, uncomment these lines in place of build: above
#build: $(SOURCES)
# @echo "Compiling readseq with NCBI toolkit support...";
# $(CC) -o readseq $(NLDFLAGS) $(NCFLAGS) readseq.c ureadseq.c ureadasn.c $(NLIBS)
test: $(SOURCES) readseq
@echo ""
@echo "Test for general read/write of all chars:"
./readseq -p alphabet.std -otest.alpha
-diff test.alpha alphabet.std
@echo ""
@echo "Test for valid format conversions:"
./readseq -v -p -f=ig nucleic.std -otest.ig
./readseq -v -p -f=gb test.ig -otest.gb
./readseq -v -p -f=nbrf test.gb -otest.nbrf
./readseq -v -p -f=embl test.nbrf -otest.embl
./readseq -v -p -f=gcg test.embl -otest.gcg
./readseq -v -p -f=strider test.gcg -otest.strider
./readseq -v -p -f=fitch test.strider -otest.fitch
./readseq -v -p -f=fasta test.fitch -otest.fasta
./readseq -v -p -f=pir test.fasta -otest.pir
./readseq -v -p -f=ig test.pir -otest.ig-b
-diff test.ig test.ig-b
@echo ""
@echo "Test for multiple-sequence format conversions:"
./readseq -p -f=ig multi.std -otest.m-ig
./readseq -p -f=gb test.m-ig -otest.m-gb
./readseq -p -f=nbrf test.m-gb -otest.m-nbrf
./readseq -p -f=embl test.m-nbrf -otest.m-embl
./readseq -p -f=fasta test.m-embl -otest.m-fasta
./readseq -p -f=pir test.m-fasta -otest.m-pir
./readseq -p -f=msf test.m-pir -otest.m-msf
./readseq -p -f=paup test.m-msf -otest.m-paup
./readseq -p -f=ig test.m-paup -otest.m-ig-b
-diff test.m-ig test.m-ig-b
#
# if using NCBI, uncomment these lines
# @echo ""
# @echo "Test of NCBI ASN.1 conversions:"
# ./readseq -p -f=asn test.m-ig -otest.m-asn
# ./readseq -p -f=ig test.m-asn -otest.m-ig-c
# -diff test.m-ig test.m-ig-c
#
@echo ""
@echo "Expect differences in the header lines due to"
@echo "different format headers. If any sequence lines"
@echo "differ, or if the checksums differ, there is a problem."
@echo "----------------------"
@echo ""
@echo "To clean up test files, command me:"
@echo " make clean"
clean:
rm -f *.o core test.*
shar:
@echo "shell archiving files..."
-rm -f readseq*.shar
mkdir readseqd
cp $(SOURCES) readseqd
cp $(DOCS) readseqd
shar -v readseqd > readseq.shar
rm -rf readseqd

292
macinit.c Normal file
View File

@ -0,0 +1,292 @@
/*
macinit.c
-- Macintosh initializations, then call real main
Note: compile this segment as Main for generic 68000 processor, so it won't
fail on generic mac
*/
#pragma segment Main
#include <Events.h>
#include <Memory.h>
#include <OSUtils.h>
#include <Palettes.h>
#include <Quickdraw.h>
#include <StandardFile.h>
#include <StdLib.h>
#include <ToolUtils.h>
#include <Types.h>
#include <Windows.h>
#include <ctype.h>
#include <dialogs.h>
#include <stdio.h>
#include <string.h>
// #include <Menus.h>
// #include <Fonts.h>
Boolean StopKey()
{
EventRecord ev;
if (EventAvail(keyDownMask + autoKeyMask, &ev)) {
if ((ev.modifiers & cmdKey) &&
((char)(ev.message & charCodeMask) == '.')) {
SysBeep(1);
(void)GetNextEvent(keyDownMask + autoKeyMask, &ev);
return true;
}
}
return false;
}
Boolean cmdKeyIsDown()
{
KeyMap kmap;
GetKeys(&kmap);
return BitTst(kmap, (sizeof(KeyMap) * 8) - 55);
}
Boolean shiftKeyIsDown()
{
KeyMap kmap;
GetKeys(&kmap);
return BitTst(kmap, (sizeof(KeyMap) * 8) - 56);
}
Boolean capsLockIsDown()
{
KeyMap kmap;
GetKeys(&kmap);
return BitTst(kmap, (sizeof(KeyMap) * 8) - 57);
}
Boolean optionKeyIsDown()
{
KeyMap kmap;
GetKeys(&kmap);
return BitTst(kmap, (sizeof(KeyMap) * 8) - 58);
}
Boolean MouseButton() { return Button(); }
Boolean Keypress()
{
EventRecord ev;
return EventAvail(keyDownMask + keyUpMask + autoKeyMask, &ev);
}
char *StdGetFile(char *prompt, OSType fileTypes[], int nFileTypes)
{
Point wher; /*where to display dialog*/
SFReply reply; /*reply record*/
short len;
static char filename[80] = "\0";
wher.h = 80;
wher.v = 90;
if (optionKeyIsDown()) nFileTypes = 0;
SFGetFile(wher, prompt, nil, nFileTypes, fileTypes, nil, &reply);
if (reply.good) {
len = SetVol(nil, reply.vRefNum);
len = reply.fName[0];
strncpy(filename, (char *)(&reply.fName[1]), len);
filename[len] = '\0';
return filename;
}
else
return NULL;
}
int readCmdOptions(FILE *cl, char *progname, char ***argv)
/* command line reader for Mac/MPW -- dgg */
{
#define MAXS 255
#define addarg(sptr) \
if (strlen(sptr) > 0) { \
targv = (char **)realloc(targv, (argc + 1) * sizeof(char *)); \
targv[argc] = (char *)malloc(1 + strlen(sptr) * sizeof(char)); \
strcpy(targv[argc], sptr); \
argc++; \
}
char *pword, st[MAXS];
int argc = 0;
char **targv;
targv = (char **)malloc(1);
if (progname == NULL) progname = "program";
addarg(progname);
fgets(st, MAXS, cl);
if (!feof(cl) && st != NULL && *st != 0) {
pword = strtok(st, "\ \n");
while (pword != NULL) {
addarg(pword);
pword = strtok(NULL, "\ \n");
}
}
*argv = targv;
return argc;
}
int ccommand(char ***argv)
{
int argc;
char **targv;
argc = readCmdOptions(stdin, *argv[0], &targv);
*argv = targv;
return argc;
}
extern _DataInit();
// #define VERSION curSysEnvVers
#define nocolorID 130
#define no68020 133
#define no68881 132
#define no256 134
#define nosys6 135
void MacInit()
{
SysEnvRec theWorld;
OSErr OSys;
DialogPtr crashDia;
long tick;
UnloadSeg(_DataInit);
InitGraf((Ptr)&qd.thePort);
// InitFonts();
InitWindows();
// InitMenus();
// TEInit();
InitDialogs(nil);
InitCursor();
/*______________________________________________________*/
/* If not right Machine then stop */
/*______________________________________________________*/
OSys = SysEnvirons(curSysEnvVers, &theWorld);
/*if(!theWorld.hasColorQD) {
crashDia = GetNewDialog (nocolorID, nil, (WindowPtr) -1);
DrawDialog (crashDia);
Delay (300, &tick);
ExitToShell();
}*/
/*if(theWorld.processor < env68020) {
crashDia = GetNewDialog (no68020, nil, (WindowPtr) -1);
DrawDialog (crashDia);
Delay (300, &tick);
ExitToShell();
}*/
/*if(!theWorld.hasFPU) {
crashDia = GetNewDialog (no68881, nil, (WindowPtr) -1);
DrawDialog (crashDia);
Delay (300, &tick);
ExitToShell();
}
if(theWorld.systemVersion < 0x0600) {
crashDia = GetNewDialog (nosys6, nil, (WindowPtr) -1);
DrawDialog (crashDia);
Delay (300, &tick);
ExitToShell();
}*/
#ifdef UnDeFineD
/*______________________________________________________*/
/* Set Rects */
/*______________________________________________________*/
screenRect = qd.screenBits.bounds;
offLeft = 0;
offTop = 0;
offRight = screenRect.right;
offBottom = screenRect.bottom;
SetRect(&BaseRect, 40, 60, 472, 282);
tempRgn = GetGrayRgn();
HLock((Handle)tempRgn);
TotalRect = (**tempRgn).rgnBBox;
SetRect(&minRect, 80, 80, (**tempRgn).rgnBBox.right - 40,
(**tempRgn).rgnBBox.bottom - 40);
HUnlock((Handle)tempRgn);
/*______________________________________________________*/
/* Open Window & set Palette & Picture */
/*______________________________________________________*/
theGDevice = GetMainDevice();
HLock((Handle)theGDevice);
mycolors = (**(**theGDevice).gdPMap).pmTable;
numcolor = (**(**theGDevice).gdPMap).pixelSize;
HUnlock((Handle)theGDevice);
switch (numcolor) {
case 1:
numcolor = 2;
break;
case 2:
numcolor = 4;
break;
case 4:
numcolor = 16;
break;
case 8:
numcolor = 256;
break;
}
myWindow = NewCWindow(nil, &BaseRect, "", true, zoomDocProc,
(WindowPtr)-1, true, 150);
SetPort((WindowPtr)myWindow);
DrawGrowIcon(myWindow);
srcPalette = NewPalette(numcolor, mycolors, pmCourteous, 0);
SetPalette((WindowPtr)myWindow, srcPalette, true);
/*______________________________________________________*/
/* Set menus */
/*______________________________________________________*/
mymenu0 = GetMenu(appleID);
AddResMenu(mymenu0, 'DRVR');
InsertMenu(mymenu0, 0);
mymenu1 = newmenu(129, "File");
appendmenu(mymenu1, "Start;Quit");
InsertMenu(mymenu1, 0);
mymenu2 = newmenu(130, "Edit");
InsertMenu(mymenu2, 0);
DrawMenuBar();
/*______________________________________________________*/
/* Init variables */
/*______________________________________________________*/
DoneFlag = false;
yieldTime = 0;
return;
#endif
}
main(int argc, char *argv[])
{
Boolean loop = true;
char **myargv;
int myargc;
/* MacInit(); -- SIOW library handles this */
do {
fprintf(stderr, "\nEnter command line for %s [cmd-Q to quit]\n",
argv[0]);
fprintf(stderr, "-> %s ", argv[0]);
myargv = argv;
myargc = ccommand(&myargv);
siow_main(myargc, myargv);
fflush(stdout);
} while (true);
exit(0);
}

1411
readseq.c Normal file

File diff suppressed because it is too large Load Diff

324
ureadasn.c Normal file
View File

@ -0,0 +1,324 @@
/* ureadasn.c
-- parse, mangle and otherwise rewrite ASN1 file/entries for readseq reading
-- from NCBI toolkit (ncbi.nlm.nih.gov:/toolkit)
*/
#ifdef NCBI
#include <ctype.h>
#include <stdio.h>
#include <string.h>
/* NCBI toolkit :include: must be on lib path */
#include <ncbi.h>
#include <seqport.h>
#define UREADASN
#include "ureadseq.h"
#pragma segment ureadasn
/* this stuff is hacked up from tofasta.c of ncbitools */
#define kBaseAny 0
#define kBaseNucleic 1
#define kBaseAmino 2
typedef struct tofasta {
Boolean idonly;
short *seqnum;
short whichSeq;
char **seq, **seqid;
long *seqlen;
} FastaDat, PNTR FastaPtr;
void BioseqRawToRaw(BioseqPtr bsp, Boolean idonly, short whichSeq,
short *seqnum, char **seq, char **seqid, long *seqlen)
{
SeqPortPtr spp;
SeqIdPtr bestid;
Uint1 repr, code, residue;
CharPtr tmp, title;
long outlen, outmax;
char localid[256], *sp;
/* !!! this may be called several times for a single sequence
because SeqEntryExplore looks for parts and joins them...
assume seq, seqid, seqlen may contain data (or NULL)
*/
if (bsp == NULL) return;
repr = Bioseq_repr(bsp);
if (!(repr == Seq_repr_raw || repr == Seq_repr_const)) return;
(*seqnum)++;
if (!(whichSeq == *seqnum || whichSeq == 0)) return;
bestid = SeqIdFindBest(bsp->id, (Uint1)0);
title = BioseqGetTitle(bsp);
if (idonly) {
sprintf(localid, " %d) ", *seqnum);
tmp = localid + strlen(localid) - 1;
}
else {
strcpy(localid, " ");
tmp = localid;
}
tmp = SeqIdPrint(bestid, tmp, PRINTID_FASTA_SHORT);
tmp = StringMove(tmp, " ");
StringNCpy(tmp, title, 200);
/* fprintf(stderr,"BioseqRawToRaw: localid='%s'\n",localid); */
/* < seqid is fixed storage */
/* strcpy( *seqid, localid); */
/* < seqid is variable sized */
outmax = strlen(localid) + 3;
if (*seqid == NULL) {
*seqid = (char *)malloc(outmax);
if (*seqid == NULL) return;
strcpy(*seqid, localid);
}
else {
outmax += strlen(*seqid) + 2;
*seqid = (char *)realloc(*seqid, outmax);
if (*seqid == NULL) return;
if (!idonly) strcat(*seqid, "; ");
strcat(*seqid, localid);
}
if (idonly) {
strcat(*seqid, "\n");
return;
}
if (ISA_na(bsp->mol))
code = Seq_code_iupacna;
else
code = Seq_code_iupacaa;
spp = SeqPortNew(bsp, 0, -1, 0, code);
SeqPortSeek(spp, 0, SEEK_SET);
sp = *seq;
if (sp == NULL) { /* this is always true now !? */
outlen = 0;
outmax = 500;
sp = (char *)malloc(outmax);
}
else {
outlen = strlen(sp);
outmax = outlen + 500;
sp = (char *)realloc(sp, outmax);
}
if (sp == NULL) return;
while ((residue = SeqPortGetResidue(spp)) != SEQPORT_EOF) {
if (outlen >= outmax) {
outmax = outlen + 500;
sp = (char *)realloc(sp, outmax);
if (sp == NULL) return;
}
sp[outlen++] = residue;
}
sp = (char *)realloc(sp, outlen + 1);
if (sp != NULL) sp[outlen] = '\0';
*seq = sp;
*seqlen = outlen;
SeqPortFree(spp);
return;
}
static void SeqEntryRawseq(SeqEntryPtr sep, Pointer data, Int4 index,
Int2 indent)
{
FastaPtr tfa;
BioseqPtr bsp;
if (!IS_Bioseq(sep)) return;
bsp = (BioseqPtr)sep->data.ptrvalue;
tfa = (FastaPtr)data;
BioseqRawToRaw(bsp, tfa->idonly, tfa->whichSeq, tfa->seqnum, tfa->seq,
tfa->seqid, tfa->seqlen);
}
void SeqEntryToRaw(SeqEntryPtr sep, Boolean idonly, short whichSeq,
short *seqnum, char **seq, char **seqid, long *seqlen)
{
FastaDat tfa;
if (sep == NULL) return;
tfa.idonly = idonly;
tfa.seqnum = seqnum;
tfa.whichSeq = whichSeq;
tfa.seq = seq;
tfa.seqid = seqid;
tfa.seqlen = seqlen;
SeqEntryExplore(sep, (Pointer)&tfa, SeqEntryRawseq);
}
char *listASNSeqs(
const char *filename, const long skiplines,
const short format, /* note: this is kASNseqentry or kASNseqset */
short *nseq, short *error)
{
AsnIoPtr aip = NULL;
SeqEntryPtr the_set;
AsnTypePtr atp, atp2;
AsnModulePtr amp;
Boolean inIsBinary =
FALSE; /* damn, why can't asn routines test this? */
char *seq = NULL;
char *seqid = NULL, stemp[256];
long seqlen;
int i, count;
*nseq = 0;
*error = 0;
/* asn dictionary setups */
/*fprintf(stderr,"listASNSeqs: SeqEntryLoad\n");*/
if (!SeqEntryLoad())
goto errxit; /* sequence alphabets (and sequence parse trees)
*/
amp = AsnAllModPtr(); /* get pointer to all loaded ASN.1 modules */
if (amp == NULL) goto errxit;
atp = AsnFind("Bioseq-set"); /* get the initial type pointers */
if (atp == NULL) goto errxit;
atp2 = AsnFind("Bioseq-set.seq-set.E");
if (atp2 == NULL) goto errxit;
/*fprintf(stderr,"listASNSeqs: AsnIoOpen\n");*/
/* open the ASN.1 input file in the right mode */
/* !!!! THIS FAILS when filename has MAC PATH (& other paths?)
* (:folder:filename) */
if ((aip = AsnIoOpen(filename, inIsBinary ? "rb" : "r")) == NULL)
goto errxit;
for (i = 0; i < skiplines; i++)
fgets(stemp, 255,
aip->fp); /* this may mess up asn routines... */
if (!ErrSetLog("stderr"))
goto errxit;
else
ErrSetOpts(ERR_CONTINUE,
ERR_LOG_ON); /*?? log errors instead of die */
if (format == kASNseqentry) { /* read one Seq-entry */
/*fprintf(stderr,"listASNSeqs: SeqEntryAsnRead\n");*/
the_set = SeqEntryAsnRead(aip, NULL);
SeqEntryToRaw(the_set, true, 0, nseq, &seq, &seqid, &seqlen);
if (seq) free(seq);
seq = NULL;
SeqEntryFree(the_set);
}
else { /* read Seq-entry's from a Bioseq-set */
count = 0;
/*fprintf(stderr,"listASNSeqs: AsnReadId\n");*/
while ((atp = AsnReadId(aip, amp, atp)) != NULL) {
if (atp == atp2) { /* top level Seq-entry */
the_set = SeqEntryAsnRead(aip, atp);
SeqEntryToRaw(the_set, true, 0, nseq, &seq,
&seqid, &seqlen);
SeqEntryFree(the_set);
if (seq) free(seq);
seq = NULL;
}
else
AsnReadVal(aip, atp, NULL);
count++;
}
}
AsnIoClose(aip);
*error = 0;
return seqid;
errxit:
AsnIoClose(aip);
if (seqid) free(seqid);
*error = eASNerr;
return NULL;
}
char *readASNSeq(
const short whichEntry, const char *filename, const long skiplines,
const short format, /* note: this is kASNseqentry or kASNseqset */
long *seqlen, short *nseq, short *error, char **seqid)
{
AsnIoPtr aip = NULL;
SeqEntryPtr the_set;
AsnTypePtr atp, atp2;
AsnModulePtr amp;
Boolean inIsBinary =
FALSE; /* damn, why can't asn routines test this? */
char *seq, stemp[200];
int i, count;
*seqlen = 0;
*nseq = 0;
*error = 0;
seq = NULL;
/*fprintf(stderr,"readASNseq: SeqEntryLoad\n");*/
/* asn dictionary setups */
if (!SeqEntryLoad())
goto errxit; /* sequence alphabets (and sequence parse trees)
*/
amp = AsnAllModPtr(); /* get pointer to all loaded ASN.1 modules */
if (amp == NULL) goto errxit;
atp = AsnFind("Bioseq-set"); /* get the initial type pointers */
if (atp == NULL) goto errxit;
atp2 = AsnFind("Bioseq-set.seq-set.E");
if (atp2 == NULL) goto errxit;
/* open the ASN.1 input file in the right mode */
/*fprintf(stderr,"readASNseq: AsnIoOpen(%s)\n", filename);*/
if ((aip = AsnIoOpen(filename, inIsBinary ? "rb" : "r")) == NULL)
goto errxit;
for (i = 0; i < skiplines; i++)
fgets(stemp, 255,
aip->fp); /* this may mess up asn routines... */
if (!ErrSetLog("stderr"))
goto errxit;
else
ErrSetOpts(ERR_CONTINUE,
ERR_LOG_ON); /*?? log errors instead of die */
seq = NULL;
if (format == kASNseqentry) { /* read one Seq-entry */
/*fprintf(stderr,"readASNseq: SeqEntryAsnRead\n");*/
the_set = SeqEntryAsnRead(aip, NULL);
SeqEntryToRaw(the_set, false, whichEntry, nseq, &seq, seqid,
seqlen);
SeqEntryFree(the_set);
goto goodexit;
}
else { /* read Seq-entry's from a Bioseq-set */
count = 0;
/*fprintf(stderr,"readASNseq: AsnReadId\n");*/
while ((atp = AsnReadId(aip, amp, atp)) != NULL) {
if (atp == atp2) { /* top level Seq-entry */
the_set = SeqEntryAsnRead(aip, atp);
SeqEntryToRaw(the_set, false, whichEntry, nseq,
&seq, seqid, seqlen);
SeqEntryFree(the_set);
if (*nseq >= whichEntry) goto goodexit;
}
else
AsnReadVal(aip, atp, NULL);
count++;
}
}
goodexit:
AsnIoClose(aip);
*error = 0;
return seq;
errxit:
AsnIoClose(aip);
*error = eASNerr;
if (seq) free(seq);
return NULL;
}
#endif /*NCBI*/

2121
ureadseq.c Normal file

File diff suppressed because it is too large Load Diff

172
ureadseq.h Normal file
View File

@ -0,0 +1,172 @@
/* File: ureadseq.h
*
* Header for module UReadSeq
*/
#ifndef UREADSEQ_H
#define UREADSEQ_H
typedef char boolean;
#define NEWLINE '\n'
#define false 0
#define true 1
#define min(a, b) (a < b) ? a : b
#define max(a, b) (a > b) ? a : b
#define skipwhitespace(string) \
{ \
while (*string <= ' ' && *string != 0) string++; \
}
/* NLM strings */
#define is_upper(c) ('A' <= (c) && (c) <= 'Z')
#define is_lower(c) ('a' <= (c) && (c) <= 'z')
#define to_lower(c) ((char)(is_upper(c) ? (c) + ' ' : (c)))
#define to_upper(c) ((char)(is_lower(c) ? (c) - ' ' : (c)))
/* readSeq errors */
#define eFileNotFound -1
#define eNoData -2
#define eMemFull -3
#define eItemNotFound -4
#define eOneFormat -5
#define eUnequalSize -6
#define eFileCreate -7
#define eUnknownFormat -8
#define eOptionBad -9
#define eASNerr -10
/* magic number for readSeq(whichEntry) to give seq list */
#define kListSequences -1
/* sequence types parsed by getseqtype */
#define kOtherSeq 0
#define kDNA 1
#define kRNA 2
#define kNucleic 3
#define kAmino 4
/* formats known to readSeq */
#define kIG 1
#define kGenBank 2
#define kNBRF 3
#define kEMBL 4
#define kGCG 5
#define kStrider 6
#define kFitch 7
#define kPearson 8
#define kZuker 9
#define kOlsen 10
#define kPhylip2 11
#define kPhylip4 12
#define kPhylip3 kPhylip4
#define kPhylip kPhylip4
#define kPlain 13 /* keep this at #13 */
#define kPIR 14
#define kMSF 15
#define kASN1 16
#define kPAUP 17
#define kPretty 18
#define kMaxFormat 18
#define kMinFormat 1
#define kNoformat -1 /* format not tested */
#define kUnknown 0 /* format not determinable */
/* subsidiary types */
#define kASNseqentry 51
#define kASNseqset 52
#define kPhylipInterleave 61
#define kPhylipSequential 62
typedef struct {
boolean isactive, baseonlynum;
boolean numright, numleft, numtop, numbot;
boolean nameright, nameleft, nametop;
boolean noleaves, domatch, degap;
char matchchar, gapchar;
short numline, atseq;
short namewidth, numwidth;
short interline, spacer, seqwidth, tab;
} prettyopts;
#define gPrettyInit(p) \
{ \
p.isactive = false; \
p.baseonlynum = true; \
p.numline = p.atseq = 0; \
p.numright = p.numleft = p.numtop = p.numbot = false; \
p.nameright = p.nameleft = p.nametop = false; \
p.noleaves = p.domatch = p.degap = false; \
p.matchchar = '.'; \
p.gapchar = '-'; \
p.namewidth = 8; \
p.numwidth = 5; \
p.interline = 1; \
p.spacer = 10; \
p.seqwidth = 50; \
p.tab = 0; \
}
#ifdef UREADSEQ_G
prettyopts gPretty;
#else
extern prettyopts gPretty;
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern short seqFileFormat(const char *filename, long *skiplines, short *error);
extern short seqFileFormatFp(FILE *fseq, long *skiplines, short *error);
extern char *listSeqs(const char *filename, const long skiplines,
const short format, short *nseq, short *error);
extern char *readSeq(const short whichEntry, const char *filename,
const long skiplines, const short format, long *seqlen,
short *nseq, short *error, char *seqid);
extern char *readSeqFp(const short whichEntry_, FILE *fp_,
const long skiplines_, const short format_,
long *seqlen_, short *nseq_, short *error_,
char *seqid_);
extern short writeSeq(FILE *outf, const char *seq, const long seqlen,
const short outform, const char *seqid);
extern unsigned long CRC32checksum(const char *seq, const long seqlen,
unsigned long *checktotal);
extern unsigned long GCGchecksum(const char *seq, const long seqlen,
unsigned long *checktotal);
#ifdef SMALLCHECKSUM
#define seqchecksum GCGchecksum
#else
#define seqchecksum CRC32checksum
#endif
extern short getseqtype(const char *seq, const long seqlen);
extern char *compressSeq(const char gapc, const char *seq, const long seqlen,
long *newlen);
#ifdef NCBI
extern char *listASNSeqs(const char *filename, const long skiplines,
const short format, short *nseq, short *error);
extern char *readASNSeq(const short whichEntry, const char *filename,
const long skiplines, const short format, long *seqlen,
short *nseq, short *error, char **seqid);
#endif
/* patches for some missing string.h stuff */
extern int Strcasecmp(const char *a, const char *b);
extern int Strncasecmp(const char *a, const char *b, long maxn);
#ifdef __cplusplus
}
#endif
#endif /*UREADSEQ_H*/