/// <summary>
        /// Computes a curve [precursor observed intensity ; correction so that precursor computed intensity from fragments matches observed intensity]
        /// </summary>
        /// <param name="dbOptions"></param>
        /// <param name="nbProductsToKeep"></param>
        /// <returns></returns>
        private ElutionCurve GetNormalizingCurve(DBOptions dbOptions, int nbProductsToKeep)
        {
            List <CharacterizedPrecursor> Isomers = new List <CharacterizedPrecursor>();

            Isomers.Add(this);

            ElutionCurve curve = new ElutionCurve();

            foreach (Query query in this.Queries)
            {
                double timeInMilliSeconds = query.spectrum.RetentionTimeInMin * 60.0 * 1000.0;

                double underFlow    = 0;
                double percentError = 0;
                double intInTrap    = query.spectrum.PrecursorIntensityPerMilliSecond * query.spectrum.InjectionTime;
                Dictionary <CharacterizedPrecursor, PositionnalIsomerSolver.SolvedResult> finalRatios = PositionnalIsomerSolver.SolveFromSpectrum(Isomers, nbProductsToKeep, query.spectrum.Peaks, dbOptions.productMassTolerance,
                                                                                                                                                  intInTrap, query.spectrum.PrecursorIntensity,
                                                                                                                                                  out underFlow, out percentError, dbOptions.ConSole);

                if (percentError < 0.5 && finalRatios[this].NbFitTimes > 0)
                {
                    double ratio = intInTrap / finalRatios[this].NbFitTimes;
                    if (ratio > 0.5 && ratio < 2)
                    {
                        curve.AddPoint(intInTrap, intInTrap / finalRatios[this].NbFitTimes);
                    }
                }
            }
            curve.Compute(CurveType.LINEAR, true);
            return(curve);
        }
Example #2
0
        //Spilt a precursor ion if the elution curve has a 'pause' (intensities drop to zero for a while)
        public IEnumerable <PrecursorIon> SplitBasedOnTime(DBOptions dbOptions)
        {
            if (Queries.Count > 0)
            {
                this.Queries.Sort(Query.AscendingRetentionTimeComparison);
                List <double> timePoints = new List <double>();
                for (int i = 1; i < Queries.Count; i++)
                {
                    timePoints.Add(Queries[i].spectrum.RetentionTimeInMin - Queries[i - 1].spectrum.RetentionTimeInMin);
                }

                double  variance = MathNet.Numerics.Statistics.Statistics.UpperQuartile(timePoints);
                Queries newQ     = new Queries(dbOptions);
                newQ.Add(Queries[0]);
                for (int i = 1; i < Queries.Count; i++)
                {
                    if (timePoints[i - 1] > 10 * variance)
                    {
                        yield return(new PrecursorIon(Sample, newQ, MZ, Charge));

                        newQ.Clear();
                    }
                    newQ.Add(Queries[i]);
                }
                yield return(new PrecursorIon(Sample, newQ, MZ, Charge));
            }
        }
Example #3
0
        public static void MonoAce(IConSol console)
        {
            DBOptions dbOptions     = GetDBOptions(false, false, console);
            Samples   ProjectRatios = new Samples(@"C:\_IRIC\DATA\NB\ProjectTest_MonoAce_Spiked_19Oct.csv", 0, dbOptions);//Group 2 (all)
            Samples   ProjectMixed  = new Samples(@"C:\_IRIC\DATA\NB\ProjectTest_MonoAce_Varied_19Oct.csv", 0, dbOptions);
            Samples   ProjectStable = new Samples(@"C:\_IRIC\DATA\NB\ProjectTest_StableMix_MonoAce_19Oct.csv", 0, dbOptions);

            string[] SpikedRaws = new string[ProjectRatios.Count];
            for (int i = 0; i < ProjectRatios.Count; i++)
            {
                SpikedRaws[i] = ProjectRatios[i].sSDF;
            }

            string[] MixedRaws = new string[ProjectMixed.Count];
            for (int i = 0; i < ProjectMixed.Count; i++)
            {
                MixedRaws[i] = ProjectMixed[i].sSDF;
            }

            //string[] StableRaws = new string[ProjectStable.Count];
            //for (int i = 0; i < ProjectStable.Count; i++)
            //    StableRaws[i] = ProjectStable[i].sSDF;

            (new PositionnalIsomerSolver()).Solve(SpikedRaws, MixedRaws, dbOptions.FastaDatabaseFilepath, dbOptions.OutputFolder, console);
        }
Example #4
0
        public CharacterizedPrecursor(Sample sample, DBOptions dbOptions, Peptide peptide, IEnumerable <Query> queries, double mz)
            : base(sample, queries, mz, -1)
        {
            this.Peptide = peptide;
            Psms         = new PeptideSpectrumMatches();

            foreach (Query query in queries)
            {
                if (query.sample == sample)
                {
                    Psms.Add(new PeptideSpectrumMatch(query, peptide, dbOptions));
                    Charge = query.precursor.Charge;
                }
            }
            Psms.Sort(PeptideSpectrumMatches.AscendingRetentionTime);
            AllFragments = Psms.GetCombinedSpectrum(dbOptions);
            AllFragments.Sort(ProductMatch.DescendingWeightComparison);

            DicOfPsmFactor = new Dictionary <PeptideSpectrumMatch, double>();
            foreach (PeptideSpectrumMatch psm in Psms)
            {
                DicOfPsmFactor.Add(psm, psm.ProbabilityScore());
            }

            Fragments = new Dictionary <int, List <ProductMatch> >();
            PrecursorLossNormalizeFactor = new Dictionary <int, double>();
        }
        /// <summary>
        /// Opens a connection to a SQLite database file
        /// </summary>
        /// <param name="fileName">Filename of SQLite databse</param>
        /// <param name="options">DBOptions object contianing the objects that should be active</param>
        /// <param name="CreateIfNotExisting">If true, the database is created if required</param>
        /// <returns>Open connection to the database</returns>
        public static SQLiteConnection OpenDatabase(string fileName, DBOptions options, bool CreateIfNotExisting = true)
        {
            log.Debug("Opening database {0}", fileName);

            string connectionString = options.GenerateConnectionString(fileName);

            if (CreateIfNotExisting == true)
            {
                if (File.Exists(fileName) == false)
                {
                    //Create the database
                    SQLiteConnection.CreateFile(fileName);
                }
            }

            //Open it
            SQLiteConnection connection = new SQLiteConnection(connectionString);
            connection.Open();

            //Now apply all PRAGMA options
            //ApplyOptions(connection, definedOptions, ignorePersistentOptions: false);
            options.ApplyOptions(connection);

            //TODO: Check if all options have their desired values!

            return connection;
        }
Example #6
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="mySqlDBOptions"></param>
 public MySqlDB(string connStr, int timeout = 1800)
 {
     // 创建一个数据库连接
     MySqlDBOptions = new DBOptions {
         ConnectionString = connStr, CommandTimeout = timeout
     };
 }
Example #7
0
        public static AnnotatedSpectrum TestNeo4j(IConSol console)
        {
            DBOptions dbOptions     = GetDBOptions(false, false, console);
            Samples   ProjectRatios = new Samples(@"C:\_IRIC\DATA\NB\ProjectTest_MonoAce_Spiked_19Oct.csv", 0, dbOptions);//Group 2 (all)

            Result rez = Propheus.Start(dbOptions, ProjectRatios, false, false, false);

            Database.Neo4j.ResultsToNeo4j.Export(rez);
            PeptideSpectrumMatch bestPsm = null;

            foreach (Query query in rez.queries)
            {
                foreach (PeptideSpectrumMatch psm in query.psms)
                {
                    if (psm.Peptide.Sequence.CompareTo("GK(acetylation of K)GGK(propionylation of K)GLGK(propionylation of K)GGAK(propionylation of K)R") == 0 &&
                        (bestPsm == null || bestPsm.ProbabilityScore() < query.psms[0].ProbabilityScore()))
                    {
                        bestPsm = psm;
                    }
                }
            }
            AnnotatedSpectrum aSpec = new AnnotatedSpectrum(ProjectRatios[0], bestPsm.Query.spectrum, bestPsm.Peptide);

            return(aSpec);
        }
Example #8
0
        public static object CreateView(string rawName, string scan, IConSol consol)
        {
            if (options == null)
            {
                options = DotNetMHC.MHCSearcher.CreateOptions(new string[] { "" }, "", 15, 0.05, consol);
            }
            //Get file path
            //Get Spectrum
            Numerics.SequenceStore store = Numerics.SequenceStore.GetStore(0.05);
            string rawFile = Numerics.SourceStore.GetDictionary()[rawName];

            DotNetMHC.Data.Spectrum spectrum = DotNetMHC.RawExtractor.LoadSpectrum(rawFile, scan, options);
            List <Data.PeptideView> peptides = store.GetPeptides(spectrum, options);
            double bestScore = 0.0;

            Data.PeptideView bestPeptide = peptides[0];
            foreach (Data.PeptideView peptide in peptides)
            {
                if (peptide.SpectrumScore > bestScore)
                {
                    bestScore   = peptide.SpectrumScore;
                    bestPeptide = peptide;
                }
            }
            return(new Data.SpecView(spectrum, peptides, bestPeptide));
        }
Example #9
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="options">数据库连接字配置</param>
 private ConnectionPool(DBOptions options)
 {
     _logger                = LogHelper.Logger;
     _mySqlConnection       = options.ConnectionString;
     InitialConnections     = options.InitialConnections;
     IncrementalConnections = options.IncrementalConnections;
     MaxConnections         = options.MaxConnections;
 }
Example #10
0
 /// <summary>
 /// 通过配置实例化DBHelper
 /// </summary>
 /// <param name="dbOptions">配置项</param>
 public DBHelper(DBOptions dbOptions)
 {
     _dbOptions = dbOptions;
     if (MySqlDB == null)
     {
         MySqlDB = new MySqlDB(_dbOptions);
     }
 }
Example #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HitchedProvider"/> class.
 /// </summary>
 /// <param name="apiService">The Supplier API Service</param>
 /// <param name="queryProvider">The sql query provider object.</param>
 /// <param name="database">The database configuration settings object.</param>
 /// <param name="extract">The extract configuration settings object</param>
 public HitchedProvider(IApiService apiService, IQueryProvider queryProvider, IOptions <DBOptions> database, IOptions <ExtractOptions> extract)
 {
     this.apiService       = apiService;
     this.queryProvider    = queryProvider;
     this.database         = database.Value;
     this.extract          = extract.Value;
     this.ConnectionString = this.database.ConnectionString;
 }
Example #12
0
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
            var option = new DBOptions();

            Configuration.GetSection("ConnectionOptions").Bind(option);
            IndexService.InitDbUtils(option);
        }
Example #13
0
 /// <summary>
 /// Get DbConnection instance
 /// </summary>
 public static DbConnection GetInstance(DBOptions options)
 {
     if (_instance == null || !_instance.IsValueCreated)
     {
         _instance = new Lazy <DbConnection>(() => new DbConnection(options));
     }
     return(_instance.Value);
 }
Example #14
0
 /// <summary>
 /// 创建一个连接池
 /// </summary>
 /// <param name="key"></param>
 /// <param name="option"></param>
 /// <returns></returns>
 public bool CreateConnectionPool(string key, DBOptions option)
 {
     if (!_poolList.ContainsKey(key))
     {
         _poolList.Add(key, ConnectionPool.CreateConnectionPoolInstance(option).CreatePool());
         return(true);
     }
     return(false);
 }
Example #15
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mySqlDBOptions"></param>
        public MySqlDB(DBOptions mySqlDBOptions)
        {
            MySqlDBOptions = mySqlDBOptions;

            // 创建一个数据库连接
            if (MySqlDBOptions.UseConnectPool && connectionPool == null)
            {
                connectionPool = ConnectionPool.CreateConnectionPoolInstance(mySqlDBOptions).CreatePool();
            }
        }
        public static bool Run()
        {
            string      outputPath = @"C:\_IRIC\DATA\Test\testMhc\Stats\";
            vsCSVWriter writer     = new vsCSVWriter(outputPath + "output.csv");

            writer.AddLine("File,# MS1s,# MSMS,1 Charge,2 Charge,3 Charge,4 Charge,5 Charge,6 Charge,7 Charge,8 Charge,9 Charge,10 Charge,11 Charge,12 Charge,13 Charge,14 Charge");

            DBOptions options = MhcSample.CreateOptions(outputPath);

            string[] files = new string[] { @"N:\Thibault\-=Proteomics_Raw_Data=-\ELITE\JUL29_2013\Settepeptides_300713_10uL.raw",
                                            @"N:\Thibault\-=Proteomics_Raw_Data=-\ELITE\JUL29_2013\Settepeptides_300713_10uL_MS60_MSMS15.raw",
                                            @"N:\Thibault\-=Proteomics_Raw_Data=-\ELITE\JUL29_2013\Settepeptides_300713_10uL_MS60_MSMS30.raw",
                                            @"N:\Thibault\-=Proteomics_Raw_Data=-\ELITE\JUL29_2013\Settepeptides_300713_10uL_MS60_MSMS60.raw",
                                            @"N:\Thibault\-=Proteomics_Raw_Data=-\ELITE\JUL29_2013\Settepeptides_300713_10uL_MS120_MSMS15.raw",
                                            @"N:\Thibault\-=Proteomics_Raw_Data=-\ELITE\JUL29_2013\Settepeptides_300713_10uL_MS120_MSMS30.raw",
                                            @"N:\Thibault\-=Proteomics_Raw_Data=-\ELITE\JUL29_2013\Settepeptides_300713_10uL_MS120_MSMS60.raw" };
            foreach (string file in files)
            {
                pwiz.CLI.msdata.MSDataFile msFile = new pwiz.CLI.msdata.MSDataFile(file);
                Spectra spectra = Spectra.Load(msFile, options, file);
                spectra.Sort(ProductSpectrum.AscendingPrecursorMassComparison);

                Dictionary <Track, Precursor> DicOfComputedTracks = new Dictionary <Track, Precursor>();
                int[] charges = new int[14];
                foreach (Track track in spectra.tracks)
                {
                    if (!DicOfComputedTracks.ContainsKey(track))
                    {
                        DicOfComputedTracks.Add(track, null);
                        int charge = 0;
                        foreach (Precursor precursor in Queries.GetIsotopes(track, options, spectra.tracks, null))
                        {
                            if (precursor.Charge > 0)
                            {
                                charge = precursor.Charge;
                            }
                            if (!DicOfComputedTracks.ContainsKey(precursor.Track))
                            {
                                DicOfComputedTracks.Add(precursor.Track, precursor);
                            }
                        }
                        charges[charge]++;
                    }
                }
                string line = file + "," + spectra.MS1s.Count + "," + spectra.Count;
                for (int i = 0; i < charges.Length; i++)
                {
                    line += "," + charges[i];
                }
                writer.AddLine(line);
            }
            writer.WriteToFile();
            return(true);
        }
Example #17
0
        public static DBOptions GetDBOptions(bool loadFromRaw, bool onlyYions, IConSol console)
        {
            string    outputDir = @"C:\_IRIC\DATA\Test\testNB\Iso3\";
            string    fastaFile = @"C:\_IRIC\Data\NB\peptide.fasta";
            DBOptions dbOptions = new DBOptions(fastaFile, console);

            dbOptions.precursorMassTolerance = new MassTolerance(8 /*8*//*8withoutisotopes*/, MassToleranceUnits.ppm);
            dbOptions.productMassTolerance   = new MassTolerance(20 /*8*//*8withoutisotopes*/, MassToleranceUnits.ppm);
            //dbOptions.productMassTolerance = new MassTolerance(0.05/*0.034*//*without isotopes*/, MassToleranceUnits.Da);//0.034 is a 60 000 resolution over 2000 range in mz
            dbOptions.MaximumPeptideMass = 200000;
            dbOptions.OutputFolder       = outputDir;
            ProteaseDictionary proteases = ProteaseDictionary.Instance;

            dbOptions.DigestionEnzyme = proteases["no enzyme"]; //trypsin (no proline rule)"];
            dbOptions.NoEnzymeSearch  = false;                  // true;
            dbOptions.DecoyFusion     = false;
            dbOptions.MaximumNumberOfFragmentsPerSpectrum = 400;
            //dbOptions.protease = proteases["trypsin (no proline rule)"];
            dbOptions.ToleratedMissedCleavages = 200;// 2;
            dbOptions.MinimumPeptideLength     = 5;
            dbOptions.MaximumPeptideLength     = 300;

            GraphML_List <Modification> fixMods = new GraphML_List <Modification>();

            //fixMods.Add(ModificationDictionary.Instance["propionylation of K"]);
            dbOptions.fixedModifications = fixMods;

            GraphML_List <Modification> varMods = new GraphML_List <Modification>();

            varMods.Add(ModificationDictionary.Instance["acetylation of K"]);
            varMods.Add(ModificationDictionary.Instance["propionylation of K"]);
            dbOptions.maximumVariableModificationIsoforms = 1024;
            dbOptions.variableModifications = varMods;

            dbOptions.addFragmentLoss = false; // true;
            dbOptions.addFragmentMods = false; // true;
            dbOptions.fragments       = new Fragments();
            if (!onlyYions)
            {
                dbOptions.fragments.Add(new FragmentA());
                dbOptions.fragments.Add(new FragmentB());
                dbOptions.fragments.Add(new FragmentC());
                dbOptions.fragments.Add(new FragmentX());
                dbOptions.fragments.Add(new FragmentZ());
            }
            dbOptions.fragments.Add(new FragmentY());

            dbOptions.SaveMS1Peaks       = true;
            dbOptions.SaveMSMSPeaks      = true;
            dbOptions.LoadSpectraIfFound = !loadFromRaw;

            dbOptions.NbPSMToKeep = 100;
            return(dbOptions);
        }
Example #18
0
        /*
        public static DBOptions DefaultSettings()
        {
            DBOptions list = new DBOptions();
            return list;
        }
        */

        public static DBOptions VeryFast_v10()
        {
            DBOptions list = new DBOptions();
            list.Name = "Very fast v1.0";

            //UTF-8 only uses one bytes so this should be the fastest option
            DBOptionEncoding encoding = new DBOptionEncoding();
            encoding.TargetValue = SQLiteDBOptions.Encoding.UTF8;
            list.Add(encoding);

            //Page size should be 4k on windows, this alligns with NTFS cluster size
            DBOptionPageSize pageSize = new DBOptionPageSize();
            pageSize.TargetValue = 4096;
            list.Add(pageSize);

            //The more cache the better, but we are assuming 10MB to be enough
            DBOptionCacheSize cacheSize = new DBOptionCacheSize();
            cacheSize.TargetValue = -1024 * 10;
            list.Add(cacheSize);

            //Temp store is in memory, hence no disk I/O
            DBOptionTempStore tempStore = new DBOptionTempStore();
            tempStore.TargetValue = TempStore.Memory;
            list.Add(tempStore);

            //Synchronous ist set to OFF. This is dangerous, but FAST
            DBOptionSynchronous syncMode = new DBOptionSynchronous();
            syncMode.TargetValue = SynchronousMode.Off;
            list.Add(syncMode);

            //Cell size check helps to detect database corruption but it costs performance as the data is read from disk 
            DBOptionCellSizeCheck cellCheck = new DBOptionCellSizeCheck();
            cellCheck.TargetValue = false;
            list.Add(cellCheck);

            //Locking mode should be EXCLUSIVE as this means we have an exclusive lock on the database and don't need to obtain or release locks between read or write access
            DBOptionExclusiveLocking lockMode = new DBOptionExclusiveLocking();
            lockMode.TargetValue = true;
            list.Add(lockMode);

            //Journal mode should be MEMORY. Dangerous but FAST (OFF would result in no rollback beeing defectiv which is just plain stupid even for a temporary database)
            DBOptionJournalMode journalMode = new DBOptionJournalMode();
            journalMode.TargetValue = JournalMode.Memory;
            list.Add(journalMode);

            //Automatic index can both be good or bad so this is a tricky question. However, it is ON by default so we will also activate it
            DBOptionAutoIndex autoIndex = new DBOptionAutoIndex();
            autoIndex.TargetValue = true;
            list.Add(autoIndex);


            return list;
        }
