File: Seed.cpp

package info (click to toggle)
snap-aligner 1.0~beta.18%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 9,036 kB
  • ctags: 4,550
  • sloc: cpp: 106,701; ansic: 5,239; python: 227; makefile: 80
file content (56 lines) | stat: -rw-r--r-- 888 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*++

Module Name:

    Seed.cpp

Abstract:

    Code to handle seeds in the SNAP sequencer.

Authors:

    Bill Bolosky, August, 2011

Environment:
`
    User mode service.

Revision History:

    Adapted from Matei Zaharia's Scala implementation.

--*/

#include "stdafx.h"
#include "Seed.h"

    bool
Seed::DoesTextRepresentASeed(const char *textBases, unsigned seedLen)
{
    for (unsigned i = 0; i < seedLen; i++) {
        switch (textBases[i]) {
            case 'A':
            case 'G':
            case 'C':
            case 'T':
                    break;
            default: return false;
        }
    }
    return true;
}
    
    Seed
Seed::fromBases(
    _int64 bases,
    int seedLength)
{
    _int64 rc = 0;
    _int64 b = bases;
    for (int i = 0; i < seedLength; i++) {
        rc = (rc << 2) | ((b & 3) ^ 3);
        b = b >> 2;
    }
    return Seed(bases, rc);
}