read static method

List<NucleotideSequence> read(
  1. String fastaData, {
  2. EnumNucleotideSequenceType type = EnumNucleotideSequenceType.dna,
})

(en) The FASTA file data is converted into NucleotideSequence for each record and returned.

(ja) FASTAファイルのデータを各レコード単位でNucleotideSequenceに変換して返却します。

  • fastaData : Passes the contents of the FASTA file as a String.
  • type : DNA or RNA.

Implementation

static List<NucleotideSequence> read(String fastaData,
    {EnumNucleotideSequenceType type = EnumNucleotideSequenceType.dna}) {
  List<String> lines = LineSplitter.split(fastaData).toList();

  List<NucleotideSequence> r = [];
  String? nowDesc;
  StringBuffer nowSeq = StringBuffer();

  for (String line in lines) {
    if (line.startsWith('>')) {
      if (nowDesc != null && nowSeq.isNotEmpty) {
        r.add(NucleotideSequence(nowSeq.toString().toLowerCase(),
            type: type, info: {"description": nowDesc}));
        nowSeq.clear();
      }
      nowDesc = line.substring(1);
    } else {
      nowSeq.write(line);
    }
  }

  if (nowDesc != null && nowSeq.isNotEmpty) {
    r.add(NucleotideSequence(nowSeq.toString().toLowerCase(),
        type: type, info: {"description": nowDesc}));
  }

  return r;
}