36f8f6fb024b20cc523cdf9ebde7491eca84fd7c markd Sun Dec 6 20:33:20 2020 -0800 multiple request per connect works except hgBlat diff --git src/inc/genoFind.h src/inc/genoFind.h index 79dd214..62e02d9 100644 --- src/inc/genoFind.h +++ src/inc/genoFind.h @@ -22,33 +22,38 @@ #endif #ifndef LOCALMEM_H #include "localmem.h" #endif #ifndef BITS_H #include "bits.h" #endif #ifndef AXT_H #include "axt.h" #endif struct gfConnection -/* connection to a gfServer. This allows reuse of the connection when supported. */ +/* connection to a gfServer. This supports reuse of the connection for dynamic + * servers and reopening a connection for static server. */ { - int fd; // socket descriptor + + int fd; // socket descriptor, -1 if closed + char *hostName; // need when reconnecting + int port; + boolean isDynamic; // is this a dynamic server? }; enum gfConstants { gfMinMatch = 2, gfMaxGap = 2, gfTileSize = 11, gfMaxTileUse = 1024, gfPepMaxTileUse = 30000, }; struct gfSeqSource /* Where a block of sequence comes from. */ { struct gfSeqSource *next; char *fileName; /* Name of file. */ @@ -85,30 +90,31 @@ int queryCoverage; /* Number of bases covered in query (thx AG!) */ }; void gfClumpFree(struct gfClump **pClump); /* Free a single clump. */ void gfClumpFreeList(struct gfClump **pList); /* Free a list of dynamically allocated gfClump's */ struct genoFind /* An index of all K-mers in the genome. * WARNING: MUST MODIFY CODE TO STORE/LOAD INDEX TO FILES IF THIS STRUCTURE IS * MODIFIED!!! */ { + boolean isMapped; /* is this a mapped file? */ int maxPat; /* Max # of times pattern can occur * before it is ignored. */ int minMatch; /* Minimum number of tile hits needed * to trigger a clump hit. */ int maxGap; /* Max gap between tiles in a clump. */ int tileSize; /* Size of each N-mer. */ int stepSize; /* Spacing between N-mers. */ int tileSpaceSize; /* Number of N-mer values. */ int tileMask; /* 1-s for each N-mer. */ int sourceCount; /* Count of source files. */ bool isPep; /* Is a peptide. */ bool allowOneMismatch; /* Allow a single mismatch? */ bool noSimpRepMask; /* Dis-Allow simple repeat masking. */ int segSize; /* Index is segmented if non-zero. */ bits32 totalSeqSize; /* Total size of all sequences. */ @@ -142,30 +148,33 @@ void *memMapped; /* memory mapped if non-NULL, with amount allocated */ size_t memLength; bool isTrans; /* is this translated? */ bool noSimpRepMask; /* Suppresses simple repeat masking for very small genomes */ struct genoFind *untransGf; struct genoFind *transGf[2][3]; }; struct genoFindIndex* genoFindIndexBuild(int fileCount, char *seqFiles[], int minMatch, int maxGap, int tileSize, int repMatch, boolean doTrans, char *oocFile, boolean allowOneMismatch, boolean doMask, int stepSize, boolean noSimpRepMask); /* build a untranslated or translated index */ +void genoFindIndexFree(struct genoFindIndex **pGfIdx); +/* free a genoFindIndex */ + void genoFindIndexWrite(struct genoFindIndex *gfIdx, char *fileName); /* write index to file that can be mapped */ struct genoFindIndex* genoFindIndexLoad(char *fileName, boolean isTrans); /* load indexes from file. */ /* --- Stuff for saving results ---- */ struct gfOutput /* A polymorphic object to help us write many file types. */ { struct gfOutput *next; void *data; /* Type-specific data pointer. Must be freeMem'able */ @@ -376,36 +385,45 @@ int minMatch, struct hash *tFileHash, struct gfOutput *out, char *genome, char *genomeDataDir); /* Search indexed translated genome on server with an amino acid sequence. * Then load homologous bits of genome locally and do detailed alignment. * Call 'outFunction' with each alignment that is found. */ void gfAlignTransTrans(struct gfConnection *conn, char *nibDir, struct dnaSeq *seq, boolean qIsRc, int minMatch, struct hash *tFileCache, struct gfOutput *out, boolean isRna, char *genome, char *genomeDataDir); /* Search indexed translated genome on server with an dna sequence. Translate * this sequence in three frames. Load homologous bits of genome locally * and do detailed alignment. Call 'outFunction' with each alignment * that is found. */ -struct gfConnection *gfMayConnect(char *hostName, char *portName); +struct gfConnection *gfMayConnect(char *hostName, char *portName, boolean isDynamic); /* Set up our network connection to server, or return NULL. */ -struct gfConnection * gfConnect(char *hostName, char *portName); +struct gfConnection *gfConnect(char *hostName, char *portName, boolean isDynamic); /* Set up our network connection to server. Aborts on error. */ +void gfBeginRequest(struct gfConnection *conn); +/* called before a request is started. If the connect is not open, reopen + * it. */ + +void gfEndRequest(struct gfConnection *conn); +/* End a request that might be followed by another requests. For + * a static server, this closed the connection. A dynamic server + * it is left open. */// + void gfDisconnect(struct gfConnection **pConn); /* Disconnect from server */ int gfDefaultRepMatch(int tileSize, int stepSize, boolean protTiles); /* Figure out appropriate step repMatch value. */ void gfMakeOoc(char *outName, char *files[], int fileCount, int tileSize, bits32 maxPat, enum gfType tType, boolean noSimpRepMask); /* Count occurences of tiles in seqList and make a .ooc file. */ void gfLongDnaInMem(struct dnaSeq *query, struct genoFind *gf, boolean isRc, int minScore, Bits *qMaskBits, struct gfOutput *out, boolean fastMap, boolean band); /* Chop up query into pieces, align each, and stitch back * together again. */