⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config.h

📁 MS-Clustering is designed to rapidly cluster large MS/MS datasets. The program merges similar spectr
💻 H
📖 第 1 页 / 共 2 页
字号:
#ifndef __CONFIG_H__
#define __CONFIG_H__

#include "ConversionTables.h"
#include "Fragmentation.h"
#include "BasicDataStructs.h"
#include "includes.h"

// the Config class holds all configuration variables that are used
// by the models and programs: aa's, PTMs, thresholds etc


typedef enum PTM_REGIONS { PTM_ALL, PTM_N_TERMINAL, PTM_C_TERMINAL, PTM_POSITION } PTM_REGIONS;

typedef enum PTM_TYPES   { PTM_FIXED, PTM_OPTIONAL } PTM_TYPES;

#define NON_SPECIFIC_DIGEST 0
#define TRYPSIN_DIGEST 1


struct AA_combo;   // decleration in BasicDataStructs.h
class Peptide;


// label for fixed PTM stays the same as the orginal amino acid
struct PTM {
	PTM(int _org_aa = Gap, double _delta = 0.0,  int _type = -1, 
		int _region = PTM_ALL, int _position=0, string _label = "", string _name = "") : 
			org_aa(_org_aa), delta(_delta), type(_type), region(_region), position(_position),
			label(_label), name(_name) {};
	int org_aa;
	double delta;

	int type; //
	int region;

	int position; // used only for specific position like Q-17 at the +1 position
	
	string label;
	string name;
};

ostream& operator << (ostream& os, const PTM& ptm);



struct PTM_list {
	friend class Config;
public:

	void clear() { list.clear(); }

	int get_num_PTMs() const { return list.size(); }


	// returns the idx of the label
	// -1 is returned if label is not found
	int get_PTM_idx(const string& label) const;

private:
	
	// adds a PTM, makes sure that it wasn't already added
	// (if already added, returns false
	bool add_PTM(const PTM& ptm);

	vector<PTM> list;
};


// A class that holds a map of mass ranges
class MassRangeMap {
public:
	MassRangeMap() : was_initialized(0) { clear(); }

	void clear(mass_t max_mass = 400); 

	// adds a mass range to the map, if already covered, does nothinh
	void add_range(mass_t min_mass, mass_t range);

	// adds a new set of ranges *shift_size* away from the current existing ranges
	void add_shifted_ranges(mass_t shift_size);

	// checks if the given mass is in one of the maps ranges
	bool is_covered(mass_t mass) const
	{
		if (mass>max_map_mass)
			return true;

		MASS_T_MAP::const_iterator it;
		it = ranges.lower_bound(mass);
		if (it != ranges.end() && it != ranges.begin())
		{
			if (it->first == mass)
				return true;

			it--;
			if (it->first<= mass && it->second>= mass)
				return true;
		}
		return false;
	}

	void print(ostream& os = cout) const;

	void read_ranges(istream& is);
	void write_ranges(ostream& os = cout) const;

	void set_was_initialized(int flag) { was_initialized = flag; }
	int  get_was_initialized() const { return was_initialized; }

private:
	int was_initialized; 
	mass_t max_map_mass;
	MASS_T_MAP ranges;
};




class Config {
public:
	
	Config() : resource_dir("Models"), min_exclude_range(9999999), max_exclude_range(NEG_INF) {};

	// sets the values for all defined PTMs
	// any additional PTMs can only be user defined


	void init_with_defaults();

	void init_regional_fragment_set_defaults(int type_set = 0, int max_charge  =5);

	void print_supported_PTMs() const;

	void apply_selected_PTMs(char *ptm_line);

	void apply_site_input_PTMs(const vector<string>& ptm_lines);

	void read_PTM_file(char *file);

	void fill_allowed_double_edges(bool allow_all = false);

	// returns the idx of an aa from its label
	// -1 if label is not found
	int get_aa_from_label(const string& label) const;

	int get_aa_with_position_from_label(const string& label, int position) const;

	int get_max_session_aa_idx() const;

	int get_frag_idx_from_label(const string& label) const { return (all_fragments.find_idx_from_label(label)); }

