getFastaLength

Calculate the sequence length of the first record in fastaFile. Returns the length of the next record in fastaFile if it is a File object.

  1. size_t getFastaLength(string fastaFile)
    size_t
    getFastaLength
    (
    in string fastaFile
    )
  2. size_t getFastaLength(File fastaFile)

Examples

    import std.process : pipe;

    string fastaRecordData = q"EOF
        >sequence1
        CTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCT
        AACCCTAACCCTAACCCTAACCCTAACCCTAACAACCCTAACCCTAACCC
EOF".outdent;
    auto fastaFile = pipe();
    fastaFile.writeEnd.write(fastaRecordData);
    fastaFile.writeEnd.close();

    auto fastaLength = getFastaLength(fastaFile.readEnd);

    assert(fastaLength == 100);
    import std.process : pipe;

    string fastaRecordData = q"EOF
        >sequence1
        CTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCT
        AACCCTAACCCTAACCCTAACCCTAACCCTAACAACCCTAACCCTAACCC
        >sequence2
        AACCCTAACCCTAACCCTAACCCTAACCCTAACAACCCTAACCCTAACCC
EOF".outdent;
    auto fastaFile = pipe();
    fastaFile.writeEnd.write(fastaRecordData);
    fastaFile.writeEnd.close();

    auto fastaLength1 = getFastaLength(fastaFile.readEnd);
    auto fastaLength2 = getFastaLength(fastaFile.readEnd);

    assert(fastaLength1 == 100);
    assert(fastaLength2 == 50);

Meta