// -----------------------------------------------------------------
// Created automagically from ../PT.aisc
// using aisc-script '../AISC/aisc.pa'
// DO NOT EDIT THIS FILE!!!
// -----------------------------------------------------------------

#ifndef AISC_GEN_SERVER_INCLUDED
#define AISC_GEN_SERVER_INCLUDED

typedef char       *aisc_string;
typedef const char *aisc_cstring;

#ifndef AISC_GLOBAL_H
#include <aisc_global.h>
#endif
// PROBE_COM/aisc_include.header [empty] 


// some constants
#define LIST_SIZE         20 // Size of I_STR Buffer
#define PERC_SIZE         20 // How many centigrades to look
#define ALPHA_SIZE        52 // 26 BIG, 26 small letters
#define DOMAIN_MIN_LENGTH 8  // Minimum length of a domain
#define PT_PART_DEEP      2  // The Deep of the Partitions

// the keys
typedef enum enum_t_key {
    KEY_PT_COMMON       = 0x10000*0,
    KEY_PT_TPROBE       = 0x10000*9,
    KEY_PT_SEQUENCE     = 0x10000*8,
    KEY_PT_PDC          = 0x10000*7,
    KEY_PT_PEP          = 0x10000*6,
    KEY_PT_FAMILYLIST   = 0x10000*5,
    KEY_PT_FAMILYFINDER = 0x10000*12,
    KEY_PT_MATCHLIST    = 0x10000*4,
    KEY_PT_SPECIESLIST  = 0x10000*3,
    KEY_PT_LOCS         = 0x10000*2,
    KEY_PT_MAIN         = 0x10000*1,
    KEY_MAX
} t_key;

// forward decl dll types
struct dllpublic_ext;
struct dllheader_ext;

// "public" version of dll
struct dll_public { // parent of dll (=DoubledLinkedList)
    t_key          key;    // The key
    int            cnt;    // Number of elements
    long           hash;   // Hash Table
    dllheader_ext *parent; // My Owner
    dllheader_ext *last;   // Pointer to the last element
};
struct dll_header { // link header (should be head of each function)
    t_key        key;    // The Key
    dll_public  *parent; // Pointer to dll_public
    aisc_string  ident;  // The ident [not necessary]
};

template <typename USERTYPE>
struct dll {
    dll_header  mh; // ***ANOTHEROLIHACK**
    USERTYPE   *previous, *next;
    int get_count() const { return mh.parent ? mh.parent->cnt : 0; }
};

// "private" (i.e. real) version of dll (DoubledLinkedList)
struct dllpublic_ext : public dll_public { 
    dllheader_ext *first; 
};
// pseudo-base-class of dll<USERTYPE> (bit-equal)
struct dllheader_ext : dll<dllheader_ext> {}; // pseudo-base-class of dll<USERTYPE> (bit-equal)

// forward decl user datatypes
struct PT_tprobes;
struct PT_bond;
struct PT_sequence;
struct PT_pdc;
struct PT_exProb;
struct PT_family_list;
struct PT_family;
struct PT_probematch;
struct PT_species_list;
struct PT_local;
struct PT_main;