	const ConversionTables& get_session_tables() const { return session_tables; }

	const vector<int>& get_session_aas() const { return session_aas; }

	const vector<int>& get_char2aa() const { return session_tables.get_char2aa(); }

	const vector<char>&   get_aa2char() const { return session_tables.get_aa2char(); }
	const vector<string>& get_aa2label() const { return session_tables.get_aa2label(); }
	const vector<mass_t>& get_aa2mass() const { return session_tables.get_aa2mass(); }
	const vector<mass_t>& get_char2mass() const { return session_tables.get_char2mass(); }
	const vector<int>&    get_org_aa() const { return session_tables.get_org_aa(); }
	const vector<int>& get_aa_positions() const { return session_tables.get_aa_positions(); }


	int    get_digest_type() const { return digest_type; }
	void   set_digest_type(int type);
	
	const vector<int>& get_n_term_digest_aas() const { return n_term_digest_aas; }
	const vector<int>& get_c_term_digest_aas() const { return c_term_digest_aas; }
	int   get_num_n_term_digest_aas() const { return n_term_digest_aas.size(); }
	int   get_num_c_term_digest_aas() const { return c_term_digest_aas.size(); }
	bool  is_n_digest_aa(int aa) const { int i; for (i=0; i<n_term_digest_aas.size(); i++) if (aa==n_term_digest_aas[i]) break; return (i<n_term_digest_aas.size()); }
	bool  is_c_digest_aa(int aa) const { int i; for (i=0; i<c_term_digest_aas.size(); i++) if (aa==c_term_digest_aas[i]) break; return (i<c_term_digest_aas.size()); }


	int    get_need_to_estimate_pm() const { return need_to_estimate_pm; }
	void   set_need_to_estimate_pm(int val) { need_to_estimate_pm = val; }
	
	int    get_use_spectrum_charge() const { return use_spectrum_charge; }
	void   set_use_spectrum_charge(int val) { use_spectrum_charge = val; }
	
	int    get_use_spectrum_mz() const { return use_spectrum_mz; }
	void   set_use_spectrum_mz(int val) { use_spectrum_mz = val; }
	
	int    get_need_to_normalize() const { return need_to_normalize; }
	void   set_need_to_normalize(int val) { need_to_normalize = val; }

	int	   get_filter_flag() const { return filter_flag; }
	void   set_filter_flag(int val) { filter_flag = val; }

	int    get_mass_spec_type() const { return mass_spec_type; }

	int    get_itraq_mode() const { return itraq_mode; }
	void   set_itraq_mode(int mode) { itraq_mode = mode; }

	score_t get_terminal_score() const { return terminal_score; }
	void    set_terminal_score(score_t val)  { terminal_score=val; }

	score_t get_digest_score() const { return digest_score; }
	void    set_digest_score(score_t val)  { digest_score=val; }

	score_t get_forbidden_pair_penalty() const { return forbidden_pair_penalty; }
	void    set_forbidden_pair_pennalty(score_t val) { forbidden_pair_penalty=val; }

	int		get_max_edge_length() const { return max_edge_length; }
	void    set_max_edge_length(int val) { max_edge_length = val; }
	
	mass_t get_tolerance() const { return tolerance; }
	mass_t get_pm_tolerance() const { return pm_tolerance; }

	void set_tolerance(mass_t t) { tolerance = t; }
	void set_pm_tolerance(mass_t t) { pm_tolerance = t; }
	void set_tolerances(mass_t t) { tolerance = t; pm_tolerance = t; }

	mass_t get_max_n_term_mod() const { return max_n_term_mod; }
	mass_t get_max_c_term_mod() const { return max_c_term_mod; }
	mass_t get_min_n_term_mod() const { return min_n_term_mod; }
	mass_t get_min_c_term_mod() const { return min_c_term_mod; }

