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

select atleast one sequence! #35

Closed
josenikhid97 opened this issue Oct 12, 2022 · 3 comments
Closed

select atleast one sequence! #35

josenikhid97 opened this issue Oct 12, 2022 · 3 comments

Comments

@josenikhid97
Copy link

hello @julienfumey , @sebastianduchene , @Wytamma

i have written a script for downloading the 100 sequences everyday from beginning of pandemic to till now. now when I run the script it pops up an error saying that " Select at least one sequence! " and the script is down below

install.packages('devtools', repos = "http://cran.us.r-project.org")

install.packages("devtools")

devtools::install_github("Wytamma/GISAIDR", force = TRUE)

library(GISAIDR)
for (day in dates){
credentials <- login(username = , password = )
df <- query(credentials = credentials,complete = T, high_coverage = T,low_coverage_excl = T,collection_date_complete = T,from = day, to= day,start_index = 1,nrows =100)
df <- df[df$host == 'Human',]
all(df$length > 29000)
list_of_accession_ids <- df$accession_ids
full_df_with_seq <- download(
credentials = credentials,
list_of_accession_ids = list_of_accession_ids,
get_sequence=T)
full_df_with_seq$sequence
export_fasta(full_df_with_seq, out_file_name = paste0(day,".fasta"), date_format='%Y-%m-%d',delimiter='/')}

can you make this piece of code to work

Screenshot_2022-10-12_14-40-01

best
jose

@Wytamma
Copy link
Owner

Wytamma commented Oct 13, 2022

Hi @josenikhid97 I suspect on of one of the days list_of_accession_ids is empty i.e. no sequences match the query for that day. I'd suggest adding a check for that e.g.

if (nrow(df) > 0) {
  full_df_with_seq <- download(
    credentials = credentials,
    list_of_accession_ids = list_of_accession_ids,
    get_sequence = T
  )
}

@Wytamma Wytamma pinned this issue Oct 13, 2022
@josenikhid97
Copy link
Author

josenikhid97 commented Oct 13, 2022

Hello, @Wytamma i changed the line of code u mentioned, but it is still the same

@code

credentials<- login(username = ,  password = )
df <- query(credentials = credentials,complete = T, high_coverage = T,low_coverage_excl = T,collection_date_complete = T,from = '2020-08-20', to= '2020-08-20',start_index = 1,nrows =50)
df <- df[df$host == 'Human',]
all(df$length > 29000)
list_of_accession_ids <- df$accession_ids
if (nrow(df) > 0) {
  full_df_with_seq <- download(
    credentials = credentials, 
    list_of_accession_ids = list_of_accession_ids,
    get_sequence= T 
  )
}
full_df_with_seq$sequence
export_fasta(full_df_with_seq, out_file_name = paste0('2020-08-19',".fasta"), date_format='%Y-%m-%d',delimiter='/')

I am attaching the error, I even changed the dates but no luck ;(
error

thanks in advance,

@Wytamma
Copy link
Owner

Wytamma commented Oct 13, 2022

Ah, it looks like you've got a typo

list_of_accession_ids <- df$accession_ids

should be

list_of_accession_ids <- df$accession_id

@Wytamma Wytamma closed this as completed Oct 13, 2022
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