Source code for MSQuant: MSQdocDefs.vb, MSQuant/msquant/src/main/MSQdocDefs.vb.

Table of contents page.

Home page for MSQuant.

'****************************************************************************
'* Copyright (C) 2008 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: data/structure definitions. In particular the upper part        *
'*          for the pseudo-document MB: MSQuantDocumentStructure            *
'*                                                                          *
'****************************************************************************

'****************************************************************************
'*                               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:   MSQdocDefs.vb                                             *
'*    TYPE:  VISUAL_BASIC                                                   *
'*                                                                          *
'* CREATED: PM 2008-04-16   Content moved from frmProteinList.vb...         *
'* UPDATED: PM 2008-xx-xx                                                   *
'*                                                                          *
'****************************************************************************

Option Strict On
Option Explicit On


Imports System.Xml 'For XmlTextWriter
Imports System.Runtime.Serialization 'For ISerializable.

Imports SimmoTech.Utils.Serialization 'For SerializationReader and SerializationWriter.

Imports MolecularSharedStructures 'For ProteinHitStructure
Imports massSpectrometryBase 'For fileSpecStructure


'Changed PM_REFACTOR 2008-04-16. Content moved from frmProteinList.vb...


'Changed PM_AUTODOCUMENTATION 2007-04-18
'Make private and move into class?
'
'Purpose: collect report items.
Public Structure reportStructure

    Dim XMLwriter As XmlTextWriter
    Dim XMLfileName As String

    Dim massFormatStr As String 'Really a constant. E.g. "0.00000"
End Structure 'reportStructure


'Changed PM_SAVE_RECALIBRATION 2005-01-27
'****************************************************************************
'*    <placeholder for header>                                              *
'****************************************************************************
<Serializable()> _
Public Structure MSQuantDocumentStructure


    'Note: if fields are added GetObjectData() and 
    '      xxx should be updated!!!

    'Changed PM_FAST_SERIALISATION 2006-12-15
    Implements ISerializable


    'Changed PM_FAST_SERIALISATION 2006-12-30
    '****************************************************************************
    '*    For MSQuantDocumentStructure.                                         *
    '****************************************************************************
    Private Sub New( _
      ByVal anInfo As SerializationInfo, ByVal aContext As StreamingContext)

        '      Dim reader As SerializationReader = _
        'New SerializationReader(DirectCast(anInfo.GetValue("data"),Byte()),  Byte()))

        'How can this be done in one line??
        Dim someType2 As Type = GetType(Byte())
        Dim reader As SerializationReader = _
          New SerializationReader( _
            DirectCast(anInfo.GetValue("data", someType2), Byte()) _
          )

        If True Then
            Dim proteins As Integer = reader.ReadOptimizedInt32()
            parsedProts3 = New Generic.List(Of ProteinHitStructure)(proteins)

            Dim lastIndex As Integer = proteins - 1
            Dim j As Integer
            For j = 0 To lastIndex
                parsedProts3.Add(ProteinHitStructure.readFromStream(reader))
            Next j
        End If

        If True Then 'List. Not Generic, is VB array. Code is not typical.
            rawFiles = Nothing
            Dim items As Integer = reader.ReadOptimizedInt32()
            If items > 0 Then
                Dim lastIndex As Integer = items - 1

                'rawFiles = New Generic.List(Of fileSpecStruct)(items)
                ReDim rawFiles(lastIndex)

                Dim j As Integer
                For j = 0 To lastIndex
                    rawFiles(j) = fileSpecStructure.readFromStream(reader)
                Next j
            End If
        End If

        recalibSlope = reader.ReadDouble()
        Trace.Assert( _
          recalibSlope > 0.1 AndAlso recalibSlope < 10.0, _
          "PIL ASSERT. In deserialisation of MSQuantDocumentStructure; ." & _
          " recalibSlope has an unreasonable value: " & _
          recalibSlope & ".")

        recalibOffset = reader.ReadDouble()
        mascotFileStr = reader.ReadString()
        rawFileStr = reader.ReadString()

        'myInt32Field = reader.ReadInt32()
        'myString = reader.ReadString()
        ' // and so on
    End Sub 'MSQuantDocumentStructure, deserialisation constructor.


    'Changed PM_FAST_SERIALISATION 2006-12-15
    'For MSQuantDocumentStructure.
    '****************************************************************************
    '*    For MSQuantDocumentStructure.                                         *
    '****************************************************************************
    Private Sub GetObjectData( _
      ByVal anInfo As SerializationInfo, _
      ByVal anInContext As StreamingContext) _
      Implements ISerializable.GetObjectData

        Dim writer As SerializationWriter = New SerializationWriter

        'Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-19. Loop on the
        'client side.
        'writer.Write(parsedProts3)
        If True Then
            Trace.Assert(Not parsedProts3 Is Nothing, _
              "PIL ASSERT. parsedProts3 Is Nothing.")

            Dim items As Integer = parsedProts3.Count()
            'This is our own encoding.
            writer.WriteOptimized(items)

            Dim item As ProteinHitStructure
            For Each item In parsedProts3
                item.addToStream(writer)
            Next
        End If

        'Changed PM_FAST_SERIALISATION_AVOID_DOTNET 2006-12-28. Loop on the
        'client side. Avoid invoking the .NET serialisation (BinaryFormatter).
        ''writer.WriteObject(rawFiles) 'Note: object! Will
        ' ''  be .NET serialisation.
        'writer.WriteTypedArray(rawFiles)
        If True Then
            Dim items As Integer = rawFiles.Length()
            'This is our own encoding.
            writer.WriteOptimized(items)

            Dim someItem As fileSpecStructure
            For Each someItem In rawFiles
                someItem.addToStream(writer)
            Next 'Through rawFiles
        End If

        writer.Write(recalibSlope)
        writer.Write(recalibOffset)
        writer.Write(mascotFileStr)
        writer.Write(rawFileStr)

        anInfo.AddValue("data", writer.ToArray())
    End Sub 'GetObjectData. For MSQuantDocumentStructure.


    'Changed PM_TYPESAFE 2006-10-25
    'Dim parsedProts As ArrayList
    Dim parsedProts3 As Generic.List(Of ProteinHitStructure) '2 vs. 3

    Dim rawFiles() As fileSpecStructure
    Dim recalibSlope As Double
    Dim recalibOffset As Double


    'Changed PM_REFACTOR 2006-11-15
    Dim mascotFileStr As String 'Path to Mascot result file.
    Dim rawFileStr As String 'Path to raw file.
End Structure 'MSQuantDocumentStructure



Public Class MSQdocDefs
    'Empty. Do we need it? - encapsulate the two structures in it?

End Class 'MSQdocDefs



    

    

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