Skip to content

Commit

Permalink
Use the common 1-based, fully closed genomic coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
delehef committed Oct 26, 2022
1 parent 860b3be commit 44e3ccf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
6 changes: 4 additions & 2 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -227,14 +227,16 @@ 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
- Fix truncating
- 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
Expand Down
23 changes: 15 additions & 8 deletions src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -887,9 +893,10 @@ impl FustaFS {
.ok_or_else(|| format!("`{}` is not a fragment", &caps[1]))?
.id
.clone();
let start = str::parse::<usize>(&caps[2])
.map_err(|_| format!("{}: `{}` is not an integer", &error_message, &caps[1]))?;
let end = str::parse::<usize>(&caps[3])
let start = str::parse::<isize>(&caps[2])
.map_err(|_| format!("{}: `{}` is not an integer", &error_message, &caps[1]))?
- 1;
let end = str::parse::<isize>(&caps[3])
.map_err(|_| format!("{}: `{}` is not an integer", &error_message, &caps[2]))?;

self.subfragments
Expand All @@ -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)
})
Expand All @@ -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)
}
Expand Down

0 comments on commit 44e3ccf

Please sign in to comment.