Skip to content

Commit

Permalink
Release/1.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
ToniWestbrook committed May 14, 2019
1 parent 4c0de72 commit 1423498
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 24 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## [1.4.6] - 2019-05-07
### Fixed
- Web request retries now work properly

### Added
- Taxonomic ID and Lineage to UniProt report

## [1.4.5] - 2019-05-07
### Changed
- Changed UniProt web request batch size to 5000 entries to reduce chances of server timeout
Expand Down
2 changes: 1 addition & 1 deletion main.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
#define PACKAGE_VERSION STR(PACKAGE_VERSION_MAJOR) "." STR(PACKAGE_VERSION_MINOR) "." STR(PACKAGE_VERSION_REV)
#define PACKAGE_VERSION_MAJOR 1
#define PACKAGE_VERSION_MINOR 4
#define PACKAGE_VERSION_REV 5
#define PACKAGE_VERSION_REV 6
#endif

// Render usage and version details
Expand Down
50 changes: 27 additions & 23 deletions uniprot.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void renderUniprotReport(int passType, int passPrimary, FILE * passStream, const
break;

case OUTPUT_TYPE_UNIPROT_FULL:
fprintf(passStream, "%s\tUniProtKB\tID\tOrganism\tProtein Names\tGenes\tPathway\tFeatures\tGene Ontology\tReviewed\tExistence\tComments\tCross Reference (KEGG)\tCross Reference (GeneID)\tCross Reference (PATRIC)\tCross Reference(EnsemblBacteria)\n", commonHeader);
fprintf(passStream, "%s\tUniProtKB\tID\tOrganism\tProtein Names\tGenes\tPathway\tFeatures\tGene Ontology\tReviewed\tExistence\tComments\tCross Reference (KEGG)\tCross Reference (GeneID)\tCross Reference (PATRIC)\tCross Reference(EnsemblBacteria)\tTaxonomic ID\tLineage\n", commonHeader);
renderUniprotEntries(uniprotLists + UNIPROT_LIST_FULL, UNIPROT_LIST_FULL, passStream);
freeCURLBuffer(&tempBuffer);

Expand Down Expand Up @@ -246,27 +246,25 @@ void retrieveUniprotOnline(UniprotList * passList, CURLBuffer * retBuffer, const
queryCount = (passList->entryCount < UNIPROT_MAX_SUBMIT) ? passList->entryCount : UNIPROT_MAX_SUBMIT;

for (entryIdx = 0 ; entryIdx < passList->entryCount ; ) {

// Restart a limited number of times if errors encountered
for (errorIdx = 0 ; errorIdx < UNIPROT_MAX_ERROR ; errorIdx++) {

// Stage 1 preparation - build and sanitize query string
queryString[0] = 0;
for (queryIdx = 0 ; (queryIdx < queryCount) && (entryIdx < passList->entryCount) ; entryIdx++) {
for (parseIdx = 0 ; parseIdx < strlen(passList->entries[entryIdx].id) ; parseIdx++) {
sprintf(queryString, "%s%s ", queryString, passList->entries[entryIdx].id);
queryIdx++;
break;
}
// Preparation - build and sanitize query string outside of error loop
queryString[0] = 0;
for (queryIdx = 0 ; (queryIdx < queryCount) && (entryIdx < passList->entryCount) ; entryIdx++) {
for (parseIdx = 0 ; parseIdx < strlen(passList->entries[entryIdx].id) ; parseIdx++) {
sprintf(queryString, "%s%s ", queryString, passList->entries[entryIdx].id);
queryIdx++;
break;
}
}

httpString = curl_easy_escape(curlHandle, queryString, 0);
sprintf(queryString, "uploadQuery=%s&format=job&from=ACC+ID&to=ACC&landingPage=false", httpString);
curl_free(httpString);
httpString = curl_easy_escape(curlHandle, queryString, 0);
sprintf(queryString, "uploadQuery=%s&format=job&from=ACC+ID&to=ACC&landingPage=false", httpString);
curl_free(httpString);

logMessage(__func__, LOG_LEVEL_MESSAGE, "Submitted %d of %d entries to UniProt...\n", entryIdx, passList->entryCount);
// Restart a limited number of times if errors encountered
for (errorIdx = 0 ; errorIdx < UNIPROT_MAX_ERROR ; errorIdx++) {
// Stage 1 - Submit query for processing
logMessage(__func__, LOG_LEVEL_MESSAGE, "Submitting %d of %d entries to UniProt...\n", entryIdx, passList->entryCount);

// Stage 1 - Submit query for processing
curl_easy_setopt(curlHandle, CURLOPT_URL, "https://www.uniprot.org/uploadlists/");
curl_easy_setopt(curlHandle, CURLOPT_POSTFIELDS, queryString);
curl_easy_setopt(curlHandle, CURLOPT_FOLLOWLOCATION, 1L);
Expand All @@ -278,13 +276,13 @@ void retrieveUniprotOnline(UniprotList * passList, CURLBuffer * retBuffer, const
curlResult = curl_easy_perform(curlHandle);

if (curlResult != CURLE_OK) {
logMessage(__func__, LOG_LEVEL_ERROR, "CURL: %s\n", curl_easy_strerror(curlResult));
logMessage(__func__, LOG_LEVEL_ERROR, "CURL: %s (retrying)\n", curl_easy_strerror(curlResult));
continue;
}

// Stage 2 - Wait for results
if (tempBuffer.size > 50) {
logMessage(__func__, LOG_LEVEL_ERROR, "Received unexpected job ID size\n");
logMessage(__func__, LOG_LEVEL_ERROR, "Received unexpected job ID size (retrying)\n");
continue;
}
sprintf(jobID, "%s", tempBuffer.buffer);
Expand All @@ -302,16 +300,16 @@ void retrieveUniprotOnline(UniprotList * passList, CURLBuffer * retBuffer, const
}

if (tempBuffer.size > 9) {
logMessage(__func__, LOG_LEVEL_ERROR, "Received unexpected job response size\n");
logMessage(__func__, LOG_LEVEL_ERROR, "Received unexpected job response sizei (retrying)\n");
continue;
}
if (curlResult != CURLE_OK) {
logMessage(__func__, LOG_LEVEL_ERROR, "CURL: %s\n", curl_easy_strerror(curlResult));
logMessage(__func__, LOG_LEVEL_ERROR, "CURL: %s (retrying)\n", curl_easy_strerror(curlResult));
continue;
}

// Stage 3 - Retrieve Results
sprintf(queryString, "query=job:%s&format=tab&columns=entry%%20name,id,organism,protein%%20names,genes,pathway,features,go,reviewed,existence,comments,database(KEGG),database(GeneID),database(PATRIC),database(EnsemblBacteria)", jobID);
sprintf(queryString, "query=job:%s&format=tab&columns=entry%%20name,id,organism,protein%%20names,genes,pathway,features,go,reviewed,existence,comments,database(KEGG),database(GeneID),database(PATRIC),database(EnsemblBacteria),organism-id,lineage(all)", jobID);
curl_easy_setopt(curlHandle, CURLOPT_URL, "https://www.uniprot.org/uniprot/");
curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, retBuffer);

Expand All @@ -324,6 +322,12 @@ void retrieveUniprotOnline(UniprotList * passList, CURLBuffer * retBuffer, const

break;
}

// Check if download failed max number of times
if (errorIdx == UNIPROT_MAX_ERROR) {
logMessage(__func__, LOG_LEVEL_ERROR, "Download failed after multiple retries. Please check Internet connection and finalize with PALADIN-plugins\n");
break;
}
}

curl_easy_cleanup(curlHandle);
Expand Down

0 comments on commit 1423498

Please sign in to comment.