Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error is prodcued if zero ids are returne from query and reauthentication is required #51

Closed
ammaraziz opened this issue Feb 1, 2024 · 2 comments

Comments

@ammaraziz
Copy link
Contributor

ammaraziz commented Feb 1, 2024

If the query returns zero ids, gisaidr::query errors:

query(
  credentials = credentials,
  lineage =  "JN.1.1.2",
  location = 'Australia',
  fast = TRUE
  )

Output:

Selecting all 0 accession_ids.
Error in read.table(file = file, header = header, sep = sep, quote = quote,  : 
  no lines available in input

I have a script that queries many lineages in a for loop. If one lineage hits an error it stops the loop. Current solution, which might be the best solution is:

gisaid_login = function() {
    username = ""
    password = ""
    credentials <<- login(username = username, password = password)

}

lineages = list()
for (lineage in lineage_of_interest) {
    possibleError = tryCatch(
        {tmp = query(
            credentials = credentials,
            lineage = lineage,
            location = 'Australia',
            fast = TRUE
        )},
        error=function(e) e
    )
    if(inherits(possibleError, "error")) {
        gisaid_login()
        next
        }
    
    lineages = append(lineages, tmp)
}

Another odd side effect is that queries that are zero force reauthenticate:

> query(
+     credentials = credentials,
+     lineage =  "JN.1.1.2",
+     location = 'Australia',
+     fast = TRUE
+ )
Selecting all 0 accession_ids.
Error in read.table(file = file, header = header, sep = sep, quote = quote,  : 
  no lines available in input
> query(
+     credentials = credentials,
+     lineage =  "JN.1.1.2",
+     location = 'Australia',
+     fast = TRUE
+ )
Selecting all 0 accession_ids.
Error in parseResponse(response) : Error! Please login again.

Very strange. Could it be another anti-bioinformatician measures?

Posting the solution if others run into this problem.

@ammaraziz ammaraziz changed the title Catch and continue if zero ids are return from query Error is prodcued if zero ids are returne from query and reauthentication is required Feb 1, 2024
@Wytamma
Copy link
Owner

Wytamma commented Feb 1, 2024

Thanks @ammaraziz! This is related to the fast = TRUE query. When get_accession_ids fails (tries to read empty CSV of ids) the function exits and back cmd isn't sent (hence needing to log in again).

@Wytamma
Copy link
Owner

Wytamma commented Feb 1, 2024

Solved in v0.9.10

@Wytamma Wytamma closed this as completed Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants