none
How to convert a .seq file containing DNA sequences to a DataTable/String[]? RRS feed

  • Question

  • Hi,

    I'm starting a project in bioinformatics in which I need to analyze some DNA sequences. I have the desired sequences in a .seq file, but in order to process them I need to transfer them into a DataTable object in c#, or string[]. I'd be glad to know if there is an easy way, tool or a feature that would help me do that.

    Thanks

    Thursday, October 31, 2019 7:07 AM

All replies

  • Please attach an example .seq file so that we can understand its formatting.

    Andy

    Thursday, October 31, 2019 10:23 AM
  • Create a column

    dt.Columns.Add(new DataColumn() {ColumnName = "SequencesArray", DataType = typeof(string[])});

    Mockup

    // replace with your DNA sequence
    string[] mockedArray = {"","" };
    
    var dt = new DataTable();
    dt.Columns.Add(new DataColumn()
    {
        ColumnName = "Id",
        DataType = typeof(int),
        AutoIncrement = true
    });
    dt.Columns.Add(new DataColumn()
    {
        ColumnName = "SequencesArray",
        DataType = typeof(string[])
    });
    
    dt.Rows.Add(null, mockedArray);

    Later to parse the values

    private void Demo(DataTable table)
    {
        foreach (DataRow row in table.Rows)
        {
            string[] sequencesArray = row.Field<string[]>("SequencesArray"); 
        }
    }


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange


    Thursday, October 31, 2019 12:37 PM
    Moderator