be4311c07e14feb728abc6425ee606ffaa611a58
markd
  Fri Jan 22 06:46:58 2021 -0800
merge with master

diff --git src/hg/lib/hgMaf.c src/hg/lib/hgMaf.c
index 87ddce7..bd18fcc 100644
--- src/hg/lib/hgMaf.c
+++ src/hg/lib/hgMaf.c
@@ -271,45 +271,66 @@
 	        continue;
 	    }
 	else
 	    subMaf = maf;
 	for (mc = subMaf->components; mc != NULL; mc = mc->next, ++order)
 	    {
 	    /* Extract name up to dot into 'orgName' */
 	    char buf[128], *e, *orgName;
 
 	    if ((mc->size == 0) || (mc->srcSize == 0)) /* skip over components without sequence */
 		continue;
 
 	    mc->leftStatus = mc->rightStatus = 0; /* squash annotation */
 
 	    e = strchr(mc->src, '.');
+	    /* Look up dyString corresponding to  org */
 	    if (e == NULL)
+                {
 		orgName = mc->src;
+                org = hashFindVal(orgHash, orgName);
+                }
 	    else
 		{
 		int len = e - mc->src;
 		if (len >= sizeof(buf))
 		    errAbort("organism/database name %s too long", mc->src);
 		memcpy(buf, mc->src, len);
 		buf[len] = 0;
 		orgName = buf;
+                // if the orderList is present, it may have organism names with dots in them,
+                // If we can't find the sequence after one dot, we look again after two
+                if (orderList != NULL)  
+                    {
+                    if ((org = hashFindVal(orgHash, orgName)) == NULL)  // couldn't find this org
+                        {
+                        e = strchr(e + 1, '.');  // look for another dot following the first dot
+                        if (e != NULL)
+                            {
+                            // if we found a dot, try the longer name 
+                            len = e - mc->src;
+                            if (len >= sizeof(buf))
+                                errAbort("organism/database name %s too long", mc->src);
+                            memcpy(buf, mc->src, len);
+                            buf[len] = 0;
+                            org = hashFindVal(orgHash, orgName);
+                            }
+                        }
+                    }
 		}
 
-	    /* Look up dyString corresponding to  org, and create a
-	     * new one if necessary. */
-	    org = hashFindVal(orgHash, orgName);
+	    /* create a  new org if necessary. */
 	    if (org == NULL)
 		{
 		if (orderList != NULL)
 		   errAbort("%s is not in orderList", orgName);
 		AllocVar(org);
 		slAddHead(&orgList, org);
 		hashAddSaveName(orgHash, orgName, org, &org->name);
 		org->dy = dyStringNew(native->size*1.5);
 		dyStringAppendMultiC(org->dy, '.', symCount);
 		if (nativeOrg == NULL)
 		    nativeOrg = org;
 		}
 	    if (orderList == NULL && order > org->order)
 		org->order = order;
 	    org->hit = TRUE;