Source code for MSQuant: frmProteinDirector.vb, SqlInt/src/frmProteinDirector.vb.

Table of contents page.

Home page for MSQuant.

'****************************************************************************
'* Copyright (C) 2004 Leonard James Foster                                  *
'* This file is part of CEBIsoftware.                                            *
'*                                                                          *
'* CEBIsoftware is distributed under the terms of                                *
'* the GNU General Public License. See src/COPYING.TXT or                   *
'* <http://www.gnu.org/licenses/gpl.txt> for details.                       *
'*                                                                          *
'* CEBIsoftware is free software; you can redistribute it                        *
'* and/or modify it under the terms of the GNU                              *
'* General Public License as published by the Free                          *
'* Software Foundation; either version 2 of the                             *
'* License, or (at your option) any later version.                          *
'*                                                                          *
'* CEBIsoftware is distributed in the hope that it will be                       *
'* useful, but WITHOUT ANY WARRANTY; without even the                       *
'* implied warranty of MERCHANTABILITY or FITNESS FOR                       *
'* A PARTICULAR PURPOSE.  See the GNU General Public                        *
'* License for more details.                                                *
'*                                                                          *
'* You should have received a copy of the GNU General                       *
'* Public License along with CEBIsoftware; if not, write to                      *
'* the Free Software Foundation, Inc., 59 Temple                            *
'* Place, Suite 330, Boston, MA  02111-1307  USA                            *
'*                                                                          *
'* Purpose: <to be filled in>.                                              *
'*                                                                          *
'****************************************************************************

'****************************************************************************
'*                               CEBI                                       *
'*                    Software Development Group                            *
'*                         Leonard James Foster                             *
'*                E-mail: NUKESPAMMERSdrmortensen@get2netZZZZZZ.dk          *
'*                 WWW: http://www.cebi.sdu.dk/                             *
'*                                                                          *
'*  Program for post-processing of result from search in mass               *
'*    spectrometric data.                                                   *
'*                                                                          *
'*    FILENAME:   frmProteinDirector.vb                         *
'*    TYPE:  VISUAL_BASIC                                                   *
'*                                                                          *
'* CREATED: PM 2003-??-??   Vrs 1.0.                                        *
'* UPDATED: PM 2004-xx-xx                                                   *
'*                                                                          *
'****************************************************************************

Option Strict On
Option Explicit On


Public Class frmProteinDirector
    Inherits System.Windows.Forms.Form
    Public LoginScript As String
    'Private _QuerySQL As clsQuerySQL
    Structure IDList
        Dim IDNumber As Long
        Dim Name As String
    End Structure
    Dim ExptIDArray(100) As IDList
    Dim IDFound As Long
    Dim SampleIDArray(100) As IDList
    Dim AnalysisIDArray(10) As IDList
    Dim SearchIDArray(10) As IDList
    Dim SelectedProject As String
    Dim SelectedExpt As String
    Dim SelectedSample As String
    Dim SelectedAnalysis As String
    Dim ExptCount As Integer
    Dim SampleCount As Integer
    Dim AnalysisCount As Integer
    Dim SearchCount As Integer
    Dim ExptIDSelected As Long = 0
    Dim SampleIDSelected As Long = 0
    Dim AnalysisIDSelected As Integer = 0

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents lblSearches As System.Windows.Forms.Label
    Friend WithEvents lstboxSearches As System.Windows.Forms.ListBox
    Friend WithEvents lblAnalyses As System.Windows.Forms.Label
    Friend WithEvents lstboxAnalyses As System.Windows.Forms.ListBox
    Friend WithEvents lstboxSamples As System.Windows.Forms.ListBox
    Friend WithEvents lblSamples As System.Windows.Forms.Label
    Friend WithEvents lblExperiments As System.Windows.Forms.Label
    Friend WithEvents lblProject As System.Windows.Forms.Label
    Friend WithEvents lstboxExperiments As System.Windows.Forms.ListBox
    Friend WithEvents lstboxProject As System.Windows.Forms.ListBox
    Friend WithEvents SqlCEBI As System.Data.SqlClient.SqlConnection
    Friend WithEvents bttnCancel As System.Windows.Forms.Button
    Friend WithEvents bttnAuto As System.Windows.Forms.Button
    Friend WithEvents bttnSearch As System.Windows.Forms.Button
    Friend WithEvents grpboxOptions As System.Windows.Forms.GroupBox
    Friend WithEvents chkboxPeptideChk As System.Windows.Forms.CheckBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.lblSearches = New System.Windows.Forms.Label
        Me.lstboxSearches = New System.Windows.Forms.ListBox
        Me.lblAnalyses = New System.Windows.Forms.Label
        Me.lstboxAnalyses = New System.Windows.Forms.ListBox
        Me.lstboxSamples = New System.Windows.Forms.ListBox
        Me.lblSamples = New System.Windows.Forms.Label
        Me.lblExperiments = New System.Windows.Forms.Label
        Me.lblProject = New System.Windows.Forms.Label
        Me.lstboxExperiments = New System.Windows.Forms.ListBox
        Me.lstboxProject = New System.Windows.Forms.ListBox
        Me.SqlCEBI = New System.Data.SqlClient.SqlConnection
        Me.bttnSearch = New System.Windows.Forms.Button
        Me.bttnCancel = New System.Windows.Forms.Button
        Me.bttnAuto = New System.Windows.Forms.Button
        Me.grpboxOptions = New System.Windows.Forms.GroupBox
        Me.chkboxPeptideChk = New System.Windows.Forms.CheckBox
        Me.grpboxOptions.SuspendLayout()
        Me.SuspendLayout()
        '
        'lblSearches
        '
        Me.lblSearches.Location = New System.Drawing.Point(568, 248)
        Me.lblSearches.Name = "lblSearches"
        Me.lblSearches.Size = New System.Drawing.Size(160, 16)
        Me.lblSearches.TabIndex = 0
        '
        'lstboxSearches
        '
        Me.lstboxSearches.Location = New System.Drawing.Point(568, 272)
        Me.lstboxSearches.Name = "lstboxSearches"
        Me.lstboxSearches.Size = New System.Drawing.Size(144, 160)
        Me.lstboxSearches.TabIndex = 0
        '
        'lblAnalyses
        '
        Me.lblAnalyses.Location = New System.Drawing.Point(384, 248)
        Me.lblAnalyses.Name = "lblAnalyses"
        Me.lblAnalyses.Size = New System.Drawing.Size(200, 16)
        Me.lblAnalyses.TabIndex = 0
        '
        'lstboxAnalyses
        '
        Me.lstboxAnalyses.Location = New System.Drawing.Point(384, 272)
        Me.lstboxAnalyses.Name = "lstboxAnalyses"
        Me.lstboxAnalyses.Size = New System.Drawing.Size(144, 160)
        Me.lstboxAnalyses.TabIndex = 0
        '
        'lstboxSamples
        '
        Me.lstboxSamples.Location = New System.Drawing.Point(200, 272)
        Me.lstboxSamples.Name = "lstboxSamples"
        Me.lstboxSamples.Size = New System.Drawing.Size(144, 160)
        Me.lstboxSamples.TabIndex = 0
        '
        'lblSamples
        '
        Me.lblSamples.Location = New System.Drawing.Point(200, 248)
        Me.lblSamples.Name = "lblSamples"
        Me.lblSamples.Size = New System.Drawing.Size(192, 16)
        Me.lblSamples.TabIndex = 0
        '
        'lblExperiments
        '
        Me.lblExperiments.Location = New System.Drawing.Point(16, 248)
        Me.lblExperiments.Name = "lblExperiments"
        Me.lblExperiments.Size = New System.Drawing.Size(216, 16)
        Me.lblExperiments.TabIndex = 0
        '
        'lblProject
        '
        Me.lblProject.Location = New System.Drawing.Point(16, 24)
        Me.lblProject.Name = "lblProject"
        Me.lblProject.Size = New System.Drawing.Size(96, 16)
        Me.lblProject.TabIndex = 0
        Me.lblProject.Text = "Projects"
        '
        'lstboxExperiments
        '
        Me.lstboxExperiments.Location = New System.Drawing.Point(16, 272)
        Me.lstboxExperiments.Name = "lstboxExperiments"
        Me.lstboxExperiments.Size = New System.Drawing.Size(144, 160)
        Me.lstboxExperiments.TabIndex = 0
        '
        'lstboxProject
        '
        Me.lstboxProject.Location = New System.Drawing.Point(16, 48)
        Me.lstboxProject.Name = "lstboxProject"
        Me.lstboxProject.Size = New System.Drawing.Size(144, 160)
        Me.lstboxProject.TabIndex = 0
        '
        'SqlCEBI
        '
        Me.SqlCEBI.ConnectionString = "data source=PILSCANNER;initial catalog=CebiMsData;password=lfoster;persist securi" & _
        "ty info=True;user id=leonard;workstation id=LEONARD;packet size=4096; Connect Ti" & _
        "meout=3000"
        '
        'bttnSearch
        '
        Me.bttnSearch.Location = New System.Drawing.Point(568, 448)
        Me.bttnSearch.Name = "bttnSearch"
        Me.bttnSearch.Size = New System.Drawing.Size(144, 23)
        Me.bttnSearch.TabIndex = 1
        Me.bttnSearch.Text = "Use selected Search"
        '
        'bttnCancel
        '
        Me.bttnCancel.Location = New System.Drawing.Point(328, 488)
        Me.bttnCancel.Name = "bttnCancel"
        Me.bttnCancel.TabIndex = 2
        Me.bttnCancel.Text = "Cancel"
        '
        'bttnAuto
        '
        Me.bttnAuto.Location = New System.Drawing.Point(200, 448)
        Me.bttnAuto.Name = "bttnAuto"
        Me.bttnAuto.Size = New System.Drawing.Size(144, 23)
        Me.bttnAuto.TabIndex = 3
        Me.bttnAuto.Text = "Auto Analysis/Search"
        '
        'grpboxOptions
        '
        Me.grpboxOptions.Controls.Add(Me.chkboxPeptideChk)
        Me.grpboxOptions.Location = New System.Drawing.Point(224, 48)
        Me.grpboxOptions.Name = "grpboxOptions"
        Me.grpboxOptions.Size = New System.Drawing.Size(240, 120)
        Me.grpboxOptions.TabIndex = 4
        Me.grpboxOptions.TabStop = False
        Me.grpboxOptions.Text = "Options"
        '
        'chkboxPeptideChk
        '
        Me.chkboxPeptideChk.Location = New System.Drawing.Point(8, 88)
        Me.chkboxPeptideChk.Name = "chkboxPeptideChk"
        Me.chkboxPeptideChk.Size = New System.Drawing.Size(200, 24)
        Me.chkboxPeptideChk.TabIndex = 0
        Me.chkboxPeptideChk.Text = "Ignore checked status of peptides"
        '
        'frmProteinDirector
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(744, 525)
        Me.ControlBox = False
        Me.Controls.Add(Me.grpboxOptions)
        Me.Controls.Add(Me.bttnAuto)
        Me.Controls.Add(Me.bttnCancel)
        Me.Controls.Add(Me.bttnSearch)
        Me.Controls.Add(Me.lblSearches)
        Me.Controls.Add(Me.lstboxSearches)
        Me.Controls.Add(Me.lblAnalyses)
        Me.Controls.Add(Me.lstboxAnalyses)
        Me.Controls.Add(Me.lstboxSamples)
        Me.Controls.Add(Me.lblSamples)
        Me.Controls.Add(Me.lblExperiments)
        Me.Controls.Add(Me.lblProject)
        Me.Controls.Add(Me.lstboxExperiments)
        Me.Controls.Add(Me.lstboxProject)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmProteinDirector"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "Where should this data go?"
        Me.grpboxOptions.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub lstboxProject_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstboxProject.DoubleClick
        If lstboxProject.SelectedIndex = -1 Then
            Exit Sub
        End If

        'Clear the current list of experiments and any associated samples
        lstboxSamples.Items.Clear()
        lstboxExperiments.Items.Clear()
        lstboxAnalyses.Items.Clear()
        lstboxSearches.Items.Clear()


        'Clear the array of Experiment IDs
        Array.Clear(ExptIDArray, 1, 100)

        'Get the new project that has been highlighted
        SelectedProject = CStr(lstboxProject.SelectedItem)
        SqlCEBI.ConnectionString = LoginScript

        'Command to get Contact and Notes values for selected project
        Dim mySelectQuery As String = "SELECT ExptID, ExptName FROM Experiment WHERE ProjectName = '" + SelectedProject + "' ORDER BY ExptName"
        Dim myCommand As New SqlClient.SqlCommand(mySelectQuery, SqlCEBI)
        myCommand.Connection.Open()
        Dim myDataReader As SqlClient.SqlDataReader = myCommand.ExecuteReader()

        'Fill the Experiments box and add title
        ExptCount = 0
        While myDataReader.Read
            ExptCount = ExptCount + 1
            ExptIDArray(ExptCount).IDNumber = myDataReader.GetSqlInt64(0).Value
            ExptIDArray(ExptCount).Name = myDataReader.GetSqlString(1).ToString
            lstboxExperiments.Items.Add(myDataReader.GetSqlString(1).ToString)
        End While

        myCommand.Connection.Close()
        If Not lstboxExperiments.Items.Count = 0 Then
            lstboxExperiments.SelectedIndex = 0
        End If
        lblExperiments.Text = "Experiments in Project " + SelectedProject
    End Sub

    Private Sub lstboxExperiments_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstboxExperiments.DoubleClick
        If lstboxExperiments.SelectedIndex = -1 Then
            Exit Sub
        End If


        'Clear Sample list
        lstboxSamples.Items.Clear()
        lstboxAnalyses.Items.Clear()
        lstboxSearches.Items.Clear()

        'Find the ExptID number
        Dim Counter As Integer = 0
        For Counter = 1 To ExptCount
            If ExptIDArray(Counter).Name = CStr(lstboxExperiments.SelectedItem) Then
                ExptIDSelected = ExptIDArray(Counter).IDNumber
            End If
        Next
        'Clear the array of Sample IDs
        Array.Clear(SampleIDArray, 1, 100)

        'Get the new Experiment that has been highlighted
        SqlCEBI.ConnectionString = LoginScript
        Dim mySelectQuery As String = "SELECT SampleName, SampleID FROM Sample WHERE ExptID = '" + ExptIDSelected.ToString + "' ORDER BY SampleName"
        Dim myCommand As New SqlClient.SqlCommand(mySelectQuery, SqlCEBI)
        myCommand.Connection.Open()
        Dim myDataReader As SqlClient.SqlDataReader = myCommand.ExecuteReader()

        'Fill the Samples box and add title
        SampleCount = 0
        While myDataReader.Read
            SampleCount = SampleCount + 1
            SampleIDArray(SampleCount).IDNumber = myDataReader.GetSqlInt64(1).Value
            SampleIDArray(SampleCount).Name = myDataReader.GetSqlString(0).ToString
            lstboxSamples.Items.Add(myDataReader.GetSqlString(0).ToString)
        End While

        myCommand.Connection.Close()
        If Not lstboxSamples.Items.Count = 0 Then
            lstboxSamples.SelectedIndex = 0
        End If
        lblSamples.Text = "Samples in " & CStr(lstboxExperiments.SelectedItem)
    End Sub

    Private Sub lstboxSamples_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstboxSamples.DoubleClick
        If lstboxSamples.SelectedIndex = -1 Then
            Exit Sub
        End If


        'Clear the analyses
        lstboxAnalyses.Items.Clear()
        lstboxSearches.Items.Clear()

        'Find the SampleID number
        Dim Counter As Integer = 0
        For Counter = 1 To SampleCount
            If SampleIDArray(Counter).Name = CStr(lstboxSamples.SelectedItem) Then
                SampleIDSelected = CInt(SampleIDArray(Counter).IDNumber)
            End If
        Next

        'Connect and get the Analyses for the selected Sample
        SqlCEBI.ConnectionString = LoginScript
        Dim mySelectQuery As String = "SELECT AnalysisName, AnalysisID FROM Analysis WHERE SampleID = '" + SampleIDSelected.ToString + "' ORDER BY AnalysisName ASC"
        Dim myCommand As New SqlClient.SqlCommand(mySelectQuery, SqlCEBI)
        myCommand.Connection.Open()
        Dim myDataReader As SqlClient.SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)

        'Fill fields with new data
        AnalysisCount = 0
        While myDataReader.Read
            AnalysisCount = AnalysisCount + 1
            AnalysisIDArray(AnalysisCount).IDNumber = myDataReader.GetSqlInt64(1).Value
            AnalysisIDArray(AnalysisCount).Name = myDataReader.GetSqlString(0).ToString
            lstboxAnalyses.Items.Add(myDataReader.GetSqlString(0).ToString)
        End While
        myCommand.Connection.Close()
        If Not lstboxAnalyses.Items.Count = 0 Then
            lstboxAnalyses.SelectedIndex = 0
        End If
        lblAnalyses.Text = "Analyses in " & CStr(lstboxSamples.SelectedItem)
    End Sub

    Private Sub lstboxAnalyses_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstboxAnalyses.DoubleClick
        If lstboxAnalyses.SelectedIndex = -1 Then
            Exit Sub
        End If


        'Clear the searches
        lstboxSearches.Items.Clear()

        'Find the Analysis ID number
        Dim Counter As Integer = 0
        For Counter = 1 To AnalysisCount
            If AnalysisIDArray(Counter).Name = CStr(lstboxAnalyses.SelectedItem) Then
                'Cast to Integer will run into a limit if more than 2 billion Analyses are in the database
                AnalysisIDSelected = CInt(AnalysisIDArray(Counter).IDNumber)

            End If
        Next

        'Connect and get the Searches for the selected Sample
        SqlCEBI.ConnectionString = LoginScript
        Dim mySelectQuery As String = "SELECT SearchName FROM Search WHERE AnalysisID = '" + AnalysisIDSelected.ToString + "' ORDER BY SearchName ASC"
        Dim myCommand As New SqlClient.SqlCommand(mySelectQuery, SqlCEBI)
        myCommand.Connection.Open()
        Dim myDataReader As SqlClient.SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)

        'Fill fields with new data
        While myDataReader.Read
            lstboxSearches.Items.Add(myDataReader.GetSqlString(0).ToString)
        End While
        myCommand.Connection.Close()
        If Not lstboxSearches.Items.Count = 0 Then
            lstboxSearches.SelectedIndex = 0
        End If
        lblSearches.Text = "Searches in " & CStr(lstboxAnalyses.SelectedItem)
    End Sub

    Private Sub frmProteinDirector_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SqlCEBI.ConnectionString = LoginScript
        Dim mySelectQuery As String = "SELECT ProjectName FROM Project ORDER BY ProjectName ASC"
        Dim myCommand As New SqlClient.SqlCommand(mySelectQuery, SqlCEBI)
        myCommand.Connection.Open()
        Dim myDataReader As SqlClient.SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
        While myDataReader.Read()
            lstboxProject.Items.Add(myDataReader.GetSqlString(0).ToString)
        End While
        myCommand.Connection.Close()
        lstboxProject.SelectedIndex = 0
        chkboxPeptideChk.CheckState = CheckState.Unchecked
    End Sub

    Private Sub bttnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnSearch.Click
        'If user wants to manually create Analyses & Searches then return the ID of the new search to enter the data in

        Dim mySelectQuery As String
        mySelectQuery = "SELECT SearchID FROM Search WHERE AnalysisID = '" & AnalysisIDSelected.ToString & "' AND SearchName = '" & CStr(lstboxSearches.SelectedItem) + "'"
        Dim myCommand7 As New SqlClient.SqlCommand(mySelectQuery, SqlCEBI)
        myCommand7.Connection.Open()
        Dim myDataReader4 As SqlClient.SqlDataReader = myCommand7.ExecuteReader()
        While myDataReader4.Read
            IDFound = myDataReader4.GetSqlInt64(0).Value
        End While
        myCommand7.Connection.Close()
        Dim CheckedPeptides As Boolean = chkboxPeptideChk.Checked
        DataExportFunctions.AddProteins(IDFound, False, CheckedPeptides)
        Me.Close()
    End Sub

    Private Sub bttnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnCancel.Click
        Me.Close()
    End Sub

    Private Sub bttnAuto_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnAuto.Click
        'If user wants to automatically generate Analyses & Searches then return the ID of the Sample
        'Find the SampleID number
        Dim Counter As Integer = 0
        Dim SearchID As Integer
        For Counter = 1 To SampleCount
            If SampleIDArray(Counter).Name = CStr(lstboxSamples.SelectedItem) Then
                SampleIDSelected = SampleIDArray(Counter).IDNumber
            End If
        Next
        Dim Checked As Boolean = chkboxPeptideChk.Checked
        SearchID = DataExportFunctions.AddProteins(SampleIDSelected, True, Checked)

        'Check to return whether data was successfully entered or not
        If SearchID <> -10 Then
            Me.Close()
        End If
    End Sub
End Class

    

    

Generated by script codePublish.pl at 2009-01-05T15:20:59.