proteins method

List<String> proteins({
  1. bool unique = false,
})

Returns proteins from this sequence.

Implementation

List<String> proteins({bool unique = false}) {
  // Generate siz reading frames from this sequence.
  List<String> frames = _readingFrames();
  List<String> proteins = [];
  // Loop through each of the six reading frames.
  for (var frame in frames) {
    // Translate the reading frame into protein(s).
    List<String> tempProteins = _readingFrameToProteins(aaSeq: frame);
    if (proteins != []) {
      // If atleast one protein has been generated, at it/them to [proteins].
      proteins.addAll(tempProteins);
    }
  }
  // sort the proteins from longest to shortest.
  proteins.sort((b, a) => a.length.compareTo(b.length));
  if (unique) {
    // If [unique] is `true` only return the unique proteins.
    return proteins.toSet().toList();
  }
  return proteins;
}