OpenersPrimaryExamplesSection(Spacer1)Examples  (7)

OpenersExampleSection0(Spacer1)Basic Examples  (7)

This reads the raw header line from a sample FASTA file:

Import["ExampleData/mitochondrion.fa.gz", "Header"]

Extract the accession string:

Import["ExampleData/mitochondrion.fa.gz", "Accession"]

Parse the GenBank database key and the description string from the header line:

Import["ExampleData/mitochondrion.fa.gz", {{ "GenBankID", "Description"}}]

Read the first letters of the DNA sequence:

StringTake[ First@Import["ExampleData/mitochondrion.fa.gz"],256]

This converts a short sequence to the FASTA format, automatically adding default header information:

ExportString["GATAGCATTGCGAGACGCTGG","FASTA"]

This exports two sequences:

ExportString[{"TTTCGTCTGGGGGGT","GATAGCATTGCGAGACGCTGG"},"FASTA"]

This exports a pair of headers and sequences:

f = ExportString[{{"AC90483","AC74958"},{"TTCTATTATTTATCGCACC","ATATTACAGGCGAACATA"}},"FASTA"]

Import the previous output using the "Data" element gives raw headers and sequences:

ImportString[f,{"FASTA","Data"}]

Import as a list of rules:

ImportString[f, {"FASTA","LabeledData"}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {Related Formats:  (RefLink[FASTQ, paclet:ref/format/FASTQ])  ▪  (RefLink[MOL, paclet:ref/format/MOL])  ▪  (RefLink[PDB, paclet:ref/format/PDB])  ▪  (RefLink[XYZ, paclet:ref/format/XYZ])  ▪  (RefLink[SFF, paclet:ref/format/SFF])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Importing & Exporting, paclet:guide/ImportingAndExporting])}, {▪(RefLinkPlain[Listing of All Formats, paclet:guide/ListingOfAllFormats])}, {▪(RefLinkPlain[Scientific & Medical Data Formats, paclet:guide/ScientificAndMedicalDataFormats])}})}})