Skip to content

Commit

Permalink
[FEATURE] add new option for reading a genome
Browse files Browse the repository at this point in the history
  • Loading branch information
joergi-w committed Sep 27, 2021
1 parent f31f991 commit be0b88e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
1 change: 1 addition & 0 deletions include/iGenVar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct cmd_arguments
// Input:
/* -i */ std::filesystem::path alignment_short_reads_file_path{""};
/* -j */ std::filesystem::path alignment_long_reads_file_path{""};
/* -g */ std::filesystem::path genome_file_path{""};
// Output:
/* -o */ std::filesystem::path output_file_path{};
/* -s */ std::string vcf_sample_name{"MYSAMPLE"};
Expand Down
30 changes: 21 additions & 9 deletions src/iGenVar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ void initialize_argument_parser(seqan3::argument_parser & parser, cmd_arguments
"Input long read alignments in SAM or BAM format (PacBio, Oxford Nanopore, ...).",
seqan3::option_spec::standard,
seqan3::input_file_validator{{"sam", "bam"}} );
parser.add_option(args.genome_file_path,
'g', "input_genome",
"Input the reference genome in FASTA or FASTQ format.",
seqan3::option_spec::standard,
seqan3::input_file_validator{{"fasta", "fa", "fastq"}} );
parser.add_option(args.output_file_path, 'o', "output",
"The path of the vcf output file. If no path is given, will output to standard output.",
seqan3::option_spec::standard,
Expand Down Expand Up @@ -124,18 +129,25 @@ void detect_variants_in_alignment_file(cmd_arguments const & args)
std::vector<Junction> junctions{};
std::map<std::string, int32_t> references_lengths{};

// short reads
if (args.alignment_short_reads_file_path != "")
if (args.genome_file_path.empty())
{
seqan3::debug_stream << "Detect junctions in short reads...\n";
detect_junctions_in_short_reads_sam_file(junctions, references_lengths, args);
}
// short reads
if (!args.alignment_short_reads_file_path.empty())
{
seqan3::debug_stream << "Detect junctions in short reads...\n";
detect_junctions_in_short_reads_sam_file(junctions, references_lengths, args);
}

// long reads
if (args.alignment_long_reads_file_path != "")
// long reads
if (!args.alignment_long_reads_file_path.empty())
{
seqan3::debug_stream << "Detect junctions in long reads...\n";
detect_junctions_in_long_reads_sam_file(junctions, references_lengths, args);
}
}
else
{
seqan3::debug_stream << "Detect junctions in long reads...\n";
detect_junctions_in_long_reads_sam_file(junctions, references_lengths, args);
seqan3::debug_stream << "Detect SNPs, insertions and deletions in short reads...\n";
}

std::sort(junctions.begin(), junctions.end());
Expand Down
1 change: 1 addition & 0 deletions test/api/detection_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ TEST(junction_detection, analyze_sa_tag)
// Args
cmd_arguments args{std::filesystem::path{}, // alignment_short_reads_file_path
std::filesystem::path{}, // alignment_long_reads_file_path
std::filesystem::path{}, // genome_file_path
std::filesystem::path{}, // output_file_path
"MYSAMPLE", // vcf_sample_name
std::filesystem::path{}, // junctions_file_path
Expand Down
4 changes: 4 additions & 0 deletions test/api/input_file_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ TEST(input_file, detect_junctions_in_short_read_sam_file)

cmd_arguments args{default_alignment_short_reads_file_path,
"",
empty_path, // empty genome path,
empty_path, // empty output path,
default_vcf_sample_name,
empty_path, // empty junctions path,
Expand Down Expand Up @@ -100,6 +101,7 @@ TEST(input_file, detect_junctions_in_long_reads_sam_file)

cmd_arguments args{"",
default_alignment_long_reads_file_path,
empty_path, // empty genome path,
empty_path, // empty output path,
default_vcf_sample_name,
empty_path, // empty junctions path,
Expand Down Expand Up @@ -216,6 +218,7 @@ TEST(input_file, long_read_sam_file_unsorted)

cmd_arguments args{"",
unsorted_sam_path,
empty_path, // empty genome path,
empty_path, // empty output path,
default_vcf_sample_name,
empty_path, // empty junctions path,
Expand Down Expand Up @@ -295,6 +298,7 @@ TEST(input_file, short_and_long_read_sam_file_with_different_references_lengths)

cmd_arguments args{short_sam_path,
long_sam_path,
empty_path, // empty genome path
empty_path, // empty output path
default_vcf_sample_name,
empty_path, // empty junctions path
Expand Down
4 changes: 4 additions & 0 deletions test/cli/iGenVar_cli_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ std::string const help_page_part_1
" Input long read alignments in SAM or BAM format (PacBio, Oxford\n"
" Nanopore, ...). Default: \"\". The input file must exist and read\n"
" permissions must be granted. Valid file extensions are: [sam, bam].\n"
" -g, --input_genome (std::filesystem::path)\n"
" Input the reference genome in FASTA or FASTQ format. Default: \"\".\n"
" The input file must exist and read permissions must be granted.\n"
" Valid file extensions are: [fasta, fa, fastq].\n"
" -o, --output (std::filesystem::path)\n"
" The path of the vcf output file. If no path is given, will output to\n"
" standard output. Default: \"\". Write permissions must be granted.\n"
Expand Down

0 comments on commit be0b88e

Please sign in to comment.