Xyaneon.Bioinformatics.FASTA 0.1.0

dotnet add package Xyaneon.Bioinformatics.FASTA --version 0.1.0                
NuGet\Install-Package Xyaneon.Bioinformatics.FASTA -Version 0.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Xyaneon.Bioinformatics.FASTA" Version="0.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Xyaneon.Bioinformatics.FASTA --version 0.1.0                
#r "nuget: Xyaneon.Bioinformatics.FASTA, 0.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Xyaneon.Bioinformatics.FASTA as a Cake Addin
#addin nuget:?package=Xyaneon.Bioinformatics.FASTA&version=0.1.0

// Install Xyaneon.Bioinformatics.FASTA as a Cake Tool
#tool nuget:?package=Xyaneon.Bioinformatics.FASTA&version=0.1.0                


License Build Status

Package Icon

A .NET Standard 2.0 library for working with FASTA genetic sequence files.

This library is very flexible, and offers the following:

  • Nucleic and amino acid sequences
  • Descriptions and NCBI database identifiers
  • Sequential and interleaved FASTA formats
  • Single and multiple-sequence FASTA files
  • File and stream I/O (both synchronous and asynchronous) and validation, with structured data objects
  • Sequence string parsing
  • Common FASTA file extensions support



To use this library, you must first install the NuGet package for it.

Reading FASTA files

This library supports both synchronous and asynchronous file I/O operations. File reading is done by using methods provided by the SequenceFileReader class.

Below is an example of reading a FASTA file containing a single sequence:

using Xyaneon.Bioinformatics.FASTA.IO;

// Snip...

Sequence sequence = SequenceFileReader.ReadSingleFromFile("C:\some\file.fasta");

Same task, done asynchronously:

using Xyaneon.Bioinformatics.FASTA.IO;

// Snip...

CancellationTokenSource source = new CancellationTokenSource();
CancellationToken token = source.Token;
Sequence sequence = await SequenceFileReader.ReadSingleFromFileAsync("C:\some\file.fasta", token);

Reading FASTA files containing multiple sequences is also supported:

using Xyaneon.Bioinformatics.FASTA.IO;

// Snip...

IEnumerable<Sequence> sequences = SequenceFileReader.ReadMultipleFromFile("C:\some\file.fasta");

// Or:

CancellationTokenSource source = new CancellationTokenSource();
CancellationToken token = source.Token;
IEnumerable<Sequence> sequences = await SequenceFileReader.ReadMultipleFromFileAsync("C:\some\file.fasta", token);

The Sequence class

Individual sequences in FASTA files are represented by Sequence instances.

Each Sequence has a Headerand Data property, which are of types Header and IActualSequence. The Header contains one or more HeaderItems, which are the description and any database identifiers. Data is either an AminoAcidSequence or a NucleicAcidSequence, and contains the sequence data with the standard characters.

These classes are meant to be immutable; create copies with the new property values to make changes.

Here is an example for how to create a nucleic acid sequence manually with this library:

using Xyaneon.Bioinformatics.FASTA.ActualSequences;
using Xyaneon.Bioinformatics.FASTA.Identifiers;

// Snip...

// Create a local identifier.
var identifier = new LocalIdentifier("123");
// Create the sequence data.
var data = new NucleicAcidSequence("ATCGAAAA");
// Assemble.
var sequence = new Sequence(new Header(identifier), data);

// Getting back a string representation of how this sequence will actually
// appear in a FASTA file. Sequential and interleaved formats are both
// supported.
// This will return:
// >lcl|123\nATCGAAAA
string sequential = string.join('\n', sequence.ToSequentialLines());

// You can also create a Sequence identical to the one above by parsing:
var sameSequence = Sequence.Parse(sequential);

Writing FASTA files

File writing is done by using methods provided by the SequenceFileWriter class.

using Xyaneon.Bioinformatics.FASTA.IO;

// Snip...

// Writing a single sequence to an interleaved file synchronously, with a line
// length of 60 characters.
SequenceFileWriter.WriteToInterleavedFile(sequence, "C:\some\file.fasta", 60);

// Writing multiple sequences to a sequential file asynchronously.
IEnumerable<Sequence> sequences = new Sequence[] {
SequenceFileWriter.WriteToSequentialFileAsync(sequences, "C:\some\file.fasta", token);


This library is free and open-source software provided under the MIT license. Please see the LICENSE.txt file for details.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.0 980 5/23/2020

## 0.1.0 - 2020-05-23
     ### Added
     - Initial release.