readByFastaRecord static method

List<FastaRecord> readByFastaRecord(
  1. String fastaData
)

(en) The FASTA file data is converted into a class for each record and returned. It is convenient to use this when you want to operate the array data as String type.

(ja) FASTAファイルのデータを各レコード単位でクラスに変換して返却します。 配列データをString型のままで操作したい場合はこれを利用すると便利です。

  • fastaData : Passes the contents of the FASTA file as a String.

Implementation

static List<FastaRecord> readByFastaRecord(String fastaData) {
  List<String> lines = LineSplitter.split(fastaData).toList();

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

  for (String line in lines) {
    if (line.startsWith('>')) {
      if (nowDesc != null && nowSeq.isNotEmpty) {
        r.add(FastaRecord(nowDesc, nowSeq.toString()));
        nowSeq.clear();
      }
      nowDesc = line.substring(1);
    } else {
      nowSeq.write(line);
    }
  }

  if (nowDesc != null && nowSeq.isNotEmpty) {
    r.add(FastaRecord(nowDesc, nowSeq.toString()));
  }

  return r;
}