Example #19
0
        private DBOptions CreateOptions(string fastaFile, string outputFolder, IConSol consol)
        {
            DBOptions dbOptions = new DBOptions(fastaFile, consol);

            dbOptions.precursorMassTolerance = new MassTolerance(precTolPpm, MassToleranceUnits.ppm);
            dbOptions.productMassTolerance   = new MassTolerance(prodTolPpm, MassToleranceUnits.ppm);
            dbOptions.MaximumPeptideMass     = 200000;
            dbOptions.OutputFolder           = outputFolder;

            ProteaseDictionary proteases = ProteaseDictionary.Instance;

            dbOptions.DigestionEnzyme = proteases["no enzyme"];
            //dbOptions.DigestionEnzyme = proteases["top-down"];
            dbOptions.NoEnzymeSearch = false;
            dbOptions.DecoyFusion    = false;
            dbOptions.MaximumNumberOfFragmentsPerSpectrum = 400;
            dbOptions.ToleratedMissedCleavages            = 200;
            dbOptions.MinimumPeptideLength = 5;
            dbOptions.MaximumPeptideLength = 300;

            GraphML_List <Modification> fixMods = new GraphML_List <Modification>();

            dbOptions.fixedModifications = fixMods;

            GraphML_List <Modification> varMods = new GraphML_List <Modification>();

            foreach (string strMod in ModificationDictionary.Instance.Keys)
            {
                varMods.Add(ModificationDictionary.Instance[strMod]);
            }

            dbOptions.maximumVariableModificationIsoforms = 1024;
            dbOptions.variableModifications = varMods;

            dbOptions.addFragmentLoss = false;
            dbOptions.addFragmentMods = false;//Gives very bad results... might by off
            dbOptions.fragments       = new Fragments();

            dbOptions.fragments.Add(new FragmentA());
            dbOptions.fragments.Add(new FragmentB());
            dbOptions.fragments.Add(new FragmentC());
            dbOptions.fragments.Add(new FragmentX());
            dbOptions.fragments.Add(new FragmentY());
            dbOptions.fragments.Add(new FragmentZ());

            dbOptions.SaveMS1Peaks       = true;
            dbOptions.SaveMSMSPeaks      = true;
            dbOptions.LoadSpectraIfFound = true;

            dbOptions.NbPSMToKeep = 100;
            return(dbOptions);
        }
        public DbConnectionTests()
        {
            var options = new DBOptions {
                UserId   = "root",
                Password = "******",
                Host     = "localhost",
                Port     = 5432,
                Database = "rplay_db",
                Pooling  = true
            };

            connection = DbConnection.GetInstance(options);
        }
        /// <summary>
        /// Opens a connection to a SQLite database file
        /// </summary>
        /// <param name="fileName">Filename of SQLite databse</param>
        /// <param name="options">DBOptions object contianing the objects that should be active</param>
        /// <returns>Open connection to the database</returns>
        public static SQLiteConnection CreateDatabase(string fileName, DBOptions options)
        {
            log.Debug("Creating database {0}", fileName);

            if (File.Exists(fileName) == false)
            {
                return OpenDatabase(fileName, options, CreateIfNotExisting: true);
            }
            else
            {
                throw new IOException(string.Format("Database {0} already exists", fileName));
            }
        }
Example #22
0
        public static DBOptions CreateOptions(string outputDir)
        {
            //@"G:\Thibault\Olivier\MnR\Databases\BD_RefGenome_WithReverse_2012-06-20.fasta";
            string fastaFile = @"C:\_IRIC\DATA\MHC\human_reference_2013-26-03.fasta";// Ref genome
            //@"C:\_IRIC\DATA\Test\testMHC\MHC_Sette_Peptides_20091001.fasta";//Sette Peptides
            //C:\_IRIC\DATA\MHC\4468.fasta";//MnR\Mixed_M_2013-21-01.fasta";//MHC M One sample


            DBOptions dbOptions = new DBOptions(fastaFile);

            dbOptions.precursorMassTolerance = new MassTolerance(8 /*8withoutisotopes*/, MassToleranceUnits.ppm);
            dbOptions.productMassTolerance   = new MassTolerance(0.05 /*without isotopes*/, MassToleranceUnits.Da);//0.034 is a 60 000 resolution over 2000 range in mz
            dbOptions.MaximumPeptideMass     = 200000;
            dbOptions.OutputFolder           = outputDir;
            ProteaseDictionary proteases = ProteaseDictionary.Instance;

            dbOptions.DigestionEnzyme          = proteases["no enzyme"];
            dbOptions.NoEnzymeSearch           = true;
            dbOptions.ToleratedMissedCleavages = 20;// 2;


            GraphML_List <Modification> fixMods = new GraphML_List <Modification>();

            dbOptions.fixedModifications = fixMods;

            GraphML_List <Modification> varMods = new GraphML_List <Modification>();

            varMods.Add(ModificationDictionary.Instance["oxidation of M"]);//+ Deamidation M Q
            varMods.Add(ModificationDictionary.Instance["phosphorylation of S"]);
            varMods.Add(ModificationDictionary.Instance["phosphorylation of T"]);
            varMods.Add(ModificationDictionary.Instance["phosphorylation of Y"]);//*/
            varMods.Add(ModificationDictionary.Instance["deamidation of N"]);
            varMods.Add(ModificationDictionary.Instance["deamidation of Q"]);
            varMods.Add(ModificationDictionary.Instance["cysteinylation of C"]);
            dbOptions.variableModifications = varMods;

            dbOptions.maximumVariableModificationIsoforms = 1024;// 2 * (varMods.Count + fixMods.Count);//TODO Evaluate the viability of this parameter

            dbOptions.PSMFalseDiscoveryRate = 0.01;
            dbOptions.addFragmentMods       = false;
            dbOptions.addFragmentLoss       = false;
            dbOptions.fragments             = new Fragments();
            //dbOptions.fragments.Add(new FragmentA());
            dbOptions.fragments.Add(new FragmentB());
            //dbOptions.fragments.Add(new FragmentC());
            //dbOptions.fragments.Add(new FragmentX());
            dbOptions.fragments.Add(new FragmentY());
            //dbOptions.fragments.Add(new FragmentZ());
            return(dbOptions);
        }
