public void ReadInMLNFile(string filename, int _numdatasets) { // Read in MultiAlign file // Note : sep 26, 2011 - This will need to be updated when the new MLN format comes out CSVFileHandler CsvFileHandler2 = new CSVFileHandler(filename, CSVFileHandler.READ_ONLY); CsvFileHandler2.openFile(); String[] Attributes2; CsvFileHandler2.readLine(); while ((Attributes2 = CsvFileHandler2.readLine()) != null) { MultiAlignRecord mrecord = new MultiAlignRecord(); mrecord.ID = int.Parse(Attributes2[0]); mrecord.Size = int.Parse(Attributes2[1]); mrecord.Mass = double.Parse(Attributes2[2]); mrecord.NET = double.Parse(Attributes2[3]); mrecord.AllocateNumberDatasets(_numdatasets); int n_dataset = 0; for (int i = 4; i < Attributes2.Length; i += 4) { UMCRecord u = new UMCRecord(); if (Attributes2[i] != "") { u.ScanRep = int.Parse(Attributes2[i]); u.Abundance = double.Parse(Attributes2[i + 1]); u.ScanStart = int.Parse(Attributes2[i + 2]); u.ScanEnd = int.Parse(Attributes2[i + 3]); } mrecord._AssociatedUMCRecords.Add(u); n_dataset++; } AddRecord(mrecord); } }
public void ReanInMLNV2File(string filename, int _numdatasets) { // Read in new version of MLN file CSVFileHandler CsvFileHandler2 = new CSVFileHandler(filename, CSVFileHandler.READ_ONLY); CsvFileHandler2.openFile(); String[] Attributes2; CsvFileHandler2.readLine(); while ((Attributes2 = CsvFileHandler2.readLine()) != null) { MultiAlignRecord mrecord = new MultiAlignRecord(); mrecord.ID = int.Parse(Attributes2[0]); mrecord.Mass = double.Parse(Attributes2[1]); mrecord.NET = double.Parse(Attributes2[2]); int numDatasetsToAllocate = 0; if (mrecord.Mass < _MAP_MIN_MASS) _MAP_MIN_MASS = mrecord.Mass; if (mrecord.Mass > _MAP_MAX_MASS) _MAP_MAX_MASS = mrecord.Mass; if ((Attributes2.Length-5) / 8 != _numdatasets) numDatasetsToAllocate = (Attributes2.Length -5) / 8; else numDatasetsToAllocate = _numdatasets; mrecord.AllocateNumberDatasets(numDatasetsToAllocate); for (int i = 5; i < Attributes2.Length; i += 8) { UMCRecord u = new UMCRecord(); if (Attributes2[i] != "") { u.ID = int.Parse(Attributes2[i]); u.DatasetID = int.Parse(Attributes2[i + 1]); u.MW = double.Parse(Attributes2[i + 2]); u.Abundance = double.Parse(Attributes2[i + 4]); u.ScanRep = int.Parse(Attributes2[i + 5]); u.ScanStart = int.Parse(Attributes2[i + 6]); u.ScanEnd = int.Parse(Attributes2[i + 7]); mrecord._AssociatedUMCRecords.Add(u); } } AddRecord(mrecord); if (mrecord._AssociatedUMCRecords.Count > 10) { bool debig = true; } } }
/// <summary> /// Function to read in glycopeptides dictionary from file /// </summary> /// <param name="infile"></param> public void LoadGlycopeptidesFromFile(string infile, double min_mass, double max_mass, bool create_hash) { CSVFileHandler CsvFileHandler2 = new CSVFileHandler(infile, CSVFileHandler.READ_ONLY); CsvFileHandler2.openFile(); String[] Attributes2; CsvFileHandler2.readLine(); if (create_hash) _dGlycopeptides = new Dictionary<int, List<GlycopeptideRecord>>(); else _glycopeptides = new List<GlycopeptideRecord>(); while ((Attributes2 = CsvFileHandler2.readLine()) != null) { double gpmass = double.Parse(Attributes2[0]); if (gpmass >= min_mass && gpmass <= max_mass) { GlycopeptideRecord gp = new GlycopeptideRecord(); gp.GP_Mono_Mass = gpmass ; gp.GP_Average_Mass = double.Parse(Attributes2[1]) ; gp.Sequence.proteinName = Attributes2[2] ; gp.Sequence.sequence = Attributes2[3]; gp.Sequence.is_decoy = bool.Parse(Attributes2[4]); gp.Sequence.nGlycoSite = Attributes2[5] ; gp.SequenceMonoMass = double.Parse(Attributes2[6]) ; gp.SequenceAverageMass = double.Parse(Attributes2[7]) ; gp.Glycan.SetMonosaccharideCompostion(Attributes2[8]) ; gp.Glycan.composition = Attributes2[8]; gp.Glycan.is_decoy = bool.Parse(Attributes2[9]) ; gp.GlycanMonoMass = double.Parse(Attributes2[10]) ; gp.GlycanAverageMass = double.Parse(Attributes2[11]) ; gp.IsDecoy = gp.Sequence.is_decoy | gp.Glycan.is_decoy; if (create_hash) { List<GlycopeptideRecord> value_gp_list = new List<GlycopeptideRecord>(); int key_mass = (int)Math.Floor(gp.GP_Mono_Mass); int min_mass_int = (int)Math.Floor(min_mass); int max_mass_int = (int)Math.Floor(max_mass); if (!_dGlycopeptides.ContainsKey(key_mass)) { if (value_gp_list.Count > 0) value_gp_list.Clear(); value_gp_list.Add(gp); _dGlycopeptides.Add(key_mass, value_gp_list); } else { value_gp_list.Clear(); value_gp_list = _dGlycopeptides[key_mass]; value_gp_list.Add(gp); _dGlycopeptides[key_mass] = value_gp_list; } } else _glycopeptides.Add(gp); } } CsvFileHandler2.closeFile(); }