filemanagement.h
来自「MS-Clustering is designed to rapidly clu」· C头文件 代码 · 共 600 行 · 第 1/2 页
H
600 行
#ifndef __FILEMANAGEMENT_H__
#define __FILEMANAGEMENT_H__
#include "Config.h"
#include "Spectrum.h"
#include "BasicDataStructs.h"
#include "includes.h"
#define DTA 1
#define MGF 2
#define MZXML 3
#define DAT 4
#define PKL 5
#define MS2 6
#define TXT 7
// parses the type from the file name, -1 if not recognized
int get_file_extension_type(const string& fname);
struct mzXML_annotation {
mzXML_annotation() : charge(0), mzXML_file_idx(-1), scan(-1), retention_time(-1.0) {};
bool operator< (const mzXML_annotation& other) const
{
return (mzXML_file_idx<other.mzXML_file_idx ||
(mzXML_file_idx == other.mzXML_file_idx &&
scan < other.scan));
}
int charge;
int mzXML_file_idx;
int scan;
float retention_time;
string pep;
};
void read_paths_into_list(const char *list_file, vector<string>& list);
///////////////////////////////////////////////////////////////////////////
//
// INPUT FILE MANAGEMENT
//
// class for all types of files
struct SingleSpectrumFile {
SingleSpectrumFile() : org_pm_with_19(-1), pm_with_19(-1), m_over_z(-1),
charge(0), type(MGF), file_idx(-1), file_pos(0),retention_time(-1),
precursor_intensity(0),
num_peaks(0), assigned_cluster(-1), ann_idx(-1), sqs(-1) { };
bool operator< (const SingleSpectrumFile& other) const
{
return (file_idx<other.file_idx || (file_idx == other.file_idx &&
file_pos < other.file_pos) ) ;
}
int get_scan() const;
void print_ssf_stats(Config *config, ostream& os = cout) const;
mass_t org_pm_with_19;
mass_t pm_with_19;
mass_t m_over_z;
int charge;
int type; // DTA =1 , MGF =2, MZXML = 3, DAT=4
int file_idx; // the number of the MGF file (if known) / -1 default for DTA
long file_pos; // position pointer in stream
float retention_time;
float precursor_intensity;
int num_peaks;
int assigned_cluster; // if >-1 means that this spectrum was already assigned
// to a cluster.
int ann_idx;
score_t sqs;
string single_name;
Peptide peptide;
};
struct DTA_file : public SingleSpectrumFile {
// makes initial read of dta and stores the stats
void initial_read(Config *config);
/****************************************************************
quickly extracts the charge, sequence, and pm_with_19 from dta, num peaks.
*****************************************************************/
bool scan_dta(const string& file_name, const Config *config);
};
struct MGF_single : public SingleSpectrumFile {
MGF_single() : scan_number(-1), cluster_size(1), idx_in_file(-1), first_peak_mass(-1) {};
int scan_number; // if created from mzXML
int cluster_size; // if represents a cluster
int idx_in_file;
mass_t first_peak_mass;
/****************************************************************
quickly extracts the charge, sequence, and pm_with_19 from MGF location
*****************************************************************/
bool scan_mgf_single(FILE *stream, const Config *config);
};
struct MZXML_single : public SingleSpectrumFile {
MZXML_single() : scan_number(-1), MS_level(-1),
retention_time(-1), peak_buff_start_idx(-1) {};
int scan_number;
int MS_level;
float retention_time; //retentionTime="PT575.021S"
int peak_buff_start_idx; // in case peak lists were stored in the mzXML file
/****************************************************************
quickly extracts the charge...
*****************************************************************/
bool scan_mzxml_single(FILE *stream, const Config *config)
{
cout << "Error: scan_mzxml_single not implemented!" << endl;
exit(1);
}
};
struct DAT_single : public SingleSpectrumFile {
DAT_single() : scan_number(-1), mzxml_file_idx(-1) {};
int scan_number;
int mzxml_file_idx;
/****************************************************************
quickly extracts the charge, sequence, and pm_with_19 from DAT location
*****************************************************************/
bool scan_dat_single(FILE *stream, const Config *config)
{
cout << "Error: scan_DAT_single not implemented!" << endl;
exit(1);
}
};
struct PKL_single : public SingleSpectrumFile {
PKL_single() : scan_number(-1), retention_time(-1) {};
int scan_number;
float retention_time;
bool scan_pkl_single(const string& file, const Config& config)
{
cout << "Error: scan_pkl_single not implemented!" << endl;
exit(1);
}
};
struct MS2_single : public SingleSpectrumFile {
MS2_single() : idx_in_file(-1) {};
int idx_in_file;
/****************************************************************
quickly extracts the charge, sequence, and pm_with_19 from MGF location
*****************************************************************/
bool scan_ms2_single(FILE *stream, const Config *config);
};
struct MGF_file {
MGF_file() : total_num_spectra(0), min_spec_mass(1E7), max_spec_mass(0),
min_charge(9999), max_charge(0) { }
// makes initial read of mgf and stores the stats
void initial_read(Config *config, int file_idx , bool quick_flag = false);
int total_num_spectra;
mass_t min_spec_mass, max_spec_mass;
int min_charge, max_charge;
string mgf_name;
vector<MGF_single> single_spectra;
vector<int> num_spectra; // number of spectra per charge
};
struct MZXML_file {
MZXML_file() : total_num_spectra(0), min_spec_mass(1E7), max_spec_mass(0),
min_charge(9999), max_charge(0), file_peak_buff_pos(0) { }
// makes initial read of mgf and stores the stats
void initial_read(Config *config, int file_idx );
int extract_peak_lists_from_mzXML(Config *config,
string& mzxml_name,
int file_idx,
mass_t min_m_over_z,
mass_t max_m_over_z);
int total_num_spectra;
mass_t min_spec_mass, max_spec_mass;
int min_charge, max_charge;
int file_peak_buff_pos;
string mzxml_name;
vector<MZXML_single> single_spectra;
vector<int> num_spectra; // number of spectra per charge
vector<float> file_peak_buff; // for storing all peak info of a single file
};
struct DAT_file {
DAT_file() : total_num_spectra(0), min_spec_mass(1E7), max_spec_mass(0),
min_charge(9999), max_charge(0) { }
// makes initial read of DAT and stores the stats
void initial_read(Config *config, int file_idx );
int total_num_spectra;
mass_t min_spec_mass, max_spec_mass;
int min_charge, max_charge;
string dat_name;
vector<DAT_single> single_spectra;
vector<int> num_spectra; // number of spectra per charge
};
struct PKL_dir {
PKL_dir() : total_num_spectra(0), min_spec_mass(1E7), max_spec_mass(0),
min_charge(9999), max_charge(0) { }
// reads the summary tsv file and stores stats
void initial_read(Config *config, int dir_idx, const string& path, const string& tsv_file,
mass_t min_m_over_z = 0, mass_t max_m_over_z = 9999999);
int total_num_spectra;
mass_t min_spec_mass, max_spec_mass;
int min_charge, max_charge;
string dir_path;
string tsv_path;
vector<PKL_single> single_spectra;
vector<int> num_spectra; // number of spectra per charge
};
struct MS2_file {
MS2_file() : total_num_spectra(0), min_spec_mass(1E7), max_spec_mass(0),
min_charge(9999), max_charge(0) { }
// makes initial read of mgf and stores the stats
void initial_read(Config *config, int file_idx , bool quick_flag = false);
int total_num_spectra;
mass_t min_spec_mass, max_spec_mass;
int min_charge, max_charge;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?