Example #23
0
        public static DBOptions Normal_v10()
        {
            DBOptions list = new DBOptions();
            list.Name = "Normal v1.0";

            //UTF-8 is still the most used encoding so we'll stick with it 
            DBOptionEncoding encoding = new DBOptionEncoding();
            encoding.TargetValue = SQLiteDBOptions.Encoding.UTF8;
            list.Add(encoding);

            //Page size should be 4k on windows, this alligns with NTFS
            DBOptionPageSize pageSize = new DBOptionPageSize();
            pageSize.TargetValue = 4096;
            list.Add(pageSize);

            //The more cache the better, but we are assuming 10MB to be enough
            DBOptionCacheSize cacheSize = new DBOptionCacheSize();
            cacheSize.TargetValue = -1024 * 10;
            list.Add(cacheSize);

            //Temp store is in memory, hence no disk I/O.
            DBOptionTempStore tempStore = new DBOptionTempStore();
            tempStore.TargetValue = TempStore.Memory;
            list.Add(tempStore);

            //Only sync at critical operations
            DBOptionSynchronous syncMode = new DBOptionSynchronous();
            syncMode.TargetValue = SynchronousMode.Normal;
            list.Add(syncMode);

            //Cell size check helps to detect database corruption. Better activate it to prevent corrupted data
            DBOptionCellSizeCheck cellCheck = new DBOptionCellSizeCheck();
            cellCheck.TargetValue = true;
            list.Add(cellCheck);

            //Journal is set to truncate which means the journal is truncate to 0 bytes after beeing used. This is good tradeoff between Delete and Memory
            DBOptionJournalMode journalMode = new DBOptionJournalMode();
            journalMode.TargetValue = JournalMode.Truncate;
            list.Add(journalMode);

            //Automatic index can both be good or bad so this is a tricky question. However, it is ON by default so we will also activate it
            DBOptionAutoIndex autoIndex = new DBOptionAutoIndex();
            autoIndex.TargetValue = true;
            list.Add(autoIndex);



            return list;
        }
Example #24
0
        private void LoadSettings()
        {
            DBOptions        dbOption = DBOptions.Default;
            ISettingsManager manager  = VEFModule.UnityContainer.Resolve(typeof(ISettingsManager), "") as ISettingsManager;

            manager.Add(new DBSettingsItem("Datenbank", 1, dbOption));


            var managerDB = VEFModule.UnityContainer.Resolve(typeof(IDatabaseService), "") as IDatabaseService;

            managerDB.AddDBOption(dbOption);

            //    managerDB.SetCurrentDB(dbOption.Guid);
            //ObservableCollection<IDB> Databases
            //manager.Get("Text Editor").Add(new DBSettingsItem("General", 1, EditorOptions.Default));
        }
Example #25
0
        public DbContext CreateDbContext(DBOptions options = DBOptions.Write)
        {
            string connectionString = null;

            switch (options)
            {
            case DBOptions.Write:
                connectionString = dbOptions.MainConnection;
                break;

            case DBOptions.Read:
                connectionString = GetSlaveConnection();
                break;

            default:
                break;
            }
            return(new EFCoreDBContext(connectionString));
        }
        public static void UseSqlServerFromConfiguration(this DbContextOptionsBuilder OptionsBuilder)
        {
            DBOptions dBOptions = JsonHelpers <DBOptions> .GetJsonFile("DBConfiguration.json");

            //  string con = System.IO.File.ReadAllText(filePathForMigration);
            if (dBOptions != null && !string.IsNullOrEmpty(dBOptions.Stage))
            {
                string stage = dBOptions.Stage;
                if (stage.ToLower().Contains("memory"))
                {
                    OptionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString());
                }
                else
                {
                    string con = typeof(DBOptions).GetProperty(stage).GetValue(dBOptions).ToString();
                    OptionsBuilder.UseSqlServer(con);
                }
                OptionsBuilder.EnableSensitiveDataLogging();
            }
        }
        /// <summary>
        /// Creates a database in the definied path with a random name, applies all options and returns both the connection string and the SQLiteConnection
        /// </summary>
        /// <param name="definedOptions">List of DBOptions that should be applied</param>
        /// <returns>An open database connection to the newly created database</returns>
        public Tuple<string, SQLiteConnection> CreateDatabase(DBOptions definedOptions)
        {
            //First check for duplicate inside the options. Make sure each item is only definied once.
            definedOptions.CheckForDuplicates();

            string fileName = Path.Combine(_folderPath, "SQLitePragmaPerf_" + Guid.NewGuid().ToString() + ".sqlite");


            //Create the database with all options set 
            SQLiteConnection connection = DBOptionsConnectionHandler.CreateDatabase(fileName, definedOptions);

            //Finaly, create a TABLE to make sure that SQLite considers this database not empty
            CreateTable(connection);

            //Now query all options for their current values and store it in our list
            List<CurrentDBOptionValue> currentDBOptionValues = DBOptionsConnectionHandler.GetAllDBOptionsValueList(connection);

            //Close the connection to make sure that any DBOption that requires a open/close is satisfied
            DBOptionsConnectionHandler.CloseDatabase(connection);



            //Now reopen the database again and check if we get the same values if we leave out all persistent options
            CheckPersistentDBOptions(fileName, definedOptions, currentDBOptionValues);


            //If we are here, everything has worked so far. We can open the database and return the connection
            connection = DBOptionsConnectionHandler.OpenDatabase(fileName, definedOptions);

            //Debug output of all options
            List<CurrentDBOptionValue> allValues = DBOptionsConnectionHandler.GetAllDBOptionsValueList(connection);
            log.Debug("Database {0} created, DBOptions: ", fileName);
            foreach (CurrentDBOptionValue currentValue in allValues)
            {
                log.Debug("   {0}", currentValue.ToString());
            }

            return new Tuple<string, SQLiteConnection>(fileName, connection);
        }
