diff --git a/README.org b/README.org index 7e2a64f..f30f119 100644 --- a/README.org +++ b/README.org @@ -141,7 +141,7 @@ This folder contains all the individual sequences present in the original FASTA *** =append= This folder should be used to add new sequences to the mounted FASTA file. Any valid fasta file copied or moved to this directory will be appended to the original FASTA files. It should be noted that the process is completely transparent and the the folder will remain empty, even though the operation is successful. *** =get= -This folder is used for range-access to the sequences in the mounted FASTA file. Although it is empty, any read access to a (non-existing) file following the pattern =SEQID:START-END= will return the corresponding range (0-indexed) in the specified sequence. It should be noted that the access skip headers and newlines, so that the =START-END= coordinates map to actual loci in the corresponding sequence and not to bytes in the mounted FASTA file. +This folder is used for range-access to the sequences in the mounted FASTA file. Although it is empty, any read access to a (non-existing) file following the pattern =SEQID:START-END= will return the corresponding range (1-indexed, fully-closed) in the specified sequence. It should be noted that the access skip headers and newlines, so that the =START-END= coordinates map to actual loci in the corresponding sequence and not to bytes in the mounted FASTA file. ** Examples All the following examples assume that a FASTA file has been mounted (/e.g./ =fusta -D genome.fa=), and is unmounted after manipulation (/e.g./ =fusermount -u fusta=). *** Get an overview of the file content @@ -227,6 +227,8 @@ If you have any question or if you encounter a problem, do not hesitate to [[htt * Acknowledgments FUSTA is standing on the shoulders of, among others, [[https://github.com/cberner/fuser][fuser]], [[https://github.com/clap-rs/clap][clap]], [[https://github.com/RazrFalcon/memmap2-rs][memmap2]] and [[https://github.com/knsd/daemonize][daemonize]]. * Changelog +** v1.7 +- Use 1-based, fully-closed genomic coordinates ** v1.6.1 - Accept more characters as FASTA sequences: =\n - _ . + == ** v1.6 @@ -234,7 +236,7 @@ FUSTA is standing on the shoulders of, among others, [[https://github.com/cberne - Improved error handling - Better notifications - Add a flag to allow overwrite of existing sequences as a side-effect -- Only ASCII alphanumericel content can be written to sequence files +- Only ASCII alphanumerical content can be written to sequence files - Refuse to open FASTA files with IDs containing characters invalid in a filename ** v1.5.7 - Update dependencies diff --git a/src/fs.rs b/src/fs.rs index 54f9fa6..8d2326a 100755 --- a/src/fs.rs +++ b/src/fs.rs @@ -415,12 +415,18 @@ struct PendingAppend { #[derive(Debug)] struct SubFragment { fragment: String, - start: usize, - end: usize, + start: isize, + end: isize, attrs: FileAttr, } impl SubFragment { - fn new(fragment: &str, start: usize, end: usize, attrs: FileAttr) -> SubFragment { + fn new(fragment: &str, start: isize, end: isize, attrs: FileAttr) -> SubFragment { + let start = if start < 0 { + warn!("Invalid start position {}; using 1 instead", start); + 0 + } else { + start + }; let end = if end < start { warn!( "{}:{}-{}: {} < {}; using {} instead", @@ -887,9 +893,10 @@ impl FustaFS { .ok_or_else(|| format!("`{}` is not a fragment", &caps[1]))? .id .clone(); - let start = str::parse::(&caps[2]) - .map_err(|_| format!("{}: `{}` is not an integer", &error_message, &caps[1]))?; - let end = str::parse::(&caps[3]) + let start = str::parse::(&caps[2]) + .map_err(|_| format!("{}: `{}` is not an integer", &error_message, &caps[1]))? + - 1; + let end = str::parse::(&caps[3]) .map_err(|_| format!("{}: `{}` is not an integer", &error_message, &caps[2]))?; self.subfragments @@ -898,8 +905,8 @@ impl FustaFS { .map(|sf| sf.attrs) .or_else(|| { let mut attrs = FustaFS::make_file_attrs(ino, 0o444); - attrs.size = (end - start) as u64; let sf = SubFragment::new(&fragment_id, start, end, attrs); + attrs.size = (sf.end - sf.start) as u64; self.subfragments.push(sf); Some(attrs) }) @@ -916,7 +923,7 @@ impl FustaFS { let fragment_len = fragment.data.len(); let mut attrs = FustaFS::make_file_attrs(ino, 0o444); attrs.size = fragment_len as u64; - let sf = SubFragment::new(&fragment_id, 0, fragment_len, attrs); + let sf = SubFragment::new(&fragment_id, 0, fragment_len.try_into().unwrap(), attrs); self.subfragments.push(sf); Ok(attrs) }