I want to gather mRNA sequences by region (e.g. 3utr, 5utr, cds). At a certain point while accessing the sequences, I receive the following error message:
Error in .lock2(dbfile, exclusive = TRUE) : requested an exclusive lock when caller only holds a shared lock
Any suggestions would be greatly appreciated!
getRegionSequence <- function(region, start_iteration_idx){
ensembl_list <- list()
sequence_list <- list()
for(idx in start_iteration_idx:(start_iteration_idx+5000)){
# for (idx in start_iteration_idx:nrow(ensembl_ids)){
ensembl_id <- ensembl_ids[idx,]
sequence_id <- getSequence(mart=ensembl_GRCh37, seqType=region, type="ensembl_gene_id", id=ensembl_id)
sequence_only <- sequence_id[region]
print(idx)
# print(region)
# print(sequence_only[, region])
# print(sequence_only)
if (length(sequence_only[, region]) == 0){
len_ensembl <- length(ensembl_list)
len <- length(sequence_list)
ensembl_list[[len+1]] <- ensembl_id
sequence_list[[len+1]] <- "Sequence unavailable"; next
}
sequence <- sequence_only[which.max(nchar(sequence_only[, region])),]
if ((sequence == "Sequence unavailable") & (length(sequence_only[, region]) > 1)){
print(sequence_only)
sequence_only <- data.frame(sequence_only[!grepl('Sequence unavailable', sequence_only[, region]),])
colnames(sequence_only)[1] <- "3utr"
print(sequence_only)
sequence <- sequence_only[which.max(nchar(sequence_only[, region])),]
print(sequence)
}
len_ensembl <- length(ensembl_list)
len <- length(sequence_list)
ensembl_list[[len+1]] <- ensembl_id
sequence_list[[len+1]] <- sequence
}
# return(sequences)
return(list("ensembl_id" = ensembl_list, "sequence" = sequence_list))
}
id_sequences <- getRegionSequence("3utr", 7985)