JWS-112 Bumping version of ClustalO (src, binaries and windows) to version 1.2.4.
[jabaws.git] / binaries / src / clustalo / src / squid / sqio.c
index fff500b..dfd403a 100644 (file)
@@ -336,7 +336,12 @@ FreeSequence(char *seq, SQINFO *sqinfo)
       free(sqinfo->sa);
     }
   }
-}
+  if (sqinfo->flags & SQINFO_CO){
+    if (NULL != sqinfo->co){ /* FS, r296 -> */
+      free(sqinfo->co);
+    }
+  }
+} /* this is the end of FreeSequence() */
 
 int
 SetSeqinfoString(SQINFO *sqinfo, char *sptr, int flag)
@@ -438,6 +443,7 @@ SeqinfoCopy(SQINFO *sq1, SQINFO *sq2)
   if (sq2->flags & SQINFO_TYPE)  sq1->type   = sq2->type;
   if (sq2->flags & SQINFO_SS)    sq1->ss     = Strdup(sq2->ss);
   if (sq2->flags & SQINFO_SA)    sq1->sa     = Strdup(sq2->sa);
+  if (sq2->flags & SQINFO_CO)    sq1->co     = Strdup(sq2->co);
 }
 
 /* Function: ToDNA()
@@ -865,6 +871,18 @@ endPearson(char *s, int *addend)
   return(*s == '>');
 }
 
+#ifdef CLUSTALO
+static int
+only_whitespace(const char *s) {
+  while (*s != '\0') {
+    if (!isspace((unsigned char)*s))
+      return 0;
+    s++;
+  }
+  return 1;
+}
+#endif
+
 static void 
 readPearson(struct ReadSeqVars *V)
 {
@@ -872,13 +890,28 @@ readPearson(struct ReadSeqVars *V)
 
   if (V->ssimode >= 0) V->r_off = V->ssioffset;
 
+#ifdef CLUSTALO
+  while (only_whitespace(V->buf)) {
+    SeqfileGetLine(V);
+  }
+
+  if (feof(V->f) || *V->buf != '>') 
+#else
   if (*V->buf != '>') 
+#endif
+#ifdef CLUSTALO
+    Die("\
+File %s does not appear to be in FASTA format at line %d.\n\
+You may want to specify the file format on the command line.\n\
+Usually this is done with an option --infmt <fmt>.\n", 
+       V->fname, V->linenumber);
+#else
     Die("\
 File %s does not appear to be in FASTA format at line %d.\n\
 You may want to specify the file format on the command line.\n\
 Usually this is done with an option --informat <fmt>.\n", 
        V->fname, V->linenumber);
-
+#endif
   if ((sptr = strtok(V->buf+1, "\n\t ")) != NULL)
     SetSeqinfoString(V->sqinfo, sptr, SQINFO_NAME);
   if ((sptr = strtok(NULL, "\n")) != NULL)
@@ -1097,6 +1130,16 @@ ReadSeq(SQFILE *V, int format, char **ret_seq, SQINFO *sqinfo)
 #endif
        sqinfo->flags |= SQINFO_SA;
       }
+      if (V->msa->co != NULL && V->msa->co[V->msa->lastidx] != NULL) {
+/* AW: stopping squid from dealigning sequences and corresponding info */
+#ifdef CLUSTALO
+          sqinfo->co = sre_strdup(V->msa->co[V->msa->lastidx], V->msa->alen);
+#else
+          MakeDealignedString(V->msa->aseq[V->msa->lastidx], V->msa->alen, 
+                              V->msa->co[V->msa->lastidx], &(sqinfo->co));          
+#endif
+       sqinfo->flags |= SQINFO_CO;
+      } /* co */
       V->msa->lastidx++;
     } 
   else {
@@ -1209,6 +1252,9 @@ SeqfileFormat(FILE *fp)
              strncmp(buf, "!!NA_SEQUENCE", 13) == 0)
            { fmt = SQFILE_GCG; goto DONE; }
 
+         if (strncmp(buf, "# DUBLIN 1.", 11) == 0) /* -> r296, FS */
+           { fmt = MSAFILE_DUBLIN; goto DONE; }
+
          if (strncmp(buf, "# STOCKHOLM 1.", 14) == 0)
            { fmt = MSAFILE_STOCKHOLM; goto DONE; }
 
@@ -1859,7 +1905,7 @@ String2SeqfileFormat(char *s)
   
   if      (strcmp(s2, "FASTA")     == 0) code = SQFILE_FASTA;
 #ifdef CLUSTALO
-  if      (strcmp(s2, "FA")        == 0) code = SQFILE_FASTA;
+  else if (strcmp(s2, "FA")        == 0) code = SQFILE_FASTA;
   else if (strcmp(s2, "VIENNA")    == 0) code = SQFILE_VIENNA;
   else if (strcmp(s2, "VIE")       == 0) code = SQFILE_VIENNA;
 #endif