 /* file pick_min1du.c */

#if !defined(COMPILE_ENVIRONMENT)
#include <gp/stdcenvf.h> /* std compile environment for functions */
#endif

 enum edits1 pick_min1du(unsigned short int dx[])
/*********************************************************/
/* Picks the minimum cost of dx[edits1], where edits1 is */
/* enum type {DEL,SUB,INS}.                              */
/* If min-cost tie includes a SUB, then it is picked.    */
/* If min-cost tie is between INS and DEL, INS is picked.*/
/* (Used by dynamic programming alignment functions.)    */
/*********************************************************/
  {char proc[] = "pick_min1d";
   enum edits1 choice;
db_enter_msg(proc,1); /* debug only */
  /* pick min of dx[edits1] using special logic to break ties */
   if (dx[DEL] < dx[SUB])
     {if (dx[DEL] < dx[INS]) choice = DEL;
      else
        {if (dx[INS] < dx[DEL]) choice = INS;
         else
           {/* dx[DEL],dx[INS] tie */
            if (db_level > 1) printf("%s DEL,INS tie for min\n",pdb);
            choice = INS; /* arb it */
     }  }  }
   else /* dx[DEL] >= dx[SUB] */
     {if (dx[DEL] == dx[SUB])
        {if (dx[INS] < dx[DEL]) choice = INS;
         else
           {if (dx[INS] > dx[DEL])
              {/* dx[DEL],dx[SUB] tie */
               if (db_level > 1) printf("%s DEL,SUB tie for min\n",pdb);
               /* pick SUB */
               choice = SUB;
              }
            else
              {/* dx[DEL], dx[SUB], dx[INS] tie */
               if (db_level > 1) printf("%s DEL,SUB,INS tie for min\n",pdb);
               /* pick SUB */
               choice = SUB;
        }  }  }
      else
        {/* dx[DEL] is out of contention */
         if (dx[SUB] < dx[INS]) choice = SUB;
          else
           {if (dx[INS] < dx[SUB]) choice = INS;
           else
              {/* dx[SUB], dx[INS] tie */
               if (db_level > 1) printf("%s SUB,INS tie for min\n",pdb);
               /* pick SUB */
               choice = SUB;
     }  }  }  }

db_leave_msg(proc,1); /* debug only */

   return choice;
  }
