nanxstats / protr

🧬 Toolkit for generating various numerical features of protein sequences

Home Page:https://nanx.me/protr/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

extractCTDD fails when less than four amino acids maps to any one group

koefoed opened this issue · comments

> packageVersion('protr')
[1] ‘0.5.1> extractCTDD("NAKADQASSDAQTANAKADQASNDANAARSDAQAAKDDAARANQRADNAA")
Error in D[[i]][2, ] = (inds[c(1, floor(length(inds) * c(0.25, 0.5, 0.75)),  : 
  number of items to replace is not a multiple of replacement length
> 

If one, two, or three amino acids maps to a group, floor(length(inds) * c(0.25, 0.5, 0.75)) from lines 94, 96, and 98 in R/desc09CTDD.R will have one or more 0's and thus the dimensions will not match in the assignment shown in the error message.

One way to solve this is to ensure that 0'es are replaced with 1's in the results of the calculation mentioned above, thus selecting the position of the first amino acid in the group.

If zero amino acids maps to a group inds in lines 93, 95, and 97 will be empty, and indexing into inds in lines 94, 96, and 98 will return NA's.

Maybe it would be better to return zeroes in this case?
Then zero will only occur if there are no amino acids mapping to the group because if just one does, it will give a (small) value > 0.
One could also return NA's, but this may cause problems depending on how you use the results.

Hey KoeFoed I also have this problem. Thanks for fixing this .

@rnewbie You are most welcome :-)

Fixed in a0bd414.
Thanks @koefoed and @sawsimeon for the testing and patch!