예제 #1
0
파일: BulkInserter.cs 프로젝트: zrolfs/pwiz
        public void Reset(IDbConnection conn)
        {
            diskFilepath = null;

            memConn = conn;
            memConn.ExecuteNonQuery(@"PRAGMA journal_mode=OFF;
                                      PRAGMA synchronous=OFF;");
            SessionFactoryFactory.DropIndexes(memConn);

            insertCommandByTable = new List <KeyValuePair <IDbCommand, List <object[]> > >();
            for (int i = 0; i <= (int)Table.QonverterSettings; ++i)
            {
                insertCommandByTable.Add(new KeyValuePair <IDbCommand, List <object[]> >());
            }

            insertCommandByTable[(int)Table.Protein] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.Protein].Key.CommandText = createInsertSql("Protein", "Id, Accession, Length");

            insertCommandByTable[(int)Table.ProteinMetadata] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.ProteinMetadata].Key.CommandText = createInsertSql("ProteinMetadata", "Id, Description");

            insertCommandByTable[(int)Table.ProteinData] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.ProteinData].Key.CommandText = createInsertSql("ProteinData", "Id, Sequence");

            insertCommandByTable[(int)Table.Peptide] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.Peptide].Key.CommandText = createInsertSql("Peptide", "Id, MonoisotopicMass, MolecularWeight");

            insertCommandByTable[(int)Table.PeptideSequences] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.PeptideSequences].Key.CommandText = createInsertSql("PeptideSequences", "Id, Sequence");

            insertCommandByTable[(int)Table.PeptideInstance] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.PeptideInstance].Key.CommandText = createInsertSql("PeptideInstance", "Id, Protein, Peptide, Offset, Length, NTerminusIsSpecific, CTerminusIsSpecific, MissedCleavages");

            insertCommandByTable[(int)Table.Analysis] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.Analysis].Key.CommandText = createInsertSql("Analysis", "Id, Name, SoftwareName, SoftwareVersion, StartTime, Type");

            insertCommandByTable[(int)Table.AnalysisParameter] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.AnalysisParameter].Key.CommandText = createInsertSql("AnalysisParameter", "Id, Analysis, Name, Value");

            insertCommandByTable[(int)Table.SpectrumSourceGroup] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.SpectrumSourceGroup].Key.CommandText = createInsertSql("SpectrumSourceGroup", "Id, Name");

            insertCommandByTable[(int)Table.SpectrumSource] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.SpectrumSource].Key.CommandText = createInsertSql("SpectrumSource", "Id, Name, URL, Group_");

            insertCommandByTable[(int)Table.SpectrumSourceMetadata] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.SpectrumSourceMetadata].Key.CommandText = createInsertSql("SpectrumSourceMetadata", "Id, MsDataBytes");

            insertCommandByTable[(int)Table.SpectrumSourceGroupLink] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.SpectrumSourceGroupLink].Key.CommandText = createInsertSql("SpectrumSourceGroupLink", "Id, Source, Group_");

            insertCommandByTable[(int)Table.Spectrum] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.Spectrum].Key.CommandText = createInsertSql("Spectrum", "Id, Index_, NativeID, Source, PrecursorMZ");

            insertCommandByTable[(int)Table.PeptideSpectrumMatch] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.PeptideSpectrumMatch].Key.CommandText =
                createInsertSql("PeptideSpectrumMatch",
                                "Id, Peptide, Spectrum, Analysis, " +
                                "ObservedNeutralMass, " +
                                "MonoisotopicMassError, MolecularWeightError, " +
                                "Rank, QValue, Charge");

            insertCommandByTable[(int)Table.PeptideSpectrumMatchScoreName] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.PeptideSpectrumMatchScoreName].Key.CommandText = createInsertSql("PeptideSpectrumMatchScoreName", "Id, Name");

            insertCommandByTable[(int)Table.PeptideSpectrumMatchScore] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.PeptideSpectrumMatchScore].Key.CommandText = createInsertSql("PeptideSpectrumMatchScore", "PsmId, ScoreNameId, Value");

            insertCommandByTable[(int)Table.Modification] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.Modification].Key.CommandText = createInsertSql("Modification", "Id, MonoMassDelta, AvgMassDelta, Name, Formula");

            insertCommandByTable[(int)Table.PeptideModification] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.PeptideModification].Key.CommandText = createInsertSql("PeptideModification", "Id, Modification, PeptideSpectrumMatch, Offset, Site");

            insertCommandByTable[(int)Table.IntegerSet] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.IntegerSet].Key.CommandText = "INSERT INTO IntegerSet VALUES (?)";

            insertCommandByTable[(int)Table.QonverterSettings] = new KeyValuePair <IDbCommand, List <object[]> >(conn.CreateCommand(), new List <object[]>());
            insertCommandByTable[(int)Table.QonverterSettings].Key.CommandText = createInsertSql("QonverterSettings", "Id, QonverterMethod, DecoyPrefix, RerankMatches, ScoreInfoByName");

            foreach (var itr in insertCommandByTable)
            {
                createParameters(itr.Key);
                itr.Key.Prepare();
            }

            scoreIdByName = new Dictionary <string, long>();

            foreach (var queryRow in conn.ExecuteQuery("SELECT Name, Id FROM PeptideSpectrumMatchScoreName"))
            {
                scoreIdByName[queryRow.GetString(0)] = queryRow.GetInt64(1);
            }

            /*diskConn.ExecuteNonQuery("CREATE TABLE IF NOT EXISTS PeptideSequences (Id INTEGER PRIMARY KEY, Sequence TEXT)");
             * diskConn.ExecuteNonQuery("CREATE TABLE IF NOT EXISTS IntegerSet (Value INTEGER PRIMARY KEY)");
             * currentMaxSequenceLength = diskConn.ExecuteQuery("SELECT IFNULL(MAX(Value),0) FROM IntegerSet").First().GetInt64(0);
             */
            memConn.ExecuteNonQuery("CREATE TABLE IF NOT EXISTS PeptideSequences (Id INTEGER PRIMARY KEY, Sequence TEXT)");
            transaction = memConn.BeginTransaction();
        }
예제 #2
0
 public static ISessionFactory CreateSessionFactory (string path) { return SessionFactoryFactory.CreateSessionFactory(path, new SessionFactoryConfig()); }
예제 #3
0
파일: BulkInserter.cs 프로젝트: zrolfs/pwiz
 public void Reset(string diskFilepath)
 {
     Reset(SessionFactoryFactory.CreateFile(":memory:"));
     this.diskFilepath = diskFilepath;
 }