// user defined datatypes
struct PT_tprobes : public dll<PT_tprobes> { // the probe we want to test
    aisc_string  sequence;        // The Sequence to check
    int          seq_len;         // The len of the sequence
    double       sum_bonds;       // The sum of all bonds
    double       quality;         // The quality of the probe = GROUPSIZE*dT
    int          groupsize;       // The Size of the group
    int          hairpin;         // How many hairpin bonds
    double       whairpin;        // Weighted Hairpins
    int          perc[PERC_SIZE]; // Result: How many non group hits per centigrade
    double       temp;            // The temperature of the probe
    int          mishits;         // How many outgroup members hit
    int          apos;            // The absolute position of probe
    int          get_r_pos;       // The ecoli based position of probe
};
struct PT_bond { // the definition of a bond
    double  val; // how strong is that bond
};
struct PT_sequence : public dll<PT_sequence> { // the additional sequences
    bytestring  seq; // The Sequence
};
struct PT_pdc : public dll<PT_pdc> { // probe design
    double       dte;                    // The Temperature drop per percent mismatch on the edge of the probe
    double       dt;                     // The temperature drop per percent mismatch
    int          looplen;                // The Loop Length of a probe
    int          min_probelen;           // the minimum length of the designed probes
    double       mintemp;                // minimum temperature
    double       maxtemp;                // maximum temperature
    double       min_gc;                 // the minimum GC content
    double       max_gc;                 // the maximum GC content
    double       maxbonds;               // The maximum of hairpin bonds
    int          min_ecolipos;           // the minimum ecoli position [1..N]. -1 means 'no restriction'
    int          max_ecolipos;           // the maximum ecoli position [1..N]. -1 means 'no restriction'
    double       min_coverage;           // the minimum coverage for the targetted group of species
    int          max_mishits;            // the maximum mishits
    int          clipresult;             // Clip the Result list
    int          pos_groups[ALPHA_SIZE]; // Position of Groups
    bytestring   checksums;              // a list of sequence checksums separated by '#' is optional
    bytestring   names;                  // a list of names separated by '#' is expected
    dll_public   psequences;
    PT_sequence *sequences;              // Additional Sequences
    dll_public   ptprobes;
    PT_tprobes  *tprobes;                // The result
    double       max_rj_coverage;        // the maximum rejected coverage for the targetted group of species
    int          min_rj_mishits;         // the minimum rejected mishits
    int          max_probelen;           // the maximum length of the designed probes (or -1 to use MIN_PROBELEN
};
struct PT_exProb : public dll<PT_exProb> { // iterate all existing probes
    int          plength;    // Length of searched probes
    int          numget;     // Number of searched probes
    int          readable;   // Return readable probes
    int          separator;  // Separator for result (';') 
    int          tu;         // Char used for T/U ('T') 
    int          restart;    // 1 => start from beginning
    bytestring   next_probe; // next probe to look for (internal)
    aisc_string  result;     // The result
};
struct PT_family_list : public dll<PT_family_list> { // the family list
    aisc_string  name;        // name of species
    int          matches;     // number of matches
    double       rel_matches; // MATCHES / (SEQ_LEN - PROBE_LEN + 1)
};
struct PT_family : public dll<PT_family> { // next relative search
    int             pr_len;        // Length of probes
    int             mis_nr;        // Number of mismatches
    int             only_A_probes; // Type of search: 0 = search all, 1 = only a*
    int             complement;    // Search for complement? (see FF_complement)
    dll_public      pfl;
    PT_family_list *fl;            // Sorted List of family
    int             list_size;     // size of result list
    int             sort_type;     // Type of sorting 0 = MATCHES, 1 = REL_MATCHES
    int             sort_max;      // Sort only the SORT_MAX best hits
    int             range_start;   // if != -1 -> ignore matches starting left of that position [0..N-1]
    int             range_end;     // if != -1 -> ignore matches ending right  of that position [0..N-1]
    double          min_score;     // Skip results with rel or abs score below MIN_SCORE (affects reported FAMILY_LIST_SIZE)
    int             rel_scoring;   // relative scoring scaling mode (see RelativeScoreScaling)
    aisc_string     ff_error;      // the error text
};
struct PT_probematch : public dll<PT_probematch> { // the probe match list
    int     name;         // id of species
    int     b_pos;        // pos of probe
    int     g_pos;        // pos of probe (gene relative)
    int     rpos;         // relative pos of probe
    int     mismatches;   // number of mismatches
    double  wmismatches;  // number of weighted mismatches
    int     N_mismatches; // number of 'N' mismatches
    double  dt;           // the dt of a probe
    char   *sequence;     // path of probe
    int     reversed;     // reversed probe matches
};
struct PT_species_list : public dll<PT_species_list> { // the species list
    int  member; // species member of group
};
struct PT_local : public dll<PT_local> { // local communication buffer
    int            socket;              // the callback
    aisc_string    pm_sequence;         // the sequence
    aisc_string    pm_csequence;        // the complement sequence
    int            pm_reversed;         // reverse probe
    int            pm_complement;       // complement probe
    int            pm_max;              // max mismatches
    int            pm_max_hits;         // max number of hits reported (0=unlimited)
    int            sort_by;             // 0 == mismatches  1 == weighted mismatches 2 == weighted mismatches with pos and strength
    int            pm_nmatches_ignored; // max. of accepted matches vs N
    int            pm_nmatches_limit;   // N-matches are only accepted, if less than NMATCHES_LIMIT occur, otherwise no N-matches are accepted 
    dll_public     ppm;
    PT_probematch *pm;                  // result: List of species where probe matches
    int            matches_truncated;   // result: whether MATCH_LIST was truncated
    aisc_string    ls_error;            // the error text
    int            group_count;         // result: Number of selected species
    dll_public     ppdc;
    PT_pdc        *pdc;                 // The new probe design
    dll_public     pep;
    PT_exProb     *ep;                  // Find all existing probes
    dll_public     pffinder;
    PT_family     *ffinder;             // next relative search
    aisc_string    user;                // the username
    aisc_string    address;             // the useraddress
    aisc_string    login;               // the date the user logged in
    PT_bond        bond[(4*4)];         // The bond matrix
    int            dummy;               // init bond matrix
    double         split;               // Split the domains if bond value is less the average bond value - split
};
struct PT_main { // global data
    t_key            key;      // the KEY
    dll_public       ploc_st;
    PT_local        *loc_st;   // the parameters
    int              who;      // who started this server
    int              m_type;   // the message type
    aisc_string      m_text;   // the message text
    dll_public       psl;
    PT_species_list *sl;       // list of species
    aisc_string      dumpname; // filename used for DUMP_INDEX
};

extern const char *aisc_server_error;

#else 
#error header included twice 
#endif // AISC_GEN_SERVER_INCLUDED
