Click or drag to resize
XNField Class
Class XNField.

 

Code of field: N (for DNA)

Type of field: free text field containing one DNA or protein sequence.

Applicable to:

DNA or protein sequence data.

Inheritance Hierarchy

Namespace:  Biolomics.BioCallback
Assembly:  Biolomics.BioCallback (in Biolomics.BioCallback.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public class XNField : XField

The XNField type exposes the following members.

Constructors
  NameDescription
Public methodXNField(XNField)
Copy ctor
Public methodXNField(TNField, XRecord)
Initializes a new instance of the XNField class.
Public methodXNField(XNField, XRecord)
Copy ctor but into a new XRecord
Top
Properties
  NameDescription
Public propertyFieldValue
Gets or sets the field value.
(Overrides XFieldFieldValue.)
Public propertyIsModified
Gets or sets a value indicating whether this instance is modified.
(Inherited from XField.)
Public propertySequence
Gets or sets the sequence.
Top
Methods
  NameDescription
Public methodCanRead
Determines whether current connection can read from Field.
(Inherited from XField.)
Public methodCanWrite
Determines whether current connection can write from Field.
(Inherited from XField.)
Public methodClear
Clears this instance.
(Inherited from XField.)
Public methodClone
Clones this instance.
Public methodCloneAsXField
We cannot use name 'Clone' here otherwise Implements vector.TId(Of XSField) fails because XSField.Clone() returns a XField instead of a XSField !!!
(Overrides XFieldCloneAsXField(XRecord).)
Public methodStatic memberComplement
Complements the specified sequence.
Public methodDataToView
Converts field value to readable string.
(Inherited from XField.)
Public methodDataToView(Int32)
Mandatory otherwise DataToView(5) returns letter 5 of string given by DataToView(), instead of the subfield value
(Inherited from XField.)
Public methodEquals
Determines whether the specified Object is equal to this instance.
(Inherited from XField.)
Protected methodField
each derived class embed its own TField member, which can be a TAField, TCField, TEField, etc. this function must return that original TField
(Overrides XFieldField.)
Public methodFieldDef
Gets the Field definition.
(Inherited from XField.)
Public methodFieldType
The Field type.
(Inherited from XField.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodKey
Gets Field Key.
(Inherited from XField.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodParentRecord
Gets the parent record.
(Inherited from XField.)
Public methodRead
Reads the Content from source object.
(Inherited from XField.)
Public methodReset
Resets this instance.
(Inherited from XField.)
Public methodReverseComplement
Reverse a DNA sequence.
Public methodStatic memberReverseComplement(String)
Reverse the given DNA sequences. Don't call this function for proteins !
Public methodSetDefaultValues
Sets the default values.
(Inherited from XField.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodWrite
Writes data into a TQuery and Format it depending to field type
(Inherited from XField.)
Top
Examples
This is an example of use of XNField to change XNField subfield value
Example VB.Net
Imports System
Imports System.Collections
Imports System.Text  '    for StringBuilder
Imports Biolomics.BioCallback
Imports Biolomics.SharedClasses

Public Class MyNewClass

    ' This function is called when running this script
    Shared Sub Main()

        '    Create an instance of class MyNewClass and call its functions
        Dim c As New MyNewClass
        c.ChangeField()
    End Sub

    '    Write sub functions here
    Public Sub ChangeField()
        '    get the current connection
        Dim SqlCo As XConnection = Run.GetCurrentConnection()
        If SqlCo Is Nothing Then
            Return
        End If

        '    get a table from its User name
        Dim TableDef As XTableDef = SqlCo.GetTableDefByUserNameEng("Your_Table_Name")
        If TableDef Is Nothing Then   '    may happen if that table doesn't exist
            Return
        End If
        '    load a Field from that table
        Dim FieldDefMap As New XFieldDefMap
        Dim FieldDef As XFieldDef = SqlCo.GetFieldByDBName("Your_N_Field_name", TableDef.Key)
        If FieldDef Is Nothing Then   '    that field doesn't exist
            Return
        End If
        FieldDefMap.Add(FieldDef)

        '    load about 10 records
        Dim Where As XWhere = XWhere.LTE(StaticFields.id, 11)
        Dim RecordMap As XRecordMap = Run.LoadRecords(TableDef.Key, FieldDefMap, Where)

        For Each Record As XRecord In RecordMap
            Dim Field As XNField = TryCast(Record.Fields(FieldDef.Key), XNField)
            If Field Is Nothing Then   '    this field doesn't exist or is not a N-Field
                Continue For
            End If
            '    build the reverse-complement string (not the fastest method, but easy to understand)
            Dim strB As New StringBuilder(Field.Value.Length) '    the destination string    
            For Each c As Char In Field.Value
                Select Case c
                    Case "a"c
                        strB.Append("t"c)
                    Case "c"c
                        strB.Append("g"c)
                    Case "g"c
                        strB.Append("c"c)
                    Case "t"c
                        strB.Append("a"c)
                    Case "A"c
                        strB.Append("T"c)
                    Case "C"c
                        strB.Append("G"c)
                    Case "G"c
                        strB.Append("C"c)
                    Case "T"c
                        strB.Append("A"c)
                    Case Else
                        strB.Append(c) '    no change
                End Select
            Next
            '    copy the result into the field value
            Field.Value = strB.ToString

            Record.Save(False)
        Next

    End Sub

End Class
See Also