aa03a541ef25d83f1542202f784c53500c434c2d
angie
  Sat Jun 20 14:35:04 2020 -0700
New util faToVcf for extracting single-nucleotide variants from multi-sequence FASTA alignment.

diff --git src/inc/iupac.h src/inc/iupac.h
index 0d94f8f..6cee6b9 100644
--- src/inc/iupac.h
+++ src/inc/iupac.h
@@ -1,63 +1,96 @@
 /* iupac - routines to help cope with IUPAC ambiguity codes in DNA sequence. */
 
 #ifndef IUPAC_H
 #define IUPAC_H
 
 boolean iupacMatch(char iupac, char dna);
 /* See if iupac ambiguity code matches dna character */
 
 boolean iupacMatchLower(char iupac, char dna);
 /* See if iupac ambiguity code matches dna character where
  * both are lower case */
 
 boolean isIupac(char c);
 /* See if iupac c is a legal iupac char */
 
 boolean isIupacLower(char c);
 /* See if iupac c is a legal (lower case) iupac char */
 
 void iupacFilter(char *in, char *out);
 /* Filter out non-DNA non-UIPAC ambiguity code characters and change to lower case. */
 
 boolean anyIupac(char *s);
 /* Return TRUE if there are any IUPAC ambiguity codes in s */
 
 char iupacComplementBaseLower(char iupac);
 /* Return IUPAC complement for a single base */
 
 void iupacComplementLower(char *iupac, int iuSize);
 /* Return IUPAC complement many bases. Assumes iupac is lower case. */
 
 void iupacReverseComplement(char *iu, int iuSize);
 /* Reverse complement a string containing DNA and IUPAC codes. Result will be always
  * lower case. */
 
 boolean iupacMatchStart(char *iupacPrefix, char *dnaString);
 /* Return TRUE if start of DNA is compatible with iupac */
 
 char *iupacIn(char *needle, char *haystack);
 /* Return first place in haystack (DNA) that matches needle that may contain IUPAC codes. */
 
 INLINE boolean isIupacAmbiguous(char c)
 /* Return TRUE if c is an IUPAC ambiguity code. */
 {
 switch (tolower(c))
     {
     case 'r':
     case 'y':
     case 's':
     case 'w':
     case 'k':
     case 'm':
     case 'b':
     case 'd':
     case 'h':
     case 'v':
     case 'n':
         return TRUE;
     }
 return FALSE;
 }
 
+INLINE char *iupacAmbiguousToString(char c)
+/* Return a static string of [acgt] bases that C would resolve to. */
+{
+switch (tolower(c))
+    {
+    case 'r':
+        return "ag";
+    case 'y':
+        return "ct";
+    case 's':
+        return "cg";
+    case 'w':
+        return "at";
+    case 'k':
+        return "gt";
+    case 'm':
+        return "ac";
+    case 'b':
+        return "cgt";
+    case 'd':
+        return "agt";
+    case 'h':
+        return "act";
+    case 'v':
+        return "acg";
+    case 'n':
+        return "acgt";
+    default:
+        errAbort("iupacAmbiguousToString: unrecognized character '%c'", c);
+    }
+return NULL;
+}
+
 #endif /* IUPAC_H */