Ignore:
Timestamp:
06/06/18 01:45:18 (6 years ago)
Author:
Maciej Komosinski
Message:

A more complete implementation of fB, fH, fL

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/fB/fB_general.h

    r780 r797  
     1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
     2// Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
     3// See LICENSE.txt for details.
     4
    15#ifndef _FB_GENERAL_H_
    26#define _FB_GENERAL_H_
     
    1014        {
    1115                int start = 0;
     16                int prev = 0;
    1217                int count = -1;
    1318                do {
    1419                        count++;
    1520                        start = geno.indexOf("aa", start) + 1; // +1 is for progress, starting codons can overlap
     21                        int quotecount = 0;
     22                        for (int q = prev; q < start; q++) if (geno[q] == '\"') quotecount++;
     23                        prev = start;
     24                        if (quotecount % 2 != 0) count--; // 'aa' sequence is within quotes
    1625                } while (start - 1 != -1);
    1726                return count;
     
    2534                        count++;
    2635                        start = genotype.indexOf("aa", start) + 1;
     36                        int quotecount = 0;
     37                        for (int q = 0; q < start; q++) if (genotype[q] == '\"') quotecount++;
     38                        if (quotecount % 2 != 0) count--; // 'aa' sequence is within quotes
    2739                } while (start - 1 != -1 && count != i);
    2840                if (start - 1 == -1) // there is no gene with a given "i"
     
    3345                }
    3446                end = start;
    35                 end = genotype.indexOf("zz", end);
     47                int quotecount = 0;
     48                do {
     49                        quotecount = 0;
     50                        end = genotype.indexOf("zz", end);
     51                        if (end != -1)
     52                        {
     53                                for (int q = start; q < end; q++) if (genotype[q] == '\"') quotecount++;
     54                                if (quotecount % 2 != 0) end++;
     55                        }
     56                } while (quotecount % 2 != 0 && end != -1);
     57
    3658                if (end == -1) end = genotype.len();
    3759                else end += 2;
Note: See TracChangeset for help on using the changeset viewer.