Skip to content

Commit

Permalink
Improve fix #10 . Just need to decrement nseq
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpenel committed Jul 16, 2024
1 parent 1f9246b commit 1aaf4bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: seqinr
Title: Biological Sequences Retrieval and Analysis
Version: 4.2-40
Version: 4.2-41
Depends: R (>= 2.10.0)
Imports: ade4,segmented
Authors@R: c(person("Delphine", "Charif", role = "aut"),
Expand Down
19 changes: 10 additions & 9 deletions R/read.alignment.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ read.alignment <- function(file, format, forceToLower = TRUE,
white <- characters[-length(characters)] == " "
black <- characters[-1] != " "
istart <- which(white & black)[1]

# Get sequence names
nam <- character()
nseq <- 1
Expand All @@ -74,7 +73,12 @@ read.alignment <- function(file, format, forceToLower = TRUE,
nseq <- nseq - 1
break # alredy seen
}
if (seqname == 'NA') {break}
# this happens with short alignments because seqname is never found
# in mam
if (seqname == 'NA') {
nseq <- nseq - 1
break
}
nam[nseq] <- seqname
nseq <- nseq + 1
}
Expand All @@ -98,14 +102,11 @@ read.alignment <- function(file, format, forceToLower = TRUE,
# Concatenation of sequence lines in a single string
seq <- vector(mode = "list")
for(iseq in seq_len(nseq)){
if (iseq <= length(filecontent)) {
ii <- seq(iseq, length(filecontent), by = nseq)
seq[[iseq]] <- paste0(filecontent[ii], collapse = "")
if(forceToLower) seq[[iseq]] <- tolower(seq[[iseq]])
}
ii <- seq(iseq, length(filecontent), by = nseq)
seq[[iseq]] <- paste0(filecontent[ii], collapse = "")
if(forceToLower) seq[[iseq]] <- tolower(seq[[iseq]])
}

return(as.alignment(nb = length(seq), nam = nam, seq = seq, com = NA))
return(as.alignment(nb = nseq, nam = nam, seq = seq, com = NA))
}


Expand Down

0 comments on commit 1aaf4bc

Please sign in to comment.