Example #28
0
        public static void Uptimize()
        {
            string    fastaFile = @"C:\_IRIC\Data\NB\peptide.fasta";
            DBOptions dbOptions = PositionnalIsomerSolver.CreateOptions(fastaFile, @"C:\_IRIC\Data\NB\Units2\", 8, 0.05, new PeptidAce.Utilities.Interfaces.ConSolCommandLine());

            dbOptions.dProduct   = 0.0917981081138356;
            dbOptions.dPrecursor = 0.345789190542786;
            dbOptions.dMatchingProductFraction = 0.427418045898628;
            dbOptions.dMatchingProduct         = 0;
            dbOptions.dIntensityFraction       = 0.429418127252449;
            dbOptions.dIntensity     = 0;
            dbOptions.dProtein       = 0.692270441303156;
            dbOptions.dPeptideScore  = 0.636739763262095;
            dbOptions.dFragmentScore = 0.0229058195943506;

            dbOptions.fullFragment = new FullFragments(true);
            string  project = @"C:\_IRIC\Data\NB\ProjectTest_AllAce_Spiked_QEPlus_Apr21.csv";
            Samples samples = new Samples(project, 0, dbOptions);

            Uptimizer.Run(samples, dbOptions);

            dbOptions.Save(dbOptions.OutputFolder + "UptimizedOptions.csv");
        }
Example #29
0
        private double GetNbTimesFit(DBOptions dbOptions, int nbProductsToKeep, double precision, out double area)
        {
            long   nbRatios = 0;
            double nbTimes  = 0;

            area = 0.0;
            List <CharacterizedPrecursor> Isomers = new List <CharacterizedPrecursor>();

            Isomers.Add(this);

            ElutionCurve curve = new ElutionCurve();

            foreach (Query query in this.Queries)
            {
                //double overFlow = 0;
                double underFlow    = 0;
                double percentError = 0;
                Dictionary <CharacterizedPrecursor, PositionnalIsomerSolver.SolvedResult> finalRatios = PositionnalIsomerSolver.SolveFromSpectrum(Isomers, nbProductsToKeep, precision, query.spectrum.Peaks, dbOptions.productMassTolerance,
                                                                                                                                                  query.spectrum.PrecursorIntensityPerMilliSecond * query.spectrum.InjectionTime, out underFlow, out percentError, dbOptions.ConSole);

                if (percentError < 0.5)
                {
                    curve.AddPoint(query.spectrum.RetentionTimeInMin * 1000.0 * 60.0, finalRatios[this].Ratio * query.spectrum.PrecursorIntensityPerMilliSecond);
                    nbTimes += finalRatios[this].NbFitTimes;
                    nbRatios++;
                }
            }
            if (nbRatios > 2 && curve.GetNbPoints() > this.Queries.Count * 0.5)
            {
                curve.Compute();
                if (curve.Area > 0)
                {
                    area = curve.Area;
                }
            }
            return(nbTimes / (double)nbRatios);
        }
Example #30
0
        public static DBOptions CreateOptions()
        {
            DBOptions dbOptions = new DBOptions("");

            dbOptions.precursorMassTolerance = new MassTolerance(8 /*8withoutisotopes*/, MassToleranceUnits.ppm);
            dbOptions.productMassTolerance   = new MassTolerance(0.034 /*without isotopes*/, MassToleranceUnits.Da);//0.034 is a 60 000 resolution over 2000 range in mz
            dbOptions.MaximumPeptideMass     = 20000;
            dbOptions.OutputFolder           = "";
            ProteaseDictionary proteases = ProteaseDictionary.Instance;

            dbOptions.DigestionEnzyme          = proteases["no enzyme"];
            dbOptions.ToleratedMissedCleavages = 20000;

            GraphML_List <Modification> fixMods = new GraphML_List <Modification>();

            dbOptions.fixedModifications = fixMods;

            GraphML_List <Modification> varMods = new GraphML_List <Modification>();

            dbOptions.variableModifications = varMods;
            dbOptions.maximumVariableModificationIsoforms = 2 * (varMods.Count + fixMods.Count);//TODO Evaluate the viability of this parameter
            dbOptions.MinimumPeptideLength = 4;
            return(dbOptions);
        }
Example #31
0
        public static void Update(IEnumerable <CharacterizedPrecursor> isomers, int minNbProducts, int maxNbProducts, DBOptions dbOptions, double precision)
        {
            foreach (CharacterizedPrecursor prec in isomers)
            {
                prec.NormalizedFragments = new Dictionary <int, Dictionary <double, double> >();
            }

            for (int nbProduct = minNbProducts; nbProduct <= maxNbProducts; nbProduct++)
            {
                Dictionary <double, int> dicOfFrags = GetCommonFragmentMz(isomers, nbProduct);
                foreach (CharacterizedPrecursor prec in isomers)
                {
                    prec.Fragments.Add(nbProduct, prec.GetCombinedMatches(dicOfFrags, dbOptions));
                }

                foreach (CharacterizedPrecursor prec in isomers)
                {
                    if (prec.Fragments.ContainsKey(nbProduct))
                    {
                        Dictionary <double, double> dic = new Dictionary <double, double>();
                        foreach (double key in dicOfFrags.Keys)
                        {
                            dic.Add(key, 0.0);
                            foreach (ProductMatch match in prec.Fragments[nbProduct])
                            {
                                if (Math.Abs(Proteomics.Utilities.Numerics.CalculateMassError(match.theoMz, key, dbOptions.productMassTolerance.Units)) <= dbOptions.productMassTolerance.Value)
                                {
                                    dic[key] += match.normalizedIntensity;
                                }
                            }
                        }
                        prec.NormalizedFragments.Add(nbProduct, dic);
                    }
                }

                foreach (CharacterizedPrecursor prec in isomers)
                {
                    if (!prec.NormalizeFragments(isomers, nbProduct, dbOptions, false, true, precision))//If normalization fails, ignore this product
                    {
                        prec.Fragments.Remove(nbProduct);
                    }
                }
            }
        }
Example #32
0
        public static Dictionary <double, Dictionary <Sample, CharacterizedPrecursor> > GetSpikedPrecursors(Samples spikedSamples, Result spikedResult, DBOptions dbOptions, int nbMinFragments, int nbMaxFragments, long precision)
        {
            Dictionary <double, Dictionary <Query, int> > mzKeys = new Dictionary <double, Dictionary <Query, int> >();

            foreach (Query query in spikedResult.queries)
            {
                foreach (PeptideSpectrumMatch psm in query.psms)
                {
                    double mz = Proteomics.Utilities.Numerics.MZFromMass(psm.Peptide.MonoisotopicMass, query.spectrum.PrecursorCharge);
                    if (!mzKeys.ContainsKey(mz))
                    {
                        bool found = false;
                        foreach (double key in mzKeys.Keys)
                        {
                            if (Math.Abs(Proteomics.Utilities.Numerics.CalculateMassError(mz, key, dbOptions.precursorMassTolerance.Units)) <= dbOptions.precursorMassTolerance.Value)
                            {
                                mz    = key;
                                found = true;
                            }
                        }
                        if (!found)
                        {
                            mzKeys.Add(mz, new Dictionary <Query, int>());
                        }
                    }
                    if (!mzKeys[mz].ContainsKey(query))
                    {
                        mzKeys[mz].Add(query, 1);
                    }
                }
            }

            Dictionary <double, Dictionary <Sample, CharacterizedPrecursor> > spikes = new Dictionary <double, Dictionary <Sample, CharacterizedPrecursor> >();

            foreach (Sample spikedSample in spikedSamples)
            {
                Dictionary <double, PrecursorIon> DicOfSpectrumMasses = PrecursorIon.GetPrecursors(spikedResult, spikedSample, dbOptions, mzKeys.Keys);
                foreach (double mzKey in DicOfSpectrumMasses.Keys)
                {
                    if (mzKeys.ContainsKey(mzKey))
                    {
                        //Pick the best PSM for each sample/precursor pair
                        Dictionary <Peptide, double> DicOfProbabilityScores = new Dictionary <Peptide, double>();

                        foreach (Query query in mzKeys[mzKey].Keys)
                        {
                            if (query.sample == spikedSample)
                            {
                                foreach (PeptideSpectrumMatch psm in query.psms)
                                {
                                    if (!DicOfProbabilityScores.ContainsKey(psm.Peptide))
                                    {
                                        DicOfProbabilityScores.Add(psm.Peptide, psm.ProbabilityScore());
                                    }
                                    else
                                    {
                                        DicOfProbabilityScores[psm.Peptide] += psm.ProbabilityScore();
                                    }
                                }
                            }
                        }

                        Peptide bestPeptide = null;
                        double  bestScore   = double.MinValue;
                        foreach (Peptide keyPep in DicOfProbabilityScores.Keys)
                        {
                            if (DicOfProbabilityScores[keyPep] > bestScore)
                            {
                                bestScore   = DicOfProbabilityScores[keyPep];
                                bestPeptide = keyPep;
                            }
                        }
                        if (bestPeptide != null)
                        {
                            CharacterizedPrecursor cPrec = new CharacterizedPrecursor(spikedSample, dbOptions, bestPeptide, mzKeys[mzKey].Keys, mzKey);
                            //Don't keep precursors if they are not well characterized (unfragmented or missasigned)
                            if (cPrec.AllFragments.Count >= cPrec.Peptide.Length - 2)
                            {
                                if (!spikes.ContainsKey(mzKey))
                                {
                                    spikes.Add(mzKey, new Dictionary <Sample, CharacterizedPrecursor>());
                                }
                                if (!spikes[mzKey].ContainsKey(spikedSample))
                                {
                                    spikes[mzKey].Add(spikedSample, cPrec);
                                }
                                else
                                {
                                    Console.WriteLine("Twice??");
                                }
                            }
                        }
                    }
                } //End of foreach mzKey
            }     //End of foreach spiked sample

            //Normalize intensities based on average area of each precursor
            List <double> tmpKeys = new List <double>(spikes.Keys);

            foreach (double mzKey in tmpKeys)
            {
                if (spikes[mzKey].Count > 0)
                {
                    CharacterizedPrecursor.Update(spikes[mzKey].Values, nbMinFragments, nbMaxFragments, dbOptions, precision);
                }
                else
                {
                    spikes.Remove(mzKey);
                }
            }//*/
            return(spikes);
        }
        //Open a database but ignores all options that have IsPersistent=true and then checks the value of all options with the expected list.
        //This ensures that a persistent option is really persistent
        private void CheckPersistentDBOptions(string fileName, DBOptions options, List<CurrentDBOptionValue> expectedOptionValues)
        {
            log.Debug("Performing persistent option check...");

            //Create an options object without any option that is configured "Persistent"
            DBOptions optionsWithoutPersistent = new DBOptions();

            foreach (DBOptionBase option in options)
            {
                if (option.IsPersistent == false)
                {
                    optionsWithoutPersistent.Add(option);
                }
            }

            //string connectionString = optionsWithoutPersistent.GenerateConnectionString(fileName);
            SQLiteConnection connection = DBOptionsConnectionHandler.OpenDatabase(fileName, optionsWithoutPersistent);

            //Query all options for their values
            List<CurrentDBOptionValue> optionValueList = DBOptionsConnectionHandler.GetAllDBOptionsValueList(connection);

            DBOptionsConnectionHandler.CloseDatabase(connection);


            //Now compare the expected values with the current values
            foreach (CurrentDBOptionValue expected in expectedOptionValues)
            {
                foreach (CurrentDBOptionValue current in optionValueList)
                {
                    if (current.Name == expected.Name)
                    {
                        if (current.DisplayValue != expected.DisplayValue)
                        {
                            throw new InvalidOperationException(string.Format(
                                "The option [{0}] is marked as persistent, but reopening the database resulted in a different value than configured: Current value from  open test [{1}], expected [{2}]",
                                expected.Name, current.DisplayValue, expected.DisplayValue
                                ));
                        }
                    }
                }

            }

        }
Example #34
0
        private long ExecuteCommands(string fileName, DBOptions options, SQLitePragmaPerf.CommandType commandType, int batchSizeKilo, int totalRowsKilo)
        {
            SQLiteConnection connection = DBOptionsConnectionHandler.OpenDatabase(fileName, options);

            TimeSpan tsTotal = new TimeSpan(0);
            foreach (SQLCommandBase command in _listCommands)
            {
                if (command.CommandType == commandType) // SQLitePragmaPerf.CommandType.UseData)
                {
                    command.Initialize(connection);
                    TimeSpan ts = command.ExecuteKilo(connection, batchSizeKilo, totalRowsKilo);

                    tsTotal += ts;
                }
            }

            //We close the database to make sure everything is back to default and for example the cache is empty
            DBOptionsConnectionHandler.CloseDatabase(connection);

            return (long)tsTotal.TotalMilliseconds;
        }
        public static List <MixedPrecursor> GetMixedPrecursors(Sample mixedSample, Result mixedResult, DBOptions dbOptions, Dictionary <double, Dictionary <Sample, CharacterizedPrecursor> > charPeptides)
        {
            Dictionary <double, PrecursorIon> DicOfSpectrumMasses = PrecursorIon.GetPrecursors(mixedResult, mixedSample, dbOptions, charPeptides.Keys);
            //Dictionary<double, MixedPrecursor> DicOfMixedPrecursor = new Dictionary<double, MixedPrecursor>();
            List <MixedPrecursor> listOfMixedPrec = new List <MixedPrecursor>();

            foreach (double key in DicOfSpectrumMasses.Keys)
            {
                if (charPeptides.ContainsKey(key))
                {
                    foreach (PrecursorIon precIon in DicOfSpectrumMasses[key].SplitBasedOnTime(dbOptions))
                    {
                        MixedPrecursor mixedPrecursor = new MixedPrecursor(mixedSample, precIon, key);

                        //Don't try to characterize mixed precursors if there is less than five scans
                        if (mixedPrecursor.Queries.Count > 4)
                        {
                            foreach (Query q in mixedPrecursor.Queries)
                            {
                                q.spectrum.PrecursorIntensityPerMilliSecond = mixedPrecursor.eCurveIntensityPerMS.InterpolateIntensity(q.spectrum.RetentionTimeInMin * 1000.0 * 60.0 + 0.5 * q.spectrum.InjectionTime);
                            }
                            listOfMixedPrec.Add(mixedPrecursor);
                        }
                        //DicOfMixedPrecursor.Add(key, mixedPrecursor);
                    }
                }
            }
            return(listOfMixedPrec);
        }
Example #36
0
        private bool NormalizeFragments(IEnumerable <CharacterizedPrecursor> allCorrespondingPrec, int nbProductsToKeep, DBOptions dbOptions, bool normalizePrecursor, bool normalizeFragments, double precision)
        {
            bool   keepNbProds = true;
            double FragmentLossNormalizeFactor = 1.0;

            if (eCurve.Area > 0)
            {
                if (normalizeFragments)
                {
                    List <double> keys   = new List <double>(NormalizedFragments[nbProductsToKeep].Keys);
                    double        area   = this.eCurve.Area;
                    int           nbIter = 3;
                    while (nbIter > 0)
                    {
                        nbIter--;

                        double averageNbTimes = GetNbTimesFit(dbOptions, nbProductsToKeep, precision, out area);
                        FragmentLossNormalizeFactor = precision / (double)averageNbTimes;
                        foreach (ProductMatch pm in this.Fragments[nbProductsToKeep])
                        {
                            pm.normalizedIntensity /= FragmentLossNormalizeFactor;
                            pm.obsIntensity        /= FragmentLossNormalizeFactor;
                        }
                        foreach (double key in keys)
                        {
                            NormalizedFragments[nbProductsToKeep][key] /= FragmentLossNormalizeFactor;
                        }
                    }
                }
                else
                {
                    FragmentLossNormalizeFactor = 1.0;
                }

                if (normalizePrecursor)
                {
                    double average = 0;
                    PrecursorLossNormalizeFactor.Add(nbProductsToKeep, GetNormalizePrecursorFactor(allCorrespondingPrec, out average, out keepNbProds));
                }
                else
                {
                    PrecursorLossNormalizeFactor.Add(nbProductsToKeep, 1.0);
                }
            }
            return(keepNbProds);
        }
 /// <summary>
 /// Ensures that all options for this connection as set as definied in options. Throws an error if not.
 /// </summary>
 /// <param name="connection">Open connection to check</param>
 /// <param name="options">The definied options</param>
 public static void VerifyOptions(SQLiteConnection connection, DBOptions options)
 {
     throw new NotImplementedException();
 }
Example #38
0
        public static DBOptions MaxReliability_v10()
        {
            DBOptions list = new DBOptions();
            list.Name = "Max reliability v1.0";


            //UTF-16 allows us to store anything using two bytes, where UTF-8 sometimes require three bytes
            DBOptionEncoding encoding = new DBOptionEncoding();
            encoding.TargetValue = SQLiteDBOptions.Encoding.UTF16LE;
            list.Add(encoding);

            //Use the same page size as SQL Server
            DBOptionPageSize pageSize = new DBOptionPageSize();
            pageSize.TargetValue = 8192;
            list.Add(pageSize);

            //The more cache the better, but we are assuming 10MB to be enough
            DBOptionCacheSize cacheSize = new DBOptionCacheSize();
            cacheSize.TargetValue = -1024 * 10;
            list.Add(cacheSize);

            //Temp store is in memory, hence no disk I/O and also we do not have any problems with temp file locks
            DBOptionTempStore tempStore = new DBOptionTempStore();
            tempStore.TargetValue = TempStore.Memory;
            list.Add(tempStore);

            //Always wait Windows to writte our I/Os to the disk
            DBOptionSynchronous syncMode = new DBOptionSynchronous();
            syncMode.TargetValue = SynchronousMode.Full;
            list.Add(syncMode);

            //Cell size check helps to detect database corruption. Better activate it to prevent corrupted data
            DBOptionCellSizeCheck cellCheck = new DBOptionCellSizeCheck();
            cellCheck.TargetValue = true;
            list.Add(cellCheck);

            //Journal is set to WAL Mode which does allow more concurrent read and writer
            DBOptionJournalMode journalMode = new DBOptionJournalMode();
            journalMode.TargetValue = JournalMode.WAL;
            list.Add(journalMode);

            //Automatic index might (in some cases) causes queries to run slower. To keep the database exactly as the author has created it (everybody should be aware that a table without index is slow) we turn it OFF
            DBOptionAutoIndex autoIndex = new DBOptionAutoIndex();
            autoIndex.TargetValue = false;
            list.Add(autoIndex);

            return list;
        }
Example #39
0
        public static DBOptions Testing1()
        {
            DBOptions list = new DBOptions();

            DBOptionEncoding encoding = new DBOptionEncoding();
            encoding.TargetValue = SQLiteDBOptions.Encoding.UTF16LE;
            list.Add(encoding);

            DBOptionCacheSize cacheSize = new DBOptionCacheSize();
            cacheSize.TargetValue = -1024;
            list.Add(cacheSize);

            DBOptionSecureDelete secureDelete = new DBOptionSecureDelete();
            secureDelete.TargetValue = true;
            list.Add(secureDelete);



            return list;
        }
Example #40
0
        private List <ProductMatch> GetCombinedMatches(Dictionary <double, int> dicOfCommonFragments, DBOptions dbOptions)
        {
            List <ProductMatch> matches = new List <ProductMatch>(dicOfCommonFragments.Count);

            foreach (double mz in dicOfCommonFragments.Keys)
            {
                bool found = false;
                foreach (ProductMatch match in AllFragments)
                {
                    if (match.theoMz == mz)
                    {
                        matches.Add(new ProductMatch(match));
                        found = true;
                    }
                }

                if (!found)
                {
                    double       sumPsmFactor = 0;
                    ProductMatch newMatch     = new ProductMatch();
                    newMatch.theoMz              = mz;
                    newMatch.weight              = 0;
                    newMatch.obsIntensity        = 0;
                    newMatch.normalizedIntensity = 0;
                    foreach (PeptideSpectrumMatch psm in Psms)
                    {
                        foreach (MsMsPeak peak in psm.Query.spectrum.Peaks)
                        {
                            if (Math.Abs(Proteomics.Utilities.Numerics.CalculateMassError(peak.MZ, mz, dbOptions.productMassTolerance.Units)) <= dbOptions.productMassTolerance.Value)
                            {
                                newMatch.obsIntensity        += peak.Intensity * DicOfPsmFactor[psm];
                                newMatch.normalizedIntensity += (peak.Intensity / (psm.Query.spectrum.PrecursorIntensityPerMilliSecond * psm.Query.spectrum.InjectionTime)) * DicOfPsmFactor[psm];
                                sumPsmFactor += DicOfPsmFactor[psm];
                                newMatch.weight++;
                            }
                        }
                    }
                    if (newMatch.weight > 0)
                    {
                        newMatch.obsIntensity        /= sumPsmFactor;
                        newMatch.normalizedIntensity /= sumPsmFactor;
                    }
                    newMatch.weight *= newMatch.normalizedIntensity;
                    matches.Add(newMatch);
                }
            }

            double averageNormedIntensity = 0.0;

            foreach (ProductMatch match in matches)
            {
                averageNormedIntensity += match.normalizedIntensity;
            }

            if (matches.Count > 0)
            {
                averageNormedIntensity /= (double)matches.Count;
            }

            //Keep only most intense fragments (5% of average normalized intensity)
            foreach (ProductMatch pm in matches)
            {
                if (pm.normalizedIntensity < averageNormedIntensity * 0.1)//0.05
                {
                    pm.normalizedIntensity = 0;
                    pm.obsIntensity        = 0;
                }
            }

            return(matches);
        }
        /// <summary>
        /// Returns the values for the options from the given connection
        /// </summary>
        /// <param name="connection">Database connection to use</param>
        /// <param name="options">Definied options</param>
        /// <returns>List of the current values of the given DBOptions</returns>
        public static List<CurrentDBOptionValue> GetDBOptionValueList(SQLiteConnection connection, DBOptions options)
        {
            List<CurrentDBOptionValue> optionValueList = new List<CurrentDBOptionValue>();

            foreach (DBOptionBase option in options)
            {
                optionValueList.Add(option.GetCurrentOptionValue(connection));
            }

            return optionValueList;
        }