public void LoadMSMatches(List<QPeptide> Peptides)
        {
            iLog.Log("Loading Peak Shapes");
            iLog.RepProgress(0);

            for ( int f = 0 ; f < Peptides[0].Matches.GetLength(0) ; f++){

                int FileNumber = FileNumbers[f];

                SQLiteCommand Select = new SQLiteCommand(
                    "Select FileNumber, MascotScan, Charge, Score, MZ, RT, FirstIsotope, SecondIsotope, TimeCoeff "+
                    String.Format("From MSMatches Where FileNumber = {0} ",FileNumber)+
                    "Order by MascotScan,RT ",con);

                SQLiteDataReader Reader = Select.ExecuteReader();
                MSMatch[] Charges = new MSMatch[12];
                bool flag = true;

                Reader.Read();
                iLog.RepProgress(f*100/Peptides[0].Matches.GetLength(0));

                for ( int i = 0 ; i < Peptides.Count ; i++){
                    while(Reader.GetInt32(1)<Peptides[i].MascotScan) {
                        flag = Reader.Read();
                        if (!flag) break;
                    }
                    if (!flag) break;
                    while(Reader.GetInt32(1)==Peptides[i].MascotScan){

                        for ( int j = 0 ; j<12 ; j++) Charges[j] = null;

                        FileNumber = Reader.GetInt32(0);
                        double RT = Reader.GetDouble(5);

                        while(Reader.GetInt32(0) == FileNumber &&
                              Reader.GetInt32(1) == Peptides[i].MascotScan &&
                              RT == Reader.GetDouble(5) ){

                            int Charge= Reader.GetInt32(2);
                            Charges[Charge] = new MSMatch();
                            Charges[Charge].Score = Reader.GetDouble(3);
                            Charges[Charge].MZ    = Reader.GetDouble(4);
                            Charges[Charge].RT    = Reader.GetDouble(5);
                            Charges[Charge].FirstIsotope  = Reader.GetDouble(6);
                            Charges[Charge].SecondIsotope = Reader.GetDouble(7);
                            Charges[Charge].TimeCoeff     = Reader.GetDouble(8);
                            flag = Reader.Read();
                            if (!flag) break;
                        }
                        if (Charges[Peptides[i].Charge-1] != null )
                            Charges[Peptides[i].Charge].LowerCharges = Charges[Peptides[i].Charge-1];
                        if (Charges[Peptides[i].Charge+1] != null )
                            Charges[Peptides[i].Charge].LowerCharges = Charges[Peptides[i].Charge+1];
                        Peptides[i].Matches[f].MSMatches.Add(Charges[Peptides[i].Charge]);
                        if (!flag) break;
                    }
                    if (!flag) break;
                }
            }
        }
        public void LoadMSMatches(List<QPeptide> Peptides)
        {
            iLog.Log("Loading Peak Shapes");
            iLog.RepProgress(0);
            int FileNumber;
            int BandID = -1;
            int SampleID = 0;

            if (Bands < 0 ){
                FileNumber = FileNumbers.Count;
            }else{
                FileNumber = BandList.GetLength(0) * BandList.GetLength(1);
            }

            for ( int f = 0 ; f < FileNumber ; f++){

                int FileID;
                if (Bands < 0 ){
                    FileID = FileNumbers[f];
                    SampleID = f;
                }else{
                    FileID = f;
                    BandID = f / SampleNumber ;
                    SampleID = f % SampleNumber;
                }

                SQLiteCommand Select = new SQLiteCommand(
                    "Select FileNumber, MascotScan, Charge, Score, MZ, RT, FirstIsotope, SecondIsotope, TimeCoeff "+
                    String.Format("From MSMatches Where FileNumber = {0} ",FileID)+
                    "Order by MascotScan,RT ",con);

                SQLiteDataReader Reader = Select.ExecuteReader();
                MSMatch[] Charges = new MSMatch[12];
                bool flag = true;

                Reader.Read();
                if (!Reader.HasRows) break;
                iLog.RepProgress(f,FileNumber);

                for ( int i = 0 ; i < Peptides.Count ; i++){

                    while(Peptides[i].BandID != BandID){
                        i++;
                        flag = (i < Peptides.Count);
                        if (!flag) break;
                    }
                    if (!flag) break;
                    while(Reader.GetInt32(1)<Peptides[i].MascotScan) {
                        flag = Reader.Read();
                        if (!flag) break;
                    }
                    if (!flag) break;

                    while(Reader.GetInt32(1)==Peptides[i].MascotScan){

                        for ( int j = 0 ; j<12 ; j++) Charges[j] = null;

                        //FileNumber = Reader.GetInt32(0);
                        double RT = Reader.GetDouble(5);

                        while(//Reader.GetInt32(0) == FileNumber &&
                              Reader.GetInt32(1) == Peptides[i].MascotScan &&
                              RT == Reader.GetDouble(5) ){

                            int Charge= Reader.GetInt32(2);
                            Charges[Charge] = new MSMatch();
                            Charges[Charge].Score = Reader.GetDouble(3);
                            Charges[Charge].MZ    = Reader.GetDouble(4);
                            Charges[Charge].RT    = Reader.GetDouble(5);
                            Charges[Charge].FirstIsotope  = Reader.GetDouble(6);
                            Charges[Charge].SecondIsotope = Reader.GetDouble(7);
                            Charges[Charge].TimeCoeff     = Reader.GetDouble(8);
                            flag = Reader.Read();
                            if (!flag) break;
                        }
                        if (Charges[Peptides[i].Charge-1] != null )
                            Charges[Peptides[i].Charge].LowerCharges = Charges[Peptides[i].Charge-1];
                        if (Charges[Peptides[i].Charge+1] != null )
                            //порпавить в версии 2.6 - должно быть:
                            Charges[Peptides[i].Charge].UpperCharges= Charges[Peptides[i].Charge+1];
                            //Charges[Peptides[i].Charge].LowerCharges = Charges[Peptides[i].Charge+1];
                        Peptides[i].Matches[SampleID].MSMatches.Add(Charges[Peptides[i].Charge]);
                        if (!flag) break;
                    }
                    if (!flag) break;
                }
            }
        }