int main(int argv, char** argc) { File* hw; Marker* markers; Marker* it; const char* markersPath; const char* hwPath; FILE* outFile; if (argv != 3) { printf("Usage: %s markers homeworks\n", argc[0]); printf("markers: Markers file path.\n"); printf("files: HW files path.\n"); exit(EXIT_FAILURE); } markersPath = argc[1]; hwPath = argc[2]; markers = readMarkers(markersPath); srand(time(NULL)); rand(); rand(); hw = makeFileList(hwPath); markers = distribute(hw, markers); markers = sortMarkers(markers, numMarkers(markers)); for (it = markers; it; it = it->next) { it->files = sortFiles(it->files, numFiles(it->files)); } printMarkers(markers); for (it = markers; it; it = it->next) { free((void*)it->name); } freeMarkers(markers); freeFiles(hw); return 0; }
void writeOut(FILE *sto) /* write out STS marker information to a file */ { struct hashEl *mapList = NULL, *mapEl = NULL, *stsList = NULL, *stsEl = NULL; struct hashEl *aliasList = NULL, *aliasEl = NULL; struct zfin *zfEl = NULL; struct sts *sts = NULL, *s = NULL, *stsVal = NULL; struct alias *aliases = NULL; struct aliasId *aliasId = NULL; char *alias = NULL, *id = NULL, *al = NULL, *addName = NULL, *newName = NULL; boolean found = FALSE, aliasFound = FALSE; int i = 0, j = 0; char **aliasNames = NULL; mapList = hashElListHash(zfinMarkerHash); stsList = hashElListHash(stsHash); aliasList = hashElListHash(aliasByNameHash); fprintf(sto, "UniSTS ID\tUniSTS Accession\tUniSTS Name\tZFIN name\tZFIN ID\tUniSTS Alias\tZFIN Alias\tZFIN Gb Acc\tPanel\tChrom\tPosition\tUnits\n \n"); if (mapList != NULL) { /* walk through list of hash elements */ for (mapEl = mapList; mapEl != NULL; mapEl = mapEl->next) { found = FALSE; zfEl = (struct zfin *)mapEl->val; /* check aliases in all combinations */ /* if this name is a key in the stsHash */ if ((sts = hashFindVal(stsHash, mapEl->name)) != NULL) found = TRUE; /* check by ZFIN alias instead */ else if ((zfEl->zfAlias != NULL) && (!found)) { alias = cloneString(zfEl->zfAlias); touppers(alias); stsVal = NULL; if ((stsVal = hashFindVal(stsHash, alias)) != NULL) { found = TRUE; sts = stsVal; } } /* check stsHash for name with extension or remove extension from zfin name */ else if (!found) { sts = (struct sts *)addExtensionAndSearch(mapEl->name, stsHash, FALSE); if (sts != NULL) found = TRUE; } /* check if this is an alias in alias hash keyed by alias names */ /* need to get list of aliases in all cases but if sts ID not found */ /* can find it here */ /* mapEl->name is in upper case, so get lower case, zfinEl->name */ aliasFound = FALSE; if (((aliasId = hashFindVal(aliasByNameHash, mapEl->name))!=NULL) || ((aliasId = hashFindVal(aliasByNameHash, zfEl->name))!=NULL)) aliasFound = TRUE; else /* alias is not found, try different extensions */ { aliasId = (struct aliasId *)addExtensionAndSearch(zfEl->name, aliasByNameHash, TRUE); if (aliasId != NULL) aliasFound = TRUE; } if (!found && sts != NULL) sts = NULL; /* all UniSTS IDs have an entry in sts and alias files so the */ /* UniSTS ID in the sts found will also be in aliases IDs list */ if (aliasFound) { /* go through each ID in the ids array and get sts struct */ /* and the list of aliases */ for (j = 0; j < MAXIDS; j++) { if (aliasId->ids[j] != NULL) { /* get sts and alias names */ sts = hashFindVal(stsIdHash, aliasId->ids[j]); aliases = hashFindVal(aliasHash, aliasId->ids[j]); printMarkers(sto, sts, zfEl, aliases->names); } } } else printMarkers(sto, sts, zfEl, NULL); } } hashElFreeList(&mapList); hashElFreeList(&stsList); hashElFreeList(&aliasList); }