Skip to content

Commit

Permalink
Merge pull request #5 from sapporo-wes/enhancement/1
Browse files Browse the repository at this point in the history
add support for STDIN and compressed format (gzip, bz2)
  • Loading branch information
fmaccha authored Jul 11, 2024
2 parents a2cf647 + 8d9d756 commit a3ab3ad
Show file tree
Hide file tree
Showing 14 changed files with 585 additions and 124 deletions.
5 changes: 2 additions & 3 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@ pub struct Args {
#[clap(short, long, conflicts_with_all = ["num_records"])]
pub tidy: bool,

// TODO
/// Do not try to decompress the input file when detecting the file format.
#[clap(long, hide = true)]
#[clap(long)]
pub no_decompress: bool,

/// Number of records to read from the input file. Conflicts with `--tidy` option.
/// Number of records to read from the input file. Recommened to set it to a multiple of 4 to prevent false negatives. Conflicts with `--tidy` option.
#[clap(short, long, default_value = "100000", value_parser = validate_num_records_greater_than_zero)]
pub num_records: usize,

Expand Down
11 changes: 5 additions & 6 deletions src/buffered_read_seek.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,20 @@ impl<R: Read> OnetimeRewindableReader<R> {
impl<R: Read> Read for OnetimeRewindableReader<R> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
if let Some(ref mut buffer) = self.buffer {
// 既にバッファがある場合はそこから読み取る
// read from the buffer if it exists
let count = buffer.read(buf)?;
if count == 0 {
// バッファが空になった場合は、元の入力から読み取る
let innercount = self.inner.read(buf);
innercount
// if the buffer is empty, read from the original input
self.inner.read(buf)
} else {
Ok(count)
}
} else {
// 初回の読み取りでバッファを準備
// Prepare the buffer for the first read
let mut temp_buffer = vec![0; buf.len()];
let count = self.inner.read(&mut temp_buffer)?;
if count > 0 {
// 読み取ったデータをバッファとして保存
// save the read data as a buffer
self.buffer = Some(Cursor::new(temp_buffer));
self.read(buf)
} else {
Expand Down
1 change: 1 addition & 0 deletions src/edam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl EdamMap {
}
}

// A internal struct to deserialize EDAM table.
#[derive(Debug, Clone, Deserialize)]
struct Edam {
#[serde(rename = "Class ID")]
Expand Down
2 changes: 1 addition & 1 deletion src/ext_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn invoke(
cwl_file_path: &Path,
target_file_path: &Path,
cwl_input_file_path: &NamedTempFile,
options: &InvokeOptions,
_options: &InvokeOptions,
) -> Result<ModuleResult> {
info!("Invoking ext_tools {}", cwl_file_path.display());

Expand Down
Loading

0 comments on commit a3ab3ad

Please sign in to comment.