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(in string fastaFile)
    size_t
    getFastaLength
    (
    in string fastaFile
    )
  2. size_t getFastaLength(File fastaFile)

Examples

1     import std.process : pipe;
2 
3     string fastaRecordData = q"EOF
4         >sequence1
5         CTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCT
6         AACCCTAACCCTAACCCTAACCCTAACCCTAACAACCCTAACCCTAACCC
7 EOF".outdent;
8     auto fastaFile = pipe();
9     fastaFile.writeEnd.write(fastaRecordData);
10     fastaFile.writeEnd.close();
11 
12     auto fastaLength = getFastaLength(fastaFile.readEnd);
13 
14     assert(fastaLength == 100);
1     import std.process : pipe;
2 
3     string fastaRecordData = q"EOF
4         >sequence1
5         CTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCT
6         AACCCTAACCCTAACCCTAACCCTAACCCTAACAACCCTAACCCTAACCC
7         >sequence2
8         AACCCTAACCCTAACCCTAACCCTAACCCTAACAACCCTAACCCTAACCC
9 EOF".outdent;
10     auto fastaFile = pipe();
11     fastaFile.writeEnd.write(fastaRecordData);
12     fastaFile.writeEnd.close();
13 
14     auto fastaLength1 = getFastaLength(fastaFile.readEnd);
15     auto fastaLength2 = getFastaLength(fastaFile.readEnd);
16 
17     assert(fastaLength1 == 100);
18     assert(fastaLength2 == 50);

Meta