Commit 3be93c58 authored by Romain Feron's avatar Romain Feron
Browse files

Implemented computing scaffold lengths before mapping

parent 40746221
......@@ -88,6 +88,8 @@ void mapping(Parameters& parameters) {
if (not bwa_index_temp.is_open()) indexed = false;
}
scaffold_lengths(genome_file_path);
if (not indexed) {
bwa_idx_build(genome_file_path.c_str(), genome_file_path.c_str(), 0, 10000000); // Genome file, prefix, algorithm (default 0), block size (default 10000000)
}
......
......@@ -5,6 +5,7 @@
#include "popmap_file.h"
#include "output.h"
#include "stats.h"
#include "scaffold_lengths.h"
#include "bwa/bwamem.h"
#include "bwa/kseq.h"
......
#include "scaffold_lengths.h"
void scaffold_lengths(const std::string& genome_file_path) {
std::ifstream genome_file(genome_file_path);
std::ofstream lengths_file(genome_file_path + ".lengths");
std::string line, scaffold_name;
uint scaffold_length = 0;
bool start = true;
while(std::getline(genome_file, line)) {
if (line[0] == '>') {
if (not start) {
lengths_file << scaffold_name << "\t" << scaffold_length << "\n";
} else {
start = false;
}
scaffold_name = split(line, " ")[0];
scaffold_name = scaffold_name.substr(1, scaffold_name.size());
scaffold_length = 0;
} else {
scaffold_length += line.size();
}
}
lengths_file << scaffold_name << "\t" << scaffold_length << "\n";
genome_file.close();
lengths_file.close();
}
#pragma once
#include "utils.h"
void scaffold_lengths(const std::string& genome_file_path);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment