Open the-mayer opened 3 weeks ago
@jananiravi @the-mayer Can I be assigned to this issue? I want to give it a try.
Sure, @Joiejoie1!
Sure, @Joiejoie1!
Thanks @jananiravi
@jananiravi @the-mayer This is how I intend to Refactor Example Data: R-CMD check error
reverseOperonSeq processes a data frame with a GenContext column, splits it and manipulates genomic context strings. straightenOperonSeq is designed to annotate elements with directional indicators based on certain rules.
The error message (subscript out of bounds) suggests that ge is empty or not structured as expected at the lapply() call. Check where ge is assigned in the code to see if it could be empty. You’ll see that ge is created from te[witheq], where witheq is derived from te.
Insert print() statements before the problematic line (line 137) to output the contents of ge, te, and witheq: print(te) # Check the contents of te before filtering print(witheq) # Verify which elements of te have "=" print(ge) # Ensure ge has the expected structure and elements
This will allow to see if ge is empty or incorrectly structured before it’s processed with lapply.
Execute the code in sections (or line by line) up to line 137 to isolate where ge might become empty or miss elements.
Define example input data and run it with reverseOperonSeq() to observe how it handles the input and where it fails. Use the example from the documentation: prot <- data.frame(GenContext = c("A>B", "C<D", "E=F*G", "H>I")) reversed_prot <- reverseOperonSeq(prot) This test will help determine if the error is consistent with the sample input, and you can check how the function processes each step.
Consider if certain patterns in the GenContext column could lead to "ge" becoming empty, such as missing certain characters or symbols. Modify the input data to include different patterns or minimal cases (like c("A>B")) to see if the function consistently produces an output.
If identified that ge can be empty, modify the code to handle this case before applying lapply():
if (length(ge) > 0) { ge <- lapply(1:length(ge), function(x) straightenOperonSeq(ge[[x]])) } else { warning("No elements to process in ge; skipping lapply operation.") } This condition ensures that "lapply" only runs if ge contains elements.
Save the modified file and run the code from start to finish to confirm that it executes without errors.
If the function works as expected, run devtools::check() to ensure the package passes R CMD check without errors.
@jananiravi @the-mayer I have created a PR to this issue.
An R-CMD check error occurs when running this example code for
reverseOperonSeq()
:Using the example data defined in
prot
the error occurs during the lapply operation @line 137 asge
has length 0 due to the previous subset operation._Originally posted by @the-mayer in https://github.com/JRaviLab/MolEvolvR/pull/97#discussion_r1819485400_