	mass_t get_local_window_size() const { return local_window_size; }
	int    get_max_number_peaks_per_local_window() const { return max_number_peaks_per_local_window; }
	void   set_max_number_peaks_per_local_window(int n) { max_number_peaks_per_local_window = n; }
	int    get_number_of_strong_peaks_per_local_window() const { return number_of_strong_peaks_per_local_window; }
	int    get_max_charge_for_size() const { return max_charge_for_size; }
	void   set_max_charge_for_size(int max_charge) { max_charge_for_size = max_charge; }
	const vector< vector< mass_t > >& get_size_thresholds() const { return size_thresholds; }
	const vector< mass_t >& get_region_thresholds() const { return region_thresholds; }
	int get_num_sizes(int charge) const { return regional_fragment_sets[charge].size(); }
	int get_num_regions(int charge, int size_idx) const { return regional_fragment_sets[charge][size_idx].size(); }

	int determine_charge(Peptide& pep, mass_t m_over_z) const;

	string get_resource_dir() const { return resource_dir; }
	string get_config_file() const { return config_file; }
	string get_model_name() const { return model_name; }
	string get_fragments_file() const { return fragments_file; }

	string get_regional_fragment_sets_file() const { return regional_fragment_sets_file; }
	string get_aa_combo_file() const { return aa_combo_file; }
	void set_resource_dir(string _resource_dir) { resource_dir = _resource_dir; }
	void set_config_file(string _config_file) { config_file = _config_file; }
	void set_model_name(string name) { model_name = name; }
	void set_fragments_file(string file) { fragments_file = file; }
	void set_regional_fragment_sets_file(string& file) { regional_fragment_sets_file = file; }
	void set_aa_combo_file(string file) { aa_combo_file = file; }

	const vector< vector<int> >& get_aa_variants() const { return aa_variants; }

	bool is_allowed_double_edge(int aa1, int aa2) const { return allowed_double_edge[aa1][aa2]; }

	const vector< vector<bool> >& get_allowed_double_edge() const { return allowed_double_edge; }
	const vector< vector<bool> >& get_double_edge_with_same_mass_as_single() const { return double_edge_with_same_mass_as_single; }

	void set_size_thresholds_according_to_set_of_masses(int charge,
											vector<mass_t>& spectra_masses);

	mass_t get_min_mass_for_size_idx(int charge, int size_idx)
	{
		mass_t min=0;
		if (size_thresholds[charge].size()>0 && size_idx>0)
			min=size_thresholds[charge][size_idx-1];
		return min;
	}

	mass_t get_max_mass_for_size_idx(int charge, int size_idx)
	{
		mass_t max=POS_INF;
		if (size_thresholds[charge].size()>0 && size_idx<size_thresholds[charge].size())
			max=size_thresholds[charge][size_idx];
		return max;
	}
	
	// returns the size that depends on the charge and total mass
	int    calc_size_idx(int charge, mass_t pm_mass_with_19) const
	{
		const int charge_idx = (charge>max_charge_for_size) ? max_charge_for_size : charge;
		int i;
		for (i=0; i<size_thresholds[charge_idx].size(); i++)
			if (pm_mass_with_19 < size_thresholds[charge_idx][i])
				break;
		return i;
	}

	void print_size_thresholds() const;

	// returns the region idx for a (breakge) mass
	int	calc_region_idx(mass_t break_mass, mass_t pm_with_19, int charge,
					 mass_t min_peak_mass, mass_t max_peak_mass) const;


	void set_fragment_type_set(const FragmentTypeSet& fts) { all_fragments = fts; }

	void add_fragment_types(const FragmentTypeSet& fts);

	const vector<FragmentType>& get_all_fragments() const { return all_fragments.get_fragments(); }


	// accessing the fragment sets
	// these are the fragments that are applicable for a given charge/size_idx/region_idx
	const vector<int>& get_regional_fragment_type_idxs(int charge, int size_idx, int region_idx) const
	{
		if (charge > max_charge_for_size)
			charge = max_charge_for_size;

		if (size_idx>= regional_fragment_sets[charge].size())
			size_idx = regional_fragment_sets[charge].size()-1;

		if (region_idx >= regional_fragment_sets[charge][size_idx].size())
			region_idx = regional_fragment_sets[charge][size_idx].size()-1;

		return regional_fragment_sets[charge][size_idx][region_idx].get_frag_type_idxs();
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -