Source code for MSQuant: frmModificationFilter.vb, MSQuant/msquant/src/GUI/forms/frmModificationFilter.vb.

Table of contents page.

Home page for MSQuant.

'****************************************************************************
'* Copyright (C) 2004 Peter Mortensen and Matthias Mann                     *
'* This file is part of MSQuant.                                            *
'*                                                                          *
'* MSQuant 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.                       *
'*                                                                          *
'* MSQuant 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.                          *
'*                                                                          *
'* MSQuant 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 MSQuant; if not, write to                      *
'* the Free Software Foundation, Inc., 59 Temple                            *
'* Place, Suite 330, Boston, MA  02111-1307  USA                            *
'*                                                                          *
'* Purpose: Windows dialog for getting peptide modification filter          *
'*          user choices.                                                   *
'*                                                                          *
'****************************************************************************

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

Option Strict On
Option Explicit On 

Imports System.Text  'For StringBuilder
Imports System.Collections.Generic 'For Dictionary


Imports MSQuant 'For class quantApplication
Imports massSpectrometryBase 'For QuantitationModes
Imports massSpectrometryBase.quantitation


Public Class frmModificationFilter
    Inherits System.Windows.Forms.Form

    Private mPrefix As String = "_ModCB_"

    'Changed PM_PEPTIDEFILTER_GENERALISED 2007-08-24
    'Private mOptionsForm As frmOptions
    Private mFilterForm As frmPeptideFilters


    Private mApplication As quantApplication


#Region " Windows Form Designer generated code "

    Public Sub New( _
      ByRef aInModificationFilter2 As Generic.List(Of Integer), _
      ByRef aParentForm As frmPeptideFilters, _
      ByRef anApp As quantApplication)

        MyBase.New()

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

        'Add any initialization after the InitializeComponent() call

        Me.Init(aInModificationFilter2, aParentForm, anApp)
    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 Label1 As System.Windows.Forms.Label
    Friend WithEvents btnOK As System.Windows.Forms.Button
    Friend WithEvents btnCancel As System.Windows.Forms.Button
    Friend WithEvents cbxNoFilter As System.Windows.Forms.CheckBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label
        Me.btnOK = New System.Windows.Forms.Button
        Me.btnCancel = New System.Windows.Forms.Button
        Me.cbxNoFilter = New System.Windows.Forms.CheckBox
        Me.Label2 = New System.Windows.Forms.Label
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(232, 24)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(152, 16)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Peptide Modification Filter:"
        Me.Label1.Visible = False
        '
        'btnOK
        '
        Me.btnOK.Location = New System.Drawing.Point(127, 237)
        Me.btnOK.Name = "btnOK"
        Me.btnOK.Size = New System.Drawing.Size(75, 23)
        Me.btnOK.TabIndex = 1
        Me.btnOK.Text = "&OK"
        '
        'btnCancel
        '
        Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.btnCancel.Location = New System.Drawing.Point(208, 237)
        Me.btnCancel.Name = "btnCancel"
        Me.btnCancel.Size = New System.Drawing.Size(72, 24)
        Me.btnCancel.TabIndex = 2
        Me.btnCancel.Text = "&Cancel"
        '
        'cbxNoFilter
        '
        Me.cbxNoFilter.Location = New System.Drawing.Point(224, 48)
        Me.cbxNoFilter.Name = "cbxNoFilter"
        Me.cbxNoFilter.Size = New System.Drawing.Size(128, 16)
        Me.cbxNoFilter.TabIndex = 3
        Me.cbxNoFilter.Text = "No filter"
        Me.cbxNoFilter.Visible = False
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(8, 8)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(280, 16)
        Me.Label2.TabIndex = 4
        Me.Label2.Text = "Peptide must have one or more of these modifications:"
        '
        'frmModificationFilter
        '
        Me.AcceptButton = Me.btnOK
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.CancelButton = Me.btnCancel
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.cbxNoFilter)
        Me.Controls.Add(Me.btnCancel)
        Me.Controls.Add(Me.btnOK)
        Me.Controls.Add(Me.Label1)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmModificationFilter"
        Me.Text = "Peptide Modification Filter Options"
        Me.ResumeLayout(False)

    End Sub

#End Region


    Private Structure checkBoxItemStructure
        Dim text As String
        Dim ySize As Integer
        Dim checked As Boolean
        Dim modID As Integer
    End Structure


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub Init( _
      ByRef aInModificationFilter2 As Generic.List(Of Integer), _
      ByRef aParentForm As frmPeptideFilters, _
      ByRef anApp As quantApplication)

        'Changed PM_PEPTIDEFILTER_GENERALISED 2007-08-24
        'mOptionsForm = aParentForm
        mFilterForm = aParentForm

        mApplication = anApp

        Dim MAX_TEXT_LEN As Integer = 43

        'Changed PM_MODFILTER_PAGING 2007-06-06
        Dim Y_MAX As Integer = 500 'It would be better to use the actual
        '  screen size. How do we get it?
        Dim xSize As Integer = 300 'Initial size. May be increased if
        '  there is a lot of modificatios.

        Dim checkBoxInfoList As Generic.List(Of checkBoxItemStructure) = _
          New Generic.List(Of checkBoxItemStructure)
        Dim ySize As Integer = -1

        If True Then
            'Make hash table to ease setting the checked modifications.

            'Changed PM_REFACTOR 2007-08-29
            ' 'Dim modHash As Hashtable = New Hashtable
            ' Dim modHash2 As Dictionary(Of Integer, Integer) = _
            '   New Dictionary(Of Integer, Integer)
            ' 
            ' Dim modID As Integer
            ' For Each modID In aInModificationFilter2
            '     modHash2.Add(modID, 1)
            ' Next
            Dim modHash2 As Dictionary(Of Integer, Integer) = _
              peptideFilterStructure.hashForModFilter(aInModificationFilter2)

            Dim quantitationModesObject As QuantitationModes_moreGeneral = _
              mApplication.getQuantModes()

            'Dim definedMods As ArrayList = _
            '  quantitationModesObject.getModifications()
            Dim definedMods2 As Generic.List( _
              Of quantModificationStructure) = _
                quantitationModesObject.getModifications()

            Dim chkYdiff As Integer = 24
            'Dim ySize As Integer = len * chkYdiff + 100 + 30

            Dim START_YSIZE As Integer = 100 + 30
            ySize = START_YSIZE 'Starting value. Margins for before and after
            '  the checkboxes to be added.

            Dim curY As Integer = START_YSIZE

            'First loop: find strings (for length) and total y size of the dialog.
            Dim modItem As quantModificationStructure
            For Each modItem In definedMods2

                Dim checkStatus As Boolean = False
                Dim modID As Integer = modItem.quantModificationID
                If modHash2.ContainsKey(modID) Then
                    checkStatus = True
                End If

                Dim msgSB As StringBuilder = New StringBuilder
                msgSB.Append(modItem.modificationName)
                msgSB.Append(". ")
                Dim someAAset As AAsetStruct
                For Each someAAset In modItem.affectedAAs
                    msgSB.Append("+")
                    msgSB.Append(someAAset.diffFromBase3)
                    msgSB.Append(" Da for ")
                    msgSB.Append(someAAset.AAs)
                    msgSB.Append(". ")
                Next

                'Changed PM_TERMMOD 2007-09-10
                If Not (modItem.startPosition = 1 AndAlso _
                        modItem.endPosition = -1) Then

                    msgSB.Append("Pos ")
                    msgSB.Append(modItem.startPosition)
                    msgSB.Append(" to ")
                    msgSB.Append(modItem.endPosition)
                    msgSB.Append(". ")
                End If

                Dim chkText As String = msgSB.ToString

                Dim yDiff As Integer = chkYdiff
                If chkText.Length >= MAX_TEXT_LEN Then
                    yDiff = _
                      CInt(chkText.Length / MAX_TEXT_LEN - 0.5 + 1.0) * chkYdiff
                End If

                Dim someNewItem As checkBoxItemStructure
                someNewItem.text = chkText
                someNewItem.checked = checkStatus
                someNewItem.ySize = yDiff
                someNewItem.modID = modID

                checkBoxInfoList.Add(someNewItem)

                'Changed PM_MODFILTER_PAGING 2007-06-06

                curY += yDiff
                If curY > ySize Then
                    ySize = curY
                End If

                If curY > Y_MAX Then
                    curY = START_YSIZE
                    xSize += 300
                End If
            Next
        End If

        ySize += 100 'Make space for the OK and Cancel button.

        Dim newSize As System.Drawing.Size = Me.Size
        newSize.Height = ySize

        'Changed PM_MODFILTER_PAGING 2007-06-06
        newSize.Width = xSize
        Me.Size = newSize

        Dim index As Integer = 0

        Dim Y_LOC_START As Integer = 48
        Dim X_LOC_START As Integer = 40

        Dim yLoc As Integer = Y_LOC_START
        Dim xLoc As Integer = X_LOC_START

        Dim loc As System.Drawing.Point

        'Create one checkbox for each modification defined in the quantitation
        'modes file. Use the Tag property to store the modification ID.
        Dim someItem As checkBoxItemStructure
        For Each someItem In checkBoxInfoList
            Dim cbName As String = mPrefix & index

            loc.X = xLoc
            loc.Y = yLoc

            Dim yDiff As Integer = someItem.ySize

            Dim newCB As System.Windows.Forms.CheckBox = _
              Nothing 'Keep compiler happy.
            quantApplication.addCheckBox( _
              Me, cbName, someItem.text, loc, _
              someItem.checked, someItem.modID.ToString, newCB)

            'Needed?
            ''Changed PM_MODIFICATION_FILTER_UNTIDYNESS 2006-08-01
            'newCB.AutoSize = True

            newCB.Height = yDiff

            index += 1
            yLoc += yDiff

            'Changed PM_MODFILTER_PAGING 2007-06-06
            If yLoc > Y_MAX Then
                yLoc = Y_LOC_START
                xLoc += 300
            End If
        Next 'Through checkBoxInfoList

        'Adjust y-position of OK and Cancel buttons to account for
        'the variable number of modifications.
        If True Then
            Dim xDiff As Integer = xLoc - X_LOC_START + 0


            Dim buttonsY As Integer = ySize - 70

            Dim locOK As System.Drawing.Point = btnOK.Location
            locOK.Y = buttonsY

            'Changed PM_STANDARDISE 2007-06-20
            locOK.X += xDiff

            btnOK.Location = locOK

            Dim locCancel As System.Drawing.Point = btnCancel.Location
            locCancel.Y = buttonsY

            'Changed PM_STANDARDISE 2007-06-20
            locCancel.X += xDiff

            btnCancel.Location = locCancel
        End If
    End Sub 'Init


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub btnOK_Click( _
      ByVal aSender As System.Object, ByVal anEvent As System.EventArgs) _
      Handles btnOK.Click

        'Read-off ... and create new.

        'Changed PM_PEPTIDECOUNT_BUG 2007-09-04
        ''Changed PM_TYPESAFE 2007-08-23
        ''Dim filterIDs As ArrayList = New ArrayList
        'Dim filterIDs2 As Generic.List(Of Integer) = _
        '  New Generic.List(Of Integer)
        Dim filterIDs2 As Generic.List(Of Integer) = Nothing

        Dim control As Control
        For Each control In Me.Controls
            If control.Name.StartsWith(mPrefix) Then
                Dim chk As System.Windows.Forms.CheckBox = _
                  DirectCast(control, System.Windows.Forms.CheckBox)
                Dim checkStatus As Boolean = chk.Checked

                If checkStatus Then
                    'Changed PM_PEPTIDECOUNT_BUG 2007-09-04
                    'Is must be Nothing if there are no modifications in the
                    'filter. (In this case we never get here).
                    If filterIDs2 Is Nothing Then
                        filterIDs2 = New Generic.List(Of Integer)
                    End If

                    Dim modID As Integer = CInt(chk.Tag)
                    filterIDs2.Add(modID)
                End If
            End If
        Next 'Through controls, most of them check bottons.

        'mOptionsForm.newModFilterList(filterIDs2)
        mFilterForm.newModFilterList2(filterIDs2)

        Me.Close()
    End Sub 'btnOK_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub btnCancel_Click( _
      ByVal sender As System.Object, ByVal e As System.EventArgs) _
      Handles btnCancel.Click

        Me.Close()
    End Sub 'btnCancel_Click


    '****************************************************************************
    '*    <placeholder for header>                                              *
    '****************************************************************************
    Private Sub frmModificationFilter_Load( _
      ByVal sender As System.Object, ByVal e As System.EventArgs) _
      Handles MyBase.Load

        'Why does this function exist?

    End Sub 'frmModificationFilter_Load


End Class 'frmModificationFilter


    

    

Generated by script codePublish.pl at 2008-09-23T11:59:18.