<commit_before>//
//  input_model.h
//  qsim
//
//  Created by <NAME> on 9/15/15.
//  Copyright (c) 2015 JHU. All rights reserved.
//

#ifndef __qsim__input_model__
#define __qsim__input_model__

#include <stdio.h>
#include <algorithm>
#include "ds.h"
#include "template.h"
#include "rnglib.hpp"

/**
 * Encapsulates the input model so we can simulate reads similar to the input
 * reads/alignments.
 */
class InputModelUnpaired {
	
public:
	
	InputModelUnpaired(
		const EList<TemplateUnpaired>& ts,
		float fraction_even,
		float low_score_bias) :
		ts_(ts),
		fraction_even_(fraction_even),
		low_score_bias_(low_score_bias)
	{
		fraglen_avg_ = 0.0f;
		fraglen_max_ = 0;
		for(size_t i = 0; i < ts.size(); i++) {
			fraglen_avg_ += ((float)ts[i].reflen() / ts.size());
			fraglen_max_ = std::max(fraglen_max_, (size_t)ts[i].reflen());
		}
	}
	
	/**
	 * Draw a random unpaired template.
	 *
	 * TODO: allow the draw to be somehow weighted toward lower scores.
	 */
	const TemplateUnpaired& draw() const {
		assert(!empty());
		size_t rn = (size_t)(r4_uni_01() * ts_.size());
		assert(rn < ts_.size());
		return ts_[rn];
	}
	
	/**
	 * Return true iff no templates were added.
	 */
	bool empty() const {
		return ts_.empty();
	}
	
	/**
	 * Return the number of unpaired input models encountered.
	 * TODO: if we subsample prior to initializing ts_, need to update this
	 * function.
	 */
	size_t num_added() const {
		return ts_.size();
	}

	/**
	 * Return average length of all reads.
	 */
	float avg_len() const {
		return fraglen_avg_;
	}

	/**
	 * Return maximum length of any unpaired template.
	 */
	float max_len() const {
		return fraglen_max_;
	}

protected:
	
	const EList<TemplateUnpaired>& ts_;
	float fraglen_avg_;
	size_t n_;
	size_t fraglen_max_;
	float fraction_even_;
	float low_score_bias_;
};

class InputModelPaired {
	
public:
	
	InputModelPaired(
		const EList<TemplatePaired>& ts,
		float fraction_even,
		float low_score_bias) :
		ts_(ts),
		fraction_even_(fraction_even),
		low_score_bias_(low_score_bias)
	{
		fraglen_avg_ = 0.0f;
		fraglen_max_ = 0;
		for(size_t i = 0; i < ts.size(); i++) {
			fraglen_avg_ += ((float)ts[i].fraglen_ / ts.size());
			fraglen_max_ = std::max(fraglen_max_, ts[i].fraglen_);
		}
	}
	
	/**
	 * Draw a random paired template.
	 *
	 * TODO: allow the draw to be somehow weighted toward lower scores.
	 */
	const TemplatePaired& draw() const {
		assert(!empty());
		size_t rn = (size_t)(r4_uni_01() * ts_.size());
		assert(rn < ts_.size());
		return ts_[rn];
	}

	/**
	 * Return true iff no templates were added.
	 */
	bool empty() const {
		return ts_.empty();
	}

	/**
	 * Return the number of unpaired input models encountered.
	 * TODO: if we subsample prior to initializing ts_, need to update this
	 * function.
	 */
	size_t num_added() const {
		return ts_.size();
	}
	
	/**
	 * Return average length of all fragments.
	 */
	float avg_len() const {
		return fraglen_avg_;
	}

	/**
	 * Return maximum length of any unpaired template.
	 */
	float max_len() const {
		return fraglen_max_;
	}

protected:
	
	const EList<TemplatePaired>& ts_;
	float fraglen_avg_;
	size_t n_;
	size_t fraglen_max_;
	float fraction_even_;
	float low_score_bias_;
};

#endif /* defined(__qsim__input_model__) */
<commit_msg>fixing typo<commit_after>//
//  input_model.h
//  qsim
//
//  Created by <NAME> on 9/15/15.
//  Copyright (c) 2015 JHU. All rights reserved.
//

#ifndef __qsim__input_model__
#define __qsim__input_model__

#include <stdio.h>
#include <algorithm>
#include "ds.h"
#include "template.h"
#include "rnglib.hpp"

/**
 * Encapsulates the input model so we can simulate reads similar to the input
 * reads/alignments.
 */
class InputModelUnpaired {
	
public:
	
	InputModelUnpaired(
		const EList<TemplateUnpaired>& ts,
		float fraction_even,
		float low_score_bias) :
		ts_(ts),
		fraction_even_(fraction_even),
		low_score_bias_(low_score_bias)
	{
		fraglen_avg_ = 0.0f;
		fraglen_max_ = 0;
		for(size_t i = 0; i < ts.size(); i++) {
			fraglen_avg_ += ((float)ts[i].reflen() / ts.size());
			fraglen_max_ = std::max(fraglen_max_, (size_t)ts[i].reflen());
		}
	}
	
	/**
	 * Draw a random unpaired template.
	 *
	 * TODO: allow the draw to be somehow weighted toward lower scores.
	 */
	const TemplateUnpaired& draw() const {
		assert(!empty());
		size_t rn = (size_t)(r4_uni_01() * ts_.size());
		assert(rn < ts_.size());
		return ts_[rn];
	}
	
	/**
	 * Return true iff no templates were added.
	 */
	bool empty() const {
		return ts_.empty();
	}
	
	/**
	 * Return the number of unpaired input models encountered.
	 * TODO: if we subsample prior to initializing ts_, need to update this
	 * function.
	 */
	size_t num_added() const {
		return ts_.size();
	}

	/**
	 * Return average length of all reads.
	 */
	float avg_len() const {
		return fraglen_avg_;
	}

	/**
	 * Return maximum length of any unpaired template.
	 */
	size_t max_len() const {
		return fraglen_max_;
	}

protected:
	
	const EList<TemplateUnpaired>& ts_;
	float fraglen_avg_;
	size_t n_;
	size_t fraglen_max_;
	float fraction_even_;
	float low_score_bias_;
};

class InputModelPaired {
	
public:
	
	InputModelPaired(
		const EList<TemplatePaired>& ts,
		float fraction_even,
		float low_score_bias) :
		ts_(ts),
		fraction_even_(fraction_even),
		low_score_bias_(low_score_bias)
	{
		fraglen_avg_ = 0.0f;
		fraglen_max_ = 0;
		for(size_t i = 0; i < ts.size(); i++) {
			fraglen_avg_ += ((float)ts[i].fraglen_ / ts.size());
			fraglen_max_ = std::max(fraglen_max_, ts[i].fraglen_);
		}
	}
	
	/**
	 * Draw a random paired template.
	 *
	 * TODO: allow the draw to be somehow weighted toward lower scores.
	 */
	const TemplatePaired& draw() const {
		assert(!empty());
		size_t rn = (size_t)(r4_uni_01() * ts_.size());
		assert(rn < ts_.size());
		return ts_[rn];
	}

	/**
	 * Return true iff no templates were added.
	 */
	bool empty() const {
		return ts_.empty();
	}

	/**
	 * Return the number of unpaired input models encountered.
	 * TODO: if we subsample prior to initializing ts_, need to update this
	 * function.
	 */
	size_t num_added() const {
		return ts_.size();
	}
	
	/**
	 * Return average length of all fragments.
	 */
	float avg_len() const {
		return fraglen_avg_;
	}

	/**
	 * Return maximum length of any unpaired template.
	 */
	float max_len() const {
		return fraglen_max_;
	}

protected:
	
	const EList<TemplatePaired>& ts_;
	float fraglen_avg_;
	size_t n_;
	size_t fraglen_max_;
	float fraction_even_;
	float low_score_bias_;
};

#endif /* defined(__qsim__input_model__) */

{'fraction_non_alphanumeric': 0.1300414046925318, 'fraction_numerical': 0.007054132801717528, 'mean_word_length': 3.461012311901505, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7084613', 'n_tokens_mistral': 2578, 'n_tokens_neox': 2299, 'n_words': 627}