From: <si...@us...> - 2011-06-07 15:48:39
|
Revision: 4206 http://simupop.svn.sourceforge.net/simupop/?rev=4206&view=rev Author: simupop Date: 2011-06-07 15:48:29 +0000 (Tue, 07 Jun 2011) Log Message: ----------- Merge from openMP branch Modified Paths: -------------- trunk/src/initializer.cpp trunk/src/mating.h trunk/src/stator.cpp trunk/src/utility.cpp trunk/src/utility.h trunk/test/performance.csv trunk/test/performance.log trunk/test/performance.py Property Changed: ---------------- trunk/ Property changes on: trunk ___________________________________________________________________ Modified: svn:mergeinfo - /branches/openMP:3999-4176 + /branches/openMP:3999-4205 Modified: trunk/src/initializer.cpp =================================================================== --- trunk/src/initializer.cpp 2011-06-07 15:22:29 UTC (rev 4205) +++ trunk/src/initializer.cpp 2011-06-07 15:48:29 UTC (rev 4206) @@ -68,9 +68,18 @@ if (!m_sex.empty()) for (; ind.valid(); ++ind, ++idx) ind->setSex(m_sex[idx % sexSz] == 1 ? MALE : FEMALE); - else - for (; ind.valid(); ++ind) - ind->setSex(ws.draw() == 0 ? MALE : FEMALE); + else { + if (numThreads() > 1) { +#pragma omp parallel private(ind) + { + ind = pop.indIterator(sp->subPop(), omp_get_thread_num()); + for (; ind.valid(); ++ind) + ind->setSex(ws.draw() == 0 ? MALE : FEMALE); + } + } else + for (; ind.valid(); ++ind) + ind->setSex(ws.draw() == 0 ? MALE : FEMALE); + } pop.deactivateVirtualSubPop(sp->subPop()); } return true; @@ -113,15 +122,31 @@ for (; sp != sp_end; ++sp) { pop.activateVirtualSubPop(*sp); - IndIterator ind = pop.indIterator(sp->subPop()); size_t numValues = m_values.size(); - for (; ind.valid(); ++ind, ++idx) { - for (size_t i = 0; i < infoIdx.size(); ++i) { - if (values.empty()) - ind->setInfo(m_values.func() (PyObj_As_Double, "()"), infoIdx[i]); - else - ind->setInfo(values[idx % numValues], infoIdx[i]); + if (numThreads() > 1 && !values.empty()) { +#ifdef _OPENMP +# pragma omp parallel firstprivate (idx) + { + size_t id = omp_get_thread_num(); + IndIterator ind = pop.indIterator(sp->subPop(), id); + idx = idx + id * (pop.subPopSize(sp->subPop()) / numThreads()); + for (; ind.valid(); ++ind, ++idx) + for (size_t i = 0; i < infoIdx.size(); ++i) { + ind->setInfo(values[idx % numValues], infoIdx[i]); + } } + idx = idx + pop.subPopSize(sp->subPop()); +#endif + } else { + IndIterator ind = pop.indIterator(sp->subPop()); + for (; ind.valid(); ++ind, ++idx) { + for (size_t i = 0; i < infoIdx.size(); ++i) { + if (values.empty()) + ind->setInfo(m_values.func() (PyObj_As_Double, "()"), infoIdx[i]); + else + ind->setInfo(values[idx % numValues], infoIdx[i]); + } + } } pop.deactivateVirtualSubPop(sp->subPop()); } @@ -205,11 +230,24 @@ // will go through virtual subpopulation if sp is virtual pop.activateVirtualSubPop(*sp); if (!m_genotype.empty()) { - IndIterator it = pop.indIterator(sp->subPop()); - for (; it.valid(); ++it) - for (vectoru::iterator p = ploidy.begin(); p != ploidy.end(); ++p) - for (vectoru::const_iterator loc = loci.begin(); loc != loci.end(); ++loc, ++idx) - it->setAllele(ToAllele(m_genotype[idx % sz]), *loc, static_cast<int>(*p)); +#pragma omp parallel firstprivate(idx) if(numThreads() > 1) + { +#ifdef _OPENMP + size_t id = omp_get_thread_num(); + IndIterator it = pop.indIterator(sp->subPop(), id); + idx = idx + id * (pop.subPopSize(sp->subPop()) / numThreads()) * (ploidy.end() - ploidy.begin()) * (loci.end() - loci.begin()); +#else + IndIterator it = pop.indIterator(sp->subPop()); +#endif + for (; it.valid(); ++it) + for (vectoru::iterator p = ploidy.begin(); p != ploidy.end(); ++p) + for (vectoru::const_iterator loc = loci.begin(); loc != loci.end(); ++loc, ++idx) + it->setAllele(ToAllele(m_genotype[idx % sz]), *loc, static_cast<int>(*p)); + + } +#ifdef _OPENMP + idx = idx + pop.subPopSize(sp->subPop()) * (ploidy.end() - ploidy.begin()) * (loci.end() - loci.begin()); +#endif } else if (!m_prop.empty()) { WeightedSampler ws; size_t sz = pop.subPopSize(*sp); @@ -224,33 +262,47 @@ } } else { ws.set(m_prop.begin(), m_prop.end(), sz * ploidy.size()); +#pragma omp parallel if(numThreads() > 1) + { +#ifdef _OPENMP + IndIterator it = pop.indIterator(sp->subPop(), omp_get_thread_num()); +#else + IndIterator it = pop.indIterator(sp->subPop()); +#endif + for (; it.valid(); ++it) + for (vectoru::iterator p = ploidy.begin(); p != ploidy.end(); ++p) { + const vectori & haplotype = m_haplotypes[ws.draw()]; + size_t hapSz = haplotype.size(); + size_t j = 0; + for (vectoru::const_iterator loc = loci.begin(); loc != loci.end(); ++loc, ++j) + it->setAllele(ToAllele(haplotype[j % hapSz]), *loc, static_cast<int>(*p)); + } + } + } + } else { + // m_freq can be empty if .... + WeightedSampler ws(m_freq.empty() ? vectorf(m_haplotypes.size(), 1. / m_haplotypes.size()) : m_freq); +#pragma omp parallel if(numThreads() > 1) + { +#ifdef _OPENMP + IndIterator it = pop.indIterator(sp->subPop(), omp_get_thread_num()); +#else IndIterator it = pop.indIterator(sp->subPop()); +#endif for (; it.valid(); ++it) for (vectoru::iterator p = ploidy.begin(); p != ploidy.end(); ++p) { - const vectori & haplotype = m_haplotypes[ws.draw()]; - size_t hapSz = haplotype.size(); - size_t j = 0; - for (vectoru::const_iterator loc = loci.begin(); loc != loci.end(); ++loc, ++j) - it->setAllele(ToAllele(haplotype[j % hapSz]), *loc, static_cast<int>(*p)); + if (m_haplotypes.empty()) { + for (vectoru::const_iterator loc = loci.begin(); loc != loci.end(); ++loc) + it->setAllele(ToAllele(ws.draw()), *loc, static_cast<int>(*p)); + } else { + const vectori & haplotype = m_haplotypes[ws.draw()]; + size_t hapSz = haplotype.size(); + size_t j = 0; + for (vectoru::const_iterator loc = loci.begin(); loc != loci.end(); ++loc, ++j) + it->setAllele(ToAllele(haplotype[j % hapSz]), *loc, static_cast<int>(*p)); + } } } - } else { - // m_freq can be empty if .... - WeightedSampler ws(m_freq.empty() ? vectorf(m_haplotypes.size(), 1. / m_haplotypes.size()) : m_freq); - IndIterator it = pop.indIterator(sp->subPop()); - for (; it.valid(); ++it) - for (vectoru::iterator p = ploidy.begin(); p != ploidy.end(); ++p) { - if (m_haplotypes.empty()) { - for (vectoru::const_iterator loc = loci.begin(); loc != loci.end(); ++loc) - it->setAllele(ToAllele(ws.draw()), *loc, static_cast<int>(*p)); - } else { - const vectori & haplotype = m_haplotypes[ws.draw()]; - size_t hapSz = haplotype.size(); - size_t j = 0; - for (vectoru::const_iterator loc = loci.begin(); loc != loci.end(); ++loc, ++j) - it->setAllele(ToAllele(haplotype[j % hapSz]), *loc, static_cast<int>(*p)); - } - } } pop.deactivateVirtualSubPop(sp->subPop()); } Modified: trunk/src/mating.h =================================================================== --- trunk/src/mating.h 2011-06-07 15:22:29 UTC (rev 4205) +++ trunk/src/mating.h 2011-06-07 15:48:29 UTC (rev 4206) @@ -1293,6 +1293,11 @@ return "<simuPOP.CombinedParentsChooser> chooses parents using two parent choosers"; } + /// CPPONLY + virtual bool parallelizable() const + { + return m_fatherChooser->parallelizable() && m_motherChooser->parallelizable(); + } /// CPPONLY void initialize(Population & pop, size_t sp); Modified: trunk/src/stator.cpp =================================================================== --- trunk/src/stator.cpp 2011-06-07 15:22:29 UTC (rev 4205) +++ trunk/src/stator.cpp 2011-06-07 15:48:29 UTC (rev 4206) @@ -515,12 +515,19 @@ size_t totalCnt = 0; pop.activateVirtualSubPop(*sp); - IndIterator it = pop.indIterator(sp->subPop()); - for (; it.valid(); ++it) - if (it->sex() == MALE) - maleCnt++; - else - femaleCnt++; +#pragma omp parallel reduction (+ : maleCnt,femaleCnt) if(numThreads() > 1) + { +#ifdef _OPENMP + IndIterator it = pop.indIterator(sp->subPop(), omp_get_thread_num()); +#else + IndIterator it = pop.indIterator(sp->subPop()); +#endif + for (; it.valid(); ++it) + if (it->sex() == MALE) + maleCnt++; + else + femaleCnt++; + } pop.deactivateVirtualSubPop(sp->subPop()); @@ -595,12 +602,19 @@ size_t totalCnt = 0; pop.activateVirtualSubPop(*sp); - IndIterator it = pop.indIterator(sp->subPop()); - for (; it.valid(); ++it) - if (it->affected()) - affectedCnt++; - else - unaffectedCnt++; +#pragma omp parallel reduction (+ : affectedCnt,unaffectedCnt) if(numThreads() > 1) + { +#ifdef _OPENMP + IndIterator it = pop.indIterator(sp->subPop(), omp_get_thread_num()); +#else + IndIterator it = pop.indIterator(sp->subPop()); +#endif + for (; it.valid(); ++it) + if (it->affected()) + affectedCnt++; + else + unaffectedCnt++; + } pop.deactivateVirtualSubPop(sp->subPop()); @@ -688,7 +702,8 @@ pop.activateVirtualSubPop(*it); - for (size_t idx = 0; idx < loci.size(); ++idx) { +#pragma omp parallel for if(numThreads() > 1) + for (ssize_t idx = 0; idx < static_cast<ssize_t>(loci.size()); ++idx) { size_t loc = loci[idx]; #ifdef LONGALLELE @@ -726,13 +741,16 @@ allAllelesCnt[idx] += allAlleles; // output variable. #ifdef LONGALLELE - if (m_vars.contains(AlleleNum_sp_String)) + if (m_vars.contains(AlleleNum_sp_String)) { +# pragma omp critical pop.getVars().setVar(subPopVar_String(*it, AlleleNum_String) + m_suffix + "{" + toStr(loc) + "}", alleles); + } if (m_vars.contains(AlleleFreq_sp_String)) { intDict::iterator cnt = alleles.begin(); intDict::iterator cntEnd = alleles.end(); for ( ; cnt != cntEnd; ++cnt) cnt->second /= static_cast<double>(allAlleles); +# pragma omp critical pop.getVars().setVar(subPopVar_String(*it, AlleleFreq_String) + m_suffix + "{" + toStr(loc) + "}", alleles); } #else @@ -741,6 +759,7 @@ for (size_t i = 0; i < alleles.size(); ++i) if (alleles[i] != 0) d[i] = static_cast<double>(alleles[i]); +# pragma omp critical pop.getVars().setVar(subPopVar_String(*it, AlleleNum_String) + m_suffix + "{" + toStr(loc) + "}", d); } if (m_vars.contains(AlleleFreq_sp_String)) { @@ -748,6 +767,7 @@ for (size_t i = 0; i < alleles.size(); ++i) if (alleles[i] != 0) d[i] = alleles[i] / static_cast<double>(allAlleles); +# pragma omp critical pop.getVars().setVar(subPopVar_String(*it, AlleleFreq_String) + m_suffix + "{" + toStr(loc) + "}", d); } #endif @@ -850,7 +870,8 @@ uintDict heteroCnt; uintDict homoCnt; - for (size_t idx = 0; idx < loci.size(); ++idx) { +#pragma omp parallel for if(numThreads() > 1) + for (ssize_t idx = 0; idx < static_cast<ssize_t>(loci.size()); ++idx) { size_t loc = loci[idx]; #ifndef OPTIMIZED @@ -869,11 +890,14 @@ else homo += 1; } - heteroCnt[loc] = static_cast<double>(hetero); - homoCnt[loc] = static_cast<double>(homo); - // - allHeteroCnt[loc] += heteroCnt[loc]; - allHomoCnt[loc] += homoCnt[loc]; +#pragma omp critical + { + heteroCnt[loc] = static_cast<double>(hetero); + homoCnt[loc] = static_cast<double>(homo); + // + allHeteroCnt[loc] += heteroCnt[loc]; + allHomoCnt[loc] += homoCnt[loc]; + } } pop.deactivateVirtualSubPop(it->subPop()); // output subpopulation variable? @@ -981,7 +1005,8 @@ pop.activateVirtualSubPop(*it); - for (size_t idx = 0; idx < loci.size(); ++idx) { +#pragma omp parallel for if(numThreads() > 1) + for (ssize_t idx = 0; idx < static_cast<ssize_t>(loci.size()); ++idx) { size_t loc = loci[idx]; tupleDict genotypes; @@ -1022,9 +1047,11 @@ genotypeCnt[idx][dct->first] += dct->second; allGenotypeCnt[idx] += allGenotypes; // output variable. - if (m_vars.contains(GenotypeNum_sp_String)) + if (m_vars.contains(GenotypeNum_sp_String)) { +#pragma omp critical pop.getVars().setVar(subPopVar_String(*it, GenotypeNum_String) + m_suffix + "{" + toStr(loc) + "}", genotypes); + } // note that genotyeps is changed in place. if (m_vars.contains(GenotypeFreq_sp_String)) { if (allGenotypes != 0) { @@ -1033,6 +1060,7 @@ for (; dct != dctEnd; ++dct) dct->second /= allGenotypes; } +#pragma omp critical pop.getVars().setVar(subPopVar_String(*it, GenotypeFreq_String) + m_suffix + "{" + toStr(loc) + "}", genotypes); } @@ -1128,7 +1156,8 @@ pop.activateVirtualSubPop(*it); - for (size_t idx = 0; idx < m_loci.size(); ++idx) { +#pragma omp parallel for if(numThreads() > 1) + for (ssize_t idx = 0; idx < static_cast<ssize_t>(m_loci.size()); ++idx) { const vectori & loci = m_loci[idx]; size_t nLoci = loci.size(); if (nLoci == 0) @@ -1171,9 +1200,11 @@ haplotypeCnt[idx][dct->first] += dct->second; allHaplotypeCnt[idx] += allHaplotypes; // output variable. - if (m_vars.contains(HaplotypeNum_sp_String)) + if (m_vars.contains(HaplotypeNum_sp_String)) { +#pragma omp critical pop.getVars().setVar(subPopVar_String(*it, HaplotypeNum_String) + m_suffix + "{" + key + "}", haplotypes); + } // note that genotyeps is changed in place. if (m_vars.contains(HaplotypeFreq_sp_String)) { if (allHaplotypes != 0) { @@ -1182,6 +1213,7 @@ for (; dct != dctEnd; ++dct) dct->second /= allHaplotypes; } +#pragma omp critical pop.getVars().setVar(subPopVar_String(*it, HaplotypeFreq_String) + m_suffix + "{" + key + "}", haplotypes); } @@ -1284,7 +1316,8 @@ tupleDict heteroCnt; tupleDict homoCnt; - for (size_t idx = 0; idx < m_loci.size(); ++idx) { +#pragma omp parallel for if(numThreads() > 1) + for (ssize_t idx = 0; idx < static_cast<ssize_t>(m_loci.size()); ++idx) { const vectori & loci = m_loci[idx]; size_t nLoci = loci.size(); if (nLoci == 0) @@ -1318,11 +1351,14 @@ else ++homo; } - heteroCnt[loci] = static_cast<double>(hetero); - homoCnt[loci] = static_cast<double>(homo); +#pragma omp critical + { + heteroCnt[loci] = static_cast<double>(hetero); + homoCnt[loci] = static_cast<double>(homo); - allHeteroCnt[loci] += hetero; - allHomoCnt[loci] += homo; + allHeteroCnt[loci] += hetero; + allHomoCnt[loci] += homo; + } } pop.deactivateVirtualSubPop(it->subPop()); // output subpopulation variable? @@ -2426,19 +2462,43 @@ double diffCnt = 0; int numComparison = 0; - HAPLOLIST::const_iterator it = begin; + size_t size = end - begin; + size_t nThreads = numThreads(); - for (; it != end; ++it) { - HAPLOLIST::const_iterator it1 = it; - for (++it1; it1 != end; ++it1) { - const vectora & seq1 = *it; - const vectora & seq2 = *it1; - size_t sz = seq1.size(); - for (size_t i = 0; i < sz; ++i) - diffCnt += seq1[i] != seq2[i]; - ++numComparison; + if (nThreads > 1) +#ifdef _OPENMP +# pragma omp parallel reduction(+ : diffCnt, numComparison) + { + size_t id = omp_get_thread_num(); + HAPLOLIST::const_iterator it = begin + id * (size / nThreads); + HAPLOLIST::const_iterator itEnd = id == nThreads - 1 ? end : it + (size / nThreads); + for (; it != itEnd; ++it) { + HAPLOLIST::const_iterator it1 = it; + for (++it1; it1 != end; ++it1) { + const vectora & seq1 = *it; + const vectora & seq2 = *it1; + size_t sz = seq1.size(); + for (size_t i = 0; i < sz; ++i) + diffCnt += seq1[i] != seq2[i]; + ++numComparison; + } } } +#endif + else { + HAPLOLIST::const_iterator it = begin; + for (; it != end; ++it) { + HAPLOLIST::const_iterator it1 = it; + for (++it1; it1 != end; ++it1) { + const vectora & seq1 = *it; + const vectora & seq2 = *it1; + size_t sz = seq1.size(); + for (size_t i = 0; i < sz; ++i) + diffCnt += seq1[i] != seq2[i]; + ++numComparison; + } + } + } // return 0 if there is only one sequence return numComparison == 0 ? 0 : diffCnt / numComparison; } Modified: trunk/src/utility.cpp =================================================================== --- trunk/src/utility.cpp 2011-06-07 15:22:29 UTC (rev 4205) +++ trunk/src/utility.cpp 2011-06-07 15:48:29 UTC (rev 4206) @@ -492,17 +492,20 @@ ATOMICLONG fetchAndIncrement(ATOMICLONG * val) { + if(g_numThreads == 1) + return (*val)++; + else #ifdef _WIN64 - return InterlockedIncrement64(val) - 1; + return InterlockedIncrement64(val) - 1; #elif defined(_WIN32) - return InterlockedIncrement(val) - 1; + return InterlockedIncrement(val) - 1; #else // for Intel C++, see page 164 of // http://softwarecommunity.intel.com/isn/downloads/softwareproducts/pdfs/347603.pdf // // for gcc, see // http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html - return __sync_fetch_and_add(val, 1); + return __sync_fetch_and_add(val, 1); #endif } @@ -3569,6 +3572,9 @@ { DBG_FAILIF(m_algorithm == 0, ValueError, "weighted sample is not initialized"); +#ifdef _OPENMP + ATOMICLONG index = 0; +#endif switch (m_algorithm) { case 1: @@ -3593,7 +3599,13 @@ // return according to proportion. if (m_index == m_sequence.size()) m_index = 0; +#ifdef _OPENMP + index = fetchAndIncrement(&m_index); + return m_sequence[index]; +#else + return m_sequence[m_index++]; +#endif default: throw RuntimeError("Invalid weighted sampler (empty weight?)"); } Modified: trunk/src/utility.h =================================================================== --- trunk/src/utility.h 2011-06-07 15:22:29 UTC (rev 4205) +++ trunk/src/utility.h 2011-06-07 15:48:29 UTC (rev 4206) @@ -1920,7 +1920,7 @@ /// vectoru m_sequence; - ULONG m_index; + ATOMICLONG m_index; }; Modified: trunk/test/performance.csv =================================================================== --- trunk/test/performance.csv 2011-06-07 15:22:29 UTC (rev 4205) +++ trunk/test/performance.csv 2011-06-07 15:48:29 UTC (rev 4206) @@ -325,3 +325,126 @@ TestInheritTagger, 2011-05-18 17:01:51,673, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4173-intel, short, 26678, 2174, 23119, 1588, 677, 64 TestInheritTagger, 2011-05-18 17:04:27,692, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4173-intel, long, 25909, 1801, 15852, 1144, 179, 0 TestInheritTagger, 2011-05-18 17:07:35,036, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4173-intel, binary, 22938, 2168, 24949, 2026, 4616, 398 +TestStatAlleleFreq, 2011-05-25 14:16:24,057, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, short, 0.642503023148, 7.59624409676, 6.07503390312, 9.04420208931, 228.846941948, 89.078854084 +TestStatAlleleFreq, 2011-05-25 14:23:30,764, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, long, 1.01851701736, 17.1053318977, 10.8354318142, 12.6472120285, 240.113608122, 126.978461027 +TestStatAlleleFreq, 2011-05-25 14:28:33,636, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, binary, 1.08484101295, 10.7368938923, 10.8209798336, 11.4512810707, 132.637831926, 111.818598986 +TestStatAlleleFreq, 2011-05-25 14:30:39,283, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, short, 0.173316955566, 2.43554115295, 1.73279309273, 3.60566401482, 62.5272729397, 36.6046230793 +TestStatAlleleFreq, 2011-05-25 14:33:25,358, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, long, 0.287755966187, 4.98926496506, 3.02955412865, 6.11895489693, 71.2390468121, 61.2199239731 +TestStatAlleleFreq, 2011-05-25 14:35:07,703, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, binary, 0.307837963104, 3.0087928772, 3.05822300911, 3.17401409149, 36.7387290001, 31.7028801441 +TestStatNumOfMales, 2011-05-26 09:55:10,511, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, short, 16.8653411865, 17.209662199 +TestStatNumOfMales, 2011-05-26 09:55:46,138, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, long, 16.4387378693, 17.3230619431 +TestStatNumOfMales, 2011-05-26 09:56:23,810, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, binary, 17.4795110226, 17.6907908916 +TestStatNumOfMales, 2011-05-26 09:56:46,249, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, short, 9.28081488609, 10.3006439209 +TestStatNumOfMales, 2011-05-26 09:57:08,449, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, long, 9.30121707916, 10.2057070732 +TestStatNumOfMales, 2011-05-26 09:57:32,400, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, binary, 10.1437051296, 10.6698708534 +TestStatNumOfAffected, 2011-05-26 09:58:13,138, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, short, 18.7245531082, 19.554336071 +TestStatNumOfAffected, 2011-05-26 09:58:54,166, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, long, 18.9747388363, 19.5944628716 +TestStatNumOfAffected, 2011-05-26 09:59:36,526, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, binary, 19.5599150658, 20.22062397 +TestStatNumOfAffected, 2011-05-26 09:59:58,940, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, short, 9.38937807083, 10.0877468586 +TestStatNumOfAffected, 2011-05-26 10:00:20,933, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, long, 9.50907111168, 10.3536448479 +TestStatNumOfAffected, 2011-05-26 10:00:44,755, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, binary, 10.2223381996, 11.0147790909 +TestStatHaploFreq, 2011-05-26 10:21:44,402, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, short, 1.23293209076, 12.2021050453, 11.865776062, 1.29735088348, 21.6016001701, 15.2668449879 +TestStatHaploFreq, 2011-05-26 10:23:30,689, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, long, 1.41531896591, 23.2550559044, 17.4902069569, 1.51551508904, 25.3949120045, 16.8971569538 +TestStatHaploFreq, 2011-05-26 10:25:10,205, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, binary, 1.69325518608, 17.1936631203, 18.6411919594, 1.70309305191, 17.4465510845, 18.0900690556 +TestStatHaploFreq, 2011-05-26 10:26:01,853, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, short, 0.566158056259, 5.73171782494, 5.61322593689, 0.713933944702, 9.37162017822, 7.79208993912 +TestStatHaploFreq, 2011-05-26 10:26:56,395, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, long, 0.613075971603, 9.36668801308, 7.58966112137, 0.720818042755, 9.74222493172, 7.8867251873 +TestStatHaploFreq, 2011-05-26 10:27:52,943, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, binary, 0.768512964249, 7.49124717712, 7.55833601952, 0.781599998474, 7.85499882698, 7.7969429493 +TestStatHaploHomoFreq, 2011-05-26 10:28:28,350, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, short, 0.292308092117, 3.24175906181, 2.92852807045, 0.337744951248, 6.22854995728, 3.89006996155 +TestStatHaploHomoFreq, 2011-05-26 10:29:08,609, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, long, 0.31462597847, 5.88319706917, 3.6914870739, 0.325666904449, 7.17342495918, 4.69271183014 +TestStatHaploHomoFreq, 2011-05-26 10:29:59,679, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, binary, 0.631763935089, 6.12271213531, 6.13581681252, 0.631522893906, 6.96468997002, 6.4281539917 +TestStatHaploHomoFreq, 2011-05-26 10:30:26,105, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, short, 0.139616966248, 1.46904397011, 1.41087889671, 0.158464193344, 2.5026910305, 1.93978285789 +TestStatHaploHomoFreq, 2011-05-26 10:30:53,443, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, long, 0.147619009018, 2.38445401192, 1.86939907074, 0.15052485466, 2.83502817154, 2.09009408951 +TestStatHaploHomoFreq, 2011-05-26 10:31:30,481, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, binary, 0.287275075912, 2.73110985756, 2.7528860569, 0.292492866516, 3.02533006668, 2.91801309586 +TestStatGenoFreq, 2011-05-26 11:09:33,398, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, short, 0.460355997086, 4.32857394218, 4.52319002151, 0.482565879822, 6.7190079689, 6.86939692497 +TestStatGenoFreq, 2011-05-26 11:10:21,683, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, long, 0.500542163849, 6.76568007469, 6.89576387405, 0.500433206558, 7.35019493103, 7.48760890961 +TestStatGenoFreq, 2011-05-26 11:11:10,292, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, binary, 0.590523004532, 5.49827694893, 5.5768828392, 0.637578964233, 6.14054203033, 6.18443202972 +TestStatGenoFreq, 2011-05-26 11:14:14,234, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, short, 1.43687391281, 14.7355120182, 14.2837300301, 1.52868509293, 24.1452269554, 17.648113966 +TestStatGenoFreq, 2011-05-26 11:16:09,379, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, long, 1.64711523056, 25.8571681976, 18.9256169796, 1.66001415253, 28.0234498978, 19.0963768959 +TestStatGenoFreq, 2011-05-26 11:17:55,313, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4182-intel, binary, 1.89334607124, 18.6318368912, 18.7467119694, 1.92588806152, 21.1599271297, 19.6372129917 +TestStatHeteroFreq, 2011-05-26 13:08:13,920, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4184-intel, short, 0.441030979156, 5.07090187073, 4.35444688797, 5.11432695389, 117.634579182, 51.200012207 +TestStatHeteroFreq, 2011-05-26 13:12:40,530, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4184-intel, long, 0.556185007095, 9.46308708191, 5.34688615799, 6.48223590851, 162.691661835, 63.0534501076 +TestStatHeteroFreq, 2011-05-26 13:16:29,162, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4184-intel, binary, 0.831079959869, 8.2782459259, 8.30177307129, 8.63011312485, 93.6239349842, 84.6393620968 +TestStatHeteroFreq, 2011-05-26 13:18:27,983, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4184-intel, short, 0.127473115921, 1.61057591438, 1.26040196419, 1.40715408325, 33.8272380829, 13.8213179111 +TestStatHeteroFreq, 2011-05-26 13:19:57,092, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4184-intel, long, 0.136440992355, 2.69143199921, 1.42887401581, 1.70447492599, 45.7699849606, 17.6911768913 +TestStatHeteroFreq, 2011-05-26 13:21:18,570, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4184-intel, binary, 0.234434127808, 2.50543117523, 2.3329770565, 2.43857598305, 26.4068300724, 23.9802000523 +TestStatNeutrality, 2011-05-27 12:07:40,930, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4187-intel, short, 9.03047394753, 8.99528694153, 27.8919439316, 27.8793339729, 162.322354078, 161.907181978 +TestStatNeutrality, 2011-05-27 12:12:47,358, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4187-intel, long, 11.8714928627, 11.7830820084, 30.3244822025, 30.1393539906, 109.87086916, 111.744431973 +TestStatNeutrality, 2011-05-27 12:36:43,441, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4187-intel, binary, 38.0854780674, 38.7297050953, 84.4918601513, 84.3150889874, 597.092149973, 592.624132156 +TestStatNeutrality, 2011-05-27 12:47:16,722, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4187-intel, short, 3.13563299179, 3.20556497574, 27.0847280025, 27.1585049629, 267.419605017, 268.027008057 +TestStatNeutrality, 2011-05-27 12:57:26,253, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4187-intel, long, 3.10889577866, 3.15888404846, 26.967279911, 26.9330770969, 273.505503893, 275.049628019 +TestStatNeutrality, 2011-05-27 13:07:35,760, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4187-intel, binary, 8.32187199593, 8.2234890461, 32.0274319649, 31.5282058716, 265.823650122, 262.824134827 +TestStatAlleleFreq, 2011-05-30 22:36:02,049, BoPeng-PC, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4188-vc, short, 0.156656771779, 1.27655273963, 0.772660287815, 2.37574158829, 61.8670897501, 22.9204747493 +TestStatHaploFreq, 2011-05-30 22:36:39,930, BoPeng-PC, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4188-vc, short, 0.516961671952, 5.07994453068, 5.05862403715, 0.543532975813, 8.80322124159, 6.99310467028 +TestStatHaploHomoFreq, 2011-05-30 22:36:56,315, BoPeng-PC, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4188-vc, short, 0.089213063666, 1.02716445375, 0.939058905066, 0.101590728388, 1.95475398316, 1.38428928569 +TestStatNeutrality, 2011-05-30 22:40:04,670, BoPeng-PC, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4188-vc, short, 1.63284142643, 1.61529354731, 9.36116640133, 9.26592282954, 82.7843907702, 83.5741105317 +TestStatNumOfAffected, 2011-05-30 22:40:32,180, BoPeng-PC, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4188-vc, short, 12.5538024681, 14.0043555011 +TestStatNumOfMales, 2011-05-30 22:40:59,032, BoPeng-PC, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4188-vc, short, 12.1569785518, 13.7430625612 +TestStatAlleleFreq, 2011-05-30 22:42:50,881, BoPeng-PC, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4188-vc, long, 0.220509281815, 4.18473675917, 2.32420848449, 2.93125649371, 61.5509994198, 30.0181917411 +TestStatHaploFreq, 2011-05-30 22:43:34,875, BoPeng-PC, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4188-vc, long, 0.526113989825, 8.50943485645, 6.82598914158, 0.549702036511, 9.71940961513, 7.44523822892 +TestStatHaploHomoFreq, 2011-05-30 22:43:52,589, BoPeng-PC, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4188-vc, long, 0.0952381383606, 1.640990672, 1.33187294699, 0.116611155082, 2.41424260042, 1.69099849011 +TestStatNeutrality, 2011-05-30 22:47:03,999, BoPeng-PC, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4188-vc, long, 1.76370840329, 1.7402884912, 9.68770733834, 9.7137196022, 83.7511417758, 84.6337454895 +TestStatNumOfAffected, 2011-05-30 22:47:31,562, BoPeng-PC, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4188-vc, long, 12.5345379257, 14.0830832444 +TestStatNumOfMales, 2011-05-30 22:47:58,328, BoPeng-PC, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4188-vc, long, 12.1148138958, 13.7313332862 +TestStatAlleleFreq, 2011-05-30 22:48:56,724, BoPeng-PC, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4188-vc, binary, 0.12388803262, 1.45832435307, 1.32294249434, 1.57181067984, 23.3392189499, 15.4070457151 +TestStatHaploFreq, 2011-05-30 22:49:38,438, BoPeng-PC, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4188-vc, binary, 0.635344730263, 6.14874750288, 6.11202654414, 0.643167969785, 6.50306445683, 6.59007939455 +TestStatHaploHomoFreq, 2011-05-30 22:50:02,937, BoPeng-PC, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4188-vc, binary, 0.188049342826, 1.7590105958, 1.80983161788, 0.201168973159, 2.93850409107, 2.4963571843 +TestStatNeutrality, 2011-05-30 23:03:11,364, BoPeng-PC, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4188-vc, binary, 11.648486698, 11.7215078263, 40.8976600614, 40.9682174291, 341.107198032, 341.91136288 +TestStatNumOfAffected, 2011-05-30 23:03:39,740, BoPeng-PC, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4188-vc, binary, 12.6815394851, 14.3641107189 +TestStatNumOfMales, 2011-05-30 23:04:07,559, BoPeng-PC, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4188-vc, binary, 12.2875931758, 14.2055386616 +TestStatNeutrality, 2011-05-31 11:04:27,264, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4189-intel, short, 6.89465403557, 6.83319497108, 59.4530448914, 58.7852652073, 582.544010878, 575.242040157 +TestStatNeutrality, 2011-05-31 11:26:06,905, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4189-intel, long, 6.49560403824, 6.46290183067, 58.2610440254, 58.1104929447, 580.978451014, 588.665710926 +TestStatNeutrality, 2011-05-31 11:47:47,179, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4189-intel, binary, 17.2013239861, 17.1441349983, 66.1994318962, 66.1883180141, 564.6483531, 568.191828012 +TestCombinedParentsChooser, 2011-05-31 12:24:18,072, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4190-intel, short, 16601, 1443, 15558, 1021, 715, 55 +TestCombinedParentsChooser, 2011-05-31 12:26:53,397, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4190-intel, long, 17644, 1233, 9825, 804, 183, 0 +TestCombinedParentsChooser, 2011-05-31 12:30:00,590, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4190-intel, binary, 12489, 1132, 13914, 1176, 3589, 338 +TestCombinedParentsChooser, 2011-05-31 12:36:04,961, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4190-intel, short, 52566, 4674, 48309, 3269, 788, 70 +TestCombinedParentsChooser, 2011-05-31 12:38:40,375, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4190-intel, long, 52725, 4021, 19461, 1602, 205, 0 +TestCombinedParentsChooser, 2011-05-31 12:41:47,862, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4190-intel, binary, 36988, 3779, 43414, 3928, 6050, 554 +TestStatNeutrality, 2011-06-01 12:19:12,461, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4191-intel, short, 5.57430195808, 5.54049086571, 23.4916911125, 23.5364370346, 157.407531977, 157.336145878 +TestStatNeutrality, 2011-06-01 12:23:30,558, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4191-intel, long, 6.09040188789, 5.92418003082, 19.0062968731, 19.4905800819, 103.946276903, 102.977053881 +TestStatNeutrality, 2011-06-01 12:45:16,569, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4191-intel, binary, 17.0345540047, 17.1601970196, 66.7122030258, 66.5635910034, 569.442780972, 568.384868145 +TestStatNeutrality, 2011-06-01 13:15:52,983, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4191-intel, short, 3.03625702858, 3.06062293053, 26.9129579067, 26.9386310577, 266.358695984, 268.104444981 +TestStatNeutrality, 2011-06-01 13:25:52,287, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4191-intel, long, 3.10122394562, 3.10917305946, 26.9314918518, 26.8245511055, 270.068092108, 268.488473892 +TestStatNeutrality, 2011-06-01 13:35:54,684, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4191-intel, binary, 7.92105603218, 7.99158787727, 30.9572019577, 31.2986159325, 261.169814825, 262.290413141 +TestHeteroMating, 2011-06-02 13:03:44,077, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4192-intel, short, 9574, 799, 8610, 645, 680, 1 +TestHeteroMating, 2011-06-02 13:06:20,597, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4192-intel, long, 9322, 706, 6626, 529, 182, 0 +TestHeteroMating, 2011-06-02 13:09:28,174, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4192-intel, binary, 8048, 740, 8468, 711, 2888, 256 +TestHeteroMating, 2011-06-02 13:12:52,461, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4192-intel, short, 20484, 1388, 11540, 1498, 804, 44 +TestHeteroMating, 2011-06-02 13:15:30,025, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4192-intel, long, 19089, 1637, 15357, 1357, 198, 0 +TestHeteroMating, 2011-06-02 13:18:36,396, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4192-intel, binary, 17963, 1668, 19806, 1729, 5586, 532 +TestInitGenotypeCase1, 2011-06-03 10:03:58,047, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, short, 20.0126931667, 20.2507748604 +TestInitGenotypeCase1, 2011-06-03 10:04:48,348, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, long, 20.1913919449, 20.4295210838 +TestInitGenotypeCase1, 2011-06-03 10:06:18,425, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, binary, 44.585860014, 44.6598989964 +TestInitGenotypeCase1, 2011-06-03 10:06:31,379, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, short, 5.68694496155, 5.69882082939 +TestInitGenotypeCase1, 2011-06-03 10:06:44,668, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, long, 5.97290492058, 6.30002713203 +TestInitGenotypeCase1, 2011-06-03 10:07:10,443, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, binary, 12.9159140587, 12.3552010059 +TestInitGenotypeCase2, 2011-06-03 10:11:05,127, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, short, 128.611124992, 104.630683184 +TestInitGenotypeCase2, 2011-06-03 10:15:02,793, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, long, 128.964793921, 107.590738058 +TestInitGenotypeCase2, 2011-06-03 10:19:13,348, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, binary, 133.749624968, 116.280220985 +TestInitGenotypeCase2, 2011-06-03 10:23:46,829, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, short, 136.778111935, 135.20889616 +TestInitGenotypeCase2, 2011-06-03 10:28:20,802, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, long, 137.331019163, 133.9238801 +TestInitGenotypeCase2, 2011-06-03 10:32:49,232, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, binary, 135.631910086, 132.102210045 +TestInitGenotypeCase3, 2011-06-03 10:33:32,227, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, short, 20.7163860798, 20.7371339798 +TestInitGenotypeCase3, 2011-06-03 10:34:15,306, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, long, 21.2412390709, 21.0875110626 +TestInitGenotypeCase3, 2011-06-03 10:35:50,274, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, binary, 47.2954690456, 47.1605689526 +TestInitGenotypeCase3, 2011-06-03 10:36:02,968, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, short, 5.51451182365, 5.6633439064 +TestInitGenotypeCase3, 2011-06-03 10:36:15,091, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, long, 5.6491651535, 5.6448340416 +TestInitGenotypeCase3, 2011-06-03 10:36:38,723, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, binary, 11.493434906, 11.7346558571 +TestInitGenotypeCase4, 2011-06-03 10:39:15,629, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, short, 77.3453309536, 78.1487438679 +TestInitGenotypeCase4, 2011-06-03 10:41:55,561, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, long, 79.8385441303, 79.1435091496 +TestInitGenotypeCase4, 2011-06-03 10:45:27,401, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, binary, 105.690921068, 105.673449993 +TestInitGenotypeCase4, 2011-06-03 10:46:12,888, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, short, 21.8644630909, 22.1283450127 +TestInitGenotypeCase4, 2011-06-03 10:46:58,953, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, long, 22.5271499157, 22.7279741764 +TestInitGenotypeCase4, 2011-06-03 10:47:59,678, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4195-intel, binary, 29.9604380131, 30.151968956 +TestInitSex, 2011-06-06 10:22:20,721, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4197-intel, short, 14.3448200226, 14.728511095 +TestInitSex, 2011-06-06 10:22:54,606, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4197-intel, long, 14.6376848221, 14.6885848045 +TestInitSex, 2011-06-06 10:23:23,739, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4197-intel, binary, 14.1411120892, 14.4127311707 +TestInitSex, 2011-06-06 10:26:24,857, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4197-intel, short, 4.17382383347, 4.48227882385 +TestInitSex, 2011-06-06 10:26:38,022, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4197-intel, long, 4.08154797554, 4.58521986008 +TestInitSex, 2011-06-06 10:26:48,164, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4197-intel, binary, 4.46001601219, 5.02257704735 +TestInitSex, 2011-06-06 15:38:55,266, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4200-intel, short, 46.7628421783, 46.9360320568 +TestInitSex, 2011-06-06 15:40:50,926, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4200-intel, long, 47.1968901157, 47.7802641392 +TestInitSex, 2011-06-06 15:42:28,424, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4200-intel, binary, 47.520539999, 47.8896892071 +TestInitSex, 2011-06-06 15:43:11,943, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4200-intel, short, 13.1370029449, 13.5422229767 +TestInitSex, 2011-06-06 15:43:59,207, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4200-intel, long, 13.7384490967, 15.3715240955 +TestInitSex, 2011-06-06 15:44:27,405, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4200-intel, binary, 12.9587409496, 13.3092448711 Modified: trunk/test/performance.log =================================================================== --- trunk/test/performance.log 2011-06-07 15:22:29 UTC (rev 4205) +++ trunk/test/performance.log 2011-06-07 15:48:29 UTC (rev 4206) @@ -5192,3 +5192,1401 @@ TestInheritTagger : loci=10000, size=100000: 398 TestInheritTagger : 22938, 2168, 24949, 2026, 4616, 398 TestInheritTagger : End of test TestInheritTagger +TestStatAlleleFreq : Host: bp9 (Linux, x86_64, x86_64) +TestStatAlleleFreq : Time: Wed May 25 14:10:25 2011 +TestStatAlleleFreq : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatAlleleFreq : simuPOP: 1.0.6svn (rev 4182, module short, optimized, 1 threads) +TestStatAlleleFreq : Test: Stat AlleleFreq, results are time (not processor time) to apply operator for 30 times. +TestStatAlleleFreq : loci=100, size=10000: 0.642503023148 +TestStatAlleleFreq : loci=100, size=100000: 7.59624409676 +TestStatAlleleFreq : loci=100, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 6.07503390312 +TestStatAlleleFreq : loci=1000, size=10000: 9.04420208931 +TestStatAlleleFreq : loci=1000, size=100000: 228.846941948 +TestStatAlleleFreq : loci=1000, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 89.078854084 +TestStatAlleleFreq : 0.642503023148, 7.59624409676, 6.07503390312, 9.04420208931, 228.846941948, 89.078854084 +TestStatAlleleFreq : End of test TestStatAlleleFreq +TestStatAlleleFreq : Host: bp9 (Linux, x86_64, x86_64) +TestStatAlleleFreq : Time: Wed May 25 14:16:25 2011 +TestStatAlleleFreq : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatAlleleFreq : simuPOP: 1.0.6svn (rev 4182, module long, optimized, 1 threads) +TestStatAlleleFreq : Test: Stat AlleleFreq, results are time (not processor time) to apply operator for 30 times. +TestStatAlleleFreq : loci=100, size=10000: 1.01851701736 +TestStatAlleleFreq : loci=100, size=100000: 17.1053318977 +TestStatAlleleFreq : loci=100, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 10.8354318142 +TestStatAlleleFreq : loci=1000, size=10000: 12.6472120285 +TestStatAlleleFreq : loci=1000, size=100000: 240.113608122 +TestStatAlleleFreq : loci=1000, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 126.978461027 +TestStatAlleleFreq : 1.01851701736, 17.1053318977, 10.8354318142, 12.6472120285, 240.113608122, 126.978461027 +TestStatAlleleFreq : End of test TestStatAlleleFreq +TestStatAlleleFreq : Host: bp9 (Linux, x86_64, x86_64) +TestStatAlleleFreq : Time: Wed May 25 14:23:31 2011 +TestStatAlleleFreq : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatAlleleFreq : simuPOP: 1.0.6svn (rev 4182, module binary, optimized, 1 threads) +TestStatAlleleFreq : Test: Stat AlleleFreq, results are time (not processor time) to apply operator for 30 times. +TestStatAlleleFreq : loci=100, size=10000: 1.08484101295 +TestStatAlleleFreq : loci=100, size=100000: 10.7368938923 +TestStatAlleleFreq : loci=100, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 10.8209798336 +TestStatAlleleFreq : loci=1000, size=10000: 11.4512810707 +TestStatAlleleFreq : loci=1000, size=100000: 132.637831926 +TestStatAlleleFreq : loci=1000, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 111.818598986 +TestStatAlleleFreq : 1.08484101295, 10.7368938923, 10.8209798336, 11.4512810707, 132.637831926, 111.818598986 +TestStatAlleleFreq : End of test TestStatAlleleFreq +TestStatAlleleFreq : Host: bp9 (Linux, x86_64, x86_64) +TestStatAlleleFreq : Time: Wed May 25 14:28:34 2011 +TestStatAlleleFreq : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatAlleleFreq : simuPOP: 1.0.6svn (rev 4182, module short, optimized, 4 threads) +TestStatAlleleFreq : Test: Stat AlleleFreq, results are time (not processor time) to apply operator for 30 times. +TestStatAlleleFreq : loci=100, size=10000: 0.173316955566 +TestStatAlleleFreq : loci=100, size=100000: 2.43554115295 +TestStatAlleleFreq : loci=100, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 1.73279309273 +TestStatAlleleFreq : loci=1000, size=10000: 3.60566401482 +TestStatAlleleFreq : loci=1000, size=100000: 62.5272729397 +TestStatAlleleFreq : loci=1000, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 36.6046230793 +TestStatAlleleFreq : 0.173316955566, 2.43554115295, 1.73279309273, 3.60566401482, 62.5272729397, 36.6046230793 +TestStatAlleleFreq : End of test TestStatAlleleFreq +TestStatAlleleFreq : Host: bp9 (Linux, x86_64, x86_64) +TestStatAlleleFreq : Time: Wed May 25 14:30:40 2011 +TestStatAlleleFreq : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatAlleleFreq : simuPOP: 1.0.6svn (rev 4182, module long, optimized, 4 threads) +TestStatAlleleFreq : Test: Stat AlleleFreq, results are time (not processor time) to apply operator for 30 times. +TestStatAlleleFreq : loci=100, size=10000: 0.287755966187 +TestStatAlleleFreq : loci=100, size=100000: 4.98926496506 +TestStatAlleleFreq : loci=100, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 3.02955412865 +TestStatAlleleFreq : loci=1000, size=10000: 6.11895489693 +TestStatAlleleFreq : loci=1000, size=100000: 71.2390468121 +TestStatAlleleFreq : loci=1000, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 61.2199239731 +TestStatAlleleFreq : 0.287755966187, 4.98926496506, 3.02955412865, 6.11895489693, 71.2390468121, 61.2199239731 +TestStatAlleleFreq : End of test TestStatAlleleFreq +TestStatAlleleFreq : Host: bp9 (Linux, x86_64, x86_64) +TestStatAlleleFreq : Time: Wed May 25 14:33:25 2011 +TestStatAlleleFreq : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatAlleleFreq : simuPOP: 1.0.6svn (rev 4182, module binary, optimized, 4 threads) +TestStatAlleleFreq : Test: Stat AlleleFreq, results are time (not processor time) to apply operator for 30 times. +TestStatAlleleFreq : loci=100, size=10000: 0.307837963104 +TestStatAlleleFreq : loci=100, size=100000: 3.0087928772 +TestStatAlleleFreq : loci=100, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 3.05822300911 +TestStatAlleleFreq : loci=1000, size=10000: 3.17401409149 +TestStatAlleleFreq : loci=1000, size=100000: 36.7387290001 +TestStatAlleleFreq : loci=1000, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 31.7028801441 +TestStatAlleleFreq : 0.307837963104, 3.0087928772, 3.05822300911, 3.17401409149, 36.7387290001, 31.7028801441 +TestStatAlleleFreq : End of test TestStatAlleleFreq +TestStatNumOfMales : Host: bp9 (Linux, x86_64, x86_64) +TestStatNumOfMales : Time: Thu May 26 09:54:34 2011 +TestStatNumOfMales : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatNumOfMales : simuPOP: 1.0.6svn (rev 4182, module short, optimized, 1 threads) +TestStatNumOfMales : Test: Stat NumOfMales, results are time (not processor time) to apply operator for 5000 times. +TestStatNumOfMales : size=100000: 16.8653411865 +TestStatNumOfMales : size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 17.209662199 +TestStatNumOfMales : 16.8653411865, 17.209662199 +TestStatNumOfMales : End of test TestStatNumOfMales +TestStatNumOfMales : Host: bp9 (Linux, x86_64, x86_64) +TestStatNumOfMales : Time: Thu May 26 09:55:10 2011 +TestStatNumOfMales : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatNumOfMales : simuPOP: 1.0.6svn (rev 4182, module long, optimized, 1 threads) +TestStatNumOfMales : Test: Stat NumOfMales, results are time (not processor time) to apply operator for 5000 times. +TestStatNumOfMales : size=100000: 16.4387378693 +TestStatNumOfMales : size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 17.3230619431 +TestStatNumOfMales : 16.4387378693, 17.3230619431 +TestStatNumOfMales : End of test TestStatNumOfMales +TestStatNumOfMales : Host: bp9 (Linux, x86_64, x86_64) +TestStatNumOfMales : Time: Thu May 26 09:55:46 2011 +TestStatNumOfMales : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatNumOfMales : simuPOP: 1.0.6svn (rev 4182, module binary, optimized, 1 threads) +TestStatNumOfMales : Test: Stat NumOfMales, results are time (not processor time) to apply operator for 5000 times. +TestStatNumOfMales : size=100000: 17.4795110226 +TestStatNumOfMales : size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 17.6907908916 +TestStatNumOfMales : 17.4795110226, 17.6907908916 +TestStatNumOfMales : End of test TestStatNumOfMales +TestStatNumOfMales : Host: bp9 (Linux, x86_64, x86_64) +TestStatNumOfMales : Time: Thu May 26 09:56:24 2011 +TestStatNumOfMales : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatNumOfMales : simuPOP: 1.0.6svn (rev 4182, module short, optimized, 4 threads) +TestStatNumOfMales : Test: Stat NumOfMales, results are time (not processor time) to apply operator for 5000 times. +TestStatNumOfMales : size=100000: 9.28081488609 +TestStatNumOfMales : size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 10.3006439209 +TestStatNumOfMales : 9.28081488609, 10.3006439209 +TestStatNumOfMales : End of test TestStatNumOfMales +TestStatNumOfMales : Host: bp9 (Linux, x86_64, x86_64) +TestStatNumOfMales : Time: Thu May 26 09:56:47 2011 +TestStatNumOfMales : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatNumOfMales : simuPOP: 1.0.6svn (rev 4182, module long, optimized, 4 threads) +TestStatNumOfMales : Test: Stat NumOfMales, results are time (not processor time) to apply operator for 5000 times. +TestStatNumOfMales : size=100000: 9.30121707916 +TestStatNumOfMales : size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 10.2057070732 +TestStatNumOfMales : 9.30121707916, 10.2057070732 +TestStatNumOfMales : End of test TestStatNumOfMales +TestStatNumOfMales : Host: bp9 (Linux, x86_64, x86_64) +TestStatNumOfMales : Time: Thu May 26 09:57:09 2011 +TestStatNumOfMales : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatNumOfMales : simuPOP: 1.0.6svn (rev 4182, module binary, optimized, 4 threads) +TestStatNumOfMales : Test: Stat NumOfMales, results are time (not processor time) to apply operator for 5000 times. +TestStatNumOfMales : size=100000: 10.1437051296 +TestStatNumOfMales : size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 10.6698708534 +TestStatNumOfMales : 10.1437051296, 10.6698708534 +TestStatNumOfMales : End of test TestStatNumOfMales +TestStatNumOfAffected : Host: bp9 (Linux, x86_64, x86_64) +TestStatNumOfAffected : Time: Thu May 26 09:57:33 2011 +TestStatNumOfAffected : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatNumOfAffected : simuPOP: 1.0.6svn (rev 4182, module short, optimized, 1 threads) +TestStatNumOfAffected : Test: Stat NumOfAffected, results are time (not processor time) to apply operator for 5000 times. +TestStatNumOfAffected : size=100000: 18.7245531082 +TestStatNumOfAffected : size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 19.554336071 +TestStatNumOfAffected : 18.7245531082, 19.554336071 +TestStatNumOfAffected : End of test TestStatNumOfAffected +TestStatNumOfAffected : Host: bp9 (Linux, x86_64, x86_64) +TestStatNumOfAffected : Time: Thu May 26 09:58:14 2011 +TestStatNumOfAffected : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatNumOfAffected : simuPOP: 1.0.6svn (rev 4182, module long, optimized, 1 threads) +TestStatNumOfAffected : Test: Stat NumOfAffected, results are time (not processor time) to apply operator for 5000 times. +TestStatNumOfAffected : size=100000: 18.9747388363 +TestStatNumOfAffected : size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 19.5944628716 +TestStatNumOfAffected : 18.9747388363, 19.5944628716 +TestStatNumOfAffected : End of test TestStatNumOfAffected +TestStatNumOfAffected : Host: bp9 (Linux, x86_64, x86_64) +TestStatNumOfAffected : Time: Thu May 26 09:58:54 2011 +TestStatNumOfAffected : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatNumOfAffected : simuPOP: 1.0.6svn (rev 4182, module binary, optimized, 1 threads) +TestStatNumOfAffected : Test: Stat NumOfAffected, results are time (not processor time) to apply operator for 5000 times. +TestStatNumOfAffected : size=100000: 19.5599150658 +TestStatNumOfAffected : size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 20.22062397 +TestStatNumOfAffected : 19.5599150658, 20.22062397 +TestStatNumOfAffected : End of test TestStatNumOfAffected +TestStatNumOfAffected : Host: bp9 (Linux, x86_64, x86_64) +TestStatNumOfAffected : Time: Thu May 26 09:59:37 2011 +TestStatNumOfAffected : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatNumOfAffected : simuPOP: 1.0.6svn (rev 4182, module short, optimized, 4 threads) +TestStatNumOfAffected : Test: Stat NumOfAffected, results are time (not processor time) to apply operator for 5000 times. +TestStatNumOfAffected : size=100000: 9.38937807083 +TestStatNumOfAffected : size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 10.0877468586 +TestStatNumOfAffected : 9.38937807083, 10.0877468586 +TestStatNumOfAffected : End of test TestStatNumOfAffected +TestStatNumOfAffected : Host: bp9 (Linux, x86_64, x86_64) +TestStatNumOfAffected : Time: Thu May 26 09:59:59 2011 +TestStatNumOfAffected : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatNumOfAffected : simuPOP: 1.0.6svn (rev 4182, module long, optimized, 4 threads) +TestStatNumOfAffected : Test: Stat NumOfAffected, results are time (not processor time) to apply operator for 5000 times. +TestStatNumOfAffected : size=100000: 9.50907111168 +TestStatNumOfAffected : size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 10.3536448479 +TestStatNumOfAffected : 9.50907111168, 10.3536448479 +TestStatNumOfAffected : End of test TestStatNumOfAffected +TestStatNumOfAffected : Host: bp9 (Linux, x86_64, x86_64) +TestStatNumOfAffected : Time: Thu May 26 10:00:21 2011 +TestStatNumOfAffected : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatNumOfAffected : simuPOP: 1.0.6svn (rev 4182, module binary, optimized, 4 threads) +TestStatNumOfAffected : Test: Stat NumOfAffected, results are time (not processor time) to apply operator for 5000 times. +TestStatNumOfAffected : size=100000: 10.2223381996 +TestStatNumOfAffected : size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 11.0147790909 +TestStatNumOfAffected : 10.2223381996, 11.0147790909 +TestStatNumOfAffected : End of test TestStatNumOfAffected +TestStatHaploFreq : Host: bp9 (Linux, x86_64, x86_64) +TestStatHaploFreq : Time: Thu May 26 10:20:21 2011 +TestStatHaploFreq : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatHaploFreq : simuPOP: 1.0.6svn (rev 4182, module short, optimized, 1 threads) +TestStatHaploFreq : Test: Stat HaploFreq, results are time (not processor time) to apply operator for 200 times. +TestStatHaploFreq : loci=100, size=10000: 1.23293209076 +TestStatHaploFreq : loci=100, size=100000: 12.2021050453 +TestStatHaploFreq : loci=100, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 11.865776062 +TestStatHaploFreq : loci=1000, size=10000: 1.29735088348 +TestStatHaploFreq : loci=1000, size=100000: 21.6016001701 +TestStatHaploFreq : loci=1000, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 15.2668449879 +TestStatHaploFreq : 1.23293209076, 12.2021050453, 11.865776062, 1.29735088348, 21.6016001701, 15.2668449879 +TestStatHaploFreq : End of test TestStatHaploFreq +TestStatHaploFreq : Host: bp9 (Linux, x86_64, x86_64) +TestStatHaploFreq : Time: Thu May 26 10:21:45 2011 +TestStatHaploFreq : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatHaploFreq : simuPOP: 1.0.6svn (rev 4182, module long, optimized, 1 threads) +TestStatHaploFreq : Test: Stat HaploFreq, results are time (not processor time) to apply operator for 200 times. +TestStatHaploFreq : loci=100, size=10000: 1.41531896591 +TestStatHaploFreq : loci=100, size=100000: 23.2550559044 +TestStatHaploFreq : loci=100, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 17.4902069569 +TestStatHaploFreq : loci=1000, size=10000: 1.51551508904 +TestStatHaploFreq : loci=1000, size=100000: 25.3949120045 +TestStatHaploFreq : loci=1000, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 16.8971569538 +TestStatHaploFreq : 1.41531896591, 23.2550559044, 17.4902069569, 1.51551508904, 25.3949120045, 16.8971569538 +TestStatHaploFreq : End of test TestStatHaploFreq +TestStatHaploFreq : Host: bp9 (Linux, x86_64, x86_64) +TestStatHaploFreq : Time: Thu May 26 10:23:31 2011 +TestStatHaploFreq : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatHaploFreq : simuPOP: 1.0.6svn (rev 4182, module binary, optimized, 1 threads) +TestStatHaploFreq : Test: Stat HaploFreq, results are time (not processor time) to apply operator for 200 times. +TestStatHaploFreq : loci=100, size=10000: 1.69325518608 +TestStatHaploFreq : loci=100, size=100000: 17.1936631203 +TestStatHaploFreq : loci=100, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 18.6411919594 +TestStatHaploFreq : loci=1000, size=10000: 1.70309305191 +TestStatHaploFreq : loci=1000, size=100000: 17.4465510845 +TestStatHaploFreq : loci=1000, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 18.0900690556 +TestStatHaploFreq : 1.69325518608, 17.1936631203, 18.6411919594, 1.70309305191, 17.4465510845, 18.0900690556 +TestStatHaploFreq : End of test TestStatHaploFreq +TestStatHaploFreq : Host: bp9 (Linux, x86_64, x86_64) +TestStatHaploFreq : Time: Thu May 26 10:25:12 2011 +TestStatHaploFreq : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatHaploFreq : simuPOP: 1.0.6svn (rev 4182, module short, optimized, 4 threads) +TestStatHaploFreq : Test: Stat HaploFreq, results are time (not processor time) to apply operator for 200 times. +TestStatHaploFreq : loci=100, size=10000: 0.566158056259 +TestStatHaploFreq : loci=100, size=100000: 5.73171782494 +TestStatHaploFreq : loci=100, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 5.61322593689 +TestStatHaploFreq : loci=1000, size=10000: 0.713933944702 +TestStatHaploFreq : loci=1000, size=100000: 9.37162017822 +TestStatHaploFreq : loci=1000, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 7.79208993912 +TestStatHaploFreq : 0.566158056259, 5.73171782494, 5.61322593689, 0.713933944702, 9.37162017822, 7.79208993912 +TestStatHaploFreq : End of test TestStatHaploFreq +TestStatHaploFreq : Host: bp9 (Linux, x86_64, x86_64) +TestStatHaploFreq : Time: Thu May 26 10:26:02 2011 +TestStatHaploFreq : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatHaploFreq : simuPOP: 1.0.6svn (rev 4182, module long, optimized, 4 threads) +TestStatHaploFreq : Test: Stat HaploFreq, results are time (not processor time) to apply operator for 200 times. +TestStatHaploFreq : loci=100, size=10000: 0.613075971603 +TestStatHaploFreq : loci=100, size=100000: 9.36668801308 +TestStatHaploFreq : loci=100, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 7.58966112137 +TestStatHaploFreq : loci=1000, size=10000: 0.720818042755 +TestStatHaploFreq : loci=1000, size=100000: 9.74222493172 +TestStatHaploFreq : loci=1000, size=[10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]: 7.8867251873 +TestStatHaploFreq : 0.613075971603, 9.36668801308, 7.58966112137, 0.720818042755, 9.74222493172, 7.8867251873 +TestStatHaploFreq : End of test TestStatHaploFreq +TestStatHaploFreq : Host: bp9 (Linux, x86_64, x86_64) +TestStatHaploFreq : Time: Thu May 26 10:26:57 2011 +TestStatHaploFreq : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestStatHaploFreq : simuPOP: 1.0.6svn (rev 4182, module binary, optimized, 4 threads) +TestStatHaploFreq : Test: Stat HaploFreq, results are time (not processor time) to apply operator for 200 times. +TestStatHaploFreq : loci=100, size=10000: 0.768512964249 +TestStatHaploFreq : loci=10... [truncated message content] |
From: <si...@us...> - 2011-06-29 21:34:52
|
Revision: 4242 http://simupop.svn.sourceforge.net/simupop/?rev=4242&view=rev Author: simupop Date: 2011-06-29 21:34:43 +0000 (Wed, 29 Jun 2011) Log Message: ----------- Merge the openMP branch to trunk Modified Paths: -------------- trunk/setup.py trunk/src/customizedTypes.c trunk/src/individual.h trunk/src/initializer.cpp trunk/src/mating.cpp trunk/src/mating.h trunk/src/migrator.cpp trunk/src/penetrance.cpp trunk/src/penetrance.h trunk/src/population.cpp trunk/src/selector.cpp trunk/src/selector.h trunk/src/stator.cpp trunk/src/transmitter.cpp trunk/src/transmitter.h trunk/src/utility.cpp trunk/src/utility.h trunk/test/performance.csv trunk/test/performance.log trunk/test/performance.py trunk/test/test_03_operator.py Property Changed: ---------------- trunk/ Property changes on: trunk ___________________________________________________________________ Modified: svn:mergeinfo - /branches/openMP:3999-4205 + /branches/openMP:3999-4241 Modified: trunk/setup.py =================================================================== --- trunk/setup.py 2011-06-29 21:13:49 UTC (rev 4241) +++ trunk/setup.py 2011-06-29 21:34:43 UTC (rev 4242) @@ -41,13 +41,22 @@ """ import os, sys, platform, shutil, glob, re, tempfile, subprocess import distutils.sysconfig +USE_DISTRIBUTE = False +try: + from distribute_setup import use_setuptools + use_setuptools() + from setuptools import setup, find_packages, Extension + USE_DISTRIBUTE = True +except ImportError: + from distutils.core import setup, Extension + print("fail to import distribute/setuptools, build the program with distutils") if sys.version_info[0] <= 2 and sys.version_info[1] <= 4: print("simuPOP supports Python version 2.5 or higher, including Python 3.x. Please upgrade your Python installation and try again.") sys.exit(1) # Change this to False if you would like to compile simuPOP without openMP support -USE_OPENMP = True +USE_OPENMP = False if os.name == 'nt': VS9PATH = os.environ.get('VS90COMNTOOLS') @@ -113,7 +122,6 @@ # ############################################################################ -from distutils.core import setup, Extension from distutils.sysconfig import get_config_var try: from distutils.command.build_py import build_py_2to3 as build_py @@ -468,7 +476,7 @@ else: res['libraries'] = ['stdc++', 'z'] if USE_OPENMP: - res['libraries'].append('iomp5' if USE_ICC else 'gomp') + res['libraries'].append(['iomp5','tbb'] if USE_ICC else 'gomp') res['libraries'].extend(boost_lib_names) res['include_dirs'] = ['.', 'gsl', boost_inc_path] res['library_dirs'] = ['build'] @@ -506,6 +514,10 @@ # this one disables a lot of warnings about VC Checked iterators. #('_SCL_SECURE_NO_WARNINGS', None) ]) + else: + if not USE_ICC: + if USE_OPENMP: + res['define_macros'].append(('_GLIBCXX_PARALLEL', None)) res['undef_macros'] = [] return res @@ -515,6 +527,8 @@ # Build extensions # ############################################################################ +import filecmp + if os.name == 'nt': # Windows # copy platform dependent dll files machine = platform.uname()[4].lower() @@ -571,8 +585,8 @@ os.mkdir('build/%s' % modu) for src in SOURCE_FILES: mod_src = 'build/%s/%s' % (modu, src) - shutil.copy('src/' + src, mod_src) - copied_files.append(mod_src) + if not os.path.isfile(mod_src) or not filecmp.cmp(mod_src,'src/'+src): + shutil.copy('src/'+src, mod_src) # build # For module simuPOP.gsl EXT_MODULES = [ @@ -595,6 +609,13 @@ undef_macros = info['undef_macros'], ) ) + if USE_DISTRIBUTE : + setup_params = dict(packages = find_packages(), include_package_data = True, + exclude_package_data = {'':['README.txt']}, zip_safe = False, + install_requires = ['distribute']) + else : + setup_params = dict(packages = ['simuPOP']) + setup( name = "simuPOP", version = SIMUPOP_VER, @@ -621,7 +642,6 @@ ], platforms = ['all'], # - packages = ['simuPOP'], package_dir = {'simuPOP': 'src'}, package_data = {'simuPOP': PACKAGE_DATA}, py_modules = [ @@ -633,10 +653,9 @@ 'simuPOP.sandbox', ] + ['simuPOP.simuPOP_%s' % x for x in MODULES], ext_modules = EXT_MODULES, - cmdclass = {'build_py': build_py} + cmdclass = {'build_py': build_py}, + **setup_params ) - # remove copied files - for file in copied_files: - os.remove(file) + Modified: trunk/src/customizedTypes.c =================================================================== --- trunk/src/customizedTypes.c 2011-06-29 21:13:49 UTC (rev 4241) +++ trunk/src/customizedTypes.c 2011-06-29 21:34:43 UTC (rev 4242) @@ -1395,11 +1395,17 @@ } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; - +#if PY_VERSION_HEX >= 0x03020000 + if (PySlice_GetIndicesEx((PyObject*)item, Py_SIZE(self), + &start, &stop, &step, &slicelength) < 0) { + return NULL; + } +#else if (PySlice_GetIndicesEx((PySliceObject*)item, Py_SIZE(self), &start, &stop, &step, &slicelength) < 0) { return NULL; } +#endif if (step > 1) { PyErr_SetString(PyExc_TypeError, "Slice with step > 1 is not supported for type simuPOP.array"); @@ -1448,11 +1454,19 @@ return setarrayitem(self, i, value); } else if (PySlice_Check(item)) { +#if PY_VERSION_HEX >= 0x03020000 + if (PySlice_GetIndicesEx((PyObject *)item, + Py_SIZE(self), &start, &stop, + &step, &slicelength) < 0) { + return -1; + } +#else if (PySlice_GetIndicesEx((PySliceObject *)item, Py_SIZE(self), &start, &stop, &step, &slicelength) < 0) { return -1; } +#endif } else { PyErr_SetString(PyExc_TypeError, Modified: trunk/src/individual.h =================================================================== --- trunk/src/individual.h 2011-06-29 21:13:49 UTC (rev 4241) +++ trunk/src/individual.h 2011-06-29 21:34:43 UTC (rev 4242) @@ -515,7 +515,7 @@ indCompare(const vectoru & idx) : m_fields(idx) {} - bool operator()(const Individual & lhs, const Individual & rhs) + bool operator()(const Individual & lhs, const Individual & rhs) const { for (size_t i = 0; i < m_fields.size(); ++i) { double v1 = lhs.info(m_fields[i]); Modified: trunk/src/initializer.cpp =================================================================== --- trunk/src/initializer.cpp 2011-06-29 21:13:49 UTC (rev 4241) +++ trunk/src/initializer.cpp 2011-06-29 21:34:43 UTC (rev 4242) @@ -70,12 +70,14 @@ ind->setSex(m_sex[idx % sexSz] == 1 ? MALE : FEMALE); else { if (numThreads() > 1) { +#ifdef _OPENMP #pragma omp parallel private(ind) { ind = pop.indIterator(sp->subPop(), omp_get_thread_num()); for (; ind.valid(); ++ind) ind->setSex(ws.draw() == 0 ? MALE : FEMALE); } +#endif } else for (; ind.valid(); ++ind) ind->setSex(ws.draw() == 0 ? MALE : FEMALE); Modified: trunk/src/mating.cpp =================================================================== --- trunk/src/mating.cpp 2011-06-29 21:13:49 UTC (rev 4241) +++ trunk/src/mating.cpp 2011-06-29 21:34:43 UTC (rev 4242) @@ -627,7 +627,7 @@ DBG_ASSERT(m_ind.valid(), RuntimeError, "No valid individual if found.") } return ParentChooser::IndividualPair(&*m_ind++, NULL); - }else { + } else { if (m_curInd == m_index.size()) m_curInd = 0; @@ -1270,7 +1270,6 @@ // scrtach will have the right structure. if (!prepareScratchPop(pop, scratch)) return false; - for (size_t sp = 0; sp < static_cast<size_t>(pop.numSubPop()); ++sp) if (!mateSubPop(pop, scratch, sp, scratch.rawIndBegin(sp), scratch.rawIndEnd(sp))) return false; @@ -1431,46 +1430,64 @@ for (; it != it_end; ++it) idMap[toID(it->info(idIdx))] = &*it; - it = scratch.rawIndBegin(); - it_end = scratch.rawIndEnd(); - for (size_t i = 0; it != it_end; ++it, ++i) { - const Individual & pedInd = m_ped.individual(static_cast<double>(i)); + // initialize operator before entering parallel region in order to avoid race condition + opList::const_iterator iop = m_transmitters.begin(); + opList::const_iterator iopEnd = m_transmitters.end(); + for (; iop != iopEnd; ++iop) + (*iop)->initializeIfNeeded(*pop.rawIndBegin()); - size_t my_id = toID(pedInd.info(m_ped.idIdx())); - size_t father_id = m_ped.fatherOf(my_id); - size_t mother_id = m_ped.motherOf(my_id); - Individual * dad = NULL; - Individual * mom = NULL; +#pragma omp parallel private(it, it_end) if (numThreads() > 1 && parallelizable()) + { +#ifdef _OPENMP + size_t id = omp_get_thread_num(); + size_t offPopSize = scratch.rawIndEnd() - scratch.rawIndBegin(); + it = scratch.rawIndBegin() + id * (offPopSize / numThreads()); + it_end = id == numThreads() - 1 ? scratch.rawIndEnd() : it + (offPopSize / numThreads()); + size_t i = id * (offPopSize / numThreads()); +#else + it = scratch.rawIndBegin(); + it_end = scratch.rawIndEnd(); + size_t i = 0; +#endif + for (; it != it_end; ++it, ++i) { + const Individual & pedInd = m_ped.individual(static_cast<double>(i)); - if (father_id) { - IdMap::iterator dad_it = idMap.find(father_id); - DBG_FAILIF(dad_it == idMap.end(), RuntimeError, - "Could not locate individual with ID " + toStr(father_id)); - dad = &*(dad_it->second); - } - if (mother_id) { - IdMap::iterator mom_it = idMap.find(mother_id); - DBG_FAILIF(mom_it == idMap.end(), RuntimeError, - "Could not locate individual with ID " + toStr(mother_id)); - mom = &*(mom_it->second); - } - DBG_DO(DBG_MATING, cerr << "Choosing parents " << father_id << " and " - << mother_id << " for offspring " << my_id << endl); + size_t my_id = toID(pedInd.info(m_ped.idIdx())); + size_t father_id = m_ped.fatherOf(my_id); + size_t mother_id = m_ped.motherOf(my_id); + Individual * dad = NULL; + Individual * mom = NULL; - // copy sex - it->setSex(pedInd.sex()); - // copy id - it->setInfo(static_cast<double>(my_id), m_idField); - // - opList::const_iterator iop = m_transmitters.begin(); - opList::const_iterator iopEnd = m_transmitters.end(); - for (; iop != iopEnd; ++iop) { - if ((*iop)->isActive(pop.rep(), pop.gen())) - (*iop)->applyDuringMating(pop, scratch, it, dad, mom); + if (father_id) { + IdMap::iterator dad_it = idMap.find(father_id); + DBG_FAILIF(dad_it == idMap.end(), RuntimeError, + "Could not locate individual with ID " + toStr(father_id)); + dad = &*(dad_it->second); + } + if (mother_id) { + IdMap::iterator mom_it = idMap.find(mother_id); + DBG_FAILIF(mom_it == idMap.end(), RuntimeError, + "Could not locate individual with ID " + toStr(mother_id)); + mom = &*(mom_it->second); + } + DBG_DO(DBG_MATING, cerr << "Choosing parents " << father_id << " and " + << mother_id << " for offspring " << my_id << endl); + + // copy sex + it->setSex(pedInd.sex()); + // copy id + it->setInfo(static_cast<double>(my_id), m_idField); + // + opList::const_iterator iop = m_transmitters.begin(); + opList::const_iterator iopEnd = m_transmitters.end(); + for (; iop != iopEnd; ++iop) { + if ((*iop)->isActive(pop.rep(), pop.gen())) + (*iop)->applyDuringMating(pop, scratch, it, dad, mom); + } + // copy individual ID again, just to make sure that even if during mating operators + // changes ID, pedigree mating could proceed normally. + it->setInfo(static_cast<double>(my_id), m_idField); } - // copy individual ID again, just to make sure that even if during mating operators - // changes ID, pedigree mating could proceed normally. - it->setInfo(static_cast<double>(my_id), m_idField); } const_cast<Pedigree &>(m_ped).useAncestralGen(oldGen); submitScratch(pop, scratch); @@ -1492,6 +1509,19 @@ } +bool PedigreeMating::parallelizable() const +{ + opList::const_iterator iop = m_transmitters.begin(); + opList::const_iterator iopEnd = m_transmitters.end(); + + for (; iop != iopEnd; ++iop) { + if (!(*iop)->parallelizable()) + return false; + } + return true; +} + + HeteroMating::HeteroMating(const vectormating & matingSchemes, const uintListFunc & subPopSize, bool shuffleOffspring) Modified: trunk/src/mating.h =================================================================== --- trunk/src/mating.h 2011-06-29 21:13:49 UTC (rev 4241) +++ trunk/src/mating.h 2011-06-29 21:34:43 UTC (rev 4242) @@ -1293,12 +1293,14 @@ return "<simuPOP.CombinedParentsChooser> chooses parents using two parent choosers"; } + /// CPPONLY virtual bool parallelizable() const { return m_fatherChooser->parallelizable() && m_motherChooser->parallelizable(); } + /// CPPONLY void initialize(Population & pop, size_t sp); @@ -1639,6 +1641,8 @@ */ virtual bool mate(Population & pop, Population & scratch); + bool parallelizable() const; + private: const Pedigree & m_ped; Modified: trunk/src/migrator.cpp =================================================================== --- trunk/src/migrator.cpp 2011-06-29 21:13:49 UTC (rev 4241) +++ trunk/src/migrator.cpp 2011-06-29 21:34:43 UTC (rev 4242) @@ -70,9 +70,24 @@ for (size_t sp = 0; sp < pop.numSubPop(); ++sp) { RawIndIterator it = pop.rawIndBegin(sp); RawIndIterator it_end = pop.rawIndEnd(sp); - for (; it != it_end; ++it) - it->setInfo(static_cast<double>(sp), info); + if (numThreads() > 1) { +#ifdef _OPENMP + size_t popSize = it_end - it; +# pragma omp parallel firstprivate(it, it_end) + { + size_t id = omp_get_thread_num(); + it = it + id * (popSize / numThreads()); + it_end = id == numThreads() - 1 ? it_end : it + popSize / numThreads(); + for (; it != it_end; ++it) + it->setInfo(static_cast<double>(sp), info); + } +#endif + } else { + for (; it != it_end; ++it) + it->setInfo(static_cast<double>(sp), info); + } } + } DBG_FAILIF(pop.hasActivatedVirtualSubPop(), RuntimeError, @@ -150,26 +165,51 @@ // restore information fields set by user so that other individuals // can stay at their original subpopulation. if (!oldInfo.empty()) { - for (IndIterator ind = pop.indIterator(spFrom); ind.valid(); ++ind) - ind->setInfo(oldInfo[&*ind - &*pop.rawIndBegin()], info); + if (numThreads() > 1) { +#ifdef _OPENMP +# pragma omp parallel + { + for (IndIterator ind = pop.indIterator(spFrom, omp_get_thread_num()); ind.valid(); ++ind) + ind->setInfo(oldInfo[&*ind - &*pop.rawIndBegin()], info); + } +#endif + } else { + for (IndIterator ind = pop.indIterator(spFrom); ind.valid(); ++ind) + ind->setInfo(oldInfo[&*ind - &*pop.rawIndBegin()], info); + } } } else if (m_mode == BY_PROBABILITY) { WeightedSampler ws(migrationRate[from]); // for each individual, migrate according to migration probability - for (IndIterator ind = pop.indIterator(spFrom); ind.valid(); ++ind) { - //toIndex = getRNG().randIntByFreq( rateSize, &migrationRate[from][0] ) ; - toIndex = ws.draw(); + if (numThreads() > 1) { +#ifdef _OPENMP +# pragma omp parallel private(toIndex) + { + for (IndIterator ind = pop.indIterator(spFrom, omp_get_thread_num()); ind.valid(); ++ind) { + toIndex = ws.draw(); + DBG_ASSERT(toIndex < migrationRate[from].size(), ValueError, + "Return index out of range."); + if (toIndex < toSize && toSubPops[toIndex] != spFrom) + ind->setInfo(static_cast<double>(toSubPops[toIndex]), info); + } + } +#endif + } else { + for (IndIterator ind = pop.indIterator(spFrom); ind.valid(); ++ind) { + //toIndex = getRNG().randIntByFreq( rateSize, &migrationRate[from][0] ) ; + toIndex = ws.draw(); - DBG_ASSERT(toIndex < migrationRate[from].size(), ValueError, - "Return index out of range."); + DBG_ASSERT(toIndex < migrationRate[from].size(), ValueError, + "Return index out of range."); - // rateSize == toSize (no i->i addition) - // toIndex < toSize - // rateSize = toSize + 1, ignore i->1 (last one) - // toIndex < toSize - if (toIndex < toSize && toSubPops[toIndex] != spFrom) - ind->setInfo(static_cast<double>(toSubPops[toIndex]), info); + // rateSize == toSize (no i->i addition) + // toIndex < toSize + // rateSize = toSize + 1, ignore i->1 (last one) + // toIndex < toSize + if (toIndex < toSize && toSubPops[toIndex] != spFrom) + ind->setInfo(static_cast<double>(toSubPops[toIndex]), info); + } } } else { // 2nd, or 3rd method Modified: trunk/src/penetrance.cpp =================================================================== --- trunk/src/penetrance.cpp 2011-06-29 21:13:49 UTC (rev 4241) +++ trunk/src/penetrance.cpp 2011-06-29 21:34:43 UTC (rev 4242) @@ -60,17 +60,37 @@ if (sp->isVirtual()) pop.activateVirtualSubPop(*sp); - IndIterator ind = pop.indIterator(sp->subPop()); - for (; ind.valid(); ++ind) { - double p = penet(&pop, &*ind); + if (numThreads() > 1 && parallelizable()) { +#pragma omp parallel + { +#ifdef _OPENMP + IndIterator ind = pop.indIterator(sp->subPop(), omp_get_thread_num()); + for (; ind.valid(); ++ind) { + double p = penet(&pop, &*ind); - if (savePene) - ind->setInfo(p, infoIdx); + if (savePene) + ind->setInfo(p, infoIdx); - if (getRNG().randUniform() < p) - ind->setAffected(true); - else - ind->setAffected(false); + if (getRNG().randUniform() < p) + ind->setAffected(true); + else + ind->setAffected(false); + } +#endif + } + } else { + IndIterator ind = pop.indIterator(sp->subPop()); + for (; ind.valid(); ++ind) { + double p = penet(&pop, &*ind); + + if (savePene) + ind->setInfo(p, infoIdx); + + if (getRNG().randUniform() < p) + ind->setAffected(true); + else + ind->setAffected(false); + } } if (sp->isVirtual()) pop.deactivateVirtualSubPop(sp->subPop()); Modified: trunk/src/penetrance.h =================================================================== --- trunk/src/penetrance.h 2011-06-29 21:13:49 UTC (rev 4241) +++ trunk/src/penetrance.h 2011-06-29 21:34:43 UTC (rev 4242) @@ -191,6 +191,13 @@ } + /// CPPONLY + bool parallelizable() const + { + return true; + } + + private: /// one locus const lociList m_loci; @@ -261,6 +268,13 @@ /// HIDDEN string describe(bool format = true) const; + /// CPPONLY + bool parallelizable() const + { + return true; + } + + private: /// one locus const lociList m_loci; @@ -333,6 +347,13 @@ } + /// CPPONLY + bool parallelizable() const + { + return true; + } + + private: /// a list of peneOps const opList m_peneOps; @@ -395,6 +416,13 @@ } + /// CPPONLY + bool parallelizable() const + { + return false; + } + + private: /// user supplied python function const pyFunc m_func; Modified: trunk/src/population.cpp =================================================================== --- trunk/src/population.cpp 2011-06-29 21:13:49 UTC (rev 4241) +++ trunk/src/population.cpp 2011-06-29 21:34:43 UTC (rev 4242) @@ -787,7 +787,7 @@ for (size_t i = 0; i < infoFields.size(); ++i) fields[i] = infoIdx(infoFields[i]); for (size_t sp = 0; sp < numSubPop(); ++sp) - std::sort(rawIndBegin(sp), rawIndEnd(sp), indCompare(fields)); + parallelSort(rawIndBegin(sp), rawIndEnd(sp), indCompare(fields)); setIndOrdered(false); } @@ -798,10 +798,9 @@ "This operation is not allowed when there is an activated virtual subpopulation"); size_t info = infoIdx(field); - DBG_DO(DBG_POPULATION, cerr << "Sorting individuals." << endl); // sort individuals first - std::sort(rawIndBegin(), rawIndEnd(), indCompare(info)); + parallelSort(rawIndBegin(), rawIndEnd(), indCompare(info)); setIndOrdered(false); // sort individuals first Modified: trunk/src/selector.cpp =================================================================== --- trunk/src/selector.cpp 2011-06-29 21:13:49 UTC (rev 4241) +++ trunk/src/selector.cpp 2011-06-29 21:34:43 UTC (rev 4242) @@ -42,9 +42,21 @@ for (; sp != spEnd; ++sp) { if (sp->isVirtual()) pop.activateVirtualSubPop(*sp); - IndIterator ind = pop.indIterator(sp->subPop()); - for (; ind.valid(); ++ind) - ind->setInfo(indFitness(pop, &*ind), fit_id); + if (numThreads() > 1 && parallelizable()) { +#pragma omp parallel + { +#ifdef _OPENMP + IndIterator ind = pop.indIterator(sp->subPop(), omp_get_thread_num()); + for (; ind.valid(); ++ind) + ind->setInfo(indFitness(pop, &*ind), fit_id); +#endif + } + + } else { + IndIterator ind = pop.indIterator(sp->subPop()); + for (; ind.valid(); ++ind) + ind->setInfo(indFitness(pop, &*ind), fit_id); + } if (sp->isVirtual()) pop.deactivateVirtualSubPop(sp->subPop()); } @@ -253,3 +265,5 @@ } + + Modified: trunk/src/selector.h =================================================================== --- trunk/src/selector.h 2011-06-29 21:13:49 UTC (rev 4241) +++ trunk/src/selector.h 2011-06-29 21:34:43 UTC (rev 4242) @@ -225,6 +225,13 @@ } + /// CPPONLY + bool parallelizable() const + { + return true; + } + + private: /// const lociList m_loci; @@ -297,6 +304,13 @@ } + /// CPPONLY + bool parallelizable() const + { + return true; + } + + private: /// one locus const lociList m_loci; @@ -366,6 +380,13 @@ } + /// CPPONLY + bool parallelizable() const + { + return true; + } + + private: /// a list of selectors const opList m_selectors; @@ -425,6 +446,13 @@ } + /// CPPONLY + bool parallelizable() const + { + return false; + } + + private: /// user supplied python function const pyFunc m_func; Modified: trunk/src/stator.cpp =================================================================== --- trunk/src/stator.cpp 2011-06-29 21:13:49 UTC (rev 4241) +++ trunk/src/stator.cpp 2011-06-29 21:34:43 UTC (rev 4242) @@ -2462,32 +2462,15 @@ double diffCnt = 0; int numComparison = 0; - size_t size = end - begin; - size_t nThreads = numThreads(); - - if (nThreads > 1) + if (numThreads() > 1) { #ifdef _OPENMP + size_t size = end - begin; # pragma omp parallel reduction(+ : diffCnt, numComparison) - { - size_t id = omp_get_thread_num(); - HAPLOLIST::const_iterator it = begin + id * (size / nThreads); - HAPLOLIST::const_iterator itEnd = id == nThreads - 1 ? end : it + (size / nThreads); - for (; it != itEnd; ++it) { - HAPLOLIST::const_iterator it1 = it; - for (++it1; it1 != end; ++it1) { - const vectora & seq1 = *it; - const vectora & seq2 = *it1; - size_t sz = seq1.size(); - for (size_t i = 0; i < sz; ++i) - diffCnt += seq1[i] != seq2[i]; - ++numComparison; - } - } - } -#endif - else { - HAPLOLIST::const_iterator it = begin; - for (; it != end; ++it) { + { + size_t id = omp_get_thread_num(); + HAPLOLIST::const_iterator it = begin + id * (size / numThreads()); + HAPLOLIST::const_iterator itEnd = id == numThreads() - 1 ? end : it + (size / numThreads()); + for (; it != itEnd; ++it) { HAPLOLIST::const_iterator it1 = it; for (++it1; it1 != end; ++it1) { const vectora & seq1 = *it; @@ -2499,6 +2482,21 @@ } } } +#endif + } else { + HAPLOLIST::const_iterator it = begin; + for (; it != end; ++it) { + HAPLOLIST::const_iterator it1 = it; + for (++it1; it1 != end; ++it1) { + const vectora & seq1 = *it; + const vectora & seq2 = *it1; + size_t sz = seq1.size(); + for (size_t i = 0; i < sz; ++i) + diffCnt += seq1[i] != seq2[i]; + ++numComparison; + } + } + } // return 0 if there is only one sequence return numComparison == 0 ? 0 : diffCnt / numComparison; } Modified: trunk/src/transmitter.cpp =================================================================== --- trunk/src/transmitter.cpp 2011-06-29 21:13:49 UTC (rev 4241) +++ trunk/src/transmitter.cpp 2011-06-29 21:34:43 UTC (rev 4242) @@ -417,11 +417,15 @@ const stringFunc & output, int begin, int end, int step, const intList & at, const intList & reps, const subPopList & subPops, const stringList & infoFields) : - GenoTransmitter(output, begin, end, step, at, reps, subPops, infoFields) - , m_intensity(intensity), m_rates(rates.elems()), m_loci(loci), - m_recBeforeLoci(0), m_convMode(convMode.elems()), - m_bt(numThreads(), getRNG()), m_chromX(-1), m_chromY(-1), m_customizedBegin(-1), m_customizedEnd(-1), - m_algorithm(0), m_debugOutput(NULL) + GenoTransmitter(output, begin, end, step, at, reps, subPops, infoFields), + m_intensity(intensity), m_rates(rates.elems()), m_loci(loci), + m_recBeforeLoci(0), m_convMode(convMode.elems()), m_chromX(-1), m_chromY(-1), + m_customizedBegin(-1), m_customizedEnd(-1), m_algorithm(0), m_debugOutput(NULL), +#ifdef _OPENMP + m_bt(numThreads(), getRNG()) +#else + m_bt(getRNG()) +#endif { DBG_FAILIF(m_convMode.empty(), ValueError, @@ -589,9 +593,13 @@ // if the operator is called directly, there is no way to know population size so we // a variable to tell it. +#ifdef _OPENMP for (size_t i = 0; i < numThreads(); i++) m_bt[i].setParameter(vecP, 0 /* obsolete m_intendedSize */); +#else + m_bt.setParameter(vecP, 0 /* obsolete m_intendedSize */); +#endif // choose an algorithm // if recombinations are dense. use the first algorithm // For example 10 chromoes, regular 0.5*10=5 @@ -614,7 +622,11 @@ initializeIfNeeded(offspring); //Bernullitrial for each thread +#ifdef _OPENMP Bernullitrials & bt = m_bt[omp_get_thread_num()]; +#else + Bernullitrials & bt = m_bt; +#endif // use which copy of chromosome GenoIterator cp[2], off; Modified: trunk/src/transmitter.h =================================================================== --- trunk/src/transmitter.h 2011-06-29 21:13:49 UTC (rev 4241) +++ trunk/src/transmitter.h 2011-06-29 21:34:43 UTC (rev 4242) @@ -623,9 +623,6 @@ const vectorf m_convMode; - /// bernulli trials - mutable vector<Bernullitrials> m_bt; - // locataion of special chromosomes mutable int m_chromX; mutable int m_chromY; @@ -637,6 +634,14 @@ mutable ostream * m_debugOutput; + /// bernulli trials +#ifdef _OPENMP + mutable vector<Bernullitrials> m_bt; +#else + mutable Bernullitrials m_bt; +#endif + + }; } Modified: trunk/src/utility.cpp =================================================================== --- trunk/src/utility.cpp 2011-06-29 21:13:49 UTC (rev 4241) +++ trunk/src/utility.cpp 2011-06-29 21:34:43 UTC (rev 4242) @@ -2263,7 +2263,11 @@ PyObject * res = NULL; if (m_stmts != NULL) { +#if PY_VERSION_HEX >= 0x03020000 + res = PyEval_EvalCode((PyObject *)m_stmts, m_locals, m_locals); +#else res = PyEval_EvalCode((PyCodeObject *)m_stmts, m_locals, m_locals); +#endif if (res == NULL) { #ifndef OPTIMIZED if (debug(DBG_GENERAL)) { @@ -2279,7 +2283,11 @@ } if (m_expr != NULL) { +#if PY_VERSION_HEX >= 0x03020000 + res = PyEval_EvalCode((PyObject *)m_expr, m_locals, m_locals); +#else res = PyEval_EvalCode((PyCodeObject *)m_expr, m_locals, m_locals); +#endif if (res == NULL) { #ifndef OPTIMIZED if (debug(DBG_GENERAL)) { Modified: trunk/src/utility.h =================================================================== --- trunk/src/utility.h 2011-06-29 21:13:49 UTC (rev 4241) +++ trunk/src/utility.h 2011-06-29 21:34:43 UTC (rev 4242) @@ -76,6 +76,12 @@ /// for openMP #ifdef _OPENMP # include "omp.h" +# if defined(__INTEL_COMPILER) +# include "tbb/parallel_sort.h" +# include "tbb/task_scheduler_init.h" +# elif defined(GCC_VERSION) && GCC_VERSION >= 40300 +# include "parallel/algorithm" +# endif #endif /// for bernulli trials. // use vector<bool> instead of dynamic_bitset since I can manipulate @@ -145,6 +151,26 @@ /// CPPONLY return val and increase val by 1, ensuring thread safety ATOMICLONG fetchAndIncrement(ATOMICLONG * val); +/// CPPONLY parallel sort by using tbb or gnu parallel +template<class T1, class T2> +void parallelSort(T1 start, T1 end, T2 cmp) +{ + if (numThreads() > 1) { +#ifdef _OPENMP +# if defined(__INTEL_COMPILER) + tbb::task_scheduler_init init(numThreads()); + tbb::parallel_sort(start, end, cmp); +# elif defined(GCC_VERSION) && GCC_VERSION >= 40300 + __gnu_parallel::sort(start, end, cmp); +# else + std::sort(start, end, cmp); +# endif +#endif + } else { + std::sort(start, end, cmp); + } +} + /// a utility function to check keyboard stroke /// CPPONLY int simuPOP_kbhit(); @@ -1202,6 +1228,12 @@ if (expr.empty() && stmts.empty()) return; + //detect leading spaces from python expressions + DBG_FAILIF(!expr.empty() && (expr[0] == ' ' || expr[0] == '\t'), ValueError, + "Can not include leading space in python expression '" + expr + "'"); + DBG_FAILIF(!stmts.empty() && (stmts[0] == ' ' || stmts[0] == '\t'), ValueError, + "Can not include leading space in python statement '" + stmts + "'"); + compileExpr(expr); compileStmts(stmts); } Modified: trunk/test/performance.csv =================================================================== --- trunk/test/performance.csv 2011-06-29 21:13:49 UTC (rev 4241) +++ trunk/test/performance.csv 2011-06-29 21:34:43 UTC (rev 4242) @@ -448,3 +448,120 @@ TestInitSex, 2011-06-06 15:43:11,943, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4200-intel, short, 13.1370029449, 13.5422229767 TestInitSex, 2011-06-06 15:43:59,207, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4200-intel, long, 13.7384490967, 15.3715240955 TestInitSex, 2011-06-06 15:44:27,405, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4200-intel, binary, 12.9587409496, 13.3092448711 +TestInitInfo, 2011-06-07 10:50:29,049, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4205-intel, short, 28.5263929367, 28.5497779846 +TestInitInfo, 2011-06-07 10:51:25,868, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4205-intel, long, 27.8562178612, 28.108784914 +TestInitInfo, 2011-06-07 10:52:22,403, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4205-intel, binary, 27.9055569172, 27.9653069973 +TestInitInfo, 2011-06-07 11:01:39,745, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4205-intel, short, 8.08958816528, 8.34579896927 +TestInitInfo, 2011-06-07 11:01:57,159, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4205-intel, long, 8.00524497032, 8.44241905212 +TestInitInfo, 2011-06-07 11:02:13,861, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4205-intel, binary, 8.06356215477, 8.2104408741 +TestInitInfo, 2011-06-07 11:52:02,098, EPI7-0541302, AMD64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4205-vc, short, 42.5138275974, 42.0906409373 +TestInitInfo, 2011-06-07 11:53:30,035, EPI7-0541302, AMD64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4205-vc, long, 42.7154268612, 43.2257380443 +TestInitInfo, 2011-06-07 11:55:01,380, EPI7-0541302, AMD64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4205-vc, binary, 45.0157581313, 44.4060398472 +TestInitInfo, 2011-06-07 11:55:52,381, EPI7-0541302, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4205-vc, short, 12.986396842, 14.089627703 +TestInitInfo, 2011-06-07 11:56:20,819, EPI7-0541302, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4205-vc, long, 13.1444051231, 13.6804705765 +TestInitInfo, 2011-06-07 11:56:49,009, EPI7-0541302, AMD64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4205-vc, binary, 12.6781480139, 13.7568184564 +TestMapSelector, 2011-06-08 12:32:43,362, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4212-intel, short, 137.560660124, 136.669243097 +TestMapSelector, 2011-06-08 12:37:05,477, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4212-intel, long, 131.439245939, 129.801275969 +TestMapSelector, 2011-06-08 12:42:04,585, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4212-intel, binary, 149.361258984, 148.818060875 +TestMapSelector, 2011-06-08 12:48:18,478, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4212-intel, short, 45.7759559155, 52.9312109947 +TestMapSelector, 2011-06-08 12:49:53,758, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4212-intel, long, 46.7970941067, 47.7334721088 +TestMapSelector, 2011-06-08 12:51:42,545, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4212-intel, binary, 52.5352201462, 55.497841835 +TestMaSelector, 2011-06-08 14:28:08,546, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4214-intel, short, 25.4252510071, 25.5701878071 +TestMaSelector, 2011-06-08 14:29:05,049, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4214-intel, long, 27.9332430363, 27.9779438972 +TestMaSelector, 2011-06-08 14:30:42,441, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4214-intel, binary, 48.2308118343, 48.3816211224 +TestMaSelector, 2011-06-08 14:31:09,735, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4214-intel, short, 7.88334703445, 8.11231207848 +TestMaSelector, 2011-06-08 14:31:26,819, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4214-intel, long, 8.17427706718, 8.4179918766 +TestMaSelector, 2011-06-08 14:31:57,265, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4214-intel, binary, 15.1356091499, 14.8043692112 +TestMlSelector, 2011-06-08 15:46:22,150, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4215-intel, short, 50.193365097, 50.2650611401 +TestMlSelector, 2011-06-08 15:48:09,026, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4215-intel, long, 51.6552660465, 54.0810310841 +TestMlSelector, 2011-06-08 15:50:16,152, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4215-intel, binary, 62.9643480778, 62.9600830078 +TestMlSelector, 2011-06-08 15:58:01,759, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4215-intel, short, 20.2570528984, 18.9420928955 +TestMlSelector, 2011-06-08 15:58:42,519, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4215-intel, long, 19.7100989819, 20.2147932053 +TestMlSelector, 2011-06-08 15:59:33,111, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4215-intel, binary, 24.4318461418, 25.4335269928 +TestMapPenetrance, 2011-06-09 13:29:16,820, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4217-intel, short, 30.1838719845, 29.9526631832 +TestMapPenetrance, 2011-06-09 13:30:24,110, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4217-intel, long, 32.5619549751, 32.8275830746 +TestMapPenetrance, 2011-06-09 13:31:39,551, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4217-intel, binary, 36.6352450848, 36.3903110027 +TestMapPenetrance, 2011-06-09 13:34:04,566, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4217-intel, short, 13.2235410213, 13.5193769932 +TestMapPenetrance, 2011-06-09 13:34:30,985, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4217-intel, long, 12.4324560165, 13.0819602013 +TestMapPenetrance, 2011-06-09 13:34:59,703, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4217-intel, binary, 13.6132779121, 14.0616240501 +TestMaPenetrance, 2011-06-09 14:15:27,807, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4218-intel, short, 9.05448889732, 9.03937888145 +TestMaPenetrance, 2011-06-09 14:15:49,226, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4218-intel, long, 9.61507201195, 9.80975604057 +TestMaPenetrance, 2011-06-09 14:16:19,546, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4218-intel, binary, 13.9117228985, 14.0005609989 +TestMaPenetrance, 2011-06-09 14:16:26,804, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4218-intel, short, 2.95468306541, 3.07803201675 +TestMaPenetrance, 2011-06-09 14:16:33,916, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4218-intel, long, 3.09952521324, 3.21534013748 +TestMaPenetrance, 2011-06-09 14:16:44,022, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4218-intel, binary, 4.47951889038, 4.53425717354 +TestMlPenetrance, 2011-06-09 14:18:44,988, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4218-intel, short, 59.3637518883, 59.5009410381 +TestMlPenetrance, 2011-06-09 14:20:48,471, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4218-intel, long, 61.0185468197, 60.5403618813 +TestMlPenetrance, 2011-06-09 14:23:09,441, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4218-intel, binary, 69.4342930317, 69.1806800365 +TestMlPenetrance, 2011-06-09 14:23:57,203, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4218-intel, short, 22.7854809761, 23.7821338177 +TestMlPenetrance, 2011-06-09 14:24:45,537, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4218-intel, long, 22.8191227913, 24.6416099072 +TestMlPenetrance, 2011-06-09 14:25:41,754, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4218-intel, binary, 26.4700949192, 28.6646509171 +TestMigratorByProbability, 2011-06-14 15:22:26,387, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4226-intel, short, 25.6720509529, 289.408267021 +TestMigratorByProbability, 2011-06-14 15:27:43,088, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4226-intel, long, 26.1059360504, 289.273638964 +TestMigratorByProbability, 2011-06-14 15:33:03,204, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4226-intel, binary, 26.363268137, 292.225383997 +TestMigratorByProbability, 2011-06-14 15:36:25,599, bp9, x86_64-2threads, python2.7.1, simuPOP-1.0.6svn, rev4226-intel, short, 3.85128188133, 37.7105200291 +TestMigratorByProbability, 2011-06-14 15:37:09,576, bp9, x86_64-2threads, python2.7.1, simuPOP-1.0.6svn, rev4226-intel, long, 3.8537299633, 38.7310800552 +TestMigratorByProbability, 2011-06-14 15:37:52,903, bp9, x86_64-2threads, python2.7.1, simuPOP-1.0.6svn, rev4226-intel, binary, 3.89192581177, 37.8206448555 +TestMigratorByProbability, 2011-06-14 15:39:51,191, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4226-intel, short, 3.68470191956, 36.2090260983 +TestMigratorByProbability, 2011-06-14 15:40:32,838, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4226-intel, long, 3.67241191864, 36.6956839561 +TestMigratorByProbability, 2011-06-14 15:41:14,535, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4226-intel, binary, 3.70908212662, 36.3693478107 +TestMigratorByProbability, 2011-06-14 16:00:42,787, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4226-gcc, short, 19.2052230835, 213.073572874 +TestMigratorByProbability, 2011-06-14 16:04:33,578, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4226-gcc, long, 19.0889210701, 210.232218981 +TestMigratorByProbability, 2011-06-14 16:08:30,824, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4226-gcc, binary, 19.5818870068, 215.983033895 +TestMigratorByProbability, 2011-06-14 16:11:28,255, bp9, x86_64-2threads, python2.7.1, simuPOP-1.0.6svn, rev4226-gcc, short, 11.753456831, 129.562813044 +TestMigratorByProbability, 2011-06-14 16:13:45,338, bp9, x86_64-2threads, python2.7.1, simuPOP-1.0.6svn, rev4226-gcc, long, 11.34167099, 124.56328702 +TestMigratorByProbability, 2011-06-14 16:16:09,380, bp9, x86_64-2threads, python2.7.1, simuPOP-1.0.6svn, rev4226-gcc, binary, 11.8418748379, 130.746499777 +TestMigratorByProbability, 2011-06-14 16:17:49,311, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4226-gcc, short, 7.99957203865, 84.460050106 +TestMigratorByProbability, 2011-06-14 16:19:20,940, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4226-gcc, long, 7.60408210754, 82.7148649693 +TestMigratorByProbability, 2011-06-14 16:20:57,946, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4226-gcc, binary, 8.37837600708, 87.1949620247 +TestMigratorByProbability, 2011-06-15 12:26:38,514, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4229-intel, short, 1.9312608242, 17.998347044 +TestMigratorByProbability, 2011-06-15 12:26:59,075, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4229-intel, long, 1.87130308151, 17.1944150925 +TestMigratorByProbability, 2011-06-15 12:27:20,130, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4229-intel, binary, 1.89324998856, 17.7626860142 +TestMigratorByProbability, 2011-06-15 13:42:10,927, bp9, x86_64-2threads, python2.7.1, simuPOP-1.0.6svn, rev4229-intel, short, 2.60852098465, 25.8612132072 +TestMigratorByProbability, 2011-06-15 13:42:44,813, bp9, x86_64-2threads, python2.7.1, simuPOP-1.0.6svn, rev4229-intel, long, 2.70065402985, 25.6916520596 +TestMigratorByProbability, 2011-06-15 13:43:15,274, bp9, x86_64-2threads, python2.7.1, simuPOP-1.0.6svn, rev4229-intel, binary, 2.63936305046, 25.8546738625 +TestMigratorByProbability, 2011-06-15 14:03:33,076, bp9, x86_64-2threads, python2.7.1, simuPOP-1.0.6svn, rev4229-gcc, short, 11.1535990238, 123.792095184 +TestMigratorByProbability, 2011-06-15 14:08:02,558, bp9, x86_64-2threads, python2.7.1, simuPOP-1.0.6svn, rev4229-gcc, long, 10.8459448814, 119.107388973 +TestMigratorByProbability, 2011-06-15 14:12:34,146, bp9, x86_64-2threads, python2.7.1, simuPOP-1.0.6svn, rev4229-gcc, binary, 11.3297309875, 125.051301003 +TestMigratorByProbability, 2011-06-15 14:44:25,953, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4229-gcc, short, 6.46779084206, 73.2599718571 +TestMigratorByProbability, 2011-06-15 14:45:48,805, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4229-gcc, long, 6.84860181808, 74.6199998856 +TestMigratorByProbability, 2011-06-15 14:47:15,090, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4229-gcc, binary, 7.11267113686, 77.6748759747 +TestMigratorByIndInfo, 2011-06-15 15:26:07,842, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4230-intel, short, 26.1453762054, 293.74267602 +TestMigratorByIndInfo, 2011-06-15 15:31:32,104, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4230-intel, long, 26.3325400352, 295.03544116 +TestMigratorByIndInfo, 2011-06-15 15:37:02,364, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4230-intel, binary, 27.2269229889, 299.873353958 +TestMigratorByIndInfo, 2011-06-15 15:37:35,940, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4230-intel, short, 2.99913883209, 27.3614680767 +TestMigratorByIndInfo, 2011-06-15 15:38:13,350, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4230-intel, long, 3.31677007675, 31.3634848595 +TestMigratorByIndInfo, 2011-06-15 15:38:52,125, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4230-intel, binary, 3.51236987114, 32.3257880211 +TestMigratorByCount, 2011-06-15 15:44:37,405, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4230-intel, short, 27.3829629421, 313.405131102 +TestMigratorByCount, 2011-06-15 15:50:18,503, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4230-intel, long, 27.1348381042, 312.564651012 +TestMigratorByCount, 2011-06-15 15:56:05,059, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4230-intel, binary, 28.0947768688, 316.94431901 +TestMigratorByCount, 2011-06-15 15:57:04,649, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4230-intel, short, 4.43328809738, 53.2696549892 +TestMigratorByCount, 2011-06-15 15:58:03,514, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4230-intel, long, 4.49258899689, 53.0905818939 +TestMigratorByCount, 2011-06-15 15:59:03,128, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4230-intel, binary, 4.42320084572, 53.5732860565 +TestMigratorByProportion, 2011-06-16 09:31:14,071, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4230-intel, short, 27.1460089684, 311.949622869 +TestMigratorByProportion, 2011-06-16 09:37:00,421, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4230-intel, long, 27.462939024, 316.891449928 +TestMigratorByProportion, 2011-06-16 09:42:50,875, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4230-intel, binary, 28.1410610676, 320.35036397 +TestMigratorByProportion, 2011-06-16 09:43:50,063, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4230-intel, short, 4.38145494461, 53.0418229103 +TestMigratorByProportion, 2011-06-16 09:44:49,681, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4230-intel, long, 4.43273711205, 53.8642539978 +TestMigratorByProportion, 2011-06-16 09:45:50,018, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4230-intel, binary, 4.50796914101, 54.1398379803 +TestMigratorByIndInfo, 2011-06-16 12:18:46,099, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4232-intel, short, 2.966381073, 27.7702920437 +TestMigratorByIndInfo, 2011-06-16 12:19:19,834, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4232-intel, long, 2.91467499733, 28.0086240768 +TestMigratorByIndInfo, 2011-06-16 12:19:54,456, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4232-intel, binary, 3.1325969696, 28.1677310467 +TestMigratorByProportion, 2011-06-16 12:20:50,553, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4232-intel, short, 4.09359002113, 50.0307469368 +TestMigratorByProportion, 2011-06-16 12:21:45,803, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4232-intel, long, 4.10800004005, 49.5832879543 +TestMigratorByProportion, 2011-06-16 12:22:42,183, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4232-intel, binary, 4.32871103287, 50.3448860645 +TestMigratorByCount, 2011-06-16 12:23:39,026, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4232-intel, short, 4.16416311264, 50.6448938847 +TestMigratorByCount, 2011-06-16 12:24:34,253, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4232-intel, long, 4.0694630146, 49.7850799561 +TestMigratorByCount, 2011-06-16 12:25:30,668, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4232-intel, binary, 4.26471400261, 50.2679200172 +TestSortIndividuals, 2011-06-17 14:19:38,738, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4236-intel, short, 53.682005167, 33.6767070293 +TestSortIndividuals, 2011-06-17 14:21:20,066, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4236-intel, long, 52.7289278507, 33.5573928356 +TestSortIndividuals, 2011-06-17 14:23:07,867, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4236-intel, binary, 56.0339119434, 36.2461290359 +TestSortIndividuals, 2011-06-17 14:24:03,903, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4236-intel, short, 1.04947304726, 1.13233399391 +TestSortIndividuals, 2011-06-17 14:24:21,066, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4236-intel, long, 1.03604102135, 1.10664105415 +TestSortIndividuals, 2011-06-17 14:24:38,181, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4236-intel, binary, 1.10549497604, 1.12094712257 +TestPedigreeMating, 2011-06-22 15:43:19,001, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4238-intel, short, 39.6762161255, 88.2637140751 +TestPedigreeMating, 2011-06-22 15:48:12,256, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4238-intel, long, 46.6159968376, 99.869631052 +TestPedigreeMating, 2011-06-22 15:52:44,522, bp9, x86_64-1threads, python2.7.1, simuPOP-1.0.6svn, rev4238-intel, binary, 41.4395649433, 85.7024009228 +TestPedigreeMating, 2011-06-22 16:05:06,221, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4238-intel, short, 25.8149080276, 61.1918590069 +TestPedigreeMating, 2011-06-22 16:10:02,036, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4238-intel, long, 28.0662469864, 62.3663561344 +TestPedigreeMating, 2011-06-22 16:14:42,413, bp9, x86_64-4threads, python2.7.1, simuPOP-1.0.6svn, rev4238-intel, binary, 26.5212380886, 54.3880081177 Modified: trunk/test/performance.log =================================================================== --- trunk/test/performance.log 2011-06-29 21:13:49 UTC (rev 4241) +++ trunk/test/performance.log 2011-06-29 21:34:43 UTC (rev 4242) @@ -6590,3 +6590,1056 @@ TestInitSex : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 13.3092448711 TestInitSex : 12.9587409496, 13.3092448711 TestInitSex : End of test TestInitSex +TestInitInfo : Host: bp9 (Linux, x86_64, x86_64) +TestInitInfo : Time: Tue Jun 7 10:49:31 2011 +TestInitInfo : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestInitInfo : simuPOP: 1.0.6svn (rev 4205, module short, optimized, 1 threads) +TestInitInfo : Test: InitInfo, results are time (not processor time) to apply operator for 1000 times. +TestInitInfo : size=1000000: 28.5263929367 +TestInitInfo : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 28.5497779846 +TestInitInfo : 28.5263929367, 28.5497779846 +TestInitInfo : End of test TestInitInfo +TestInitInfo : Host: bp9 (Linux, x86_64, x86_64) +TestInitInfo : Time: Tue Jun 7 10:50:29 2011 +TestInitInfo : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestInitInfo : simuPOP: 1.0.6svn (rev 4205, module long, optimized, 1 threads) +TestInitInfo : Test: InitInfo, results are time (not processor time) to apply operator for 1000 times. +TestInitInfo : size=1000000: 27.8562178612 +TestInitInfo : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 28.108784914 +TestInitInfo : 27.8562178612, 28.108784914 +TestInitInfo : End of test TestInitInfo +TestInitInfo : Host: bp9 (Linux, x86_64, x86_64) +TestInitInfo : Time: Tue Jun 7 10:51:26 2011 +TestInitInfo : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestInitInfo : simuPOP: 1.0.6svn (rev 4205, module binary, optimized, 1 threads) +TestInitInfo : Test: InitInfo, results are time (not processor time) to apply operator for 1000 times. +TestInitInfo : size=1000000: 27.9055569172 +TestInitInfo : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 27.9653069973 +TestInitInfo : 27.9055569172, 27.9653069973 +TestInitInfo : End of test TestInitInfo +TestInitInfo : Host: bp9 (Linux, x86_64, x86_64) +TestInitInfo : Time: Tue Jun 7 11:01:22 2011 +TestInitInfo : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestInitInfo : simuPOP: 1.0.6svn (rev 4205, module short, optimized, 4 threads) +TestInitInfo : Test: InitInfo, results are time (not processor time) to apply operator for 1000 times. +TestInitInfo : size=1000000: 8.08958816528 +TestInitInfo : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 8.34579896927 +TestInitInfo : 8.08958816528, 8.34579896927 +TestInitInfo : End of test TestInitInfo +TestInitInfo : Host: bp9 (Linux, x86_64, x86_64) +TestInitInfo : Time: Tue Jun 7 11:01:40 2011 +TestInitInfo : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestInitInfo : simuPOP: 1.0.6svn (rev 4205, module long, optimized, 4 threads) +TestInitInfo : Test: InitInfo, results are time (not processor time) to apply operator for 1000 times. +TestInitInfo : size=1000000: 8.00524497032 +TestInitInfo : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 8.44241905212 +TestInitInfo : 8.00524497032, 8.44241905212 +TestInitInfo : End of test TestInitInfo +TestInitInfo : Host: bp9 (Linux, x86_64, x86_64) +TestInitInfo : Time: Tue Jun 7 11:01:57 2011 +TestInitInfo : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestInitInfo : simuPOP: 1.0.6svn (rev 4205, module binary, optimized, 4 threads) +TestInitInfo : Test: InitInfo, results are time (not processor time) to apply operator for 1000 times. +TestInitInfo : size=1000000: 8.06356215477 +TestInitInfo : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 8.2104408741 +TestInitInfo : 8.06356215477, 8.2104408741 +TestInitInfo : End of test TestInitInfo +TestInitInfo : Host: EPI7-0541302 (Windows, AMD64, Intel64 Family 6 Model 30 Stepping 5, GenuineIntel) +TestInitInfo : Time: Tue Jun 07 11:50:36 2011 +TestInitInfo : Python: 2.7.1 [MSC v.1500 64 bit (AMD64)] +TestInitInfo : simuPOP: 1.0.6svn (rev 4205, module short, optimized, 1 threads) +TestInitInfo : Test: InitInfo, results are time (not processor time) to apply operator for 1000 times. +TestInitInfo : size=1000000: 42.5138275974 +TestInitInfo : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 42.0906409373 +TestInitInfo : 42.5138275974, 42.0906409373 +TestInitInfo : End of test TestInitInfo +TestInitInfo : Host: EPI7-0541302 (Windows, AMD64, Intel64 Family 6 Model 30 Stepping 5, GenuineIntel) +TestInitInfo : Time: Tue Jun 07 11:52:02 2011 +TestInitInfo : Python: 2.7.1 [MSC v.1500 64 bit (AMD64)] +TestInitInfo : simuPOP: 1.0.6svn (rev 4205, module long, optimized, 1 threads) +TestInitInfo : Test: InitInfo, results are time (not processor time) to apply operator for 1000 times. +TestInitInfo : size=1000000: 42.7154268612 +TestInitInfo : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 43.2257380443 +TestInitInfo : 42.7154268612, 43.2257380443 +TestInitInfo : End of test TestInitInfo +TestInitInfo : Host: EPI7-0541302 (Windows, AMD64, Intel64 Family 6 Model 30 Stepping 5, GenuineIntel) +TestInitInfo : Time: Tue Jun 07 11:53:30 2011 +TestInitInfo : Python: 2.7.1 [MSC v.1500 64 bit (AMD64)] +TestInitInfo : simuPOP: 1.0.6svn (rev 4205, module binary, optimized, 1 threads) +TestInitInfo : Test: InitInfo, results are time (not processor time) to apply operator for 1000 times. +TestInitInfo : size=1000000: 45.0157581313 +TestInitInfo : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 44.4060398472 +TestInitInfo : 45.0157581313, 44.4060398472 +TestInitInfo : End of test TestInitInfo +TestInitInfo : Host: EPI7-0541302 (Windows, AMD64, Intel64 Family 6 Model 30 Stepping 5, GenuineIntel) +TestInitInfo : Time: Tue Jun 07 11:55:24 2011 +TestInitInfo : Python: 2.7.1 [MSC v.1500 64 bit (AMD64)] +TestInitInfo : simuPOP: 1.0.6svn (rev 4205, module short, optimized, 4 threads) +TestInitInfo : Test: InitInfo, results are time (not processor time) to apply operator for 1000 times. +TestInitInfo : size=1000000: 12.986396842 +TestInitInfo : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 14.089627703 +TestInitInfo : 12.986396842, 14.089627703 +TestInitInfo : End of test TestInitInfo +TestInitInfo : Host: EPI7-0541302 (Windows, AMD64, Intel64 Family 6 Model 30 Stepping 5, GenuineIntel) +TestInitInfo : Time: Tue Jun 07 11:55:52 2011 +TestInitInfo : Python: 2.7.1 [MSC v.1500 64 bit (AMD64)] +TestInitInfo : simuPOP: 1.0.6svn (rev 4205, module long, optimized, 4 threads) +TestInitInfo : Test: InitInfo, results are time (not processor time) to apply operator for 1000 times. +TestInitInfo : size=1000000: 13.1444051231 +TestInitInfo : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 13.6804705765 +TestInitInfo : 13.1444051231, 13.6804705765 +TestInitInfo : End of test TestInitInfo +TestInitInfo : Host: EPI7-0541302 (Windows, AMD64, Intel64 Family 6 Model 30 Stepping 5, GenuineIntel) +TestInitInfo : Time: Tue Jun 07 11:56:21 2011 +TestInitInfo : Python: 2.7.1 [MSC v.1500 64 bit (AMD64)] +TestInitInfo : simuPOP: 1.0.6svn (rev 4205, module binary, optimized, 4 threads) +TestInitInfo : Test: InitInfo, results are time (not processor time) to apply operator for 1000 times. +TestInitInfo : size=1000000: 12.6781480139 +TestInitInfo : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 13.7568184564 +TestInitInfo : 12.6781480139, 13.7568184564 +TestInitInfo : End of test TestInitInfo +TestMapSelector : Host: bp9 (Linux, x86_64, x86_64) +TestMapSelector : Time: Wed Jun 8 12:28:08 2011 +TestMapSelector : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestMapSelector : simuPOP: 1.0.6svn (rev 4212, module short, optimized, 1 threads) +TestMapSelector : Test: MapSelector, results are time (not processor time) to apply operator for 1000 times. +TestMapSelector : size=1000000: 137.560660124 +TestMapSelector : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 136.669243097 +TestMapSelector : 137.560660124, 136.669243097 +TestMapSelector : End of test TestMapSelector +TestMapSelector : Host: bp9 (Linux, x86_64, x86_64) +TestMapSelector : Time: Wed Jun 8 12:32:43 2011 +TestMapSelector : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestMapSelector : simuPOP: 1.0.6svn (rev 4212, module long, optimized, 1 threads) +TestMapSelector : Test: MapSelector, results are time (not processor time) to apply operator for 1000 times. +TestMapSelector : size=1000000: 131.439245939 +TestMapSelector : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 129.801275969 +TestMapSelector : 131.439245939, 129.801275969 +TestMapSelector : End of test TestMapSelector +TestMapSelector : Host: bp9 (Linux, x86_64, x86_64) +TestMapSelector : Time: Wed Jun 8 12:37:06 2011 +TestMapSelector : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestMapSelector : simuPOP: 1.0.6svn (rev 4212, module binary, optimized, 1 threads) +TestMapSelector : Test: MapSelector, results are time (not processor time) to apply operator for 1000 times. +TestMapSelector : size=1000000: 149.361258984 +TestMapSelector : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 148.818060875 +TestMapSelector : 149.361258984, 148.818060875 +TestMapSelector : End of test TestMapSelector +TestMapSelector : Host: bp9 (Linux, x86_64, x86_64) +TestMapSelector : Time: Wed Jun 8 12:46:39 2011 +TestMapSelector : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestMapSelector : simuPOP: 1.0.6svn (rev 4212, module short, optimized, 4 threads) +TestMapSelector : Test: MapSelector, results are time (not processor time) to apply operator for 1000 times. +TestMapSelector : size=1000000: 45.7759559155 +TestMapSelector : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 52.9312109947 +TestMapSelector : 45.7759559155, 52.9312109947 +TestMapSelector : End of test TestMapSelector +TestMapSelector : Host: bp9 (Linux, x86_64, x86_64) +TestMapSelector : Time: Wed Jun 8 12:48:19 2011 +TestMapSelector : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestMapSelector : simuPOP: 1.0.6svn (rev 4212, module long, optimized, 4 threads) +TestMapSelector : Test: MapSelector, results are time (not processor time) to apply operator for 1000 times. +TestMapSelector : size=1000000: 46.7970941067 +TestMapSelector : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 47.7334721088 +TestMapSelector : 46.7970941067, 47.7334721088 +TestMapSelector : End of test TestMapSelector +TestMapSelector : Host: bp9 (Linux, x86_64, x86_64) +TestMapSelector : Time: Wed Jun 8 12:49:54 2011 +TestMapSelector : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestMapSelector : simuPOP: 1.0.6svn (rev 4212, module binary, optimized, 4 threads) +TestMapSelector : Test: MapSelector, results are time (not processor time) to apply operator for 1000 times. +TestMapSelector : size=1000000: 52.5352201462 +TestMapSelector : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 55.497841835 +TestMapSelector : 52.5352201462, 55.497841835 +TestMapSelector : End of test TestMapSelector +TestMaSelector : Host: bp9 (Linux, x86_64, x86_64) +TestMaSelector : Time: Wed Jun 8 14:27:17 2011 +TestMaSelector : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestMaSelector : simuPOP: 1.0.6svn (rev 4214, module short, optimized, 1 threads) +TestMaSelector : Test: MaSelector, results are time (not processor time) to apply operator for 1000 times. +TestMaSelector : size=1000000: 25.4252510071 +TestMaSelector : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 25.5701878071 +TestMaSelector : 25.4252510071, 25.5701878071 +TestMaSelector : End of test TestMaSelector +TestMaSelector : Host: bp9 (Linux, x86_64, x86_64) +TestMaSelector : Time: Wed Jun 8 14:28:08 2011 +TestMaSelector : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestMaSelector : simuPOP: 1.0.6svn (rev 4214, module long, optimized, 1 threads) +TestMaSelector : Test: MaSelector, results are time (not processor time) to apply operator for 1000 times. +TestMaSelector : size=1000000: 27.9332430363 +TestMaSelector : size=[100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]: 27.9779438972 +TestMaSelector : 27.9332430363, 27.9779438972 +TestMaSelector : End of test TestMaSelector +TestMaSelector : Host: bp9 (Linux, x86_64, x86_64) +TestMaSelector : Time: Wed Jun 8 14:29:05 2011 +TestMaSelector : Python: 2.7.1 [GCC Intel(R) C++ g++ 4.4 mode] +TestMaSelector : simuPOP: 1.0.6svn... [truncated message content] |
From: <si...@us...> - 2011-07-06 16:23:42
|
Revision: 4244 http://simupop.svn.sourceforge.net/simupop/?rev=4244&view=rev Author: simupop Date: 2011-07-06 15:33:58 +0000 (Wed, 06 Jul 2011) Log Message: ----------- Rename src to simuPOP so that the development mode of setup.py/distribute will work directly Added Paths: ----------- trunk/simuPOP/ Removed Paths: ------------- trunk/src/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2011-07-06 16:24:18
|
Revision: 4245 http://simupop.svn.sourceforge.net/simupop/?rev=4245&view=rev Author: simupop Date: 2011-07-06 15:46:04 +0000 (Wed, 06 Jul 2011) Log Message: ----------- Update manifest and setup.py for the rename Modified Paths: -------------- trunk/MANIFEST.in trunk/setup.py Modified: trunk/MANIFEST.in =================================================================== --- trunk/MANIFEST.in 2011-07-06 15:33:58 UTC (rev 4244) +++ trunk/MANIFEST.in 2011-07-06 15:46:04 UTC (rev 4245) @@ -18,86 +18,86 @@ include config_win32.h include config_linux.h include config_mac.h -include src/simuPOP_cfg.h -include src/utility.h -include src/genoStru.h -include src/individual.h -include src/population.h -include src/simulator.h -include src/mating.h -include src/operator.h -include src/initializer.h -include src/migrator.h -include src/outputer.h -include src/selector.h -include src/penetrance.h -include src/qtrait.h -include src/stator.h -include src/mutator.h -include src/transmitter.h -include src/tagger.h -include src/pedigree.h -include src/virtualSubPop.h -include src/sandbox.h +include simuPOP/simuPOP_cfg.h +include simuPOP/utility.h +include simuPOP/genoStru.h +include simuPOP/individual.h +include simuPOP/population.h +include simuPOP/simulator.h +include simuPOP/mating.h +include simuPOP/operator.h +include simuPOP/initializer.h +include simuPOP/migrator.h +include simuPOP/outputer.h +include simuPOP/selector.h +include simuPOP/penetrance.h +include simuPOP/qtrait.h +include simuPOP/stator.h +include simuPOP/mutator.h +include simuPOP/transmitter.h +include simuPOP/tagger.h +include simuPOP/pedigree.h +include simuPOP/virtualSubPop.h +include simuPOP/sandbox.h # source files -include src/customizedTypes.c -include src/utility.cpp -include src/genoStru.cpp -include src/individual.cpp -include src/population.cpp -include src/simulator.cpp -include src/mating.cpp -include src/operator.cpp -include src/initializer.cpp -include src/migrator.cpp -include src/outputer.cpp -include src/selector.cpp -include src/penetrance.cpp -include src/qtrait.cpp -include src/stator.cpp -include src/mutator.cpp -include src/transmitter.cpp -include src/tagger.cpp -include src/pedigree.cpp -include src/virtualSubPop.cpp -include src/sandbox.cpp -include src/main.cpp +include simuPOP/customizedTypes.c +include simuPOP/utility.cpp +include simuPOP/genoStru.cpp +include simuPOP/individual.cpp +include simuPOP/population.cpp +include simuPOP/simulator.cpp +include simuPOP/mating.cpp +include simuPOP/operator.cpp +include simuPOP/initializer.cpp +include simuPOP/migrator.cpp +include simuPOP/outputer.cpp +include simuPOP/selector.cpp +include simuPOP/penetrance.cpp +include simuPOP/qtrait.cpp +include simuPOP/stator.cpp +include simuPOP/mutator.cpp +include simuPOP/transmitter.cpp +include simuPOP/tagger.cpp +include simuPOP/pedigree.cpp +include simuPOP/virtualSubPop.cpp +include simuPOP/sandbox.cpp +include simuPOP/main.cpp # source generated files -include src/swigpyrun.h -include src/simuPOP_std_wrap.cpp -include src/simuPOP_op_wrap.cpp -include src/simuPOP_la_wrap.cpp -include src/simuPOP_laop_wrap.cpp -include src/simuPOP_ba_wrap.cpp -include src/simuPOP_baop_wrap.cpp -include src/simuPOP_std.py -include src/simuPOP_op.py -include src/simuPOP_la.py -include src/simuPOP_laop.py -include src/simuPOP_ba.py -include src/simuPOP_baop.py -include src/gsl_wrap.c +include simuPOP/swigpyrun.h +include simuPOP/simuPOP_std_wrap.cpp +include simuPOP/simuPOP_op_wrap.cpp +include simuPOP/simuPOP_la_wrap.cpp +include simuPOP/simuPOP_laop_wrap.cpp +include simuPOP/simuPOP_ba_wrap.cpp +include simuPOP/simuPOP_baop_wrap.cpp +include simuPOP/simuPOP_std.py +include simuPOP/simuPOP_op.py +include simuPOP/simuPOP_la.py +include simuPOP/simuPOP_laop.py +include simuPOP/simuPOP_ba.py +include simuPOP/simuPOP_baop.py +include simuPOP/gsl_wrap.c # source wrap files -include src/simuPOP_common.i -include src/simuPOP_doc.i -include src/simuPOP_std.i -include src/simuPOP_op.i -include src/simuPOP_la.i -include src/simuPOP_laop.i -include src/simuPOP_ba.i -include src/simuPOP_baop.i -include src/gsl.i +include simuPOP/simuPOP_common.i +include simuPOP/simuPOP_doc.i +include simuPOP/simuPOP_std.i +include simuPOP/simuPOP_op.i +include simuPOP/simuPOP_la.i +include simuPOP/simuPOP_laop.i +include simuPOP/simuPOP_ba.i +include simuPOP/simuPOP_baop.i +include simuPOP/gsl.i # source python files (modules) include simuOpt.py -include src/__init__.py -include src/utils.py -include src/plotter.py -include src/sampling.py -include src/sandbox.py +include simuPOP/__init__.py +include simuPOP/utils.py +include simuPOP/plotter.py +include simuPOP/sampling.py +include simuPOP/sandbox.py # gsl files include gsl/gsl_machine.h Modified: trunk/setup.py =================================================================== --- trunk/setup.py 2011-07-06 15:33:58 UTC (rev 4244) +++ trunk/setup.py 2011-07-06 15:46:04 UTC (rev 4245) @@ -399,9 +399,9 @@ SWIG_CC_FLAGS += ' -py3' SWIG_RUNTIME_FLAGS = '-python -external-runtime' -# python setup.py reads py_modules from src so we have to produce simuPOP_std.py +# python setup.py reads py_modules from simuPOP so we have to produce simuPOP_std.py # etc to this directory. -SWIG_OUTDIR = 'src' +SWIG_OUTDIR = 'simuPOP' if not os.path.isdir('build'): os.mkdir('build') @@ -421,12 +421,12 @@ } WRAP_INFO = { - 'std': ['src/simuPOP_std_wrap.cpp', 'src/simuPOP_std.i', ''], - 'op': ['src/simuPOP_op_wrap.cpp', 'src/simuPOP_op.i', '-DOPTIMIZED'], - 'la': ['src/simuPOP_la_wrap.cpp', 'src/simuPOP_la.i', '-DLONGALLELE'], - 'laop': ['src/simuPOP_laop_wrap.cpp', 'src/simuPOP_laop.i', '-DLONGALLELE -DOPTIMIZED'], - 'ba': ['src/simuPOP_ba_wrap.cpp', 'src/simuPOP_ba.i', '-DBINARYALLELE'], - 'baop': ['src/simuPOP_baop_wrap.cpp', 'src/simuPOP_baop.i', '-DBINARYALLELE -DOPTIMIZED'], + 'std': ['simuPOP/simuPOP_std_wrap.cpp', 'simuPOP/simuPOP_std.i', ''], + 'op': ['simuPOP/simuPOP_op_wrap.cpp', 'simuPOP/simuPOP_op.i', '-DOPTIMIZED'], + 'la': ['simuPOP/simuPOP_la_wrap.cpp', 'simuPOP/simuPOP_la.i', '-DLONGALLELE'], + 'laop': ['simuPOP/simuPOP_laop_wrap.cpp', 'simuPOP/simuPOP_laop.i', '-DLONGALLELE -DOPTIMIZED'], + 'ba': ['simuPOP/simuPOP_ba_wrap.cpp', 'simuPOP/simuPOP_ba.i', '-DBINARYALLELE'], + 'baop': ['simuPOP/simuPOP_baop_wrap.cpp', 'simuPOP/simuPOP_baop.i', '-DBINARYALLELE -DOPTIMIZED'], } if os.name == 'nt': @@ -466,7 +466,7 @@ boost_lib_names = [] boost_lib_path = None res = {} - res['src'] = ['src/simuPOP_' + modu + '_wrap.cpp'] + res['src'] = ['simuPOP/simuPOP_' + modu + '_wrap.cpp'] for src in SOURCE_FILES: res['src'].append('build/%s/%s' % (modu, src)) res['src'].extend(LIB_FILES) @@ -534,8 +534,8 @@ machine = platform.uname()[4].lower() if machine == '': # have to guess machine = 'x86' - shutil.copy('win32/%s/vcomp90.dll' % machine, 'src/vcomp90.dll') - shutil.copy('win32/%s/msvcr90.dll' % machine, 'src/msvcr90.dll') + shutil.copy('win32/%s/vcomp90.dll' % machine, 'simuPOP/vcomp90.dll') + shutil.copy('win32/%s/msvcr90.dll' % machine, 'simuPOP/msvcr90.dll') if __name__ == '__main__': SIMUPOP_VER, SIMUPOP_REV = simuPOP_version() @@ -546,9 +546,9 @@ # # if any of the wrap files does not exist # or if the wrap files are older than any of the source files. - if (not os.path.isfile('src/gsl_wrap.c') or (not os.path.isfile('src/swigpyrun.h')) or \ + if (not os.path.isfile('simuPOP/gsl_wrap.c') or (not os.path.isfile('simuPOP/swigpyrun.h')) or \ False in [os.path.isfile(WRAP_INFO[x][0]) for x in MODULES]) or \ - (max( [os.path.getmtime('src/' + x) for x in HEADER_FILES] ) > \ + (max( [os.path.getmtime('simuPOP/' + x) for x in HEADER_FILES] ) > \ min( [os.path.getmtime(WRAP_INFO[x][0]) for x in MODULES])): (v1, v2, v3) = swig_version() if (v1, v2, v3) < (1, 3, 35): @@ -558,8 +558,8 @@ print('Swig >= 2.0.4 is required for Python 3.2 or higher') sys.exit(1) # generate header file - print("Generating external runtime header file src/swigpyrun.h...") - os.system('%s %s src/swigpyrun.h' % (SWIG, SWIG_RUNTIME_FLAGS)) + print("Generating external runtime header file simuPOP/swigpyrun.h...") + os.system('%s %s simuPOP/swigpyrun.h' % (SWIG, SWIG_RUNTIME_FLAGS)) # try the first option set with the first library for lib in MODULES: print("Generating wrapper file " + WRAP_INFO[lib][0]) @@ -567,9 +567,9 @@ SWIG_OUTDIR, WRAP_INFO[lib][2], WRAP_INFO[lib][0], WRAP_INFO[lib][1])) != 0: print("Calling swig failed. Please check your swig version.") sys.exit(1) - print("Generating wrapper file src/gsl_wrap.c") + print("Generating wrapper file simuPOP/gsl_wrap.c") if os.system('%s %s -outdir %s %s -o %s %s' % (SWIG, SWIG_CC_FLAGS, \ - SWIG_OUTDIR, '', 'src/gsl_wrap.c', 'src/gsl.i')) != 0: + SWIG_OUTDIR, '', 'simuPOP/gsl_wrap.c', 'simuPOP/gsl.i')) != 0: print("Calling swig failed. Please check your swig version.") sys.exit(1) print("\nAll wrap files are generated successfully.\n") @@ -585,13 +585,13 @@ os.mkdir('build/%s' % modu) for src in SOURCE_FILES: mod_src = 'build/%s/%s' % (modu, src) - if not os.path.isfile(mod_src) or not filecmp.cmp(mod_src,'src/'+src): - shutil.copy('src/'+src, mod_src) + if not os.path.isfile(mod_src) or not filecmp.cmp(mod_src,'simuPOP/'+src): + shutil.copy('simuPOP/'+src, mod_src) # build # For module simuPOP.gsl EXT_MODULES = [ Extension('simuPOP._gsl', - sources = GSL_FILES + ['src/gsl_wrap.c'], + sources = GSL_FILES + ['simuPOP/gsl_wrap.c'], include_dirs = ['gsl', 'gsl/specfunc', 'build', '.'], ) ] @@ -602,7 +602,7 @@ sources = info['src'], extra_compile_args = info['extra_compile_args'], # src for config.h etc, build for swigpyrun.h - include_dirs = info['include_dirs'] + ['src', 'build'], + include_dirs = info['include_dirs'] + ['simuPOP', 'build'], library_dirs = info['library_dirs'], libraries = info['libraries'], define_macros = info['define_macros'], @@ -642,7 +642,7 @@ ], platforms = ['all'], # - package_dir = {'simuPOP': 'src'}, + package_dir = {'simuPOP': 'simuPOP'}, package_data = {'simuPOP': PACKAGE_DATA}, py_modules = [ 'simuOpt', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2011-07-06 16:52:38
|
Revision: 4248 http://simupop.svn.sourceforge.net/simupop/?rev=4248&view=rev Author: simupop Date: 2011-07-06 16:52:32 +0000 (Wed, 06 Jul 2011) Log Message: ----------- Update processing scripts. Prepare for a release Modified Paths: -------------- trunk/Doxy_web trunk/Doxyfile trunk/Makefile trunk/simuPOP/initializer.cpp trunk/simuPOP/simuPOP_doc.i trunk/simuPOP/stator.cpp trunk/simuPOP/transmitter.cpp trunk/simuPOP/transmitter.h trunk/simuPOP/utility.cpp trunk/simuPOP/utility.h trunk/tools/doxy2swig.py Modified: trunk/Doxy_web =================================================================== --- trunk/Doxy_web 2011-07-06 16:18:23 UTC (rev 4247) +++ trunk/Doxy_web 2011-07-06 16:52:32 UTC (rev 4248) @@ -578,7 +578,7 @@ # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = src +INPUT = simuPOP # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is Modified: trunk/Doxyfile =================================================================== --- trunk/Doxyfile 2011-07-06 16:18:23 UTC (rev 4247) +++ trunk/Doxyfile 2011-07-06 16:52:32 UTC (rev 4248) @@ -578,7 +578,7 @@ # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = src \ +INPUT = simuPOP \ config_linux.h # This tag can be used to specify the character encoding of the source files Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2011-07-06 16:18:23 UTC (rev 4247) +++ trunk/Makefile 2011-07-06 16:52:32 UTC (rev 4248) @@ -4,7 +4,7 @@ rebuild: - bcpp src/*.h src/*.cpp + bcpp simuPOP/*.h simuPOP/*.cpp doxygen tools/doxy2swig.py scons install -j4 std @@ -17,7 +17,7 @@ clean: @rm -rf build - @rm -f src/*wrap* src/simuPOP_*.py + @rm -f simuPOP/*wrap* simuPOP/simuPOP_*.py @find . -name '*~' -exec rm -f {} \; @find . -name '*.bak' -exec rm -f {} \; @find . -name '*.py?' -exec rm -f {} \; Modified: trunk/simuPOP/initializer.cpp =================================================================== --- trunk/simuPOP/initializer.cpp 2011-07-06 16:18:23 UTC (rev 4247) +++ trunk/simuPOP/initializer.cpp 2011-07-06 16:52:32 UTC (rev 4248) @@ -71,13 +71,13 @@ else { if (numThreads() > 1) { #ifdef _OPENMP -#pragma omp parallel private(ind) +# pragma omp parallel private(ind) { ind = pop.indIterator(sp->subPop(), omp_get_thread_num()); for (; ind.valid(); ++ind) ind->setSex(ws.draw() == 0 ? MALE : FEMALE); } -#endif +#endif } else for (; ind.valid(); ++ind) ind->setSex(ws.draw() == 0 ? MALE : FEMALE); Modified: trunk/simuPOP/simuPOP_doc.i =================================================================== --- trunk/simuPOP/simuPOP_doc.i 2011-07-06 16:18:23 UTC (rev 4247) +++ trunk/simuPOP/simuPOP_doc.i 2011-07-06 16:52:32 UTC (rev 4248) @@ -740,13 +740,13 @@ "; -%ignore simuPOP::Bernullitrials::Bernullitrials(RNG &rng); +%ignore simuPOP::Bernullitrials::Bernullitrials(RNG &); %feature("docstring") simuPOP::Bernullitrials::Bernullitrials " Usage: - Bernullitrials(rng, prob, trials) + Bernullitrials(, prob, trials=0) "; @@ -768,7 +768,7 @@ "; -%ignore simuPOP::Bernullitrials::setParameter(const vectorf &prob, size_t trials); +%ignore simuPOP::Bernullitrials::setParameter(const vectorf &prob, size_t trials=0); %feature("docstring") simuPOP::Bernullitrials::doTrial " @@ -1032,6 +1032,8 @@ %feature("docstring") simuPOP::CombinedParentsChooser::describe "Obsolete or undocumented function." +%ignore simuPOP::CombinedParentsChooser::parallelizable() const; + %ignore simuPOP::CombinedParentsChooser::initialize(Population &pop, size_t sp); %ignore simuPOP::CombinedParentsChooser::finalize(Population &pop, size_t sp); @@ -3191,6 +3193,8 @@ %feature("docstring") simuPOP::InheritTagger::clone "Obsolete or undocumented function." +%ignore simuPOP::InheritTagger::parallelizable() const; + %feature("docstring") simuPOP::InitGenotype " Details: @@ -3547,6 +3551,8 @@ %feature("docstring") simuPOP::MaPenetrance::describe "Obsolete or undocumented function." +%ignore simuPOP::MaPenetrance::parallelizable() const; + %feature("docstring") simuPOP::MapPenetrance " Details: @@ -3595,6 +3601,8 @@ %feature("docstring") simuPOP::MapPenetrance::describe "Obsolete or undocumented function." +%ignore simuPOP::MapPenetrance::parallelizable() const; + %feature("docstring") simuPOP::MapSelector " Details: @@ -3644,6 +3652,8 @@ %feature("docstring") simuPOP::MapSelector::describe "Obsolete or undocumented function." +%ignore simuPOP::MapSelector::parallelizable() const; + %feature("docstring") simuPOP::MaSelector " Details: @@ -3700,6 +3710,8 @@ %feature("docstring") simuPOP::MaSelector::describe "Obsolete or undocumented function." +%ignore simuPOP::MaSelector::parallelizable() const; + %feature("docstring") simuPOP::MatingScheme " Details: @@ -4065,6 +4077,8 @@ %ignore simuPOP::MitochondrialGenoTransmitter::applyDuringMating(Population &pop, Population &offPop, RawIndIterator offspring, Individual *dad=NULL, Individual *mom=NULL) const; +%ignore simuPOP::MitochondrialGenoTransmitter::parallelizable() const; + %feature("docstring") simuPOP::MixedMutator " Details: @@ -4158,6 +4172,8 @@ %feature("docstring") simuPOP::MlPenetrance::describe "Obsolete or undocumented function." +%ignore simuPOP::MlPenetrance::parallelizable() const; + %feature("docstring") simuPOP::MlSelector " Details: @@ -4208,6 +4224,8 @@ %feature("docstring") simuPOP::MlSelector::describe "Obsolete or undocumented function." +%ignore simuPOP::MlSelector::parallelizable() const; + %feature("docstring") simuPOP::MutSpaceMutator " Details: @@ -4838,6 +4856,8 @@ %ignore simuPOP::ParentsTagger::applyDuringMating(Population &pop, Population &offPop, RawIndIterator offspring, Individual *dad=NULL, Individual *mom=NULL) const; +%ignore simuPOP::ParentsTagger::parallelizable() const; + %feature("docstring") simuPOP::Pause " Details: @@ -5256,6 +5276,14 @@ %ignore simuPOP::PedigreeMating::mate(Population &pop, Population &scratch); +%feature("docstring") simuPOP::PedigreeMating::parallelizable " + +Usage: + + x.parallelizable() + +"; + %feature("docstring") simuPOP::PedigreeTagger " Details: @@ -5330,6 +5358,8 @@ %ignore simuPOP::PedigreeTagger::applyDuringMating(Population &pop, Population &offPop, RawIndIterator offspring, Individual *dad=NULL, Individual *mom=NULL) const; +%ignore simuPOP::PedigreeTagger::parallelizable() const; + %feature("docstring") simuPOP::PointMutator " Details: @@ -5445,6 +5475,8 @@ %feature("docstring") simuPOP::PolyParentsChooser::describe "Obsolete or undocumented function." +%ignore simuPOP::PolyParentsChooser::parallelizable() const; + %ignore simuPOP::PolyParentsChooser::initialize(Population &pop, size_t sp); %ignore simuPOP::PolyParentsChooser::chooseParents(RawIndIterator basePtr); @@ -7190,6 +7222,8 @@ %feature("docstring") simuPOP::PyParentsChooser::describe "Obsolete or undocumented function." +%ignore simuPOP::PyParentsChooser::parallelizable() const; + %ignore simuPOP::PyParentsChooser::initialize(Population &pop, size_t sp); %ignore simuPOP::PyParentsChooser::finalize(Population &pop, size_t sp); @@ -7251,6 +7285,8 @@ %feature("docstring") simuPOP::PyPenetrance::describe "Obsolete or undocumented function." +%ignore simuPOP::PyPenetrance::parallelizable() const; + %feature("docstring") simuPOP::pyPopIterator " Details: @@ -7383,6 +7419,8 @@ %feature("docstring") simuPOP::PySelector::describe "Obsolete or undocumented function." +%ignore simuPOP::PySelector::parallelizable() const; + %feature("docstring") simuPOP::PyTagger " Details: @@ -7424,6 +7462,8 @@ %ignore simuPOP::PyTagger::applyDuringMating(Population &pop, Population &offPop, RawIndIterator offspring, Individual *dad=NULL, Individual *mom=NULL) const; +%ignore simuPOP::PyTagger::parallelizable() const; + %feature("docstring") simuPOP::RandomParentChooser " Details: @@ -7767,6 +7807,8 @@ %ignore simuPOP::Recombinator::applyDuringMating(Population &pop, Population &offPop, RawIndIterator offspring, Individual *dad, Individual *mom) const; +%ignore simuPOP::Recombinator::parallelizable() const; + %feature("docstring") simuPOP::ResizeSubPops " Details: @@ -7942,8 +7984,6 @@ "; -%ignore simuPOP::RNG::generateRandomSeed(); - %feature("docstring") simuPOP::RNG::randUniform " Usage: @@ -10378,6 +10418,8 @@ %ignore simuPOP::fetchAndIncrement(ATOMICLONG *val); +%ignore simuPOP::parallelSort(T1 start, T1 end, T2 cmp); + %ignore simuPOP::simuPOPkbhit(); %ignore simuPOP::simuPOPgetch(); Modified: trunk/simuPOP/stator.cpp =================================================================== --- trunk/simuPOP/stator.cpp 2011-07-06 16:18:23 UTC (rev 4247) +++ trunk/simuPOP/stator.cpp 2011-07-06 16:52:32 UTC (rev 4248) @@ -2483,7 +2483,7 @@ } } #endif - } else { + } else{ HAPLOLIST::const_iterator it = begin; for (; it != end; ++it) { HAPLOLIST::const_iterator it1 = it; Modified: trunk/simuPOP/transmitter.cpp =================================================================== --- trunk/simuPOP/transmitter.cpp 2011-07-06 16:18:23 UTC (rev 4247) +++ trunk/simuPOP/transmitter.cpp 2011-07-06 16:52:32 UTC (rev 4248) @@ -420,7 +420,7 @@ GenoTransmitter(output, begin, end, step, at, reps, subPops, infoFields), m_intensity(intensity), m_rates(rates.elems()), m_loci(loci), m_recBeforeLoci(0), m_convMode(convMode.elems()), m_chromX(-1), m_chromY(-1), - m_customizedBegin(-1), m_customizedEnd(-1), m_algorithm(0), m_debugOutput(NULL), + m_customizedBegin(-1), m_customizedEnd(-1), m_algorithm(0), m_debugOutput(NULL), #ifdef _OPENMP m_bt(numThreads(), getRNG()) #else Modified: trunk/simuPOP/transmitter.h =================================================================== --- trunk/simuPOP/transmitter.h 2011-07-06 16:18:23 UTC (rev 4247) +++ trunk/simuPOP/transmitter.h 2011-07-06 16:52:32 UTC (rev 4248) @@ -638,7 +638,7 @@ #ifdef _OPENMP mutable vector<Bernullitrials> m_bt; #else - mutable Bernullitrials m_bt; + mutable Bernullitrials m_bt; #endif Modified: trunk/simuPOP/utility.cpp =================================================================== --- trunk/simuPOP/utility.cpp 2011-07-06 16:18:23 UTC (rev 4247) +++ trunk/simuPOP/utility.cpp 2011-07-06 16:52:32 UTC (rev 4248) @@ -492,7 +492,7 @@ ATOMICLONG fetchAndIncrement(ATOMICLONG * val) { - if(g_numThreads == 1) + if (g_numThreads == 1) return (*val)++; else #ifdef _WIN64 @@ -500,11 +500,11 @@ #elif defined(_WIN32) return InterlockedIncrement(val) - 1; #else - // for Intel C++, see page 164 of - // http://softwarecommunity.intel.com/isn/downloads/softwareproducts/pdfs/347603.pdf - // - // for gcc, see - // http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html + // for Intel C++, see page 164 of + // http://softwarecommunity.intel.com/isn/downloads/softwareproducts/pdfs/347603.pdf + // + // for gcc, see + // http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html return __sync_fetch_and_add(val, 1); #endif } @@ -2265,9 +2265,9 @@ if (m_stmts != NULL) { #if PY_VERSION_HEX >= 0x03020000 res = PyEval_EvalCode((PyObject *)m_stmts, m_locals, m_locals); -#else +#else res = PyEval_EvalCode((PyCodeObject *)m_stmts, m_locals, m_locals); -#endif +#endif if (res == NULL) { #ifndef OPTIMIZED if (debug(DBG_GENERAL)) { @@ -2287,7 +2287,7 @@ res = PyEval_EvalCode((PyObject *)m_expr, m_locals, m_locals); #else res = PyEval_EvalCode((PyCodeObject *)m_expr, m_locals, m_locals); -#endif +#endif if (res == NULL) { #ifndef OPTIMIZED if (debug(DBG_GENERAL)) { Modified: trunk/simuPOP/utility.h =================================================================== --- trunk/simuPOP/utility.h 2011-07-06 16:18:23 UTC (rev 4247) +++ trunk/simuPOP/utility.h 2011-07-06 16:52:32 UTC (rev 4248) @@ -80,7 +80,7 @@ # include "tbb/parallel_sort.h" # include "tbb/task_scheduler_init.h" # elif defined(GCC_VERSION) && GCC_VERSION >= 40300 -# include "parallel/algorithm" +# include "parallel/algorithm" # endif #endif /// for bernulli trials. @@ -171,6 +171,7 @@ } } + /// a utility function to check keyboard stroke /// CPPONLY int simuPOP_kbhit(); @@ -1228,7 +1229,7 @@ if (expr.empty() && stmts.empty()) return; - //detect leading spaces from python expressions + //detect leading spaces from python expressions DBG_FAILIF(!expr.empty() && (expr[0] == ' ' || expr[0] == '\t'), ValueError, "Can not include leading space in python expression '" + expr + "'"); DBG_FAILIF(!stmts.empty() && (stmts[0] == ' ' || stmts[0] == '\t'), ValueError, Modified: trunk/tools/doxy2swig.py =================================================================== --- trunk/tools/doxy2swig.py 2011-07-06 16:18:23 UTC (rev 4247) +++ trunk/tools/doxy2swig.py 2011-07-06 16:52:32 UTC (rev 4248) @@ -1375,7 +1375,7 @@ xml_file = sys.argv[1] # output interface file if len(sys.argv) < 3: - interface_file = os.path.join(src_path, 'src', 'simuPOP_doc.i') + interface_file = os.path.join(src_path, 'simuPOP', 'simuPOP_doc.i') else: interface_file = sys.argv[2] # output ref_single.tex file @@ -1400,7 +1400,7 @@ # write interface file to output interface file. print 'Writing SWIG interface file to', interface_file p.write(interface_file, type='swig') - sys.path = [os.path.join(src_path, 'src')] + sys.path + sys.path = [os.path.join(src_path, 'simuPOP')] + sys.path p.scan_module('simuPOP') p.scan_module('simuOpt') p.scan_module('simuPOP.utils') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2011-07-06 17:25:01
|
Revision: 4251 http://simupop.svn.sourceforge.net/simupop/?rev=4251&view=rev Author: simupop Date: 2011-07-06 17:24:55 +0000 (Wed, 06 Jul 2011) Log Message: ----------- Prepare a release Modified Paths: -------------- trunk/ChangeLog trunk/doc/refManual.lyx trunk/doc/userGuide.lyx trunk/doc/userGuide.pdf trunk/simuPOP_version.py trunk/tools/build.py Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-07-06 17:10:22 UTC (rev 4250) +++ trunk/ChangeLog 2011-07-06 17:24:55 UTC (rev 4251) @@ -4,7 +4,12 @@ - BUG: simuPOP does not respond well to Ctrl-C under windows. - BUG: Textbox in Tkinter help dialog does not resize. -version 1.0.6 - Not released, available at https://simupop.svn.sourceforge.net/svnroot/simupop/trunk +version 1.0.7 - Not released, available at https://simupop.svn.sourceforge.net/svnroot/simupop/trunk + +version 1.0.6 - Rev 4250 (July 6, 2011) +Major new feature: + - Multi-thread support that allows simuPOP to take advantage of multi-core CPUs. + New features: - Expose function Population::virtualSplitter - Allow single input for parameters cutoff and values of operator InfoSplitter. Modified: trunk/doc/refManual.lyx =================================================================== --- trunk/doc/refManual.lyx 2011-07-06 17:10:22 UTC (rev 4250) +++ trunk/doc/refManual.lyx 2011-07-06 17:24:55 UTC (rev 4251) @@ -5,7 +5,7 @@ \textclass manual \begin_preamble \renewcommand{\py@ptsize}{12pt} -\setreleaseinfo{Release 1.0.5 (\mbox{Rev: 3918})} +\setreleaseinfo{Release 1.0.6 (\mbox{Rev: 4250})} % file revision $Rev: 3372$ \authoraddress{ {\bf Department of Epidemiology, U.T. M.D. Anderson Cancer Center}\\ Modified: trunk/doc/userGuide.lyx =================================================================== --- trunk/doc/userGuide.lyx 2011-07-06 17:10:22 UTC (rev 4250) +++ trunk/doc/userGuide.lyx 2011-07-06 17:24:55 UTC (rev 4251) @@ -6,7 +6,7 @@ \begin_preamble \renewcommand{\py@ptsize}{12pt} -\setreleaseinfo{Release 1.0.5 (\mbox{Rev: 3918})} +\setreleaseinfo{Release 1.0.6 (\mbox{Rev: 4250})} % file revision $Rev: 3372$ \authoraddress{ {\bf Department of Epidemiology, U.T. M.D. Anderson Cancer Center}\\ Modified: trunk/doc/userGuide.pdf =================================================================== (Binary files differ) Modified: trunk/simuPOP_version.py =================================================================== --- trunk/simuPOP_version.py 2011-07-06 17:10:22 UTC (rev 4250) +++ trunk/simuPOP_version.py 2011-07-06 17:24:55 UTC (rev 4251) @@ -1,2 +1,2 @@ -SIMUPOP_VER = "1.0.6svn" -SIMUPOP_REV = "3918" +SIMUPOP_VER = "1.0.6" +SIMUPOP_REV = "4250" Modified: trunk/tools/build.py =================================================================== --- trunk/tools/build.py 2011-07-06 17:10:22 UTC (rev 4250) +++ trunk/tools/build.py 2011-07-06 17:24:55 UTC (rev 4251) @@ -13,6 +13,7 @@ release_file = 'simuPOP_version.py' user_guide = 'doc/userGuide.lyx' ref_manual = 'doc/refManual.lyx' +download_directory = 'download' def setReleaseInManual(filename, rel, rev): '''Replace Release x.x.x with Rev: with proper value during release''' @@ -258,7 +259,6 @@ ''' if __name__ == '__main__': - config_file = 'build.cfg' release = 'snapshot' actions = [] dryrun = False @@ -274,8 +274,6 @@ sys.exit(0) elif '--release' in op: release = op[10:] - elif '--config' in op: - config_file = op[9:] elif op == 'all': actions.extend(['src', 'doc', 'svn', 'x86_64', 'rhel4', 'mac', 'win', 'fedora5', 'suse']) elif op in all_actions and op not in actions: @@ -286,12 +284,6 @@ print "Unknown option", op sys.exit(1) # - if os.path.isfile(config_file): - execfile(config_file) - else: - print 'Configuration file not found' - sys.exit(1) - # os.chdir('..') # get revision number and update last_revision_file (ver, rev, old_ver, old_rev) = setVersionRevision(release) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2011-07-07 03:06:02
|
Revision: 4253 http://simupop.svn.sourceforge.net/simupop/?rev=4253&view=rev Author: simupop Date: 2011-07-07 03:05:52 +0000 (Thu, 07 Jul 2011) Log Message: ----------- Revert src -> simuPOP directory change Modified Paths: -------------- trunk/Doxy_web trunk/Doxyfile trunk/MANIFEST.in trunk/Makefile trunk/SConstruct trunk/setup.py trunk/tools/doxy2swig.py Added Paths: ----------- trunk/src/ trunk/src/__init__.py trunk/src/customizedTypes.c trunk/src/genoStru.cpp trunk/src/genoStru.h trunk/src/gsl.i trunk/src/individual.cpp trunk/src/individual.h trunk/src/initializer.cpp trunk/src/initializer.h trunk/src/main.cpp trunk/src/mating.cpp trunk/src/mating.h trunk/src/migrator.cpp trunk/src/migrator.h trunk/src/mutator.cpp trunk/src/mutator.h trunk/src/operator.cpp trunk/src/operator.h trunk/src/outputer.cpp trunk/src/outputer.h trunk/src/pedigree.cpp trunk/src/pedigree.h trunk/src/penetrance.cpp trunk/src/penetrance.h trunk/src/plotter.py trunk/src/population.cpp trunk/src/population.h trunk/src/qtrait.cpp trunk/src/qtrait.h trunk/src/sampling.py trunk/src/sandbox.cpp trunk/src/sandbox.h trunk/src/sandbox.py trunk/src/selector.cpp trunk/src/selector.h trunk/src/simuPOP_ba.i trunk/src/simuPOP_baop.i trunk/src/simuPOP_cfg.h trunk/src/simuPOP_common.i trunk/src/simuPOP_doc.i trunk/src/simuPOP_la.i trunk/src/simuPOP_laop.i trunk/src/simuPOP_op.i trunk/src/simuPOP_std.i trunk/src/simulator.cpp trunk/src/simulator.h trunk/src/stator.cpp trunk/src/stator.h trunk/src/tagger.cpp trunk/src/tagger.h trunk/src/transmitter.cpp trunk/src/transmitter.h trunk/src/utility.cpp trunk/src/utility.h trunk/src/utils.py trunk/src/virtualSubPop.cpp trunk/src/virtualSubPop.h Removed Paths: ------------- trunk/simuPOP/ trunk/src/__init__.py trunk/src/customizedTypes.c trunk/src/genoStru.cpp trunk/src/genoStru.h trunk/src/gsl.i trunk/src/individual.cpp trunk/src/individual.h trunk/src/initializer.cpp trunk/src/initializer.h trunk/src/main.cpp trunk/src/mating.cpp trunk/src/mating.h trunk/src/migrator.cpp trunk/src/migrator.h trunk/src/mutator.cpp trunk/src/mutator.h trunk/src/operator.cpp trunk/src/operator.h trunk/src/outputer.cpp trunk/src/outputer.h trunk/src/pedigree.cpp trunk/src/pedigree.h trunk/src/penetrance.cpp trunk/src/penetrance.h trunk/src/plotter.py trunk/src/population.cpp trunk/src/population.h trunk/src/qtrait.cpp trunk/src/qtrait.h trunk/src/sampling.py trunk/src/sandbox.cpp trunk/src/sandbox.h trunk/src/sandbox.py trunk/src/selector.cpp trunk/src/selector.h trunk/src/simuPOP_ba.i trunk/src/simuPOP_baop.i trunk/src/simuPOP_cfg.h trunk/src/simuPOP_common.i trunk/src/simuPOP_doc.i trunk/src/simuPOP_la.i trunk/src/simuPOP_laop.i trunk/src/simuPOP_op.i trunk/src/simuPOP_std.i trunk/src/simulator.cpp trunk/src/simulator.h trunk/src/stator.cpp trunk/src/stator.h trunk/src/tagger.cpp trunk/src/tagger.h trunk/src/transmitter.cpp trunk/src/transmitter.h trunk/src/utility.cpp trunk/src/utility.h trunk/src/utils.py trunk/src/virtualSubPop.cpp trunk/src/virtualSubPop.h Modified: trunk/Doxy_web =================================================================== --- trunk/Doxy_web 2011-07-06 17:26:44 UTC (rev 4252) +++ trunk/Doxy_web 2011-07-07 03:05:52 UTC (rev 4253) @@ -578,7 +578,7 @@ # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = simuPOP +INPUT = src # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is Modified: trunk/Doxyfile =================================================================== --- trunk/Doxyfile 2011-07-06 17:26:44 UTC (rev 4252) +++ trunk/Doxyfile 2011-07-07 03:05:52 UTC (rev 4253) @@ -578,7 +578,7 @@ # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = simuPOP \ +INPUT = src \ config_linux.h # This tag can be used to specify the character encoding of the source files Modified: trunk/MANIFEST.in =================================================================== --- trunk/MANIFEST.in 2011-07-06 17:26:44 UTC (rev 4252) +++ trunk/MANIFEST.in 2011-07-07 03:05:52 UTC (rev 4253) @@ -18,86 +18,86 @@ include config_win32.h include config_linux.h include config_mac.h -include simuPOP/simuPOP_cfg.h -include simuPOP/utility.h -include simuPOP/genoStru.h -include simuPOP/individual.h -include simuPOP/population.h -include simuPOP/simulator.h -include simuPOP/mating.h -include simuPOP/operator.h -include simuPOP/initializer.h -include simuPOP/migrator.h -include simuPOP/outputer.h -include simuPOP/selector.h -include simuPOP/penetrance.h -include simuPOP/qtrait.h -include simuPOP/stator.h -include simuPOP/mutator.h -include simuPOP/transmitter.h -include simuPOP/tagger.h -include simuPOP/pedigree.h -include simuPOP/virtualSubPop.h -include simuPOP/sandbox.h +include src/simuPOP_cfg.h +include src/utility.h +include src/genoStru.h +include src/individual.h +include src/population.h +include src/simulator.h +include src/mating.h +include src/operator.h +include src/initializer.h +include src/migrator.h +include src/outputer.h +include src/selector.h +include src/penetrance.h +include src/qtrait.h +include src/stator.h +include src/mutator.h +include src/transmitter.h +include src/tagger.h +include src/pedigree.h +include src/virtualSubPop.h +include src/sandbox.h # source files -include simuPOP/customizedTypes.c -include simuPOP/utility.cpp -include simuPOP/genoStru.cpp -include simuPOP/individual.cpp -include simuPOP/population.cpp -include simuPOP/simulator.cpp -include simuPOP/mating.cpp -include simuPOP/operator.cpp -include simuPOP/initializer.cpp -include simuPOP/migrator.cpp -include simuPOP/outputer.cpp -include simuPOP/selector.cpp -include simuPOP/penetrance.cpp -include simuPOP/qtrait.cpp -include simuPOP/stator.cpp -include simuPOP/mutator.cpp -include simuPOP/transmitter.cpp -include simuPOP/tagger.cpp -include simuPOP/pedigree.cpp -include simuPOP/virtualSubPop.cpp -include simuPOP/sandbox.cpp -include simuPOP/main.cpp +include src/customizedTypes.c +include src/utility.cpp +include src/genoStru.cpp +include src/individual.cpp +include src/population.cpp +include src/simulator.cpp +include src/mating.cpp +include src/operator.cpp +include src/initializer.cpp +include src/migrator.cpp +include src/outputer.cpp +include src/selector.cpp +include src/penetrance.cpp +include src/qtrait.cpp +include src/stator.cpp +include src/mutator.cpp +include src/transmitter.cpp +include src/tagger.cpp +include src/pedigree.cpp +include src/virtualSubPop.cpp +include src/sandbox.cpp +include src/main.cpp # source generated files -include simuPOP/swigpyrun.h -include simuPOP/simuPOP_std_wrap.cpp -include simuPOP/simuPOP_op_wrap.cpp -include simuPOP/simuPOP_la_wrap.cpp -include simuPOP/simuPOP_laop_wrap.cpp -include simuPOP/simuPOP_ba_wrap.cpp -include simuPOP/simuPOP_baop_wrap.cpp -include simuPOP/simuPOP_std.py -include simuPOP/simuPOP_op.py -include simuPOP/simuPOP_la.py -include simuPOP/simuPOP_laop.py -include simuPOP/simuPOP_ba.py -include simuPOP/simuPOP_baop.py -include simuPOP/gsl_wrap.c +include src/swigpyrun.h +include src/simuPOP_std_wrap.cpp +include src/simuPOP_op_wrap.cpp +include src/simuPOP_la_wrap.cpp +include src/simuPOP_laop_wrap.cpp +include src/simuPOP_ba_wrap.cpp +include src/simuPOP_baop_wrap.cpp +include src/simuPOP_std.py +include src/simuPOP_op.py +include src/simuPOP_la.py +include src/simuPOP_laop.py +include src/simuPOP_ba.py +include src/simuPOP_baop.py +include src/gsl_wrap.c # source wrap files -include simuPOP/simuPOP_common.i -include simuPOP/simuPOP_doc.i -include simuPOP/simuPOP_std.i -include simuPOP/simuPOP_op.i -include simuPOP/simuPOP_la.i -include simuPOP/simuPOP_laop.i -include simuPOP/simuPOP_ba.i -include simuPOP/simuPOP_baop.i -include simuPOP/gsl.i +include src/simuPOP_common.i +include src/simuPOP_doc.i +include src/simuPOP_std.i +include src/simuPOP_op.i +include src/simuPOP_la.i +include src/simuPOP_laop.i +include src/simuPOP_ba.i +include src/simuPOP_baop.i +include src/gsl.i # source python files (modules) include simuOpt.py -include simuPOP/__init__.py -include simuPOP/utils.py -include simuPOP/plotter.py -include simuPOP/sampling.py -include simuPOP/sandbox.py +include src/__init__.py +include src/utils.py +include src/plotter.py +include src/sampling.py +include src/sandbox.py # gsl files include gsl/gsl_machine.h Modified: trunk/Makefile =================================================================== --- trunk/Makefile 2011-07-06 17:26:44 UTC (rev 4252) +++ trunk/Makefile 2011-07-07 03:05:52 UTC (rev 4253) @@ -4,7 +4,7 @@ rebuild: - bcpp simuPOP/*.h simuPOP/*.cpp + bcpp src/*.h src/*.cpp doxygen tools/doxy2swig.py scons install -j4 std @@ -17,7 +17,7 @@ clean: @rm -rf build - @rm -f simuPOP/*wrap* simuPOP/simuPOP_*.py + @rm -f src/*wrap* src/simuPOP_*.py @find . -name '*~' -exec rm -f {} \; @find . -name '*.bak' -exec rm -f {} \; @find . -name '*.py?' -exec rm -f {} \; Modified: trunk/SConstruct =================================================================== --- trunk/SConstruct 2011-07-06 17:26:44 UTC (rev 4252) +++ trunk/SConstruct 2011-07-07 03:05:52 UTC (rev 4253) @@ -159,11 +159,11 @@ # gsl_env = env.Clone() gsl_env.VariantDir('build/gsl', '.') -gsl_env['SWIGOUTDIR'] = 'build/gsl/simuPOP' +gsl_env['SWIGOUTDIR'] = 'build/gsl/src' gsl_env['SWIGFLAGS'] = SWIG_CC_FLAGS gsl = gsl_env.SharedLibrary( target = 'build/gsl/_gsl%s' % so_ext, - source = ['build/gsl/' + x for x in GSL_FILES] + ['build/gsl/simuPOP/gsl.i'], + source = ['build/gsl/' + x for x in GSL_FILES] + ['build/gsl/src/gsl.i'], SHLIBPREFIX = "", SHLIBSUFFIX = so_ext, SHLINKFLAGS = comp.ldflags_shared, @@ -176,7 +176,7 @@ Alias('gsl', gsl) Alias('all', gsl) Alias('install', gsl_env.InstallAs(os.path.join(dest_dir, '_gsl%s' % so_ext), gsl[0])) -Alias('install', gsl_env.InstallAs(os.path.join(dest_dir, 'gsl.py'), 'build/gsl/simuPOP/gsl.py')) +Alias('install', gsl_env.InstallAs(os.path.join(dest_dir, 'gsl.py'), 'build/gsl/src/gsl.py')) # # # Building a library for common files @@ -229,22 +229,22 @@ for mod in targets: mod_env = env.Clone() mod_env.VariantDir('build/' + mod, '.') - mod_env['SWIGFLAGS'] = SWIG_CPP_FLAGS + ' -IsimuPOP' # -IsimuPOP for %include interface files under simuPOP - mod_env['SWIGOUTDIR'] = 'build/%s/simuPOP' % mod + mod_env['SWIGFLAGS'] = SWIG_CPP_FLAGS + ' -Isrc' # -Isrc for %include interface files under src + mod_env['SWIGOUTDIR'] = 'build/%s/src' % mod info = ModuInfo(mod, SIMUPOP_VER, SIMUPOP_REV) - mod_env.Command('build/%s/simuPOP/swigpyrun.h' % mod, None, ['swig %s $TARGET' % SWIG_RUNTIME_FLAGS]) + mod_env.Command('build/%s/src/swigpyrun.h' % mod, None, ['swig %s $TARGET' % SWIG_RUNTIME_FLAGS]) if 'op' in mod: common_lib = op_common_lib else: common_lib = std_common_lib mod_wrapper = mod_env.StaticLibrary( - target = 'build/%s/simuPOP/_simuPOP_wrap_%s' % (mod, mod), - source = ['build/%s/simuPOP/simuPOP_%s.i' % (mod, mod)], + target = 'build/%s/src/_simuPOP_wrap_%s' % (mod, mod), + source = ['build/%s/src/simuPOP_%s.i' % (mod, mod)], SHLIBPREFIX = "", SHLIBSUFFIX = so_ext, SHLINKFLAGS = comp.ldflags_shared, LIBPATH = info['library_dirs'] + extra_path, - CPPPATH = [python_inc_dir, '.', 'simuPOP', 'build'] + info['include_dirs'], + CPPPATH = [python_inc_dir, '.', 'src', 'build'] + info['include_dirs'], CPPDEFINES = convert_def(info['define_macros']), # No extra-flags because it can have -Werror and we cannot guarantee that there is # no warning coming out of the wrapper code. @@ -253,22 +253,22 @@ ) mod_lib = mod_env.SharedLibrary( target = 'build/%s/_simuPOP_%s' % (mod, mod), - source = ['build/%s/simuPOP/%s' % (mod, x) for x in SOURCE_FILES], + source = ['build/%s/src/%s' % (mod, x) for x in SOURCE_FILES], LIBS = info['libraries'] + [mod_wrapper, common_lib], SHLIBPREFIX = "", SHLIBSUFFIX = so_ext, SHLINKFLAGS = comp.ldflags_shared, LIBPATH = info['library_dirs'] + extra_path, - CPPPATH = [python_inc_dir, '.', 'simuPOP', 'build'] + info['include_dirs'], + CPPPATH = [python_inc_dir, '.', 'src', 'build'] + info['include_dirs'], CPPDEFINES = convert_def(info['define_macros']), CCFLAGS = info['extra_compile_args'] + comp.compile_options + extra_flags, CPPFLAGS = ' '.join([basicflags, ccshared, opt]) ) - env.Depends('build/%s/simuPOP/swigpyrun.h' % mod, 'build/%s/simuPOP/utility.cpp' % mod) + env.Depends('build/%s/src/swigpyrun.h' % mod, 'build/%s/src/utility.cpp' % mod) Alias(mod, mod_lib) Alias('all', mod_lib) pyInstall = env.InstallAs(os.path.join(dest_dir, 'simuPOP_%s.py' % mod), - 'build/%s/simuPOP/simuPOP_%s.py' % (mod, mod)) + 'build/%s/src/simuPOP_%s.py' % (mod, mod)) libInstall = env.InstallAs(os.path.join(dest_dir, '_simuPOP_%s%s' % (mod, so_ext)), mod_lib[0]) mod_env.Depends(pyInstall, libInstall) @@ -285,8 +285,8 @@ mod_name = mod.split('_')[0] exe_env = env.Clone() exe_env.VariantDir('build/' + mod, '.') - exe_env['SWIGFLAGS'] = SWIG_CPP_FLAGS + ' -IsimuPOP' # -IsimuPOP for %include interface files under simuPOP - exe_env['SWIGOUTDIR'] = 'build/%s/simuPOP' % mod + exe_env['SWIGFLAGS'] = SWIG_CPP_FLAGS + ' -Isrc' # -Isrc for %include interface files under src + exe_env['SWIGOUTDIR'] = 'build/%s/src' % mod info = ModuInfo(mod_name, SIMUPOP_VER, SIMUPOP_REV) if 'op' in mod: common_lib = op_common_lib @@ -294,10 +294,10 @@ common_lib = std_common_lib mod_executable = exe_env.Program( target = 'build/simuPOP_%s' % mod, - source = ['build/%s/simuPOP/%s' % (mod, x) for x in SOURCE_FILES], + source = ['build/%s/src/%s' % (mod, x) for x in SOURCE_FILES], LIBS = info['libraries'] + [common_lib] + pylibs, LIBPATH = info['library_dirs'] + extra_path, - CPPPATH = [python_inc_dir, '.', 'simuPOP', 'build'] + info['include_dirs'], + CPPPATH = [python_inc_dir, '.', 'src', 'build'] + info['include_dirs'], CPPDEFINES = convert_def(info['define_macros'] + [('STANDALONE_EXECUTABLE', None)]), CCFLAGS = info['extra_compile_args'] + comp.compile_options + extra_flags, CPPFLAGS = ' '.join([basicflags, ccshared, opt]) @@ -309,11 +309,11 @@ env.Install(pylib_dir, 'simuOpt.py') Alias('install', pylib_dir) for pyfile in ['__init__.py', 'utils.py', 'plotter.py', 'sampling.py', 'sandbox.py']: - env.Install(dest_dir, 'simuPOP/%s' % pyfile) + env.Install(dest_dir, 'src/%s' % pyfile) Alias('install', dest_dir) for datafile in PACKAGE_DATA: - env.Install(dest_dir, 'simuPOP/%s' % datafile) + env.Install(dest_dir, 'src/%s' % datafile) Alias('install', dest_dir) Default('install') Modified: trunk/setup.py =================================================================== --- trunk/setup.py 2011-07-06 17:26:44 UTC (rev 4252) +++ trunk/setup.py 2011-07-07 03:05:52 UTC (rev 4253) @@ -399,9 +399,9 @@ SWIG_CC_FLAGS += ' -py3' SWIG_RUNTIME_FLAGS = '-python -external-runtime' -# python setup.py reads py_modules from simuPOP so we have to produce simuPOP_std.py +# python setup.py reads py_modules from src so we have to produce simuPOP_std.py # etc to this directory. -SWIG_OUTDIR = 'simuPOP' +SWIG_OUTDIR = 'src' if not os.path.isdir('build'): os.mkdir('build') @@ -421,12 +421,12 @@ } WRAP_INFO = { - 'std': ['simuPOP/simuPOP_std_wrap.cpp', 'simuPOP/simuPOP_std.i', ''], - 'op': ['simuPOP/simuPOP_op_wrap.cpp', 'simuPOP/simuPOP_op.i', '-DOPTIMIZED'], - 'la': ['simuPOP/simuPOP_la_wrap.cpp', 'simuPOP/simuPOP_la.i', '-DLONGALLELE'], - 'laop': ['simuPOP/simuPOP_laop_wrap.cpp', 'simuPOP/simuPOP_laop.i', '-DLONGALLELE -DOPTIMIZED'], - 'ba': ['simuPOP/simuPOP_ba_wrap.cpp', 'simuPOP/simuPOP_ba.i', '-DBINARYALLELE'], - 'baop': ['simuPOP/simuPOP_baop_wrap.cpp', 'simuPOP/simuPOP_baop.i', '-DBINARYALLELE -DOPTIMIZED'], + 'std': ['src/simuPOP_std_wrap.cpp', 'src/simuPOP_std.i', ''], + 'op': ['src/simuPOP_op_wrap.cpp', 'src/simuPOP_op.i', '-DOPTIMIZED'], + 'la': ['src/simuPOP_la_wrap.cpp', 'src/simuPOP_la.i', '-DLONGALLELE'], + 'laop': ['src/simuPOP_laop_wrap.cpp', 'src/simuPOP_laop.i', '-DLONGALLELE -DOPTIMIZED'], + 'ba': ['src/simuPOP_ba_wrap.cpp', 'src/simuPOP_ba.i', '-DBINARYALLELE'], + 'baop': ['src/simuPOP_baop_wrap.cpp', 'src/simuPOP_baop.i', '-DBINARYALLELE -DOPTIMIZED'], } if os.name == 'nt': @@ -466,7 +466,7 @@ boost_lib_names = [] boost_lib_path = None res = {} - res['src'] = ['simuPOP/simuPOP_' + modu + '_wrap.cpp'] + res['src'] = ['src/simuPOP_' + modu + '_wrap.cpp'] for src in SOURCE_FILES: res['src'].append('build/%s/%s' % (modu, src)) res['src'].extend(LIB_FILES) @@ -534,8 +534,8 @@ machine = platform.uname()[4].lower() if machine == '': # have to guess machine = 'x86' - shutil.copy('win32/%s/vcomp90.dll' % machine, 'simuPOP/vcomp90.dll') - shutil.copy('win32/%s/msvcr90.dll' % machine, 'simuPOP/msvcr90.dll') + shutil.copy('win32/%s/vcomp90.dll' % machine, 'src/vcomp90.dll') + shutil.copy('win32/%s/msvcr90.dll' % machine, 'src/msvcr90.dll') if __name__ == '__main__': SIMUPOP_VER, SIMUPOP_REV = simuPOP_version() @@ -546,9 +546,9 @@ # # if any of the wrap files does not exist # or if the wrap files are older than any of the source files. - if (not os.path.isfile('simuPOP/gsl_wrap.c') or (not os.path.isfile('simuPOP/swigpyrun.h')) or \ + if (not os.path.isfile('src/gsl_wrap.c') or (not os.path.isfile('src/swigpyrun.h')) or \ False in [os.path.isfile(WRAP_INFO[x][0]) for x in MODULES]) or \ - (max( [os.path.getmtime('simuPOP/' + x) for x in HEADER_FILES] ) > \ + (max( [os.path.getmtime('src/' + x) for x in HEADER_FILES] ) > \ min( [os.path.getmtime(WRAP_INFO[x][0]) for x in MODULES])): (v1, v2, v3) = swig_version() if (v1, v2, v3) < (1, 3, 35): @@ -558,8 +558,8 @@ print('Swig >= 2.0.4 is required for Python 3.2 or higher') sys.exit(1) # generate header file - print("Generating external runtime header file simuPOP/swigpyrun.h...") - os.system('%s %s simuPOP/swigpyrun.h' % (SWIG, SWIG_RUNTIME_FLAGS)) + print("Generating external runtime header file src/swigpyrun.h...") + os.system('%s %s src/swigpyrun.h' % (SWIG, SWIG_RUNTIME_FLAGS)) # try the first option set with the first library for lib in MODULES: print("Generating wrapper file " + WRAP_INFO[lib][0]) @@ -567,9 +567,9 @@ SWIG_OUTDIR, WRAP_INFO[lib][2], WRAP_INFO[lib][0], WRAP_INFO[lib][1])) != 0: print("Calling swig failed. Please check your swig version.") sys.exit(1) - print("Generating wrapper file simuPOP/gsl_wrap.c") + print("Generating wrapper file src/gsl_wrap.c") if os.system('%s %s -outdir %s %s -o %s %s' % (SWIG, SWIG_CC_FLAGS, \ - SWIG_OUTDIR, '', 'simuPOP/gsl_wrap.c', 'simuPOP/gsl.i')) != 0: + SWIG_OUTDIR, '', 'src/gsl_wrap.c', 'src/gsl.i')) != 0: print("Calling swig failed. Please check your swig version.") sys.exit(1) print("\nAll wrap files are generated successfully.\n") @@ -585,13 +585,13 @@ os.mkdir('build/%s' % modu) for src in SOURCE_FILES: mod_src = 'build/%s/%s' % (modu, src) - if not os.path.isfile(mod_src) or not filecmp.cmp(mod_src,'simuPOP/'+src): - shutil.copy('simuPOP/'+src, mod_src) + if not os.path.isfile(mod_src) or not filecmp.cmp(mod_src,'src/'+src): + shutil.copy('src/'+src, mod_src) # build # For module simuPOP.gsl EXT_MODULES = [ Extension('simuPOP._gsl', - sources = GSL_FILES + ['simuPOP/gsl_wrap.c'], + sources = GSL_FILES + ['src/gsl_wrap.c'], include_dirs = ['gsl', 'gsl/specfunc', 'build', '.'], ) ] @@ -602,7 +602,7 @@ sources = info['src'], extra_compile_args = info['extra_compile_args'], # src for config.h etc, build for swigpyrun.h - include_dirs = info['include_dirs'] + ['simuPOP', 'build'], + include_dirs = info['include_dirs'] + ['src', 'build'], library_dirs = info['library_dirs'], libraries = info['libraries'], define_macros = info['define_macros'], @@ -642,7 +642,7 @@ ], platforms = ['all'], # - package_dir = {'simuPOP': 'simuPOP'}, + package_dir = {'simuPOP': 'src'}, package_data = {'simuPOP': PACKAGE_DATA}, py_modules = [ 'simuOpt', Property changes on: trunk/src ___________________________________________________________________ Added: svn:eol-stype + LF Deleted: trunk/src/__init__.py =================================================================== --- trunk/src/__init__.py 2011-06-29 21:43:36 UTC (rev 4243) +++ trunk/src/__init__.py 2011-07-07 03:05:52 UTC (rev 4253) @@ -1,1153 +0,0 @@ -#!/usr/bin/env python - -# -# $File: __init__.py $ -# $LastChangedDate$ -# $Rev$ -# -# This file is part of simuPOP, a forward-time population genetics -# simulation environment. Please visit http://simupop.sourceforge.net -# for details. -# -# Copyright (C) 2004 - 2010 Bo Peng (bp...@md...) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# - -""" -simuPOP core module. -""" - -__all__ = [ - # Constants - # - 'MALE', - 'FEMALE', - # - 'CUSTOMIZED', - 'AUTOSOME', - 'CHROMOSOME_X', - 'CHROMOSOME_Y', - # - 'CONSTANT', - 'BINOMIAL_DISTRIBUTION', - 'EXPONENTIAL_DISTRIBUTION', - 'GEOMETRIC_DISTRIBUTION', - 'POISSON_DISTRIBUTION', - 'UNIFORM_DISTRIBUTION', - 'NORMAL_DISTRIBUTION', - 'GAMMA_DISTRIBUTION', - # - 'NO_SEX', - 'RANDOM_SEX', - 'PROB_OF_MALES', - 'NUM_OF_MALES', - 'NUM_OF_FEMALES', - 'SEQUENCE_OF_SEX', - 'GLOBAL_SEQUENCE_OF_SEX', - # - 'NO_CONVERSION', - 'NUM_MARKERS', - 'TRACT_LENGTH', - # - 'SPOUSE', - 'OUTBRED_SPOUSE', - 'FULLSIBLING', - 'SIBLING', - 'OFFSPRING', - 'COMMON_OFFSPRING', - # - 'ANY_SEX', - 'MALE_ONLY', - 'FEMALE_ONLY', - 'SAME_SEX', - 'OPPOSITE_SEX', - # - 'MULTIPLICATIVE', - 'ADDITIVE', - 'HETEROGENEITY', - # - 'BY_IND_INFO', - 'BY_PROBABILITY', - 'BY_PROPORTION', - 'BY_COUNTS', - # - 'PATERNAL', - 'MATERNAL', - # - 'MEAN', - 'MAXIMUM', - 'MINIMUM', - 'SUMMATION', - 'MULTIPLICATION', - # - 'HAPLODIPLOID', - 'ALL_AVAIL', - 'UNSPECIFIED', - # - # Major simuPOP classes - 'Population', - # This is just to make help(Individual) available to users. - 'Individual', - 'Simulator', - 'Pedigree', - # splitters - 'SexSplitter', - 'AffectionSplitter', - 'CombinedSplitter', - 'ProductSplitter', - 'ProportionSplitter', - 'InfoSplitter', - 'GenotypeSplitter', - 'RangeSplitter', - # mating schemes - 'MatingScheme', - 'HomoMating', - 'HeteroMating', - 'PedigreeMating', - 'OffspringGenerator', - 'ControlledOffspringGenerator', - 'RandomParentChooser', - 'PyParentsChooser', - 'CombinedParentsChooser', - 'SequentialParentChooser', - 'RandomParentsChooser', - 'SequentialParentsChooser', - 'ParentChooser', - 'PolyParentsChooser', - # - 'RandomMating', - 'RandomSelection', - 'MonogamousMating', - 'SelfMating', - 'CloneMating', - 'HaplodiploidMating', - #'consanguineousMating', - 'ControlledRandomMating', - 'PolygamousMating', - # - # - # Operators - # - 'InitSex', - 'InitInfo', - 'InitGenotype', - # - 'PyOutput', - 'PyEval', - 'PyExec', - 'InfoEval', - 'InfoExec', - # - 'Migrator', - 'MergeSubPops', - 'SplitSubPops', - 'ResizeSubPops', - # - 'GenoTransmitter', - 'HaplodiploidGenoTransmitter', - 'MendelianGenoTransmitter', - 'MitochondrialGenoTransmitter', - 'SelfingGenoTransmitter', - 'CloneGenoTransmitter', - 'Recombinator', - # - 'PointMutator', - 'MatrixMutator', - 'MixedMutator', - 'PyMutator', - 'StepwiseMutator', - 'SNPMutator', - 'AcgtMutator', - 'AminoAcidMutator', - 'ContextMutator', - 'KAlleleMutator', - # - 'MapSelector', - 'MaSelector', - 'MlSelector', - 'PySelector', - # - 'MaPenetrance', - 'MapPenetrance', - 'MlPenetrance', - 'PyPenetrance', - # - 'PyQuanTrait', - # - 'Stat', - # - 'IdTagger', - 'InheritTagger', - 'ParentsTagger', - 'PedigreeTagger', - 'PyTagger', - 'SummaryTagger', - # - 'TerminateIf', - 'DiscardIf', - 'discardIf', - # - 'PyOperator', - # - 'NoneOp', - 'Dumper', - 'SavePopulation', - 'IfElse', - 'Pause', - 'TicToc', - # - # Function form of operators - 'dump', - # - 'initSex', - 'initInfo', - 'initGenotype', - # - 'pyEval', - 'pyExec', - 'infoEval', - 'infoExec', - # - 'tagID', - # - 'migrate', - 'resizeSubPops', - 'splitSubPops', - 'mergeSubPops', - # - 'matrixMutate', - 'contextMutate', - 'kAlleleMutate', - 'mixedMutate', - 'pointMutate', - 'pyMutate', - 'stepwiseMutate', - 'snpMutate', - 'acgtMutate', - # - 'stat', - # - # Global functions - 'WithArgs', - # RNG Related - 'RNG', - 'getRNG', - # - 'closeOutput', - 'describeEvolProcess', - 'loadPopulation', - 'loadPedigree', - 'moduleInfo', - 'turnOffDebug', - 'turnOnDebug', - 'setOptions', - # - 'maPenetrance', - 'mapPenetrance', - 'mlPenetrance', - 'pyPenetrance', - # - 'pyQuanTrait', - # - # For testing only - 'applyDuringMatingOperator', - 'Bernullitrials', - 'WeightedSampler', - # - # modules are not loaded by default because importing plotter will fail if - # rpy is not installed, and loading R is slow and perhaps unnecessary if - # rpy is installed. - # - #'utils', - #'plotter', - #'sampling', -] - -# get options -from simuOpt import simuOptions -import os, sys - -if simuOptions['Optimized']: - if simuOptions['AlleleType'] == 'short': - from simuPOP.simuPOP_op import * - elif simuOptions['AlleleType'] == 'long': - from simuPOP.simuPOP_laop import * - elif simuOptions['AlleleType'] == 'binary': - from simuPOP.simuPOP_baop import * - else: - from simuPOP.simuPOP_op import * -else: - if simuOptions['AlleleType'] == 'short': - from simuPOP.simuPOP_std import * - elif simuOptions['AlleleType'] == 'long': - from simuPOP.simuPOP_la import * - elif simuOptions['AlleleType'] == 'binary': - from simuPOP.simuPOP_ba import * - else: - from simuPOP.simuPOP_std import * - - -if simuOptions['Version'] is not None: - expMajor, expMinor, expRelease = [int(x) for x in simuOptions['Version'].rstrip('svn').split('.')] - myMajor, myMinor, myRelease = [int(x) for x in moduleInfo()['version'].rstrip('svn').split('.')] - if (expMajor > myMajor) or (expMajor == myMajor and expMinor > myMinor) or \ - (expMajor == myMajor and expMinor == myMinor and expRelease > myRelease): - raise ImportError('simuPOP version %s is installed but version >= %s is required. ' % \ - (moduleInfo()['version'], simuOptions['Version']) + - 'Please upgrade your simuPOP installation.') - -if simuOptions['Revision'] is not None: - ver = moduleInfo()['version'] - rev = moduleInfo()['revision'] - if rev < simuOptions['Revision']: - raise ImportError('simuPOP version %s (revision %d) is installed ' % (ver, rev) + - 'but simuPOP revision >= %d is required. ' % simuOptions['Revision'] + - 'Please upgrade your simuPOP installation.') - if 'DBG_COMPATIBILITY' in simuOptions['Debug']: - print >> sys.stderr, 'WARNING: parameter revision in simuOpt.setOptions is obsolete and might be removed from a future version of simuPOP.' - -# set number of threads in openMP -if simuOptions['NumThreads'] is not None: - setOptions(numThreads=simuOptions['NumThreads']) - -if not simuOptions['Quiet']: - info = moduleInfo() - print "simuPOP Version %s : Copyright (c) 2004-2011 Bo Peng" % (info['version']) - # compile date, compiler etc are macros that are replaced during compile time. - print "Revision %d (%s) for Python %s (%dbit, %d%s)" % \ - (info['revision'], info['date'], info['python'], info['wordsize'], info['threads'], - 'thread' if info['threads'] <= 1 else 'threads') - print "Random Number Generator is set to %s with random seed 0x%08x." % (getRNG().name(), getRNG().seed()) - # MaxAllele + 1 since 0 is one of the allelic states - print "This is the %s %s allele version with %d maximum allelic states." % \ - ('optimized' if info['optimized'] else 'standard', info['alleleType'], info['maxAllele']+1) - print "For more information, please visit http://simupop.sourceforge.net," - print "or email sim...@li... (subscription required)." - # Turn on general debug information when not in 'quiet' mode - # This will print out error messages when needed. - turnOnDebug('DBG_GENERAL') - # only display banner once - simuOptions['Quiet'] = True - -if simuOptions['Debug'] != []: - for g in simuOptions['Debug']: - if g not in ['', None]: - print "Turn on debug '%s'" % g - turnOnDebug(g) - - -ALL_AVAIL = True -UNSPECIFIED = False - -def evolve_pop(self, initOps=[], preOps=[], matingScheme=MatingScheme(), postOps=[], - finalOps=[], gen=-1, dryrun=False): - '''Evolve the current population *gen* generations using mating scheme - *matingScheme* and operators *initOps* (applied before evolution), *preOps* - (applied to the parental population at the beginning of each life cycle), - *postOps* (applied to the offspring population at the end of each life - cycle) and *finalOps* (applied at the end of evolution). More specifically, - this function creates a *Simulator* using the current population, call its - *evolve* function using passed parameters and then replace the current - population with the evolved population. Please refer to function - ``Simulator.evolve`` for more details about each parameter.''' - if dryrun: - print describeEvolProcess(initOps, preOps, matingScheme, postOps, finalOps, gen, 1) - return (0,) - if isinstance(self, Pedigree): - raise ValueError("Evolving a pedigree object directly is not allowed.") - # create a simulator with self - simu = Simulator(self) - # evolve - gen = simu.evolve(initOps, preOps, matingScheme, postOps, finalOps, gen) - # get the evolved population - self.swap(simu.population(0)) - return gen[0] - -Population.evolve = evolve_pop - -def all_individuals(self, subPops=ALL_AVAIL, ancGens=ALL_AVAIL): - '''Return an iterator that iterat through all (virtual) subpopulations in - all ancestral generations. A list of (virtual) subpopulations (*subPops*) - and a list of ancestral generations (*ancGens*, can be a single number) - could be specified to iterate through only selected subpopulation and - generations. Value ``ALL_AVAIL`` is acceptable in the specification of - ``sp`` and/or ``vsp`` in specifying a virtual subpopulation ``(sp, vsp)`` - for the iteration through all or specific virtual subpopulation in all or - specific subpopulations. - ''' - if ancGens is ALL_AVAIL: - gens = range(self.ancestralGens() + 1) - elif hasattr(ancGens, '__iter__'): - gens = ancGens - else: - gens = [ancGens] - # - curGen = self.curAncestralGen() - for gen in gens: - self.useAncestralGen(gen) - if subPops is ALL_AVAIL: - for ind in self.individuals(): - yield ind - else: - for subPop in subPops: - if hasattr(subPop, '__iter__'): - if len(subPop) != 2: - raise ValueError('Invalid subpopulation ID %s' % subPop) - if subPop[0] is ALL_AVAIL: - # (ALL_AVAIL, ALL_AVAIL) - if subPop[1] is ALL_AVAIL and self.numVirtualSubPop() > 0: - for sp in range(self.numSubPop()): - for vsp in range(self.numVirtualSubPop()): - for ind in self.individuals([sp, vsp]): - yield ind - # (ALL_AVAIL, vsp) - else: - for sp in range(self.numSubPop()): - for ind in self.individuals([sp, subPop[1]]): - yield ind - else: - # (sp, ALL_AVAIL) - if subPop[1] is ALL_AVAIL and self.numVirtualSubPop() > 0: - for vsp in range(self.numVirtualSubPop()): - for ind in self.individuals([subPop[0], vsp]): - yield ind - # (sp, vsp) - else: - for ind in self.individuals(subPop): - yield ind - else: - for ind in self.individuals(subPop): - yield ind - self.useAncestralGen(curGen) - -Population.allIndividuals = all_individuals - -def as_pedigree(self, idField='ind_id', fatherField='father_id', motherField='mother_id'): - '''Convert the existing population object to a pedigree. After this function - pedigree function should magically be usable for this function. - ''' - if isinstance(self, Pedigree): - return - ped = Pedigree(self, loci=ALL_AVAIL, infoFields=ALL_AVAIL, ancGens=ALL_AVAIL, - idField=idField, fatherField=fatherField, motherField=motherField, - stealPop=True) - # swap ped and this object. (I do not know if this is the right thing to do) - self.__class__, ped.__class__ = ped.__class__, self.__class__ - self.this, ped.this = ped.this, self.this - -Population.asPedigree = as_pedigree - -def as_population(self): - '''Convert the existing pedigree object to a population. This function will - behave like a regular population after this function call.''' - if isinstance(self, Population): - return - pop = population(0) - # the pedigree data has been swapped to pop - pop.swap(self) - # swap ped and this object. (I do not know if this is the right thing to do) - self.__class__, pop.__class__ = pop.__class__, self.__class__ - self.this, pop.this = pop.this, self.this - -Pedigree.asPopulation = as_population - -# Other definitions that does not really belong to simuUtil.py -class _dw(object): - def __init__(self, var): - try: - self.__dict__ = var - except TypeError: - raise TypeError("The returned value is not a dictionary.\nNote: simu.vars() is a list so simu.dvars() is not allowed. \n Use simu.dvars(rep) for population namespace.") - def clear(self): - self.__dict__.clear() - def __repr__(self): - return str(self.__dict__) - -def dvars(self, *args, **kwargs): - return _dw(self.vars(*args, **kwargs)) - -Population.dvars = dvars -Simulator.dvars = dvars - -# expose the clone() method to Python copy module. -def _deepcopy(self, memo): - return self.clone() - -Population.__deepcopy__ = _deepcopy -Simulator.__deepcopy__ = _deepcopy -BaseOperator.__deepcopy__ = _deepcopy - - -Population.__deepcopy__ = _deepcopy -Simulator.__deepcopy__ = _deepcopy -BaseOperator.__deepcopy__ = _deepcopy - -def ind_setInfo2(self, field, value): - self.setInfo(value, field) - -def ind_setInfo3(self, field, value): - if field == 'this': - self.__dict__['this'] = value - else: - self.setInfo(value, field) - -def ind_getInfo3(self, field): - if field == 'this': - return self.__dict__['this'] - else: - return self.info(field) - -if sys.version_info[0] == 3: - Individual.__setattr__ = ind_setInfo3 - Individual.__getattr__ = ind_getInfo3 -else: - Individual.__setattr__ = ind_setInfo2 - Individual.__getattr__ = Individual.info - - -def obj_equal(self, obj): - return self.__cmp__(obj) == 0 - -if sys.version_info[0] == 3: - Population.__eq__ = obj_equal - Pedigree.__eq__ = obj_equal - Simulator.__eq__ = obj_equal - -## -## This is the result of an attemp to move describeEvolProcess from the C++ -## level to the Python level so that it can correctly call the 'describe' -## function of a derived operator or mating scheme if they define a 'describe' -## function. -## -## This change has been temporarily reverted because many simuPOP components -## such as HomoMating, OffspringGenerator accepts such objects but cannot -## call the Python level 'describe' function correctly. Because this function -## can only describe customized pre or post mating operators and homogeneous -## mating schemes, it does not appear to be a good idea to expose (although -## still hidden) functions such as BaseOperator.applicability() to the Python -## interface. -## - -## def describeEvolProcess(initOps = [], preOps = [], matingScheme = None, -## postOps = [], finalOps = [], gen = -1, numRep = 1): -## '''This function takes the same parameters as ``Simulator.evolve`` and -## output a description of how an evolutionary process will be executed. It is -## recommended that you call this function if you have any doubt on how your -## simulation will proceed.''' -## allDesc = [''] * numRep -## -## # handle single inputs -## if not hasattr(initOps, '__iter__'): -## initOps = [initOps] -## if not hasattr(preOps, '__iter__'): -## preOps = [preOps] -## if not hasattr(postOps, '__iter__'): -## postOps = [postOps] -## if not hasattr(finalOps, '__iter__'): -## finalOps = [finalOps] -## -## for curRep in range(numRep): -## desc = '' -## if not initOps: -## desc += 'No operator is used to initialize Population (initOps).\n' -## else: -## desc += 'Apply pre-evolution operators to the initial population (initOps).\n<ul>\n' -## for op in initOps: -## desc += '<li>' + op.describe(False) + ' ' + op.applicability(True, False) + '\n' -## desc += '</ul>\n' -## if gen < 0: -## desc += '\nEvolve a population indefinitely until an operator determines it.\n' -## else: -## desc += '\nEvolve a population for %s generations\n' % gen -## desc += '<ul>\n' -## if not preOps: -## desc += '<li>No operator is applied to the parental generation (preOps).\n' -## else: -## desc += '<li>Apply pre-mating operators to the parental generation (preOps)\n<ul>\n' -## for op in preOps: -## if op.isActive(curRep, 0): -## desc += '<li>' + op.describe(False) + ' ' + op.applicability() + '\n' -## desc += '</ul>\n' -## # -## desc += '\n<li>Populate an offspring populaton from the parental population using mating scheme ' \ -## + matingScheme.describe(False) + '\n' -## # -## if not postOps: -## desc += '\n<li>No operator is applied to the offspring population (postOps).\n' -## else: -## desc += '\n<li>Apply post-mating operators to the offspring population (postOps).\n<ul>\n' -## for op in postOps: -## if op.isActive(curRep, 0): -## desc += '<li>' + op.describe(False) + ' ' + op.applicability() + '\n' -## desc += '</ul>\n' -## desc += '</ul>\n\n' -## # -## if not finalOps: -## desc += 'No operator is applied to the final population (finalOps).\n' -## else: -## desc += 'Apply post-evolution operators (finalOps)\n<ul>\n' -## for op in finalOps: -## desc += '<li>' + op.describe(False) + ' ' + op.applicability(True, False) + '\n' -## desc += '</ul>\n' -## # -## allDesc[curRep] = desc -## # -## reps = [] -## for curRep in range(numRep): -## if not reps: -## reps.append(str(curRep)) -## else: -## if allDesc[curRep] == allDesc[curRep - 1]: -## reps.append(str(curRep)) -## else: -## desc += 'Replicate' + ' '.join(reps) -## desc += ':\n' + allDesc[curRep - 1] + '\n' -## reps = [str(curRep)] -## # -## desc += 'Replicate' + ' '.join(reps) + ':\n' + allDesc[-1] -## return formatDescription(desc) - -class WithArgs: - '''This class wraps around a user-provided function and provides an - attribute ``args`` so that simuPOP knows which parameters to send to the - function. This is only needed if the function can not be defined with - allowed parameters. - ''' - def __init__(self, func, args): - '''Return a callable object that wraps around function ``func``. - Parameter ``args`` should be a list of parameter names. - ''' - self.__args__ = args - self.func = func - - def __call__(self, *args, **kwargs): - return self.func(*args, **kwargs) - - -# mating schemes - -class SequentialParentsChooser(CombinedParentsChooser): - '''This parent chooser chooses two parents (a father and a mother) - sequentially from their respective sex groups. Selection is not considered. - If all fathers (or mothers) are exhausted, this parent chooser will choose - fathers (or mothers) from the beginning of the (virtual) subpopulation - again.''' - def __init__(self): - '''Create a parent chooser that chooses two parents sequentially from a - parental (virtual) subpopulation.''' - CombinedParentsChooser.__init__(self, - SequentialParentChooser(MALE_ONLY), - SequentialParentChooser(FEMALE_ONLY)) - - -class CloneMating(HomoMating): - '''A homogeneous mating scheme that uses a sequential parent chooser and - a clone offspring generator.''' - def __init__(self, numOffspring = 1, sexMode = None, ops = CloneGenoTransmitter(), - subPopSize = [], subPops = ALL_AVAIL, weight = 0, selectionField = None): - '''Create a clonal mating scheme that clones parents to offspring using - a ``CloneGenoTransmitter``. Please refer to class ``OffspringGenerator`` - for parameters *ops* and *numOffspring*, and to class ``HomoMating`` for - parameters *subPopSize*, *subPops* and *weight*. Parameters *sexMode* and - *selectionField* are ignored because this mating scheme does not support - natural selection, and ``CloneGenoTransmitter`` copies sex from parents - to offspring. Note that ``CloneGenoTransmitter`` by default also copies - all parental information fields to offspring. - ''' - HomoMating.__init__(self, - chooser = SequentialParentChooser(), - generator = OffspringGenerator(ops, numOffspring, RANDOM_SEX), - subPopSize = subPopSize, - subPops = subPops, - weight = weight) - - -class RandomSelection(HomoMating): - '''A homogeneous mating scheme that uses a random single-parent parent - chooser with replacement, and a clone offspring generator. This mating - scheme is usually used to simulate the basic haploid Wright-Fisher model - but it can also be applied to diploid populations.''' - def __init__(self, numOffspring = 1, sexMode = None, ops = CloneGenoTransmitter(), - subPopSize = [], subPops = ALL_AVAIL, weight = 0, selectionField = 'fitness'): - '''Create a mating scheme that select a parent randomly and copy him or - her to the offspring population. Please refer to class - ``RandomParentChooser`` for parameter *selectionField*, to class - ``OffspringGenerator`` for parameters *ops* and *numOffspring*, and to - class ``HomoMating`` for parameters *subPopSize*, *subPops* and *weight*. - Parameter *sexMode* is ignored because ``cloneOffspringGenerator`` copies - sex from parents to offspring. - ''' - HomoMating.__init__(self, - chooser = RandomParentChooser(True, selectionField), - generator = OffspringGenerator(ops, numOffspring, RANDOM_SEX), - subPopSize = subPopSize, - subPops = subPops, - weight = weight) - - -class RandomMating(HomoMating): - '''A homogeneous mating scheme that uses a random parents chooser with - replacement and a Mendelian offspring generator. This mating scheme is - widely used to simulate diploid sexual Wright-Fisher random mating.''' - def __init__(self, numOffspring = 1, sexMode = RANDOM_SEX, ops = MendelianGenoTransmitter(), - subPopSize = [], subPops = ALL_AVAIL, weight = 0, selectionField = 'fitness'): - '''Creates a random mating ssheme that selects two parents randomly and - transmit genotypes according to Mendelian laws. Please refer to class - ``RandomParentsChooser`` for parameter *selectionField*, to class - ``OffspringGenerator`` for parameters *ops*, *sexMode* and - *numOffspring*, and to class ``HomoMating`` for parameters - *subPopSize*, *subPops* and *weight*. - ''' - HomoMating.__init__(self, - chooser = RandomParentsChooser(True, selectionField), - generator = OffspringGenerator(ops, numOffspring, sexMode), - subPopSize = subPopSize, - subPops = subPops, - weight = weight) - - -class MonogamousMating(HomoMating): - '''A homogeneous mating scheme that uses a random parents chooser without - replacement and a Mendelian offspring generator. It differs from the basic - random mating scheme in that each parent can mate only once so there is no - half-sibling in the population.''' - def __init__(self, numOffspring = 1, sexMode = RANDOM_SEX, ops = MendelianGenoTransmitter(), - subPopSize = [], subPops = ALL_AVAIL, weight = 0, selectionField = None): - '''Creates a monogamous mating scheme that selects each parent only - once. Please refer to class ``OffspringGenerator`` for parameters - *ops*, *sexMode* and *numOffspring*, and to class ``HomoMating`` for - parameters *subPopSize*, *subPops* and *weight*. Parameter - *selectionField* is ignored because this mating scheme does not - support natural selection. - ''' - HomoMating.__init__(self, - chooser = RandomParentsChooser(replacement=False), - generator = OffspringGenerator(ops, numOffspring, sexMode), - subPopSize = subPopSize, - subPops = subPops, - weight = weight) - - -class PolygamousMating(HomoMating): - '''A homogeneous mating scheme that uses a multi-spouse parents chooser - and a Mendelian offspring generator. It differs from the basic random - mating scheme in that each parent of sex *polySex* will have *polyNum* - spouses.''' - def __init__(self, polySex=MALE, polyNum=1, numOffspring = 1, - sexMode = RANDOM_SEX, ops = MendelianGenoTransmitter(), subPopSize = [], - subPops = ALL_AVAIL, weight = 0, selectionField = 'fitness'): - '''Creates a polygamous mating scheme that each parent mates with - multiple spouses. Please refer to class ``PolyParentsChooser`` for - parameters *polySex*, *polyNum* and *selectionField*, to class - ``OffspringGenerator`` for parameters *ops*, *sexMode* and - *numOffspring*, and to class ``HomoMating`` for parameters - *subPopSize*, *subPops* and *weight*. ''' - HomoMating.__init__(self, - chooser = PolyParentsChooser(polySex, polyNum), - generator = OffspringGenerator(ops, numOffspring, sexMode), - subPopSize = subPopSize, - subPops = subPops, - weight = weight) - - -class HaplodiploidMating(HomoMating): - '''A homogeneous mating scheme that uses a random parents chooser with - replacement and a haplodiploid offspring generator. It should be used - in a haplodiploid population where male individuals only have one set - of homologous chromosomes.''' - def __init__(self, numOffspring = 1., sexMode = RANDOM_SEX, - ops = HaplodiploidGenoTransmitter(), subPopSize = [], subPops = ALL_AVAIL, - weight = 0, selectionField = 'fitness'): - '''Creates a mating scheme in haplodiploid populations. Please refer - to class ``RandomParentsChooser`` for parameter *selectionField*, to - class ``OffspringGenerator`` for parameters *ops*, *sexMode* and - *numOffspring*, and to class ``HomoMating`` for parameters - *subPopSize*, *subPops* and *weight*. - ''' - HomoMating.__init__(self, - chooser = RandomParentsChooser(True, selectionField), - generator = OffspringGenerator(ops, numOffspring, sexMode), - subPopSize = subPopSize, - subPops = subPops, - weight = weight) - - -class SelfMating(HomoMating): - '''A homogeneous mating scheme that uses a random single-parent parent - chooser with or without replacement (parameter *replacement*) and a - selfing offspring generator. It is used to mimic self-fertilization - in certain plant populations.''' - def __init__(self, replacement=True, numOffspring = 1, sexMode = RANDOM_SEX, - ops = SelfingGenoTransmitter(), subPopSize = [], subPops = ALL_AVAIL, weight = 0, - selectionField = 'fitness'): - '''Creates a selfing mating scheme where two homologous copies of - parental chromosomes are transmitted to offspring according to - Mendelian laws. Please refer to class ``RandomParentChooser`` for - parameter *replacement* and *selectionField*, to class - ``OffspringGenerator`` for parameters *ops*, *sexMode* and - *numOffspring*, and to class ``HomoMating`` for parameters - *subPopSize*, *subPops* and *weight*. - ''' - HomoMating.__init__(self, - chooser = RandomParentChooser(replacement, selectionField), - generator = OffspringGenerator(ops, numOffspring, sexMode), - subPopSize = subPopSize, - subPops = subPops, - weight = weight) - -## -## def consanguineousMating(infoFields = [], func = None, param = None, -## replacement = False, numOffspring = 1., sexMode = RANDOM_SEX, -## ops = MendelianGenoTransmitter(), subPopSize = [], -## subPops = ALL_AVAIL, weight = 0, selectionField = 'fitness'): -## '''A homogeneous mating scheme that uses an information parents chooser and -## a Mendelian offspring generator. A function *func* should be defined to -## locate certain types of relative to each individual and save their indexes -## to information fields *infoFields*. This mating scheme will then choose a -## parent randomly and then another parent from his/her relatives using their -## saved indexes. Please refer to class ``infoParentsChooser`` for parameters -## *infoFields*, *func*, *param* and *selectionField*, to class -## ``OffspringGenerator`` for parameters *ops*, *sexMode* and *numOffspring*, -## and to class ``HomoMating`` for parameters *subPopSize*, *subPops* and -## *weight*. -## ''' -## return HomoMating( -## chooser = infoParentsChooser(infoFields, func, param, selectionField), -## generator = OffspringGenerator(ops, numOffspring, sexMode), -## subPopSize = subPopSize, -## subPops = subPops, -## weight = weight) -## - -class ControlledRandomMating(HomoMating): - '''A homogeneous mating scheme that uses a random sexual parents chooser - with replacement and a controlled offspring generator using Mendelian - genotype transmitter. It falls back to a regular random mating scheme - if there is no locus to control or no trajectory is defined.''' - def __init__(self, loci=[], alleles=[], freqFunc=None, - numOffspring = 1, sexMode = RANDOM_SEX, ops = MendelianGenoTransmitter(), - subPopSize = [], subPops = ALL_AVAIL, weight = 0, selectionField = 'fitness'): - '''Creates a random mating scheme that controls allele frequency at - loci *loci*. At each generation, function *freqFunc* will be called to - called to obtain intended frequencies of alleles *alleles* at loci - *loci*. The controlled offspring generator will control the acceptance - of offspring so that the generation reaches desired allele frequencies - at these loci. If *loci* is empty or *freqFunc* is ``None``, this mating - scheme works identically to a ``RandomMating scheme``. Rationals and - applications of this mating scheme is described in details in a paper *Peng - et al, 2007 (PLoS Genetics)*. Please refer to class ``RandomParentsChooser`` - for parameters *selectionField*, to class ``ControlledOffspringGenerator`` - for parameters *loci*, *alleles*, *freqFunc*, to class - ``OffspringGenerator`` for parameters *ops*, *sexMode* and *numOffspring*, - and to class ``HomoMating`` for parameters *subPopSize*, *subPops* and - *weight*. - ''' - if (type(loci) in [type([]), type(())] and len(loci) == 0) or (freqFunc is None): - HomoMating.__init__(self, - chooser = RandomParentsChooser(True, selectionField), - generator = OffspringGenerator(ops, numOffspring, sexMode), - subPopSize = subPopSize, - subPops = subPops, - weight = weight) - else: - HomoMating.__init__(self, - chooser = RandomParentsChooser(True, selectionField), - generator = ControlledOffspringGenerator(loci, alleles, freqFunc, - ops, numOffspring, sexMode), - subPopSize = subPopSize, - subPops = subPops, - weight = weight) - - -class SNPMutator(MatrixMutator): - '''A mutator model that assumes two alleles 0 and 1 and accepts mutation - rate from 0 to 1, and from 1 to 0 alleles. ''' - def __init__(self, u=0, v=0, *args, **kwargs): - '''Return a ``MatrixMutator`` with proper mutate matrix for a two-allele - mutation model using mutation rate from allele 0 to 1 (parameter ``u``) - and from 1 to 0 (parameter ``v``)''' - MatrixMutator.__init__(self, [[1-u, u], [v, 1-v]], *args, **kwargs) - - -class AcgtMutator(MatrixMutator): - '''This mutation operator assumes alleles 0, 1, 2, 3 as nucleotides ``A``, - ``C``, ``G`` and ``T`` and use a 4 by 4 mutation rate matrix to mutate them. - Although a general model needs 12 parameters, less parameters are needed - for specific nucleotide mutation models (parameter ``model``). The length - and meaning of parameter ``rate`` is model dependent.''' - def __init__(self, rate=[], model='general', *args, **kwargs): - '''Create a mutation model that mutates between nucleotides ``A``, - ``C``, ``G``, and ``T`` (alleles are coded in that order as 0, 1, 2 - and 3). Currently supported models are Jukes and Cantor 1969 model - (``JC69``), Kimura's 2-parameter model (``K80``), Felsenstein 1981 - model (``F81``), Hasgawa, Kishino and Yano 1985 model (``HKY85``), - Tamura 1992 model (``T92``), Tamura and Nei 1993 model (``TN93``), - Generalized time reversible model (``GTR``), and a general model - (``general``) with 12 parameters. Please refer to the simuPOP user's - guide for detailed information about each model. - ''' - if model == 'JC69': - if type(rate) in [type(()), type([])]: - if len(rate) != 1: - raise ValueError('A Jukes and Cantor 1969 model needs one parameter mu.') - mu = rate[0] - else: - mu = rate - m = [[0, mu/4., mu/4., mu/4.], - [mu/4., 0, mu/4., mu/4.], - [mu/4., mu/4., 0, mu/4.], - [mu/4., mu/4., mu/4., 0 ]] - elif model == 'K80': - if len(rate) != 2: - raise ValueError('A Kimura 2-parameter model requires two parameters mu and k') - mu, k = rate - m = [[0, mu/4., mu*k/4., mu/4. ], - [mu/4., 0, mu/4., mu*k/4.], - [mu*k/4., mu/4., 0, mu/4. ], - [mu/4., mu*k/4., mu/4., 0 ]] - elif model == 'F81': - if len(rate) != 4: - raise ValueError('A Felsenstein 1981 model requires four parameters mu, pi_A, pi_C and pi_G') - mu, piA, piC, piG = rate - piT = 1 - piA - piC - piG - if piA < 0 or piA > 1 or piC < 0 or piC > 1 or \ - piG < 0 or piG > 1 or piT < 0 or piT > 1: - raise ValueError('Basic frequencies should be between 0 and 1') - m = [[0, mu*piC, mu*piG, mu*piT], - [mu*piA, 0, mu*piG, mu*piT], - [mu*piA, mu*piC, 0, mu*piT], - [mu*piA, mu*piC, mu*piG, 0 ]] - elif model == 'HKY85': - if len(rate) != 5: - raise ValueError('A Hasegawa, Kishino and Yano 1985 model requires five parameters mu, k, pi_A, pi_C and pi_G') - mu, k, piA, piC, piG = rate - piT = 1 - piA - piC - piG - if piA < 0 or piA > 1 or piC < 0 or piC > 1 or \ - piG < 0 or piG > 1 or piT < 0 or piT > 1: - raise ValueError('Basic frequencies should be between 0 and 1') - m = [[0, mu*piC, mu*k*piG, mu*piT ], - [mu*piA, 0, mu*piG, mu*k*piT], - [mu*k*piA, mu*piC, 0, mu*piT ], - [mu*piA, mu*k*piC, mu*piG, 0 ]] - elif model == 'T92': - if len(rate) != 2: - raise ValueError('A Tamura 1992 model requires two parameters mu and pi_GC') - mu, piGC = rate - piG = piC = piGC/2. - piA = piT = (1 - piGC)/2. - if piA < 0 or piA > 1 or piC < 0 or piC > 1 or \ - piG < 0 or piG > 1 or piT < 0 or piT > 1: - raise ValueError('B... [truncated message content] |
From: <si...@us...> - 2011-07-07 04:27:17
|
Revision: 4256 http://simupop.svn.sourceforge.net/simupop/?rev=4256&view=rev Author: simupop Date: 2011-07-07 04:27:10 +0000 (Thu, 07 Jul 2011) Log Message: ----------- Reapply format change Modified Paths: -------------- trunk/doc/refManual.lyx trunk/doc/userGuide.lyx trunk/simuPOP_version.py trunk/src/initializer.cpp trunk/src/simuPOP_doc.i trunk/src/stator.cpp trunk/src/transmitter.cpp trunk/src/transmitter.h trunk/src/utility.cpp trunk/src/utility.h Modified: trunk/doc/refManual.lyx =================================================================== --- trunk/doc/refManual.lyx 2011-07-07 03:09:56 UTC (rev 4255) +++ trunk/doc/refManual.lyx 2011-07-07 04:27:10 UTC (rev 4256) @@ -5,7 +5,7 @@ \textclass manual \begin_preamble \renewcommand{\py@ptsize}{12pt} -\setreleaseinfo{Release 1.0.6 (\mbox{Rev: 4250})} +\setreleaseinfo{Release 1.0.6 (\mbox{Rev: 4252})} % file revision $Rev: 3372$ \authoraddress{ {\bf Department of Epidemiology, U.T. M.D. Anderson Cancer Center}\\ Modified: trunk/doc/userGuide.lyx =================================================================== --- trunk/doc/userGuide.lyx 2011-07-07 03:09:56 UTC (rev 4255) +++ trunk/doc/userGuide.lyx 2011-07-07 04:27:10 UTC (rev 4256) @@ -6,7 +6,7 @@ \begin_preamble \renewcommand{\py@ptsize}{12pt} -\setreleaseinfo{Release 1.0.6 (\mbox{Rev: 4250})} +\setreleaseinfo{Release 1.0.6 (\mbox{Rev: 4252})} % file revision $Rev: 3372$ \authoraddress{ {\bf Department of Epidemiology, U.T. M.D. Anderson Cancer Center}\\ Modified: trunk/simuPOP_version.py =================================================================== --- trunk/simuPOP_version.py 2011-07-07 03:09:56 UTC (rev 4255) +++ trunk/simuPOP_version.py 2011-07-07 04:27:10 UTC (rev 4256) @@ -1,2 +1,2 @@ SIMUPOP_VER = "1.0.6" -SIMUPOP_REV = "4250" +SIMUPOP_REV = "4252" Modified: trunk/src/initializer.cpp =================================================================== --- trunk/src/initializer.cpp 2011-07-07 03:09:56 UTC (rev 4255) +++ trunk/src/initializer.cpp 2011-07-07 04:27:10 UTC (rev 4256) @@ -71,13 +71,13 @@ else { if (numThreads() > 1) { #ifdef _OPENMP -#pragma omp parallel private(ind) +# pragma omp parallel private(ind) { ind = pop.indIterator(sp->subPop(), omp_get_thread_num()); for (; ind.valid(); ++ind) ind->setSex(ws.draw() == 0 ? MALE : FEMALE); } -#endif +#endif } else for (; ind.valid(); ++ind) ind->setSex(ws.draw() == 0 ? MALE : FEMALE); Modified: trunk/src/simuPOP_doc.i =================================================================== --- trunk/src/simuPOP_doc.i 2011-07-07 03:09:56 UTC (rev 4255) +++ trunk/src/simuPOP_doc.i 2011-07-07 04:27:10 UTC (rev 4256) @@ -740,13 +740,13 @@ "; -%ignore simuPOP::Bernullitrials::Bernullitrials(RNG &rng); +%ignore simuPOP::Bernullitrials::Bernullitrials(RNG &); %feature("docstring") simuPOP::Bernullitrials::Bernullitrials " Usage: - Bernullitrials(rng, prob, trials) + Bernullitrials(, prob, trials=0) "; @@ -768,7 +768,7 @@ "; -%ignore simuPOP::Bernullitrials::setParameter(const vectorf &prob, size_t trials); +%ignore simuPOP::Bernullitrials::setParameter(const vectorf &prob, size_t trials=0); %feature("docstring") simuPOP::Bernullitrials::doTrial " @@ -1032,6 +1032,8 @@ %feature("docstring") simuPOP::CombinedParentsChooser::describe "Obsolete or undocumented function." +%ignore simuPOP::CombinedParentsChooser::parallelizable() const; + %ignore simuPOP::CombinedParentsChooser::initialize(Population &pop, size_t sp); %ignore simuPOP::CombinedParentsChooser::finalize(Population &pop, size_t sp); @@ -3191,6 +3193,8 @@ %feature("docstring") simuPOP::InheritTagger::clone "Obsolete or undocumented function." +%ignore simuPOP::InheritTagger::parallelizable() const; + %feature("docstring") simuPOP::InitGenotype " Details: @@ -3547,6 +3551,8 @@ %feature("docstring") simuPOP::MaPenetrance::describe "Obsolete or undocumented function." +%ignore simuPOP::MaPenetrance::parallelizable() const; + %feature("docstring") simuPOP::MapPenetrance " Details: @@ -3595,6 +3601,8 @@ %feature("docstring") simuPOP::MapPenetrance::describe "Obsolete or undocumented function." +%ignore simuPOP::MapPenetrance::parallelizable() const; + %feature("docstring") simuPOP::MapSelector " Details: @@ -3644,6 +3652,8 @@ %feature("docstring") simuPOP::MapSelector::describe "Obsolete or undocumented function." +%ignore simuPOP::MapSelector::parallelizable() const; + %feature("docstring") simuPOP::MaSelector " Details: @@ -3700,6 +3710,8 @@ %feature("docstring") simuPOP::MaSelector::describe "Obsolete or undocumented function." +%ignore simuPOP::MaSelector::parallelizable() const; + %feature("docstring") simuPOP::MatingScheme " Details: @@ -4065,6 +4077,8 @@ %ignore simuPOP::MitochondrialGenoTransmitter::applyDuringMating(Population &pop, Population &offPop, RawIndIterator offspring, Individual *dad=NULL, Individual *mom=NULL) const; +%ignore simuPOP::MitochondrialGenoTransmitter::parallelizable() const; + %feature("docstring") simuPOP::MixedMutator " Details: @@ -4158,6 +4172,8 @@ %feature("docstring") simuPOP::MlPenetrance::describe "Obsolete or undocumented function." +%ignore simuPOP::MlPenetrance::parallelizable() const; + %feature("docstring") simuPOP::MlSelector " Details: @@ -4208,6 +4224,8 @@ %feature("docstring") simuPOP::MlSelector::describe "Obsolete or undocumented function." +%ignore simuPOP::MlSelector::parallelizable() const; + %feature("docstring") simuPOP::MutSpaceMutator " Details: @@ -4838,6 +4856,8 @@ %ignore simuPOP::ParentsTagger::applyDuringMating(Population &pop, Population &offPop, RawIndIterator offspring, Individual *dad=NULL, Individual *mom=NULL) const; +%ignore simuPOP::ParentsTagger::parallelizable() const; + %feature("docstring") simuPOP::Pause " Details: @@ -5256,6 +5276,14 @@ %ignore simuPOP::PedigreeMating::mate(Population &pop, Population &scratch); +%feature("docstring") simuPOP::PedigreeMating::parallelizable " + +Usage: + + x.parallelizable() + +"; + %feature("docstring") simuPOP::PedigreeTagger " Details: @@ -5330,6 +5358,8 @@ %ignore simuPOP::PedigreeTagger::applyDuringMating(Population &pop, Population &offPop, RawIndIterator offspring, Individual *dad=NULL, Individual *mom=NULL) const; +%ignore simuPOP::PedigreeTagger::parallelizable() const; + %feature("docstring") simuPOP::PointMutator " Details: @@ -5445,6 +5475,8 @@ %feature("docstring") simuPOP::PolyParentsChooser::describe "Obsolete or undocumented function." +%ignore simuPOP::PolyParentsChooser::parallelizable() const; + %ignore simuPOP::PolyParentsChooser::initialize(Population &pop, size_t sp); %ignore simuPOP::PolyParentsChooser::chooseParents(RawIndIterator basePtr); @@ -7190,6 +7222,8 @@ %feature("docstring") simuPOP::PyParentsChooser::describe "Obsolete or undocumented function." +%ignore simuPOP::PyParentsChooser::parallelizable() const; + %ignore simuPOP::PyParentsChooser::initialize(Population &pop, size_t sp); %ignore simuPOP::PyParentsChooser::finalize(Population &pop, size_t sp); @@ -7251,6 +7285,8 @@ %feature("docstring") simuPOP::PyPenetrance::describe "Obsolete or undocumented function." +%ignore simuPOP::PyPenetrance::parallelizable() const; + %feature("docstring") simuPOP::pyPopIterator " Details: @@ -7383,6 +7419,8 @@ %feature("docstring") simuPOP::PySelector::describe "Obsolete or undocumented function." +%ignore simuPOP::PySelector::parallelizable() const; + %feature("docstring") simuPOP::PyTagger " Details: @@ -7424,6 +7462,8 @@ %ignore simuPOP::PyTagger::applyDuringMating(Population &pop, Population &offPop, RawIndIterator offspring, Individual *dad=NULL, Individual *mom=NULL) const; +%ignore simuPOP::PyTagger::parallelizable() const; + %feature("docstring") simuPOP::RandomParentChooser " Details: @@ -7767,6 +7807,8 @@ %ignore simuPOP::Recombinator::applyDuringMating(Population &pop, Population &offPop, RawIndIterator offspring, Individual *dad, Individual *mom) const; +%ignore simuPOP::Recombinator::parallelizable() const; + %feature("docstring") simuPOP::ResizeSubPops " Details: @@ -7942,8 +7984,6 @@ "; -%ignore simuPOP::RNG::generateRandomSeed(); - %feature("docstring") simuPOP::RNG::randUniform " Usage: @@ -10378,6 +10418,8 @@ %ignore simuPOP::fetchAndIncrement(ATOMICLONG *val); +%ignore simuPOP::parallelSort(T1 start, T1 end, T2 cmp); + %ignore simuPOP::simuPOPkbhit(); %ignore simuPOP::simuPOPgetch(); Modified: trunk/src/stator.cpp =================================================================== --- trunk/src/stator.cpp 2011-07-07 03:09:56 UTC (rev 4255) +++ trunk/src/stator.cpp 2011-07-07 04:27:10 UTC (rev 4256) @@ -2483,7 +2483,7 @@ } } #endif - } else { + } else{ HAPLOLIST::const_iterator it = begin; for (; it != end; ++it) { HAPLOLIST::const_iterator it1 = it; Modified: trunk/src/transmitter.cpp =================================================================== --- trunk/src/transmitter.cpp 2011-07-07 03:09:56 UTC (rev 4255) +++ trunk/src/transmitter.cpp 2011-07-07 04:27:10 UTC (rev 4256) @@ -420,7 +420,7 @@ GenoTransmitter(output, begin, end, step, at, reps, subPops, infoFields), m_intensity(intensity), m_rates(rates.elems()), m_loci(loci), m_recBeforeLoci(0), m_convMode(convMode.elems()), m_chromX(-1), m_chromY(-1), - m_customizedBegin(-1), m_customizedEnd(-1), m_algorithm(0), m_debugOutput(NULL), + m_customizedBegin(-1), m_customizedEnd(-1), m_algorithm(0), m_debugOutput(NULL), #ifdef _OPENMP m_bt(numThreads(), getRNG()) #else Modified: trunk/src/transmitter.h =================================================================== --- trunk/src/transmitter.h 2011-07-07 03:09:56 UTC (rev 4255) +++ trunk/src/transmitter.h 2011-07-07 04:27:10 UTC (rev 4256) @@ -638,7 +638,7 @@ #ifdef _OPENMP mutable vector<Bernullitrials> m_bt; #else - mutable Bernullitrials m_bt; + mutable Bernullitrials m_bt; #endif Modified: trunk/src/utility.cpp =================================================================== --- trunk/src/utility.cpp 2011-07-07 03:09:56 UTC (rev 4255) +++ trunk/src/utility.cpp 2011-07-07 04:27:10 UTC (rev 4256) @@ -495,7 +495,7 @@ ATOMICLONG fetchAndIncrement(ATOMICLONG * val) { - if(g_numThreads == 1) + if (g_numThreads == 1) return (*val)++; else #ifdef _WIN64 @@ -503,11 +503,11 @@ #elif defined(_WIN32) return InterlockedIncrement(val) - 1; #else - // for Intel C++, see page 164 of - // http://softwarecommunity.intel.com/isn/downloads/softwareproducts/pdfs/347603.pdf - // - // for gcc, see - // http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html + // for Intel C++, see page 164 of + // http://softwarecommunity.intel.com/isn/downloads/softwareproducts/pdfs/347603.pdf + // + // for gcc, see + // http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html return __sync_fetch_and_add(val, 1); #endif } @@ -2268,9 +2268,9 @@ if (m_stmts != NULL) { #if PY_VERSION_HEX >= 0x03020000 res = PyEval_EvalCode((PyObject *)m_stmts, m_locals, m_locals); -#else +#else res = PyEval_EvalCode((PyCodeObject *)m_stmts, m_locals, m_locals); -#endif +#endif if (res == NULL) { #ifndef OPTIMIZED if (debug(DBG_GENERAL)) { @@ -2290,7 +2290,7 @@ res = PyEval_EvalCode((PyObject *)m_expr, m_locals, m_locals); #else res = PyEval_EvalCode((PyCodeObject *)m_expr, m_locals, m_locals); -#endif +#endif if (res == NULL) { #ifndef OPTIMIZED if (debug(DBG_GENERAL)) { Modified: trunk/src/utility.h =================================================================== --- trunk/src/utility.h 2011-07-07 03:09:56 UTC (rev 4255) +++ trunk/src/utility.h 2011-07-07 04:27:10 UTC (rev 4256) @@ -80,7 +80,7 @@ # include "tbb/parallel_sort.h" # include "tbb/task_scheduler_init.h" # elif defined(GCC_VERSION) && GCC_VERSION >= 40300 -# include "parallel/algorithm" +# include "parallel/algorithm" # endif #endif /// for bernulli trials. @@ -171,6 +171,7 @@ } } + /// a utility function to check keyboard stroke /// CPPONLY int simuPOP_kbhit(); @@ -1228,7 +1229,7 @@ if (expr.empty() && stmts.empty()) return; - //detect leading spaces from python expressions + //detect leading spaces from python expressions DBG_FAILIF(!expr.empty() && (expr[0] == ' ' || expr[0] == '\t'), ValueError, "Can not include leading space in python expression '" + expr + "'"); DBG_FAILIF(!stmts.empty() && (stmts[0] == ' ' || stmts[0] == '\t'), ValueError, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2011-07-11 21:13:49
|
Revision: 4260 http://simupop.svn.sourceforge.net/simupop/?rev=4260&view=rev Author: simupop Date: 2011-07-11 21:13:42 +0000 (Mon, 11 Jul 2011) Log Message: ----------- automatic checkin on Mon Jul 11 16:13:35 2011 Modified Paths: -------------- trunk/ChangeLog trunk/Doxy_web trunk/doc/refManual.lyx trunk/doc/userGuide.lyx trunk/simuPOP_version.py Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-07-08 21:48:07 UTC (rev 4259) +++ trunk/ChangeLog 2011-07-11 21:13:42 UTC (rev 4260) @@ -6,7 +6,7 @@ version 1.0.7 - Not released, available at https://simupop.svn.sourceforge.net/svnroot/simupop/trunk -version 1.0.6 - Rev 4250 (July 6, 2011) +version 1.0.6 - Rev 4260 (July 11, 2011) Major new feature: - Multi-thread support that allows simuPOP to take advantage of multi-core CPUs. Modified: trunk/Doxy_web =================================================================== --- trunk/Doxy_web 2011-07-08 21:48:07 UTC (rev 4259) +++ trunk/Doxy_web 2011-07-11 21:13:42 UTC (rev 4260) @@ -25,7 +25,7 @@ # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. -PROJECT_NAME = "simuPOP: a forward-time population genetics simulation framework" +PROJECT_NAME = "simuPOP: a forward-time population genetics simulation environment" # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or Modified: trunk/doc/refManual.lyx =================================================================== --- trunk/doc/refManual.lyx 2011-07-08 21:48:07 UTC (rev 4259) +++ trunk/doc/refManual.lyx 2011-07-11 21:13:42 UTC (rev 4260) @@ -5,7 +5,7 @@ \textclass manual \begin_preamble \renewcommand{\py@ptsize}{12pt} -\setreleaseinfo{Release 1.0.6 (\mbox{Rev: 4252})} +\setreleaseinfo{Release 1.0.6 (\mbox{Rev: 4259})} % file revision $Rev: 3372$ \authoraddress{ {\bf Department of Epidemiology, U.T. M.D. Anderson Cancer Center}\\ Modified: trunk/doc/userGuide.lyx =================================================================== --- trunk/doc/userGuide.lyx 2011-07-08 21:48:07 UTC (rev 4259) +++ trunk/doc/userGuide.lyx 2011-07-11 21:13:42 UTC (rev 4260) @@ -6,7 +6,7 @@ \begin_preamble \renewcommand{\py@ptsize}{12pt} -\setreleaseinfo{Release 1.0.6 (\mbox{Rev: 4252})} +\setreleaseinfo{Release 1.0.6 (\mbox{Rev: 4259})} % file revision $Rev: 3372$ \authoraddress{ {\bf Department of Epidemiology, U.T. M.D. Anderson Cancer Center}\\ Modified: trunk/simuPOP_version.py =================================================================== --- trunk/simuPOP_version.py 2011-07-08 21:48:07 UTC (rev 4259) +++ trunk/simuPOP_version.py 2011-07-11 21:13:42 UTC (rev 4260) @@ -1,2 +1,2 @@ SIMUPOP_VER = "1.0.6" -SIMUPOP_REV = "4252" +SIMUPOP_REV = "4259" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2011-12-25 20:15:29
|
Revision: 4354 http://simupop.svn.sourceforge.net/simupop/?rev=4354&view=rev Author: simupop Date: 2011-12-25 20:15:22 +0000 (Sun, 25 Dec 2011) Log Message: ----------- Merge the bug fixes to trunk Modified Paths: -------------- trunk/ChangeLog trunk/src/genoStru.h trunk/src/population.cpp trunk/src/sandbox.cpp trunk/src/sandbox.h Property Changed: ---------------- trunk/ trunk/SConstruct trunk/simuOpt.py trunk/src/__init__.py trunk/src/main.cpp trunk/src/qtrait.h trunk/src/sandbox.py trunk/test/performance.csv trunk/test/performance.log trunk/test/performance.py trunk/test/run_tests.py trunk/test/test_00_genoStru.py trunk/test/test_01_individual.py trunk/test/test_02_population.py trunk/test/test_03_operator.py trunk/test/test_04_simulator.py trunk/test/test_05_matings.py trunk/test/test_06_initialization.py trunk/test/test_07_tagging.py trunk/test/test_08_stat.py trunk/test/test_09_selection.py trunk/test/test_10_qtrait.py trunk/test/test_11_terminator.py trunk/test/test_12_migration.py trunk/test/test_13_mutation.py trunk/test/test_14_transmitter.py trunk/test/test_15_penetrance.py trunk/test/test_16_sampling.py trunk/test/test_17_utils.py trunk/test/test_18_plotter.py Property changes on: trunk ___________________________________________________________________ Modified: svn:mergeinfo - /branches/openMP:3999-4241 + /branches/mutant_new:4352-4353 /branches/openMP:3999-4241 Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-12-25 19:53:08 UTC (rev 4353) +++ trunk/ChangeLog 2011-12-25 20:15:22 UTC (rev 4354) @@ -6,6 +6,10 @@ version 1.0.7 - Not released, available at https://simupop.svn.sourceforge.net/svnroot/simupop/trunk +BUG: + - Fix a bug that prevents the correct handling of population structure when evolving + populations with changing population structure. + version 1.0.6 - Rev 4260 (July 11, 2011) Major new feature: - Multi-thread support that allows simuPOP to take advantage of multi-core CPUs. Property changes on: trunk/SConstruct ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/SConstruct:4262-4317 /branches/mutant_new/SConstruct:4318-4337 /branches/openMP/SConstruct:3999-4241 + /branches/mutant/SConstruct:4262-4317 /branches/mutant_new/SConstruct:4318-4337,4352-4353 /branches/openMP/SConstruct:3999-4241 Property changes on: trunk/simuOpt.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/simuOpt.py:4262-4317 /branches/mutant_new/simuOpt.py:4318-4337 /branches/openMP/simuOpt.py:3999-4241 + /branches/mutant/simuOpt.py:4262-4317 /branches/mutant_new/simuOpt.py:4318-4337,4352-4353 /branches/openMP/simuOpt.py:3999-4241 Property changes on: trunk/src/__init__.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/src/__init__.py:4262-4317 /branches/mutant_new/src/__init__.py:4318-4337 /branches/openMP/src/__init__.py:3999-4241 + /branches/mutant/src/__init__.py:4262-4317 /branches/mutant_new/src/__init__.py:4318-4337,4352-4353 /branches/openMP/src/__init__.py:3999-4241 Modified: trunk/src/genoStru.h =================================================================== --- trunk/src/genoStru.h 2011-12-25 19:53:08 UTC (rev 4353) +++ trunk/src/genoStru.h 2011-12-25 20:15:22 UTC (rev 4354) @@ -305,7 +305,13 @@ m_genoStruIdx = static_cast<TraitIndexType>(idx); } + /// CPPONLY set geno stru + void swapGenoStru(GenoStruTrait & rhs) + { + std::swap(m_genoStruIdx, rhs.m_genoStruIdx); + } + /** Return the distance between loci \e locus1 and \e locus2 on the * same chromosome. A negative value will be returned if \e locus1 is * after \e locus2. Property changes on: trunk/src/main.cpp ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/src/main.cpp:4262-4317 /branches/mutant_new/src/main.cpp:4318-4337 /branches/openMP/src/main.cpp:3999-4241 + /branches/mutant/src/main.cpp:4262-4317 /branches/mutant_new/src/main.cpp:4318-4337,4352-4353 /branches/openMP/src/main.cpp:3999-4241 Modified: trunk/src/population.cpp =================================================================== --- trunk/src/population.cpp 2011-12-25 19:53:08 UTC (rev 4353) +++ trunk/src/population.cpp 2011-12-25 20:15:22 UTC (rev 4354) @@ -2359,9 +2359,11 @@ void Population::push(Population & rhs) { - DBG_ASSERT(rhs.genoStruIdx() == genoStruIdx(), ValueError, - "Evolution can not continue because the new generation has different \n" - "genotypic structure.\n"); + if (rhs.genoStruIdx() != genoStruIdx()) { + if (m_ancestralGens > 0) + throw ValueError("Cannot save a population with different structure as an ancestral population to the existing population"); + swapGenoStru(rhs); + } DBG_FAILIF(this == &rhs, ValueError, "Passed population is a reference of current population, population.push failed."); Property changes on: trunk/src/qtrait.h ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/src/qtrait.h:4262-4317 /branches/mutant_new/src/qtrait.h:4318-4337 /branches/openMP/src/qtrait.h:3999-4241 + /branches/mutant/src/qtrait.h:4262-4317 /branches/mutant_new/src/qtrait.h:4318-4337,4352-4353 /branches/openMP/src/qtrait.h:3999-4241 Modified: trunk/src/sandbox.cpp =================================================================== --- trunk/src/sandbox.cpp 2011-12-25 19:53:08 UTC (rev 4353) +++ trunk/src/sandbox.cpp 2011-12-25 20:15:22 UTC (rev 4354) @@ -564,6 +564,7 @@ added[j] = static_cast<double>(offPop.numLoci(ch) + j + 1); vectoru addedChrom(sz, ch); offPop.addLoci(addedChrom, added); + pop.addLoci(addedChrom, added); } // GenoIterator it = offPop.individual(offIndex).genoBegin(ploidy, ch); @@ -577,7 +578,7 @@ } -void MutSpaceRecombinator::transmitGenotype1(Population & offPop, const Individual & parent, +void MutSpaceRecombinator::transmitGenotype1(Population & pop, Population & offPop, const Individual & parent, size_t offIndex, int ploidy) const { #ifdef BINARYALLELE @@ -677,6 +678,7 @@ added[j] = static_cast<double>(offPop.numLoci(ch) + j + 1); vectoru addedChrom(sz, ch); offPop.addLoci(addedChrom, added); + pop.addLoci(addedChrom, added); } // it = offPop.individual(offIndex).genoBegin(ploidy, ch); @@ -707,11 +709,11 @@ copyChromosome(*dad, getRNG().randBit(), *offspring, 1, ch); } } else if (m_rate == 0.5) { - transmitGenotype0(offPop, *mom, offspring - offPop.rawIndBegin(), 0); - transmitGenotype0(offPop, *dad, offspring - offPop.rawIndBegin(), 1); + transmitGenotype0(pop, offPop, *mom, offspring - offPop.rawIndBegin(), 0); + transmitGenotype0(pop, offPop, *dad, offspring - offPop.rawIndBegin(), 1); } else { - transmitGenotype1(offPop, *mom, offspring - offPop.rawIndBegin(), 0); - transmitGenotype1(offPop, *dad, offspring - offPop.rawIndBegin(), 1); + transmitGenotype1(pop, offPop, *mom, offspring - offPop.rawIndBegin(), 0); + transmitGenotype1(pop, offPop, *dad, offspring - offPop.rawIndBegin(), 1); } return true; } Modified: trunk/src/sandbox.h =================================================================== --- trunk/src/sandbox.h 2011-12-25 19:53:08 UTC (rev 4353) +++ trunk/src/sandbox.h 2011-12-25 20:15:22 UTC (rev 4354) @@ -232,6 +232,349 @@ * mutation rates are low, these two mutation models should yield * similar results. */ + MutSpaceMutator(double rate, + // FIXME: we should not have ranges, because ranges are just + // chromosomes, so, ranges=[1, 63000], [5000, 50000] shouldbe + // loci=[63000, 450000], lociPos=range(63000) + range(5000, 500000) + // + // The problem is that you need to optimize the storage of loci positions + // by saving ranges, not every locations in genoStru.h/cpp. + // + const intMatrix & ranges, + int model = 1, + const stringFunc & output = "", + int begin = 0, int end = -1, int step = 1, const intList & at = vectori(), + const intList & reps = intList(), const subPopList & subPops = subPopList(), + const stringList & infoFields = vectorstr()) : + BaseOperator(output, begin, end, step, at, reps, subPops, infoFields), + m_rate(rate), m_ranges(ranges), m_model(model) + { + const matrixi & rngs = m_ranges.elems(); + + for (size_t i = 0; i < rngs.size(); ++i) { + DBG_FAILIF(rngs[i].size() != 2, ValueError, "Ranges should have two elements"); + for (size_t j = i + 1; j < rngs.size(); ++j) { + DBG_FAILIF(rngs[j].size() != 2, ValueError, "Ranges should have two elements"); + if (i == j) + continue; + if (rngs[i][0] >= rngs[j][0] && rngs[i][0] <= rngs[j][1]) + throw ValueError("Overlapping ranges are currently not supported because of potential conflict of mutant locations on different chromosomes."); + if (rngs[i][1] >= rngs[j][0] && rngs[i][1] <= rngs[j][1]) + throw ValueError("Overlapping ranges are currently not supported because of potential conflict of mutant locations on different chromosomes."); + } + } +#ifdef BINARYALLELE + DBG_FAILIF(true, ValueError, "This operator does not work in binary allele type."); +#endif + } + + + /// destructor. + ~MutSpaceMutator() + { + } + + + virtual bool apply(Population & pop) const; + + /// HIDDEN Deep copy of a \c MutSpaceMutator + virtual BaseOperator * clone() const + { + return new MutSpaceMutator(*this); + } + + + /// HIDDEN + string describe(bool format = true) const + { + (void)format; // avoid warning about unused parameter + return "<simuPOP.MutSpaceMutator>"; + } + + +private: + size_t locateVacantLocus(Population & pop, size_t beg, size_t end, std::set<size_t> & mutants) const; + +private: + const double m_rate; + + const intMatrix m_ranges; + + const int m_model; +}; + + +/** This during mating operator recombine chromosomes, which records mutant + * locations, using a fixed recombination rate (per base pair). + */ + // FIXME: + // This should jsut be the usual recombinator that is implemented for + // mutational model. so this should be removed and be replaced with regular + // recombinator. + // +class MutSpaceRecombinator : public GenoTransmitter +{ +public: + /** Create a Recombinator (a mendelian genotype transmitter with + * recombination and gene conversion) that passes genotypes from parents + * (or a parent in case of self-fertilization) to offspring. A + * recombination \e rate in the unit of base pair is needed. + */ + MutSpaceRecombinator(double rate, const intMatrix & ranges, + const stringFunc & output = "", int begin = 0, int end = -1, int step = 1, + const intList & at = vectori(), + const intList & reps = intList(), const subPopList & subPops = subPopList(), + const stringList & infoFields = vectorstr()) + : GenoTransmitter(output, begin, end, step, at, reps, subPops, infoFields), + m_rate(rate), m_ranges(ranges) + { + DBG_FAILIF(rate > 0.5 || rate < 0, ValueError, "Recombination rate should be between 0 and 0.5"); +#ifdef BINARYALLELE + DBG_FAILIF(true, ValueError, "This operator does not work in binary allele type."); +#endif + } + + + /// HIDDEN Deep copy of a Recombinator + virtual BaseOperator * clone() const + { + return new MutSpaceRecombinator(*this); + } + + + virtual ~MutSpaceRecombinator() + { + } + + + /// HIDDEN + string describe(bool format = true) const + { + (void)format; // avoid warning about unused parameter + return "<simuPOP.MutSpaceRecombinator>"; + } + + + /** CPPONLY + * Apply the Recombinator during mating + */ + virtual bool applyDuringMating(Population & pop, Population & offPop, + RawIndIterator offspring, + Individual * dad, Individual * mom) const; + +private: +#if TR1_SUPPORT == 0 + typedef std::map<unsigned int, int> MutCounter; +#else + // this is faster than std::map + typedef std::tr1::unordered_map<unsigned int, int> MutCounter; +#endif + // use when m_rate = 0.5 + void transmitGenotype0(Population & pop, Population & offPop, const Individual & parent, + size_t offIndex, int ploidy) const; + + // use when m_rate < 1e-4 + void transmitGenotype1(Population & pop, Population & offPop, const Individual & parent, + size_t offIndex, int ploidy) const; + +private: + /// recombination rate + const double m_rate; + const intMatrix m_ranges; +}; + + +/// ###################################### +#else + +/** This operator looks into a population in mutational space and revert a mutant + * to wildtype allele if it is fixed in the population. If a valid output is + * specifieid, fixed alleles will be outputed with a leading generation number. + */ +class RevertFixedSites : public BaseOperator +{ +public: + /** Create an operator to revert alleles at fixed loci from value 1 to 0. + * Parameter \e subPops is ignored. + */ + RevertFixedSites(const stringFunc & output = "", int begin = 0, int end = -1, int step = 1, + const intList & at = vectori(), + const intList & reps = intList(), const subPopList & subPops = subPopList(), + const stringList & infoFields = vectorstr()) + : BaseOperator(output, begin, end, step, at, reps, subPops, infoFields) + { + } + + + /// destructor + virtual ~RevertFixedSites() + { + } + + + /// HIDDEN Deep copy of a Migrator + virtual BaseOperator * clone() const + { + return new RevertFixedSites(*this); + } + + + /// HIDDEN apply the Migrator to populaiton \e pop. + virtual bool apply(Population & pop) const; + + /// HIDDEN + string describe(bool format = true) const + { + (void)format; // avoid warning about unused parameter + return "Revert fixed alleles to wildtype allele if it is fixed in the population."; + } + + +}; + +/** This selector assumes that alleles are mutant locations in the mutational + * space and assign fitness values to them according to a random distribution. + * The overall individual fitness is determined by either an additive, an + * multiplicative or an exponential model. + */ +class MutSpaceSelector : public BaseSelector +{ +public: + /** Create a selector that assigns individual fitness values according to + * random fitness effects. \e selDist can be + * \li <tt>(CONSTANT, s, h)</tt> where s will be used for all mutants. The + * fitness value for genotypes AA, Aa and aa will be (1, 1-hs, 1-s). + * If h is unspecified, a default value h=0.5 (additive model) will + * be used. + * \li <tt>(GAMMA_DISTRIBUTION, theta, k, h</tt> where s follows a gamma + * distribution with scale parameter theta and shape parameter k. + * Fitness values for genotypes AA, Aa and aa will be 1, 1-hs and 1-s. + * A default value h=0.5 will be used if h is unspecified. + * \li a Python function, which will be called when selection coefficient + * of a new mutant is needed. This function should return a single + * value s (with default value h=0.5) or a sequence of (h, s). Mutant + * location will be passed to this function if it accepts a parameter + * \c loc. This allows the definition of site-specific selection + * coefficients. + * Individual fitness will be combined in \c ADDITIVE, + * \c MULTIPLICATIVE or \c EXPONENTIAL mode. (See \c MlSelector for + * details). + * If an output is given, mutants and their fitness values will be written + * to the output, in the form of 'mutant s h'. + */ + MutSpaceSelector(const floatListFunc & selDist, int mode = EXPONENTIAL, + const stringFunc & output = "", + int begin = 0, int end = -1, int step = 1, const intList & at = vectori(), + const intList & reps = intList(), const subPopList & subPops = subPopList(), + const stringList & infoFields = stringList("fitness")) : + BaseSelector(output, begin, end, step, at, reps, subPops, infoFields), + m_selDist(selDist), m_mode(mode), m_selFactory(), m_additive(true) + { + if (m_selDist.size() == 0) { + DBG_FAILIF(!m_selDist.func().isValid(), ValueError, + "Please specify either a distribution with parameter or a function."); + } else if (static_cast<int>(m_selDist[0]) == CONSTANT) { + DBG_FAILIF(m_selDist.size() < 2, ValueError, "At least one parameter is needed for constant selection coefficient."); + } else if (static_cast<int>(m_selDist[0]) == GAMMA_DISTRIBUTION) { + DBG_FAILIF(m_selDist.size() < 3, ValueError, "At least two parameters are needed for gamma distribution."); + } + } + + + virtual ~MutSpaceSelector() + { + } + + + /// HIDDEN Deep copy of a map selector + virtual BaseOperator * clone() const + { + return new MutSpaceSelector(*this); + } + + + /** CPPONLY + * calculate/return the fitness value, currently assuming diploid + */ + virtual double indFitness(Population & pop, Individual * ind) const; + + /// HIDDEN + string describe(bool format = true) const + { + (void)format; // avoid warning about unused parameter + return "<simuPOP.MutSpaceSelector>" ; + } + + + /// CPPONLY + bool apply(Population & pop) const; + + typedef std::pair<double, double> SelCoef; + +private: + SelCoef getFitnessValue(size_t mutant) const; + + + double randomSelAddFitness(GenoIterator it, GenoIterator it_end) const; + + double randomSelExpFitness(GenoIterator it, GenoIterator it_end) const; + + // extended models does not assume additivity (h != 0.5) + double randomSelMulFitnessExt(GenoIterator it, GenoIterator it_end) const; + + double randomSelAddFitnessExt(GenoIterator it, GenoIterator it_end) const; + + double randomSelExpFitnessExt(GenoIterator it, GenoIterator it_end) const; + +private: + /// + floatListFunc m_selDist; + + int m_mode; + /// +#if TR1_SUPPORT == 0 + typedef std::map<unsigned int, SelCoef> SelMap; + typedef std::map<unsigned int, int> MutCounter; +#else + // this is faster than std::map + typedef std::tr1::unordered_map<size_t, SelCoef> SelMap; + typedef std::tr1::unordered_map<size_t, size_t> MutCounter; +#endif + mutable SelMap m_selFactory; + mutable vectoru m_newMutants; + // whether or not all markers are additive. + mutable bool m_additive; +}; + + +/** This is an infite site mutation model in mutational space. The alleles + * in the population is assumed to be locations of mutants. A mutation + * rate is given that mutate alleles in 'regions'. If number of mutants + * for an individual exceed the number of loci, 10 loci will be added + * to everyone in the population. + */ +class MutSpaceMutator : public BaseOperator +{ +public: + /** This operator accepts a list of ranges which is the 'real range' of + * each chromosome. Mutation happens with muation rate \e rate and mutants + * will be recorded to the population (instead of alleles). By default, + * this mutator assumes an finite-allele model where all mutations are + * allowed and if a mutant (allele 1) is mutated, it will be mutated to + * allele 0 (back mutation). Alternatively (\e model = 2), an + * infinite-sites mutation model can be used where mutations can happen + * only at a new locus. Mutations happen at a locus with existing mutants + * will be moved to a random locus without existing mutant. A warning + * message will be printed if there is no vacant locus available. If a + * valid \e output is given, mutants will be outputted in the format of + * "gen mutant ind type" where type is 0 for forward (0->1), 1 for + * backward (1->0), 2 for relocated mutations, and 3 for ignored mutation + * because no vacent locus is available. The second mode has the + * advantage that all mutants in the simulated population can be traced + * to a single mutation event. If the regions are reasonably wide and + * mutation rates are low, these two mutation models should yield + * similar results. + */ MutSpaceMutator(double rate, const intMatrix & ranges, int model = 1, const stringFunc & output = "", int begin = 0, int end = -1, int step = 1, const intList & at = vectori(), @@ -356,11 +699,11 @@ typedef std::tr1::unordered_map<unsigned int, int> MutCounter; #endif // use when m_rate = 0.5 - void transmitGenotype0(Population & offPop, const Individual & parent, + void transmitGenotype0(Population & pop, Population & offPop, const Individual & parent, size_t offIndex, int ploidy) const; // use when m_rate < 1e-4 - void transmitGenotype1(Population & offPop, const Individual & parent, + void transmitGenotype1(Population & pop, Population & offPop, const Individual & parent, size_t offIndex, int ploidy) const; private: Property changes on: trunk/src/sandbox.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/src/sandbox.py:4262-4317 /branches/mutant_new/src/sandbox.py:4318-4337 /branches/openMP/src/sandbox.py:3999-4241 + /branches/mutant/src/sandbox.py:4262-4317 /branches/mutant_new/src/sandbox.py:4318-4337,4352-4353 /branches/openMP/src/sandbox.py:3999-4241 Property changes on: trunk/test/performance.csv ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/performance.csv:4262-4317 /branches/mutant_new/test/performance.csv:4318-4337 /branches/openMP/test/performance.csv:3999-4241 + /branches/mutant/test/performance.csv:4262-4317 /branches/mutant_new/test/performance.csv:4318-4337,4352-4353 /branches/openMP/test/performance.csv:3999-4241 Property changes on: trunk/test/performance.log ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/performance.log:4262-4317 /branches/mutant_new/test/performance.log:4318-4337 /branches/openMP/test/performance.log:3999-4241 + /branches/mutant/test/performance.log:4262-4317 /branches/mutant_new/test/performance.log:4318-4337,4352-4353 /branches/openMP/test/performance.log:3999-4241 Property changes on: trunk/test/performance.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/performance.py:4262-4317 /branches/mutant_new/test/performance.py:4318-4337 /branches/openMP/test/performance.py:3999-4241 + /branches/mutant/test/performance.py:4262-4317 /branches/mutant_new/test/performance.py:4318-4337,4352-4353 /branches/openMP/test/performance.py:3999-4241 Property changes on: trunk/test/run_tests.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/run_tests.py:4262-4317 /branches/mutant_new/test/run_tests.py:4318-4337 /branches/openMP/test/run_tests.py:3999-4241 + /branches/mutant/test/run_tests.py:4262-4317 /branches/mutant_new/test/run_tests.py:4318-4337,4352-4353 /branches/openMP/test/run_tests.py:3999-4241 Property changes on: trunk/test/test_00_genoStru.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/test_00_genoStru.py:4262-4317 /branches/mutant_new/test/test_00_genoStru.py:4318-4337 /branches/openMP/test/test_00_genoStru.py:3999-4241 + /branches/mutant/test/test_00_genoStru.py:4262-4317 /branches/mutant_new/test/test_00_genoStru.py:4318-4337,4352-4353 /branches/openMP/test/test_00_genoStru.py:3999-4241 Property changes on: trunk/test/test_01_individual.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/test_01_individual.py:4262-4317 /branches/mutant_new/test/test_01_individual.py:4318-4337 /branches/openMP/test/test_01_individual.py:3999-4241 + /branches/mutant/test/test_01_individual.py:4262-4317 /branches/mutant_new/test/test_01_individual.py:4318-4337,4352-4353 /branches/openMP/test/test_01_individual.py:3999-4241 Property changes on: trunk/test/test_02_population.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/test_02_population.py:4262-4317 /branches/mutant_new/test/test_02_population.py:4318-4337 /branches/openMP/test/test_02_population.py:3999-4241 + /branches/mutant/test/test_02_population.py:4262-4317 /branches/mutant_new/test/test_02_population.py:4318-4337,4352-4353 /branches/openMP/test/test_02_population.py:3999-4241 Property changes on: trunk/test/test_03_operator.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/test_03_operator.py:4262-4317 /branches/mutant_new/test/test_03_operator.py:4318-4337 /branches/openMP/test/test_03_operator.py:3999-4241 + /branches/mutant/test/test_03_operator.py:4262-4317 /branches/mutant_new/test/test_03_operator.py:4318-4337,4352-4353 /branches/openMP/test/test_03_operator.py:3999-4241 Property changes on: trunk/test/test_04_simulator.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/test_04_simulator.py:4262-4317 /branches/mutant_new/test/test_04_simulator.py:4318-4337 /branches/openMP/test/test_04_simulator.py:3999-4241 + /branches/mutant/test/test_04_simulator.py:4262-4317 /branches/mutant_new/test/test_04_simulator.py:4318-4337,4352-4353 /branches/openMP/test/test_04_simulator.py:3999-4241 Property changes on: trunk/test/test_05_matings.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/test_05_matings.py:4262-4317 /branches/mutant_new/test/test_05_matings.py:4318-4337 /branches/openMP/test/test_05_matings.py:3999-4241 + /branches/mutant/test/test_05_matings.py:4262-4317 /branches/mutant_new/test/test_05_matings.py:4318-4337,4352-4353 /branches/openMP/test/test_05_matings.py:3999-4241 Property changes on: trunk/test/test_06_initialization.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/test_06_initialization.py:4262-4317 /branches/mutant_new/test/test_06_initialization.py:4318-4337 /branches/openMP/test/test_06_initialization.py:3999-4241 + /branches/mutant/test/test_06_initialization.py:4262-4317 /branches/mutant_new/test/test_06_initialization.py:4318-4337,4352-4353 /branches/openMP/test/test_06_initialization.py:3999-4241 Property changes on: trunk/test/test_07_tagging.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/test_07_tagging.py:4262-4317 /branches/mutant_new/test/test_07_tagging.py:4318-4337 /branches/openMP/test/test_07_tagging.py:3999-4241 + /branches/mutant/test/test_07_tagging.py:4262-4317 /branches/mutant_new/test/test_07_tagging.py:4318-4337,4352-4353 /branches/openMP/test/test_07_tagging.py:3999-4241 Property changes on: trunk/test/test_08_stat.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/test_08_stat.py:4262-4317 /branches/mutant_new/test/test_08_stat.py:4318-4337 /branches/openMP/test/test_08_stat.py:3999-4241 + /branches/mutant/test/test_08_stat.py:4262-4317 /branches/mutant_new/test/test_08_stat.py:4318-4337,4352-4353 /branches/openMP/test/test_08_stat.py:3999-4241 Property changes on: trunk/test/test_09_selection.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/test_09_selection.py:4262-4317 /branches/mutant_new/test/test_09_selection.py:4318-4337 /branches/openMP/test/test_09_selection.py:3999-4241 + /branches/mutant/test/test_09_selection.py:4262-4317 /branches/mutant_new/test/test_09_selection.py:4318-4337,4352-4353 /branches/openMP/test/test_09_selection.py:3999-4241 Property changes on: trunk/test/test_10_qtrait.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/test_10_qtrait.py:4262-4317 /branches/mutant_new/test/test_10_qtrait.py:4318-4337 /branches/openMP/test/test_10_qtrait.py:3999-4241 + /branches/mutant/test/test_10_qtrait.py:4262-4317 /branches/mutant_new/test/test_10_qtrait.py:4318-4337,4352-4353 /branches/openMP/test/test_10_qtrait.py:3999-4241 Property changes on: trunk/test/test_11_terminator.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/test_11_terminator.py:4262-4317 /branches/mutant_new/test/test_11_terminator.py:4318-4337 /branches/openMP/test/test_11_terminator.py:3999-4241 + /branches/mutant/test/test_11_terminator.py:4262-4317 /branches/mutant_new/test/test_11_terminator.py:4318-4337,4352-4353 /branches/openMP/test/test_11_terminator.py:3999-4241 Property changes on: trunk/test/test_12_migration.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/test_12_migration.py:4262-4317 /branches/mutant_new/test/test_12_migration.py:4318-4337 /branches/openMP/test/test_12_migration.py:3999-4241 + /branches/mutant/test/test_12_migration.py:4262-4317 /branches/mutant_new/test/test_12_migration.py:4318-4337,4352-4353 /branches/openMP/test/test_12_migration.py:3999-4241 Property changes on: trunk/test/test_13_mutation.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/test_13_mutation.py:4262-4317 /branches/mutant_new/test/test_13_mutation.py:4318-4337 /branches/openMP/test/test_13_mutation.py:3999-4241 + /branches/mutant/test/test_13_mutation.py:4262-4317 /branches/mutant_new/test/test_13_mutation.py:4318-4337,4352-4353 /branches/openMP/test/test_13_mutation.py:3999-4241 Property changes on: trunk/test/test_14_transmitter.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/test_14_transmitter.py:4262-4317 /branches/mutant_new/test/test_14_transmitter.py:4318-4337 /branches/openMP/test/test_14_transmitter.py:3999-4241 + /branches/mutant/test/test_14_transmitter.py:4262-4317 /branches/mutant_new/test/test_14_transmitter.py:4318-4337,4352-4353 /branches/openMP/test/test_14_transmitter.py:3999-4241 Property changes on: trunk/test/test_15_penetrance.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/test_15_penetrance.py:4262-4317 /branches/mutant_new/test/test_15_penetrance.py:4318-4337 /branches/openMP/test/test_15_penetrance.py:3999-4241 + /branches/mutant/test/test_15_penetrance.py:4262-4317 /branches/mutant_new/test/test_15_penetrance.py:4318-4337,4352-4353 /branches/openMP/test/test_15_penetrance.py:3999-4241 Property changes on: trunk/test/test_16_sampling.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/test_16_sampling.py:4262-4317 /branches/mutant_new/test/test_16_sampling.py:4318-4337 /branches/openMP/test/test_16_sampling.py:3999-4241 + /branches/mutant/test/test_16_sampling.py:4262-4317 /branches/mutant_new/test/test_16_sampling.py:4318-4337,4352-4353 /branches/openMP/test/test_16_sampling.py:3999-4241 Property changes on: trunk/test/test_17_utils.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/test_17_utils.py:4262-4317 /branches/mutant_new/test/test_17_utils.py:4318-4337 /branches/openMP/test/test_17_utils.py:3999-4241 + /branches/mutant/test/test_17_utils.py:4262-4317 /branches/mutant_new/test/test_17_utils.py:4318-4337,4352-4353 /branches/openMP/test/test_17_utils.py:3999-4241 Property changes on: trunk/test/test_18_plotter.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant/test/test_18_plotter.py:4262-4317 /branches/mutant_new/test/test_18_plotter.py:4318-4337 /branches/openMP/test/test_18_plotter.py:3999-4241 + /branches/mutant/test/test_18_plotter.py:4262-4317 /branches/mutant_new/test/test_18_plotter.py:4318-4337,4352-4353 /branches/openMP/test/test_18_plotter.py:3999-4241 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2011-12-25 20:26:18
|
Revision: 4355 http://simupop.svn.sourceforge.net/simupop/?rev=4355&view=rev Author: simupop Date: 2011-12-25 20:26:08 +0000 (Sun, 25 Dec 2011) Log Message: ----------- Merge mutant_new to trunk in order to make trunk compile Modified Paths: -------------- trunk/ChangeLog trunk/setup.py trunk/simuPOP_version.py trunk/src/customizedTypes.c trunk/src/individual.cpp trunk/src/individual.h trunk/src/mating.cpp trunk/src/mutator.cpp trunk/src/population.cpp trunk/src/population.h trunk/src/sandbox.cpp trunk/src/sandbox.h trunk/src/simuPOP_cfg.h trunk/src/simuPOP_common.i trunk/src/simuPOP_doc.i trunk/src/stator.cpp trunk/src/stator.h trunk/src/transmitter.cpp trunk/src/utility.cpp trunk/src/virtualSubPop.cpp trunk/test/performance.csv trunk/test/performance.log trunk/test/performance.py trunk/test/test_08_stat.py Added Paths: ----------- trunk/src/mutant_vector.h trunk/src/simuPOP_mu.i trunk/src/simuPOP_muop.i Property Changed: ---------------- trunk/ trunk/SConstruct trunk/simuOpt.py trunk/src/__init__.py trunk/src/main.cpp trunk/src/qtrait.h trunk/src/sandbox.py trunk/test/performance.csv trunk/test/performance.log trunk/test/performance.py trunk/test/run_tests.py trunk/test/test_00_genoStru.py trunk/test/test_01_individual.py trunk/test/test_02_population.py trunk/test/test_03_operator.py trunk/test/test_04_simulator.py trunk/test/test_05_matings.py trunk/test/test_06_initialization.py trunk/test/test_07_tagging.py trunk/test/test_08_stat.py trunk/test/test_09_selection.py trunk/test/test_10_qtrait.py trunk/test/test_11_terminator.py trunk/test/test_12_migration.py trunk/test/test_13_mutation.py trunk/test/test_14_transmitter.py trunk/test/test_15_penetrance.py trunk/test/test_16_sampling.py trunk/test/test_17_utils.py trunk/test/test_18_plotter.py Property changes on: trunk ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant_new:4352-4353 /branches/openMP:3999-4241 + /branches/mutant:4262-4317 /branches/mutant_new:4318-4354 /branches/openMP:3999-4241 Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-12-25 20:15:22 UTC (rev 4354) +++ trunk/ChangeLog 2011-12-25 20:26:08 UTC (rev 4355) @@ -6,6 +6,10 @@ version 1.0.7 - Not released, available at https://simupop.svn.sourceforge.net/svnroot/simupop/trunk +New features: + - New option numOfSegSites to operator Stat to calculate the number of segragating + sites. + BUG: - Fix a bug that prevents the correct handling of population structure when evolving populations with changing population structure. Property changes on: trunk/SConstruct ___________________________________________________________________ Deleted: svn:mergeinfo - /branches/mutant/SConstruct:4262-4317 /branches/mutant_new/SConstruct:4318-4337,4352-4353 /branches/openMP/SConstruct:3999-4241 Modified: trunk/setup.py =================================================================== --- trunk/setup.py 2011-12-25 20:15:22 UTC (rev 4354) +++ trunk/setup.py 2011-12-25 20:26:08 UTC (rev 4355) @@ -70,10 +70,11 @@ output = ferr.readlines()[-1].decode('utf8') try: version = re.match('.*gcc version\s*(\d+).(\d+).(\d+).*', output).groups() + if int(version[0]) < 4 or int(version[1]) < 2: + print('Support for openMP is turned off because version %s.%s.%s of gcc does not support this feature' % version) + USE_OPENMP = False except: - print('Can not obtain version of gcc.') - if int(version[0]) < 4 or int(version[1]) < 2: - print('Support for openMP is turned off because version %s.%s.%s of gcc does not support this feature' % version) + print('Can not obtain version of gcc, and openMP is disable') USE_OPENMP = False USE_ICC = False @@ -192,6 +193,7 @@ # HEADER_FILES = [ + 'mutant_vector.h', 'simuPOP_cfg.h', 'utility.h', 'genoStru.h', @@ -236,7 +238,7 @@ 'pedigree.cpp', 'virtualSubPop.cpp', 'sandbox.cpp', - 'main.cpp', +# 'main.cpp', ] # since it is troublesome to link to external gsl library, @@ -418,6 +420,11 @@ ('_SECURE_SCL', 1), ('_HAS_ITERATOR_DEBUGGING', 0)], 'baop': [('SIMUPOP_MODULE', 'simuPOP_baop'), ('BINARYALLELE', None), ('OPTIMIZED', None), ('_SECURE_SCL', 0), ('_HAS_ITERATOR_DEBUGGING', 0)], + 'mu': [('SIMUPOP_MODULE', 'simuPOP_mu'), ('MUTANTALLELE', None), + ('_SECURE_SCL', 1), ('_HAS_ITERATOR_DEBUGGING', 0)], + 'muop': [('SIMUPOP_MODULE', 'simuPOP_muop'), ('MUTANTALLELE', None), ('OPTIMIZED', None), + ('_SECURE_SCL', 0), ('_HAS_ITERATOR_DEBUGGING', 0)], + } WRAP_INFO = { @@ -427,6 +434,8 @@ 'laop': ['src/simuPOP_laop_wrap.cpp', 'src/simuPOP_laop.i', '-DLONGALLELE -DOPTIMIZED'], 'ba': ['src/simuPOP_ba_wrap.cpp', 'src/simuPOP_ba.i', '-DBINARYALLELE'], 'baop': ['src/simuPOP_baop_wrap.cpp', 'src/simuPOP_baop.i', '-DBINARYALLELE -DOPTIMIZED'], + 'mu': ['src/simuPOP_mu_wrap.cpp', 'src/simuPOP_mu.i', '-DMUTANTALLELE'], + 'muop': ['src/simuPOP_muop_wrap.cpp', 'src/simuPOP_muop.i', '-DMUTANTALLELE -DOPTIMIZED'], } if os.name == 'nt': @@ -501,7 +510,7 @@ if USE_OPENMP: res['extra_compile_args'].append('/Qopenmp' if USE_ICC else '/openmp') else: - res['extra_compile_args'] = ['-O3', '-Wall', '-Wno-unknown-pragmas'] + res['extra_compile_args'] = ['-O3', '-Wall', '-Wno-unknown-pragmas', '-Wno-unused-parameter'] if not USE_ICC: # for gcc, turn on extra warning message res['extra_compile_args'].append('-Wextra') if USE_OPENMP: @@ -544,7 +553,7 @@ if __name__ == '__main__': SIMUPOP_VER, SIMUPOP_REV = simuPOP_version() # create source file for each module - MODULES = ['std', 'op', 'la', 'laop', 'ba', 'baop'] + MODULES = ['std', 'op', 'la', 'laop', 'ba', 'baop', 'mu', 'muop'] # # Generate Wrapping files # Property changes on: trunk/simuOpt.py ___________________________________________________________________ Deleted: svn:mergeinfo - /branches/mutant/simuOpt.py:4262-4317 /branches/mutant_new/simuOpt.py:4318-4337,4352-4353 /branches/openMP/simuOpt.py:3999-4241 Modified: trunk/simuPOP_version.py =================================================================== --- trunk/simuPOP_version.py 2011-12-25 20:15:22 UTC (rev 4354) +++ trunk/simuPOP_version.py 2011-12-25 20:26:08 UTC (rev 4355) @@ -1,2 +1,2 @@ -SIMUPOP_VER = "1.0.6" +SIMUPOP_VER = "1.0.7svn" SIMUPOP_REV = "4259" Property changes on: trunk/src/__init__.py ___________________________________________________________________ Deleted: svn:mergeinfo - /branches/mutant/src/__init__.py:4262-4317 /branches/mutant_new/src/__init__.py:4318-4337,4352-4353 /branches/openMP/src/__init__.py:3999-4241 Modified: trunk/src/customizedTypes.c =================================================================== --- trunk/src/customizedTypes.c 2011-12-25 20:15:22 UTC (rev 4354) +++ trunk/src/customizedTypes.c 2011-12-25 20:26:08 UTC (rev 4355) @@ -715,7 +715,11 @@ } // op->ob_iter = begin; +#ifdef MUTANTALLELE + Py_SIZE(op) = end.getIndex() - begin.getIndex(); +#else Py_SIZE(op) = end - begin; +#endif return (PyObject *)op; } Modified: trunk/src/individual.cpp =================================================================== --- trunk/src/individual.cpp 2011-12-25 20:15:22 UTC (rev 4354) +++ trunk/src/individual.cpp 2011-12-25 20:26:08 UTC (rev 4355) @@ -49,7 +49,11 @@ Individual & Individual::copyFrom(const Individual & rhs) { m_flags = rhs.m_flags; +#ifdef MUTANTALLELE + simuPOP::copy(rhs.genoBegin(), rhs.genoEnd(), genoBegin()); +#else copy(rhs.genoBegin(), rhs.genoEnd(), genoBegin()); +#endif copy(rhs.infoBegin(), rhs.infoEnd(), infoBegin()); // also copy genoStru pointer... this->setGenoStruIdx(rhs.genoStruIdx()); @@ -234,6 +238,7 @@ } + PyObject * Individual::genoAtLoci(const lociList & lociList) { ssize_t ply = ploidy(); @@ -295,16 +300,28 @@ "A valid ploidy index has to be specified if chrom is non-positive"); if (p < 0) { CHECKRANGEGENOSIZE(idx); +#ifdef MUTANTALLELE + (m_genoPtr + idx).assign(allele); +#else *(m_genoPtr + idx) = allele; +#endif } else if (chrom < 0) { CHECKRANGEABSLOCUS(idx); CHECKRANGEPLOIDY(static_cast<size_t>(p)); +#ifdef MUTANTALLELE + (m_genoPtr + idx + p * totNumLoci()).assign(allele); +#else *(m_genoPtr + idx + p * totNumLoci()) = allele; +#endif } else { CHECKRANGELOCUS(static_cast<size_t>(chrom), idx); CHECKRANGEPLOIDY(static_cast<size_t>(p)); CHECKRANGECHROM(static_cast<size_t>(chrom)); - *(m_genoPtr + idx + p * totNumLoci() + chromBegin(chrom)) = allele; +#ifdef MUTANTALLELE + (m_genoPtr + idx + p * totNumLoci() + chromBegin(chrom)).assign(allele); +#else + *(m_genoPtr + idx + p * totNumLoci() + chromBegin(chrom)) = allele; +#endif } } @@ -344,9 +361,8 @@ for (size_t j = 0; j < chroms.size(); ++j) { size_t chrom = chroms[j]; GenoIterator ptr = m_genoPtr + p * totNumLoci() + chromBegin(chrom); - for (size_t i = 0; i < numLoci(chrom); i++, ++idx) - *(ptr + i) = ToAllele(geno[idx % sz]); + *(ptr + i) = ToAllele(geno[idx % sz]); } } } Modified: trunk/src/individual.h =================================================================== --- trunk/src/individual.h 2011-12-25 20:15:22 UTC (rev 4354) +++ trunk/src/individual.h 2011-12-25 20:26:08 UTC (rev 4355) @@ -343,7 +343,6 @@ m_infoPtr[idx] = value; } - /// CPPONLY start of alleles GenoIterator genoBegin() const { @@ -363,7 +362,6 @@ { CHECKRANGEPLOIDY(p); return m_genoPtr + p * totNumLoci(); - } @@ -394,7 +392,6 @@ } - /// CPPONLY start of info InfoIterator infoBegin() const { @@ -903,13 +900,12 @@ typedef Allele value_type; typedef long int difference_type; typedef AlleleRef reference; - typedef GenoIterator pointer; + //typedef GenoIterator pointer; CombinedAlleleIterator() { } - CombinedAlleleIterator(size_t shift, GenoIterator ptr, GenoIterator ptrEnd, size_t size) : m_useGappedIterator(true), m_valid(true), m_shift(shift), m_ptr(ptr), m_ptrEnd(ptrEnd), m_size(size), Property changes on: trunk/src/main.cpp ___________________________________________________________________ Deleted: svn:mergeinfo - /branches/mutant/src/main.cpp:4262-4317 /branches/mutant_new/src/main.cpp:4318-4337,4352-4353 /branches/openMP/src/main.cpp:3999-4241 Modified: trunk/src/mating.cpp =================================================================== --- trunk/src/mating.cpp 2011-12-25 20:15:22 UTC (rev 4354) +++ trunk/src/mating.cpp 2011-12-25 20:26:08 UTC (rev 4355) @@ -1599,8 +1599,6 @@ // scrtach will have the right structure. if (!prepareScratchPop(pop, scratch)) return false; - vectormating::const_iterator it = m_matingSchemes.begin(); - vectormating::const_iterator it_end = m_matingSchemes.end(); for (size_t sp = 0; sp < static_cast<size_t>(pop.numSubPop()); ++sp) { vectormating m; Added: trunk/src/mutant_vector.h =================================================================== --- trunk/src/mutant_vector.h (rev 0) +++ trunk/src/mutant_vector.h 2011-12-25 20:26:08 UTC (rev 4355) @@ -0,0 +1,527 @@ +#include "boost/numeric/ublas/vector_sparse.hpp" +using boost::numeric::ublas::compressed_vector; +using boost::numeric::ublas::sparse_vector_element; + +#ifndef _MUTANT_VECTOR_H +#define _MUTANT_VECTOR_H + + +namespace simuPOP { + +/// CPPONLY +template <class T> +class mutant_vector +{ + public: + + class iterator; + typedef const iterator const_iterator; + + mutant_vector() + { + } + + mutant_vector(size_t size) + { + m_container.resize(size); + } + + mutant_vector(size_t size, const T& value) + { + if (value == 0) + m_container.resize(size); + else { + m_container.resize(size); + m_container.reserve(size); + for ( size_t i = 0; i < size; i++) + m_container.push_back(i, value); + } + } + + void resize (size_t size) + { + m_container.resize(size); + } + + void reserve (size_t size) + { + m_container.reserve(size); + } + + size_t size() const { + return m_container.size(); + } + + typename mutant_vector<T>::iterator begin() + { + return typename mutant_vector<T>::iterator(&m_container, 0); + } + + const typename mutant_vector<T>::iterator begin() const + { + return typename mutant_vector<T>::iterator(const_cast<compressed_vector<T> *>(&m_container), 0); + } + + typename mutant_vector<T>::iterator end() + { + return typename mutant_vector<T>::iterator(&m_container, m_container.size()); + } + + const typename mutant_vector<T>::iterator end() const + { + return typename mutant_vector<T>::iterator(const_cast<compressed_vector<T> *>(&m_container), m_container.size()); + } + + typename compressed_vector<T>::reference operator [] (size_t i) + { + return m_container[i]; + } + + void push_back (typename compressed_vector<T>::size_type i, typename compressed_vector<T>::const_reference t) + { + m_container.push_back(i, t); + } + + void swap(mutant_vector<T> & vec) + { + m_container.swap(vec.getContainer()); + + } + + + compressed_vector<T> & getContainer() + { + return m_container; + } + + const compressed_vector<T> & getContainer() const + { + return m_container; + } + + class iterator + { + protected: + compressed_vector<T> * m_container; + mutable size_t m_index; + mutable ssize_t m_com_index; + + public: + + iterator (compressed_vector<T> * c) : m_container(c), m_index(0), m_com_index(-1) + { + // m_com_index is the smallest index of mutants (or -1 is nothing is there) + } + + iterator (const compressed_vector<T> * c) : m_container(c), m_index(0), m_com_index(-1) + { + } + + iterator (compressed_vector<T> * c, size_t index) : m_container(c), m_index(index) + { + typename compressed_vector<size_t>::index_array_type::iterator lower = + std::lower_bound(m_container->index_data().begin(), m_container->index_data().begin() + m_container->filled(), index); + m_com_index = lower - m_container->index_data().begin(); + // find the smallest m_com_index that is larger than index + } + + iterator (const compressed_vector<T> * c, size_t index) : m_container(c), m_index(index) + { + typename compressed_vector<size_t>::index_array_type::iterator lower = + std::lower_bound(m_container->index_data().begin(), m_container->index_data().begin() + m_container->filled(), index); + m_com_index = lower - m_container->index_data().begin(); + } + + iterator () : m_container(NULL), m_index(0), m_com_index(-1) + { + } + + iterator & operator = (const iterator & iter) + { + m_container = iter.m_container; + m_index = iter.m_index; + return *this; + } + + bool operator == (const iterator & iter) const + { + if (m_index == iter.m_index) + return true; + return false; + } + + bool operator != (const iterator & iter) const + { + if (m_index != iter.m_index) + return true; + return false; + } + bool operator >= (const iterator & iter) const + { + if (m_index >= iter.m_index) + return true; + return false; + } + + bool operator <= (const iterator & iter) const { + if (m_index <= iter.m_index) + return true; + return false; + } + + bool operator > (const iterator & iter) const + { + if (m_index > iter.m_index) + return true; + return false; + } + + bool operator < (const iterator & iter) const + { + if (m_index < iter.m_index) + return true; + return false; + } + + typename compressed_vector<T>::const_reference operator* () const + { + static const T zero = 0; + if (m_index < m_container->index_data()[m_com_index]) + return zero; + else + return m_container->value_data()[m_com_index]; + + } + + typename compressed_vector<T>::reference operator* () + { + return (*m_container)[m_index]; + } + + + + typename compressed_vector<T>::reference operator [] (const size_t i) + { + return (*m_container)[m_index + i]; + } + + typename compressed_vector<T>::const_reference operator [] (const size_t i) const + { + return (*m_container)[m_index + i]; + } + + /// CPPONLY pre-incrment return by-reference + iterator & operator++ () + { + ++m_index; + if (m_index >= m_container->index_data()[m_com_index]) + ++m_com_index; + return *this; + } + + const iterator & operator++ () const + { + ++m_index; + if (m_index >= m_container->index_data()[m_com_index]) + ++m_com_index; + return *this; + } + + /// CPPONLY post-incrment return by-value + iterator operator++ ( int ) + { + iterator orig = *this; + ++(*this); + return orig; + } + + const iterator operator++ ( int ) const + { + const iterator orig = *this; + ++(*this); + return orig; + } + + iterator & operator+= (const iterator & iter) + { + m_index+=iter.m_index; + if (m_index > m_container->size()) + m_index = m_container->size(); + while (true) { + if (m_com_index < (int)m_container->filled()) + if (m_index < m_container->index_data()[m_com_index]) { + break; + } + else if (m_index == m_container->index_data()[m_com_index]) { + ++m_com_index; + break; + } else { + ++m_com_index; + } + else + break; + } + return *this; + } + + const iterator & operator+= (const iterator & iter) const + { + m_index+=iter.m_index; + if (m_index > m_container->size()) + m_index = m_container->size(); + while (true) { + if (m_com_index < (int)m_container->filled()) + if (m_index < m_container->index_data()[m_com_index]) { + break; + } + else if (m_index == m_container->index_data()[m_com_index]) { + ++m_com_index; + break; + } else { + ++m_com_index; + } + else + break; + } + + return *this; + } + + iterator & operator+= (const size_t size) + { + m_index+=size; + if (m_index > m_container->size()) + m_index = m_container->size(); + while (true) { + if (m_com_index < (int)m_container->filled()) + if (m_index < m_container->index_data()[m_com_index]) { + break; + } + else if (m_index == m_container->index_data()[m_com_index]) { + ++m_com_index; + break; + } else { + ++m_com_index; + } + else + break; + } + + return *this; + } + + const iterator & operator+= (const size_t size) const + { + m_index+=size; + if (m_index > m_container->size()) + m_index = m_container->size(); + while (true) { + if (m_com_index < (int)m_container->filled()) + if (m_index < m_container->index_data()[m_com_index]) { + break; + } + else if (m_index == m_container->index_data()[m_com_index]) { + ++m_com_index; + break; + } else { + ++m_com_index; + } + else + break; + } + + return *this; + } + + /*size_t operator + (iterator & iter) + { + return (*this).m_index + iter.m_index; + } + */ + + iterator operator + (const iterator & iter) const + { + iterator result = *this; + result.m_index += iter.m_index; + return result; + } + + iterator operator + (const size_t size) const + { + iterator result = *this; + result.m_index += size; + return result; + } + + /* + size_t operator - (iterator & iter) + { + return (*this).m_index - iter.m_index; + } + */ + + + iterator operator - (const iterator & iter) const + { + iterator result = *this; + result.m_index -= iter.m_index; + return result; + } + + iterator operator - (const size_t size) const + { + iterator result = *this; + result.m_index -= size; + return result; + } + + size_t findPositionIndexData () { + for (size_t i = 0; i < m_container->filled(); i++) { + if (i < m_container->filled() - 1 && m_index > m_container->index_data()[i]) { + continue; + } else if (i == m_container->filled() - 1 && m_index > m_container->index_data()[i]) { + return i + 1; + } + else { + return i; + } + } + return 0; + } + + + typename compressed_vector<T>::index_array_type::iterator getIndexIterator () { + //return m_container->index_data().begin() + findPositionIndexData(); + return std::lower_bound(m_container->index_data().begin(), m_container->index_data().begin() + m_container->filled(), m_index); + } + + typename compressed_vector<T>::value_array_type::iterator getValueIterator () { + return m_container->value_data().begin() + findPositionIndexData(); + //return m_container->value_data().begin() + (getIndexIterator() - m_container->index_data().begin()); + } + + typename compressed_vector<T>::iterator getCompressedVectorIterator() + { + return m_container->find(m_index); + } + + size_t getIndex () + { + return m_index; + } + + compressed_vector<T> * getContainer() + { + return m_container; + } + + void deleted () + { + m_container->erase_element(m_index); + } + + void assign (typename compressed_vector<T>::const_reference value) + { + if (value == 0u && (*m_container)[m_index] == 0u) + return; + else + (*m_container)[m_index] = value; + } + + + }; + + void erase (typename mutant_vector<T>::iterator begin,typename mutant_vector<T>::iterator end) + { + typename mutant_vector<T>::iterator it = begin; + typename mutant_vector<T>::iterator it2 = end; + for(;it != end; ++it) { + it.deleted(); + } + it = begin; + if (end != this->end()) + for(it2 = end; it2 != this->end(); ++it2, ++it) { + *it = *it2; + } + // compressed vector doesn't decrease the size when it is erased. + // we have to resize it. + m_container.resize(m_container.size() - (end.getIndex() - begin.getIndex())); + } + + void insert(typename mutant_vector<T>::iterator it, typename mutant_vector<T>::iterator begin, typename mutant_vector<T>::iterator end) + { + compressed_vector<size_t>::index_array_type::iterator it_src_begin = begin.getIndexIterator(); + compressed_vector<size_t>::index_array_type::iterator iend = end.getIndexIterator(); + size_t src_begin = *it_src_begin; + size_t src_index = *it_src_begin != begin.getIndex() ? *it_src_begin - begin.getIndex() : 0; + size_t dest_begin = it.getIndex(); + + m_container.resize(m_container.size() + (end.getIndex() - begin.getIndex())); + + for (;it_src_begin != iend; ++it_src_begin) { + m_container.push_back(((*it_src_begin + src_index) - src_begin) + dest_begin, (*begin.getContainer())[*it_src_begin]); + } + + } + + template<class Archive> + void serialize(Archive & ar, const unsigned int /*file_version*/) + { + ar & m_container; + } + + + private: + compressed_vector<T> m_container; +}; + +} + +# ifdef MUTANTALLELE +typedef unsigned int Allele; +typedef compressed_vector<Allele>::reference AlleleRef; +typedef simuPOP::mutant_vector<Allele> mutant_vectora; + +namespace simuPOP +{ + +inline void copy(mutant_vectora::iterator begin, mutant_vectora::iterator end, mutant_vectora::iterator it) +{ + mutant_vectora::iterator itt = begin; + for (;itt != end; ++itt, ++it) { + if (*it == 0u && *itt == 0u) + continue; + else + *it = *itt; + } +} + +inline void fill (mutant_vectora::iterator begin, mutant_vectora::iterator end, Allele value) +{ + if (value == 0) + for (mutant_vectora::iterator it = begin; it != end; ++it) + it.deleted(); + else + for (mutant_vectora::iterator it = begin; it != end; ++it) + *it = value; + + + +} + +inline mutant_vectora::iterator find (mutant_vectora::iterator begin, mutant_vectora::iterator end, Allele value) +{ + mutant_vectora::iterator it = begin; + for(; it != end; ++it) + { + if(*it == value) + return it; + } + return end; + +} + +} +# endif + +#endif Modified: trunk/src/mutator.cpp =================================================================== --- trunk/src/mutator.cpp 2011-12-25 20:15:22 UTC (rev 4354) +++ trunk/src/mutator.cpp 2011-12-25 20:26:08 UTC (rev 4355) @@ -232,7 +232,6 @@ } } - void MatrixMutator::mutate(AlleleRef allele, size_t) const { if (static_cast<size_t>(allele) >= m_sampler.size()) { @@ -254,15 +253,15 @@ + toStr(m_k - 1)); return; } -#ifdef BINARYALLELE +# ifdef BINARYALLELE allele = !allele; -#else +# else Allele new_allele = static_cast<Allele>(getRNG().randInt(m_k - 1)); if (new_allele >= allele) allele = new_allele + 1; else allele = new_allele; -#endif +# endif } @@ -297,6 +296,13 @@ void StepwiseMutator::mutate(AlleleRef allele, size_t) const { +#ifdef BINARYALLELE + if (getRNG().randUniform() < m_incProb) + allele = 1; + // decrease + else + allele = 0; +#else UINT step = 1; if (m_mutStep.size() == 1) @@ -310,29 +316,21 @@ "Invalid Python function for StepwiseMutator"); step = m_mutStep.func() (PyObj_As_Int, "(i)", static_cast<int>(allele)); } - // increase if (getRNG().randUniform() < m_incProb) { -#ifdef BINARYALLELE - allele = 1; -#else if (static_cast<UINT>(allele + step) < m_maxAllele) AlleleAdd(allele, step); else allele = ToAllele(m_maxAllele); -#endif } // decrease else { -#ifdef BINARYALLELE - allele = 0; -#else if (allele > step) AlleleMinus(allele, step); else allele = 0; -#endif } +#endif } Modified: trunk/src/population.cpp =================================================================== --- trunk/src/population.cpp 2011-12-25 20:15:22 UTC (rev 4354) +++ trunk/src/population.cpp 2011-12-25 20:26:08 UTC (rev 4355) @@ -13,8 +13,7 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -144,10 +143,10 @@ // copy genotype one by one so Individual genoPtr will not // point outside of subpopulation region. - GenoIterator ptr = m_genotype.begin(); InfoIterator infoPtr = m_info.begin(); + size_t infoStep = infoSize(); size_t step = genoSize(); - size_t infoStep = infoSize(); + GenoIterator ptr = m_genotype.begin(); for (size_t i = 0; i < m_popSize; ++i, ptr += step, infoPtr += infoStep) { m_inds[i].setGenoPtr(ptr); m_inds[i].setInfoPtr(infoPtr); @@ -165,10 +164,8 @@ vector<Individual> & linds = lp.m_inds; const vector<Individual> & rinds = rp.m_inds; - GenoIterator lg = lp.m_genotype.begin(); ConstGenoIterator rg = rp.m_genotype.begin(); - InfoIterator li = lp.m_info.begin(); ConstInfoIterator ri = rp.m_info.begin(); @@ -194,12 +191,27 @@ void Population::popData::swap(Population & pop) { +#ifdef MUTANTALLELE + size_t genoSize = 0; + if (m_inds.size() != 0) + genoSize = m_genotype.size() / m_inds.size(); +#endif + pop.m_subPopSize.swap(m_subPopSize); pop.m_subPopNames.swap(m_subPopNames); pop.m_genotype.swap(m_genotype); pop.m_info.swap(m_info); pop.m_inds.swap(m_inds); std::swap(pop.m_indOrdered, m_indOrdered); +#ifdef MUTANTALLELE + // compressed_vectora must be setGenoPtr after swap + GenoIterator ptr = pop.m_genotype.begin(); + for (size_t i = 0; i < pop.m_inds.size(); ++i, ptr += genoSize) + pop.m_inds[i].setGenoPtr(ptr); + ptr = m_genotype.begin(); + for (size_t i = 0; i < m_inds.size(); ++i, ptr += pop.genoSize()) + m_inds[i].setGenoPtr(ptr); +#endif } @@ -511,7 +523,6 @@ totNumLoci()); } - /// CPPONLY allele begin, for given subPop IndAlleleIterator Population::alleleIterator(size_t locus, size_t subPop) { @@ -655,13 +666,17 @@ #ifdef BINARYALLELE + toStr((m_popSize * step / 8 + m_popSize * is * sizeof(double) + m_popSize * sizeof(Individual)) / 1024) #else +# ifdef MUTANTALLELE + + toStr((m_popSize * is * sizeof(double) + m_popSize * sizeof(Individual)) / 1024) +# else + toStr((m_popSize * step * sizeof(Allele) + m_popSize * is * sizeof(double) + m_popSize * sizeof(Individual)) / 1024) +# endif #endif + "k bytes)"); } // reset individual pointers + InfoIterator infoPtr = m_info.begin(); GenoIterator ptr = m_genotype.begin(); - InfoIterator infoPtr = m_info.begin(); for (size_t i = 0; i < m_popSize; ++i, ptr += step, infoPtr += is) { m_inds[i].setGenoPtr(ptr); m_inds[i].setInfoPtr(infoPtr); @@ -702,8 +717,8 @@ if (oldInfoSize != newInfoSize) m_info.resize(newInfoSize * popSize()); // reset structure + InfoIterator infoPtr = m_info.begin(); GenoIterator ptr = m_genotype.begin(); - InfoIterator infoPtr = m_info.begin(); for (size_t i = 0; i < m_popSize; ++i, ptr += newSize, infoPtr += newInfoSize) { m_inds[i].setGenoStruIdx(stru); m_inds[i].setGenoPtr(ptr); @@ -739,6 +754,7 @@ } + size_t Population::subPopSize(vspID subPopID, int ancGen) const { vspID subPop = subPopID.resolve(*this); @@ -792,6 +808,7 @@ } + void Population::setSubPopByIndInfo(const string & field) { DBG_FAILIF(hasActivatedVirtualSubPop(), ValueError, @@ -820,15 +837,19 @@ DBG_DO(DBG_POPULATION, cerr << "New pop size" << newPopSize << endl); // allocate new genotype and inds +#ifdef MUTANTALLELE + mutant_vectora newGenotype(genoSize() * newPopSize); +#else vectora newGenotype(genoSize() * newPopSize); +#endif vectorf newInfo(newPopSize * infoSize()); vector<Individual> newInds(newPopSize); // assign genotype location and set structure information for individuals - GenoIterator ptr = newGenotype.begin(); InfoIterator infoPtr = newInfo.begin(); size_t step = genoSize(); size_t infoStep = infoSize(); + GenoIterator ptr = newGenotype.begin(); for (size_t i = 0; i < newPopSize; ++i, ptr += step, ++it, infoPtr += infoStep) { newInds[i].setGenoStruIdx(genoStruIdx()); newInds[i].setGenoPtr(ptr); @@ -840,9 +861,15 @@ m_genotype.swap(newGenotype); m_info.swap(newInfo); m_inds.swap(newInds); - m_popSize = newPopSize; setIndOrdered(true); +#ifdef MUTANTALLELE + // compressed_vectora must be setGenoPtr after swap + ptr = m_genotype.begin(); + for (size_t i = 0; i < m_popSize; ++i, ptr += genoSize()) + m_inds[i].setGenoPtr(ptr); + +#endif } if (m_inds.empty()) { @@ -968,7 +995,11 @@ ++newSize; if (oldInd != newInd) { *newInd = *oldInd; +#ifdef MUTANTALLELE + simuPOP::copy(oldPtr, oldPtr + step, newPtr); +#else copy(oldPtr, oldPtr + step, newPtr); +#endif copy(oldInfoPtr, oldInfoPtr + infoStep, newInfoPtr); } ++newInd; @@ -990,8 +1021,12 @@ new_spNames.push_back(m_subPopNames[sp]); // do not remove. if (oldPtr != newPtr) { +#ifdef MUTANTALLELE + simuPOP::copy(oldPtr, oldPtr + step * spSize, newPtr); +#else + copy(oldPtr, oldPtr + step * spSize, newPtr); +#endif copy(oldInd, oldInd + spSize, newInd); - copy(oldPtr, oldPtr + step * spSize, newPtr); copy(oldInfoPtr, oldInfoPtr + infoStep * spSize, newInfoPtr); } newInd += spSize; @@ -1009,8 +1044,8 @@ m_popSize = std::accumulate(new_size.begin(), new_size.end(), size_t(0)); setSubPopStru(new_size, new_spNames); // + InfoIterator infoPtr = m_info.begin(); GenoIterator ptr = m_genotype.begin(); - InfoIterator infoPtr = m_info.begin(); for (size_t i = 0; i < m_popSize; ++i, ptr += step, infoPtr += infoStep) { m_inds[i].setGenoPtr(ptr); m_inds[i].setInfoPtr(infoPtr); @@ -1027,10 +1062,10 @@ size_t infoStep = infoSize(); RawIndIterator oldInd = m_inds.begin(); RawIndIterator newInd = m_inds.begin(); + InfoIterator oldInfoPtr = m_info.begin(); + InfoIterator newInfoPtr = m_info.begin(); GenoIterator oldPtr = m_genotype.begin(); - InfoIterator oldInfoPtr = m_info.begin(); GenoIterator newPtr = m_genotype.begin(); - InfoIterator newInfoPtr = m_info.begin(); // for (size_t sp = 0; sp < numSubPop(); ++sp) { size_t newSize = 0; @@ -1041,7 +1076,11 @@ ++newSize; if (oldInd != newInd) { *newInd = *oldInd; +#ifdef MUTANTALLELE + simuPOP::copy(oldPtr, oldPtr + step, newPtr); +#else copy(oldPtr, oldPtr + step, newPtr); +#endif copy(oldInfoPtr, oldInfoPtr + infoStep, newInfoPtr); } ++newInd; @@ -1061,8 +1100,8 @@ m_popSize = std::accumulate(new_size.begin(), new_size.end(), size_t(0)); setSubPopStru(new_size, m_subPopNames); // + InfoIterator infoPtr = m_info.begin(); GenoIterator ptr = m_genotype.begin(); - InfoIterator infoPtr = m_info.begin(); for (size_t i = 0; i < m_popSize; ++i, ptr += step, infoPtr += infoStep) { m_inds[i].setGenoPtr(ptr); m_inds[i].setInfoPtr(infoPtr); @@ -1223,10 +1262,14 @@ size_t step = genoSize(); size_t infoStep = infoSize(); vector<Individual> new_inds; + vectorf new_info; +#ifdef MUTANTALLELE + mutant_vectora new_genotype; +#else vectora new_genotype; - vectorf new_info; + new_genotype.reserve(step * popSize()); +#endif new_inds.reserve(popSize()); - new_genotype.reserve(step * popSize()); new_info.reserve(infoStep * popSize()); for (size_t sp = 0; sp < numSubPop(); ++sp) { @@ -1236,6 +1279,7 @@ // do not remove. new_inds.insert(new_inds.end(), rawIndBegin(src), rawIndEnd(src)); new_genotype.insert(new_genotype.end(), genoBegin(src, true), genoEnd(src, true)); + if (infoStep > 0) new_info.insert(new_info.end(), m_info.begin() + subPopBegin(src) * infoStep, @@ -1251,8 +1295,8 @@ m_info.swap(new_info); setSubPopStru(new_size, new_names); // + InfoIterator infoPtr = m_info.begin(); GenoIterator ptr = m_genotype.begin(); - InfoIterator infoPtr = m_info.begin(); for (size_t i = 0; i < m_popSize; ++i, ptr += step, infoPtr += infoStep) { m_inds[i].setGenoPtr(ptr); m_inds[i].setInfoPtr(infoPtr); @@ -1278,11 +1322,14 @@ // DBG_FAILIF(m_subPopSize != pop.m_subPopSize, ValueError, "Can not add chromosomes from a population with different subpopulation sizes"); - +#ifdef MUTANTALLELE + mutant_vectora newGenotype(genoSize() * m_popSize); +#else vectora newGenotype(genoSize() * m_popSize); - +#endif // append pop2 chromosomes to the first one GenoIterator ptr = newGenotype.begin(); + size_t pEnd = ploidy(); for (size_t i = 0; i < m_popSize; ++i) { // set new geno structure @@ -1294,10 +1341,17 @@ for (size_t j = 0; j < numLoci1; ++j) *(ptr++) = *(ptr1++); for (size_t j = 0; j < numLoci2; ++j) - *(ptr++) = *(ptr2++); + *(ptr++) = *(ptr2++); } + } m_genotype.swap(newGenotype); +#ifdef MUTANTALLELE + // compressed_vectora must be setGenoPtr after swap + ptr = m_genotype.begin(); + for (size_t i = 0; i < m_popSize; ++i, ptr += genoSize()) + m_inds[i].setGenoPtr(ptr); +#endif } if (!indOrdered()) // sort information only @@ -1305,6 +1359,7 @@ } + void Population::addIndFrom(const Population & pop) { DBG_FAILIF(genoStruIdx() != pop.genoStruIdx(), ValueError, @@ -1327,10 +1382,10 @@ m_genotype.insert(m_genotype.end(), pop.m_genotype.begin(), pop.m_genotype.end()); m_info.insert(m_info.end(), pop.m_info.begin(), pop.m_info.end()); // iterators ready - GenoIterator ptr = m_genotype.begin(); InfoIterator infoPtr = m_info.begin(); size_t step = genoSize(); size_t infoStep = infoSize(); + GenoIterator ptr = m_genotype.begin(); // set pointers for (size_t i = 0; i < m_popSize; ++i, ptr += step, infoPtr += infoStep) { m_inds[i].setGenoStruIdx(genoStruIdx()); @@ -1379,8 +1434,11 @@ DBG_FAILIF(m_subPopSize != pop.m_subPopSize, ValueError, "Can not add chromosomes from a population with different subpopulation sizes"); // +#ifdef MUTANTALLELE + mutant_vectora newGenotype(genoSize() * m_popSize); +#else vectora newGenotype(genoSize() * m_popSize); - +#endif // merge chromosome by chromosome GenoIterator ptr = newGenotype.begin(); size_t pEnd = ploidy(); @@ -1402,6 +1460,12 @@ } } m_genotype.swap(newGenotype); +#ifdef MUTANTALLELE + // compressed_vectora must be setGenoPtr after swap + ptr = m_genotype.begin(); + for (size_t i = 0; i < m_popSize; ++i, ptr += genoSize()) + m_inds[i].setGenoPtr(ptr); +#endif } // sort information only @@ -1428,17 +1492,22 @@ for (int depth = ancestralGens(); depth >= 0; --depth) { useAncestralGen(depth); - // size_t newPopGenoSize = genoSize() * m_popSize; +#ifdef MUTANTALLELE + mutant_vectora newGenotype(newPopGenoSize, 0); +#else vectora newGenotype(newPopGenoSize, 0); +#endif // copy data over GenoIterator newPtr = newGenotype.begin(); + size_t pEnd = ploidy(); size_t gap = totNumLoci() - oldNumLoci; for (size_t i = 0; i < m_popSize; ++i) { // set new geno structure m_inds[i].setGenoStruIdx(genoStruIdx()); + GenoIterator oldPtr = m_inds[i].genoPtr(); // new genotype m_inds[i].setGenoPtr(newPtr); @@ -1448,8 +1517,16 @@ *(newPtr++) = *(oldPtr++); newPtr += gap; } + } m_genotype.swap(newGenotype); +#ifdef MUTANTALLELE + // compressed_vectora must be setGenoPtr after swap + GenoIterator ptr = m_genotype.begin(); + for (size_t i = 0; i < m_popSize; ++i, ptr += genoSize()) + m_inds[i].setGenoPtr(ptr); +#endif + } // if indOrdered is false: // individual genotype is now sorted. If we do not do @@ -1489,8 +1566,11 @@ useAncestralGen(depth); // size_t newPopGenoSize = genoSize() * m_popSize; +#ifdef MUTANTALLELE + mutant_vectora newGenotype(newPopGenoSize, 0); +#else vectora newGenotype(newPopGenoSize, 0); - +#endif // copy data over GenoIterator newPtr = newGenotype.begin(); size_t pEnd = ploidy(); @@ -1509,6 +1589,12 @@ } } m_genotype.swap(newGenotype); +#ifdef MUTANTALLELE + // compressed_vectora must be setGenoPtr after swap + GenoIterator ptr = m_genotype.begin(); + for (size_t i = 0; i < m_popSize; ++i, ptr += genoSize()) + m_inds[i].setGenoPtr(ptr); +#endif } // if indOrdered is false: // individual genotype is now sorted. If we do not do @@ -1530,17 +1616,21 @@ // prepare new Population vector<Individual> newInds(newPopSize); - vectora newGenotype(genoSize() * newPopSize); vectorf newInfo(newPopSize * infoSize()); // iterators ready - GenoIterator ptr = newGenotype.begin(); InfoIterator infoPtr = newInfo.begin(); size_t step = genoSize(); size_t infoStep = infoSize(); - // set pointers +#ifdef MUTANTALLELE + mutant_vectora newGenotype(genoSize() * newPopSize); +#else + vectora newGenotype(genoSize() * newPopSize); +#endif + GenoIterator ptr = newGenotype.begin(); for (size_t i = 0; i < newPopSize; ++i, ptr += step, infoPtr += infoStep) { newInds[i].setGenoStruIdx(genoStruIdx()); newInds[i].setGenoPtr(ptr); + // set pointers newInds[i].setInfoPtr(infoPtr); } // copy stuff over @@ -1563,6 +1653,13 @@ m_popSize = newPopSize; setIndOrdered(true); m_subPopSize = newSubPopSizes; + +#ifdef MUTANTALLELE + // compressed_vectora must be setGenoPtr after swap + ptr = m_genotype.begin(); + for (size_t i = 0; i < m_popSize; ++i, ptr += genoSize()) + m_inds[i].setGenoPtr(ptr); +#endif // rebuild index size_t idx = 1; for (m_subPopIndex[0] = 0; idx <= numSubPop(); ++idx) @@ -1594,7 +1691,11 @@ size_t infoStep = infoSize(); vector<Individual> new_inds; +#ifdef MUTANTALLELE + mutant_vectora new_genotype; +#else vectora new_genotype; +#endif vectorf new_info; if (rearrange) { @@ -1622,7 +1723,11 @@ ConstIndIterator oldInd = indIterator(it->subPop()); for (; oldInd.valid(); ++oldInd) { *newInd = *oldInd; +#ifdef MUTANTALLELE + simuPOP::copy(oldInd->genoBegin(), oldInd->genoEnd(), newPtr); +#else copy(oldInd->genoBegin(), oldInd->genoEnd(), newPtr); +#endif copy(oldInd->infoBegin(), oldInd->infoEnd(), newInfoPtr); ++newInd; newPtr += step; @@ -1658,7 +1763,11 @@ new_spNames.push_back(m_subPopNames[sp]); // copy(oldInd, oldInd + spSize, newInd); +#ifdef MUTANTALLELE + simuPOP::copy(oldPtr, oldPtr + step * spSize, newPtr); +#else copy(oldPtr, oldPtr + step * spSize, newPtr); +#endif copy(oldInfoPtr, oldInfoPtr + infoStep * spSize, newInfoPtr); oldInd += spSize; @@ -1668,8 +1777,8 @@ newPtr += step * spSize; newInfoPtr += infoStep * spSize; } else if (subPops.overlap(sp)) { - // partial copy - // + // partial copy + // // mark for copy markIndividuals(sp, false); subPopList::const_iterator it = subPops.begin(); @@ -1684,7 +1793,11 @@ if (oldInd->marked()) { ++newSize; *newInd = *oldInd; +#ifdef MUTANTALLELE + simuPOP::copy(oldPtr, oldPtr + step, newPtr); +#else copy(oldPtr, oldPtr + step, newPtr); +#endif copy(oldInfoPtr, oldInfoPtr + infoStep, newInfoPtr); ++newInd; newPtr += step; @@ -1717,8 +1830,8 @@ pop.m_popSize = sz; pop.setSubPopStru(new_size, new_spNames); // + InfoIterator infoPtr = pop.m_info.begin(); GenoIterator ptr = pop.m_genotype.begin(); - InfoIterator infoPtr = pop.m_info.begin(); for (size_t i = 0; i < pop.m_popSize; ++i, ptr += step, infoPtr += infoStep) { pop.m_inds[i].setGenoPtr(ptr); pop.m_inds[i].setInfoPtr(infoPtr); @@ -1753,7 +1866,11 @@ ++sz; vector<Individual> new_inds(sz); +#ifdef MUTANTALLELE + mutant_vectora new_genotype(sz * step); +#else vectora new_genotype(sz * step); +#endif vectorf new_info(sz * infoStep); RawIndIterator newInd = new_inds.begin(); @@ -1768,7 +1885,11 @@ if (oldInd->marked()) { ++newSize; *newInd = *oldInd; +#ifdef MUTANTALLELE + simuPOP::copy(oldPtr, oldPtr + step, newPtr); +#else copy(oldPtr, oldPtr + step, newPtr); +#endif copy(oldInfoPtr, oldInfoPtr + infoStep, newInfoPtr); ++newInd; newPtr += step; @@ -1787,8 +1908,8 @@ pop.m_popSize = std::accumulate(new_size.begin(), new_size.end(), size_t(0)); pop.setSubPopStru(new_size, m_subPopNames); // + InfoIterator infoPtr = pop.m_info.begin(); GenoIterator ptr = pop.m_genotype.begin(); - InfoIterator infoPtr = pop.m_info.begin(); for (size_t i = 0; i < pop.m_popSize; ++i, ptr += step, infoPtr += infoStep) { pop.m_inds[i].setGenoPtr(ptr); pop.m_inds[i].setInfoPtr(infoPtr); @@ -2031,11 +2152,19 @@ } vector<Individual> new_inds; +#ifdef MUTANTALLELE + size_t newIdx = 0; + mutant_vectora new_genotype; + if (removeLoci) + new_genotype.resize(size * step); + new_genotype.reserve(m_genotype.getContainer().index_data().end() - m_genotype.getContainer().index_data().begin()); +#else vectora new_genotype; + new_genotype.reserve(size * step); +#endif vectorf new_info; new_inds.reserve(size); - new_genotype.reserve(size * step); new_info.reserve(size * infoStep); // copy genotype and info... if (!removeInd) { @@ -2050,7 +2179,12 @@ GenoIterator ptr = it->genoBegin(); for (size_t p = 0; p < pEnd; p += pStep) { for (lociPtr = new_loci.begin(); lociPtr != lociEnd; ++lociPtr) +#ifdef MUTANTALLELE + new_genotype.push_back(newIdx++, *(ptr + *lociPtr + p)); +#else new_genotype.push_back(*(ptr + *lociPtr + p)); +#endif + } } } @@ -2083,7 +2217,11 @@ GenoIterator ptr = indGenoBegin(*it); for (size_t p = 0; p < pEnd; p += pStep) { for (lociPtr = new_loci.begin(); lociPtr != lociEnd; ++lociPtr) +#ifdef MUTANTALLELE + new_genotype.push_back(newIdx++, *(ptr + *lociPtr + p)); +#else new_genotype.push_back(*(ptr + *lociPtr + p)); +#endif } } if (!removeInfo) @@ -2103,8 +2241,12 @@ else pop.setSubPopStru(spSizes, m_subPopNames); // set pointer + vectorf::iterator infoPtr = new_info.begin(); +#ifdef MUTANTALLELE + mutant_vectora::iterator ptr = new_genotype.begin(); +#else vectora::iterator ptr = new_genotype.begin(); - vectorf::iterator infoPtr = new_info.begin(); +#endif for (size_t i = 0; i < size; ++i, ptr += step, infoPtr += infoStep) { new_inds[i].setGenoStruIdx(pop.genoStruIdx()); new_inds[i].setGenoPtr(ptr); @@ -2122,6 +2264,13 @@ pop.m_inds.swap(new_inds); pop.m_genotype.swap(new_genotype); pop.m_info.swap(new_info); +#ifdef MUTANTALLELE + // compressed_vectora must be setGenoPtr after swap + GenoIterator ptr = pop.m_genotype.begin(); + for (size_t i = 0; i < pop.m_inds.size(); ++i, ptr += step) + pop.m_inds[i].setGenoPtr(ptr); + +#endif } else { pop.m_ancestralPops.push_front(popData()); popData & pd = pop.m_ancestralPops.front(); @@ -2129,6 +2278,12 @@ pd.m_genotype.swap(new_genotype); pd.m_info.swap(new_info); pd.m_inds.swap(new_inds); +#ifdef MUTANTALLELE + // compressed_vectora must be setGenoPtr after swap + GenoIterator ptr = pd.m_genotype.begin(); + for (size_t i = 0; i < pd.m_inds.size(); ++i, ptr += step) + pd.m_inds[i].setGenoPtr(ptr); +#endif } } pop.m_curAncestralGen = 0; @@ -2178,7 +2333,11 @@ for (int depth = ancestralGens(); depth >= 0; --depth) { useAncestralGen(depth); // +#ifdef MUTANTALLELE + mutant_vectora newGenotype(genoSize() * m_popSize); +#else vectora newGenotype(genoSize() * m_popSize); +#endif // copy data over GenoIterator newPtr = newGenotype.begin(); size_t pEnd = ploidy(); @@ -2192,11 +2351,17 @@ vectoru::iterator loc = kept.begin(); for (; loc != kept.end(); ++loc) // this line needs ordered kept array - *(newPtr++) = oldPtr[*loc]; + *(newPtr++) = oldPtr[*loc]; //assginGenotype oldPtr += oldTotNumLoci; } } m_genotype.swap(newGenotype); +#ifdef MUTANTALLELE + // compressed_vectora must be setGenoPtr after swap + GenoIterator ptr = m_genotype.begin(); + for (size_t i = 0; i < m_popSize; ++i, ptr += genoSize()) + m_inds[i].setGenoPtr(ptr); +#endif } setIndOrdered(true); } @@ -2252,6 +2417,7 @@ GenoIterator ptr = m_genotype.begin(); GenoIterator ptrEnd = m_genotype.end(); + if (!newAlleles.empty()) { const vectoru & map = newAlleles.elems(); if (loci_.allAvail()) { @@ -2396,6 +2562,17 @@ m_info.swap(rhs.m_info); m_inds.swap(rhs.m_inds); std::swap(m_indOrdered, rhs.m_indOrdered); + +#ifdef MUTANTALLELE + // compressed_vectora must be setGenoPtr after swap + GenoIterator ptr = m_genotype.begin(); + for (size_t i = 0; i < m_inds.size(); ++i, ptr += genoSize()) + m_inds[i].setGenoPtr(ptr); + ptr = rhs.m_genotype.begin(); + for (size_t i = 0; i < rhs.m_inds.size(); ++i, ptr += genoSize()) + rhs.m_inds[i].setGenoPtr(ptr); +#endif + // current population should be working well // (with all datamember copied form rhs // rhs may not be working well since m_genotype etc @@ -2655,6 +2832,14 @@ pd1.m_info.swap(pd.m_info); pd1.m_inds.swap(pd.m_inds); std::swap(pd1.m_indOrdered, pd.m_indOrdered); +#ifdef MUTANTALLELE + GenoIterator ptr = pd1.m_genotype.begin(); + for (size_t i = 0; i < pd1.m_inds.size(); ++i, ptr += pd1.m_genotype.size() / pd1.m_inds.size()) + pd1.m_inds[i].setGenoPtr(ptr); + ptr = pd.m_genotype.begin(); + for (size_t i = 0; i < pd.m_inds.size(); ++i, ptr += pd.m_genotype.size() / pd.m_inds.size()) + pd.m_inds[i].setGenoPtr(ptr); +#endif } } } @@ -2700,6 +2885,7 @@ } + //template<class Archive> void Population::save(boost::archive::text_oarchive & ar, const unsigned int /* version */) const { @@ -2732,6 +2918,15 @@ data = 0; } } +#elif defined MUTANTALLELE + size_t size = m_genotype.size(); + ar & size; + ConstGenoIterator ptr = m_genotype.begin(); + unsigned int data = 0; + for (size_t i = 0; i < size; ++i, ++ptr) { + data = *ptr; + ar & data; + } #else ar & m_genotype; #endif @@ -2763,6 +2958,15 @@ data = 0; } } +#elif defined MUTANTALLELE + size_t size = m_genotype.size(); + ar & size; + ConstGenoIterator ptr = m_genotype.begin(); + unsigned int data = 0; + for (size_t i = 0; i < size; ++i, ++ptr) { + data = *ptr; + ar & data; + } #else ar & m_genotype; #endif @@ -2809,9 +3013,20 @@ ar & data; *ptr++ = (data & (1UL << (i % 32))) != 0; } - } + // binary from mutant + } else if (ma == 256) { + DBG_DO(DBG_POPULATION, cerr << "Load bin from mutant. " << endl); + size_t size; + ar & size; + m_genotype.resize(size); + GenoIterator ptr = m_genotype.begin(); + unsigned int data = 0; + for (size_t i = 0; i < size; ++i, ++ptr) { + ar & data; + *ptr = ToAllele(data); + } // binary from others (long types) - else { + } else { DBG_DO(DBG_POPULATION, cerr << "Load bin from long. " << endl); vectoru tmpgeno; ar & tmpgeno; @@ -2820,7 +3035,7 @@ m_genotype[i] = ToAllele(tmpgeno[i]); } #else - // long from binary + // long or mutant from binary if (ma == 1) { // for version 2 and higher, archive in 32bit blocks. size_t size; @@ -2835,9 +3050,49 @@ } } // if ma == 1 else { // for non-binary types, ... - DBG_DO(DBG_POPULATION, cerr << "Load long from long. " << endl); +# ifdef MUTANTALLELE + // mutant from mutant + if (ma == 256) { + DBG_DO(DBG_POPULATION, cerr << "Load mutant from mutant. " << endl); + size_t size; + ar & size; + m_genotype.resize(size); + GenoIterator ptr = m_genotype.begin(); + unsigned int data = 0; + for (size_t i = 0; i < size; ++i, ++ptr) { + ar & data; + *ptr = data; + } + } + // mutant from long + else { + DBG_DO(DBG_POPULATION, cerr << "Load mutant from long. " << endl); + vectora data; + ar & data; + m_genotype.resize(data.size()); + for (size_t i = 0; i < data.size(); ++i) { + m_genotype[i] = data[i]; + } + } +# else + // long from mutant + if (ma == 256) { + DBG_DO(DBG_POPULATION, cerr << "Load long from mutant. " << endl); + size_t size; + ar & size; + m_genotype.resize(size); + GenoIterator ptr = m_genotype.begin(); + unsigned int data = 0; + for (size_t i = 0; i < size; ++i, ++ptr) { + ar & data; + *ptr = data; + } // long from long - ar & m_genotype; + } else { + DBG_DO(DBG_POPULATION, cerr << "Load long from long. " << endl); + ar & m_genotype; + } +# endif } #endif @@ -2867,10 +3122,11 @@ m_subPopIndex[i] = m_subPopIndex[i - 1] + m_subPopSize[i - 1]; // assign genotype location and set structure information for individuals - GenoIterator ptr = m_genotype.begin(); - size_t step = genoSize(); + InfoIterator infoPtr = m_info.begin(); size_t infoStep = infoSize(); + size_t step = genoSize(); + GenoIterator ptr = m_genotype.begin(); for (size_t i = 0; i < m_popSize; ++i, ptr += step, infoPtr += infoStep) { m_inds[i].setGenoStruIdx(genoStruIdx()); m_inds[i].setGenoPtr(ptr); @@ -2902,6 +3158,19 @@ ar & data; *ptr++ = (data & (1UL << i % 32)) != 0; } + // binary from mutant + } else if (ma == 256) { + DBG_DO(DBG_POPULATION, cerr << "Load bin from mutant. " << endl); + size_t size; + ar & size; + pd.m_genotype.resize(size); + GenoIterator ptr = pd.m_genotype.begin(); + unsigned int data = 0; + for (size_t i = 0; i < size; ++i, ++ptr) { + ar & data; + *ptr = ToAllele(data); + } + // binary from others (long types) } else { DBG_DO(DBG_POPULATION, cerr << "Load bin from long. " << endl); // binary from long types @@ -2925,9 +3194,49 @@ *ptr++ = (data & (1UL << i % 32)) != 0; } } else { - DBG_DO(DBG_POPULATION, cerr << "Load long from long. " << endl); - // long type from long type. - ar & pd.m_genotype; +# ifdef MUTANTALLELE + // mutant from mutant + if (ma == 256) { + DBG_DO(DBG_POPULATION, cerr << "Load mutant from mutant. " << endl); + size_t size; + ar & size; + pd.m_genotype.resize(size); + GenoIterator ptr = pd.m_genotype.begin(); + unsigned int data = 0; + for (size_t i = 0; i < size; ++i, ++ptr) { + ar & data; + *ptr = data; + } + } + // mutant from long + else { + DBG_DO(DBG_POPULATION, cerr << "Load mutant from long. " << endl); + vectora data; + ar & data; + pd.m_genotype.resize(data.size()); + for (size_t i = 0; i < data.size(); ++i) { + pd.m_genotype[i] = data[i]; + } + } +# else + // long from mutant + if (ma == 256) { + DBG_DO(DBG_POPULATION, cerr << "Load long from mutant. " << endl); + size_t size; + ar & size; + pd.m_genotype.resize(size); + GenoIterator ptr = pd.m_genotype.begin(); + unsigned int data = 0; + for (size_t i = 0; i < size; ++i, ++ptr) { + ar & data; + *ptr = data; + } + // long from long + } else { + DBG_DO(DBG_POPULATION, cerr << "Load long from long. " << endl); + ar & pd.m_genotype; + } +# endif } #endif ar & pd.m_info; @@ -2939,9 +3248,8 @@ // set pointers vector<Individual> & inds = p.m_inds; size_t ps = inds.size(); + infoPtr = p.m_info.begin(); ptr = p.m_genotype.begin(); - infoPtr = p.m_info.begin(); - for (size_t i = 0; i < ps; ++i, ptr += step, infoPtr += infoStep) { inds[i].setGenoPtr(ptr); inds[i].setInfoPtr(infoPtr); @@ -3001,7 +3309,6 @@ Py_INCREF(m_vars.dict()); return m_vars.dict(); } - DBG_ASSERT(static_cast<size_t>(vsp.subPop()) < numSubPop(), IndexError, "Subpop index out of range of 0 ~ " + toStr(numSubPop() - 1)); @@ -3085,11 +3392,16 @@ } else { DBG_DO(DBG_POPULATION, cerr << "Adjust geno and info position " << endl); + size_t is = infoSize(); size_t sz = genoSize(); - size_t is = infoSize(); +#ifdef MUTANTALLELE + mutant_vectora tmpGenotype(m_popSize * genoSize()); + mutant_vectora::iterator it = tmpGenotype.begin(); +#else vectora tmpGenotype(m_popSize * genoSize()); + vectora::iterator it = tmpGenotype.begin(); +#endif vectorf tmpInfo(m_popSize * infoSize()); - vectora::iterator it = tmpGenotype.begin(); vectorf::iterator infoPtr = tmpInfo.begin(); IndIterator ind = const_cast<Population *>(this)->indIterator(); @@ -3097,11 +3409,15 @@ #ifdef BINARYALLELE copyGenotype(ind->genoBegin(), it, sz); #else +# ifdef MUTANTALLELE + simuPOP::copy(ind->genoBegin(), ind->genoEnd(), it); +# else copy(ind->genoBegin(), ind->genoEnd(), it); +# endif #endif + ind->setGenoPtr(it); it += sz; - copy(ind->infoBegin(), ind->infoEnd(), infoPtr); ind->setInfoPtr(infoPtr); infoPtr += is; @@ -3123,6 +3439,7 @@ } + } Modified: trunk/src/population.h =================================================================== --- trunk/src/population.h 2011-12-25 20:15:22 UTC (rev 4354) +++ trunk/src/population.h 2011-12-25 20:26:08 UTC (rev 4355) @@ -295,9 +295,17 @@ std::swap(m_vspSplitter, rhs.m_vspSplitter); std::swap(rhs.m_gen, m_gen); std::swap(rhs.m_rep, m_rep); +#ifdef MUTANTALLELE + // compressed_vectora must be setGenoPtr after swap + GenoIterator ptr = m_genotype.begin(); + for (size_t i = 0; i < m_inds.size(); ++i, ptr += genoSize()) + m_inds[i].setGenoPtr(ptr); + ptr = rhs.m_genotype.begin(); + for (size_t i = 0; i < rhs.m_inds.size(); ++i, ptr += rhs.genoSize()) + rhs.m_inds[i].setGenoPtr(ptr); +#endif } - /// destroy a population ~Population(); @@ -824,6 +832,7 @@ IndAlleleIterator alleleIterator(size_t locus, size_t subPop); + /// CPPONLY allele iterator, go through all allels one by one, without subPop info /** if order, in order @@ -1461,9 +1470,8 @@ void execute(const string & stmts = string()) { Expression("", stmts, m_vars.dict()).evaluate(); - } + } - private: friend class boost::serialization::access; @@ -1490,7 +1498,11 @@ BaseVspSplitter * m_vspSplitter; /// pool of genotypic information +#ifdef MUTANTALLELE + mutant_vectora m_genotype; +#else vectora m_genotype; +#endif /// information /// only in head node @@ -1511,7 +1523,11 @@ { vectoru m_subPopSize; vectorstr m_subPopNames; +#ifdef MUTANTALLELE + mutant_vectora m_genotype; +#else vectora m_genotype; +#endif vectorf m_info; vector<Individual> m_inds; bool m_indOrdered; Property changes on: trunk/src/qtrait.h ___________________________________________________________________ Deleted: svn:mergeinfo - /branches/mutant/src/qtrait.h:4262-4317 /branches/mutant_new/src/qtrait.h:4318-4337,4352-4353 /branches/openMP/src/qtrait.h:3999-4241 Modified: trunk/src/sandbox.cpp =================================================================== --- trunk/src/sandbox.cpp 2011-12-25 20:15:22 UTC (rev 4354) +++ trunk/src/sandbox.cpp 2011-12-25 20:26:08 UTC (rev 4355) @@ -28,6 +28,7 @@ namespace simuPOP { +#ifdef MUTANTALLELE bool RevertFixedSites::apply(Population & pop) const { @@ -36,6 +37,702 @@ RawIndIterator it = pop.rawIndBegin(); RawIndIterator it_end = pop.rawIndEnd(); + std::set<Allele> commonAlleles(it->genoBegin(0).getIndexIterator(), it->genoEnd(0).getIndexIterator()); + + if (commonAlleles.size() == 0) + return true; + + for (; it != it_end; ++it) { + // common = commonAlleles & geno0 + std::set<Allele> common; + std::set<Allele> alleles1(it->genoBegin(0).getIndexIterator(), it->genoEnd(0).getIndexIterator()); + set_intersection(commonAlleles.begin(), + commonAlleles.end(), alleles1.begin(), alleles1.end(), + std::inserter(common, common.begin())); + // commonAlleles = common & geno1 + commonAlleles.clear(); + // ALl mutants in the second ploidy + std::set<Allele> alleles2(it->genoBegin(1).getIndexIterator(), it->genoEnd(1).getIndexIterator()); + set_intersection(common.begin(), + common.end(), alleles2.begin(), alleles2.end(), + std::inserter(commonAlleles, commonAlleles.begin())); + if (commonAlleles.size() == 0) + return true; + } + if (!noOutput()) { + ostream & out = getOstream(pop.dict()); + out << pop.gen(); + std::set<Allele>::iterator beg = commonAlleles.begin(); + std::set<Allele>::iterator end = commonAlleles.end(); + for (; beg != end ; ++beg) + out << '\t' << *beg; + out << endl; + } + it = pop.rawIndBegin(); + vectora new_alleles(pop.totNumLoci()); + for (; it != it_end; ++it) { + for (size_t p = 0; p < 2; ++p) { + // FIXME: get old alleles + std::set<Allele> old_alleles(it->genoBegin(p).getIndexIterator(), it->genoEnd(p).getIndexIterator()); + //old_alleles.erase(0); + // FIXME: fill with all zero, do not have to do that for mutant type + //std::fill(new_alleles.begin(), new_alleles.end(), Allele(0)); + set_difference(old_alleles.begin(), old_alleles.end(), + commonAlleles.begin(), commonAlleles.end(), new_alleles.begin()); + GenoIterator ptr = it->genoBegin(p); + // FIXME: basically, you need to remove those mutants. + for (vectora::iterator new_it = new_alleles.begin(); new_it != new_alleles.end(); ++new_it, ++ptr) { + if (*new_it == 0u && *ptr == 0u) + continue; + else if (*new_it == 0u && *ptr != 0u) + ptr.deleted(); + else + *ptr = *new_it; + } + + //std::copy(new_alleles.begin(), new_alleles.end(), + // it->genoBegin(p)); + } + } + return true; +} + + +double MutSpaceSelector::indFitness(Population & /* pop */, Individual * ind) const +{ + if (m_mode == MULTIPLICATIVE) { + return randomSelMulFitnessExt(ind->genoBegin(), ind->genoEnd()); + } else if (m_mode == ADDITIVE) { + if (m_additive) + return randomSelAddFitness(ind->genoBegin(), ind->genoEnd()); + else + return randomSelAddFitnessExt(ind->genoBegin(), ind->genoEnd()); + } else if (m_mode == EXPONENTIAL) { + if (m_additive) + retur... [truncated message content] |
From: <ti...@us...> - 2012-01-31 20:31:53
|
Revision: 4366 http://simupop.svn.sourceforge.net/simupop/?rev=4366&view=rev Author: tiwcpe8 Date: 2012-01-31 20:31:46 +0000 (Tue, 31 Jan 2012) Log Message: ----------- Merge mutant_new branch to trunk Modified Paths: -------------- trunk/src/mutant_vector.h trunk/src/sandbox.cpp trunk/src/stator.cpp Added Paths: ----------- trunk/test/sample_32_mu.pop trunk/test/sample_64_mu.pop Property Changed: ---------------- trunk/ Property changes on: trunk ___________________________________________________________________ Modified: svn:mergeinfo - /branches/mutant:4262-4317 /branches/mutant_new:4318-4354 /branches/openMP:3999-4241 + /branches/mutant:4262-4317 /branches/mutant_new:4318-4365 /branches/openMP:3999-4241 Modified: trunk/src/mutant_vector.h =================================================================== --- trunk/src/mutant_vector.h 2012-01-31 18:12:21 UTC (rev 4365) +++ trunk/src/mutant_vector.h 2012-01-31 20:31:46 UTC (rev 4366) @@ -107,6 +107,22 @@ mutable ssize_t m_com_index; public: + iterator (const iterator& iter) + { + m_container = iter.m_container; + m_index = iter.m_index; + m_com_index = iter.m_com_index; + if (m_index == 0) { + m_com_index = -1; + } else { + typename compressed_vector<size_t>::index_array_type::iterator lower = + std::lower_bound(m_container->index_data().begin(), m_container->index_data().begin() + m_container->filled(), m_index); + m_com_index = lower - m_container->index_data().begin(); + } + + + + } iterator (compressed_vector<T> * c) : m_container(c), m_index(0), m_com_index(-1) { @@ -119,17 +135,25 @@ iterator (compressed_vector<T> * c, size_t index) : m_container(c), m_index(index) { - typename compressed_vector<size_t>::index_array_type::iterator lower = - std::lower_bound(m_container->index_data().begin(), m_container->index_data().begin() + m_container->filled(), index); - m_com_index = lower - m_container->index_data().begin(); + if (index == 0) { + m_com_index = -1; + } else { + typename compressed_vector<size_t>::index_array_type::iterator lower = + std::lower_bound(m_container->index_data().begin(), m_container->index_data().begin() + m_container->filled(), index); + m_com_index = lower - m_container->index_data().begin(); + } // find the smallest m_com_index that is larger than index } iterator (const compressed_vector<T> * c, size_t index) : m_container(c), m_index(index) { - typename compressed_vector<size_t>::index_array_type::iterator lower = - std::lower_bound(m_container->index_data().begin(), m_container->index_data().begin() + m_container->filled(), index); - m_com_index = lower - m_container->index_data().begin(); + if (index == 0) { + m_com_index = -1; + } else { + typename compressed_vector<size_t>::index_array_type::iterator lower = + std::lower_bound(m_container->index_data().begin(), m_container->index_data().begin() + m_container->filled(), index); + m_com_index = lower - m_container->index_data().begin(); + } } iterator () : m_container(NULL), m_index(0), m_com_index(-1) @@ -140,6 +164,7 @@ { m_container = iter.m_container; m_index = iter.m_index; + m_com_index = iter.m_com_index; return *this; } @@ -186,10 +211,15 @@ typename compressed_vector<T>::const_reference operator* () const { static const T zero = 0; - if (m_index < m_container->index_data()[m_com_index]) + if (m_com_index < (int)m_container->index_data().size()) { + if (m_com_index == -1) + return zero; + else if (m_index < m_container->index_data()[m_com_index]) + return zero; + else + return m_container->value_data()[m_com_index]; + } else return zero; - else - return m_container->value_data()[m_com_index]; } @@ -214,7 +244,11 @@ iterator & operator++ () { ++m_index; - if (m_index >= m_container->index_data()[m_com_index]) + if (m_container->index_data().size() == 0) + return *this; + if (m_com_index == -1) + m_com_index = 0; + if (m_com_index < (int)m_container->index_data().size() && m_index > m_container->index_data()[m_com_index]) ++m_com_index; return *this; } @@ -222,7 +256,11 @@ const iterator & operator++ () const { ++m_index; - if (m_index >= m_container->index_data()[m_com_index]) + if (m_container->index_data().size() == 0) + return *this; + if (m_com_index == -1) + m_com_index = 0; + if (m_com_index < (int)m_container->index_data().size() && m_index > m_container->index_data()[m_com_index]) ++m_com_index; return *this; } @@ -247,6 +285,10 @@ m_index+=iter.m_index; if (m_index > m_container->size()) m_index = m_container->size(); + if (m_container->index_data().size() == 0) + return *this; + if (m_com_index == -1) + m_com_index = 0; while (true) { if (m_com_index < (int)m_container->filled()) if (m_index < m_container->index_data()[m_com_index]) { @@ -269,6 +311,10 @@ m_index+=iter.m_index; if (m_index > m_container->size()) m_index = m_container->size(); + if (m_container->index_data().size() == 0) + return *this; + if (m_com_index == -1) + m_com_index = 0; while (true) { if (m_com_index < (int)m_container->filled()) if (m_index < m_container->index_data()[m_com_index]) { @@ -292,6 +338,10 @@ m_index+=size; if (m_index > m_container->size()) m_index = m_container->size(); + if (m_container->index_data().size() == 0) + return *this; + if (m_com_index == -1) + m_com_index = 0; while (true) { if (m_com_index < (int)m_container->filled()) if (m_index < m_container->index_data()[m_com_index]) { @@ -315,6 +365,10 @@ m_index+=size; if (m_index > m_container->size()) m_index = m_container->size(); + if (m_container->index_data().size() == 0) + return *this; + if (m_com_index == -1) + m_com_index = 0; while (true) { if (m_com_index < (int)m_container->filled()) if (m_index < m_container->index_data()[m_com_index]) { @@ -353,12 +407,10 @@ return result; } - /* size_t operator - (iterator & iter) { return (*this).m_index - iter.m_index; } - */ iterator operator - (const iterator & iter) const @@ -386,13 +438,13 @@ return i; } } + return 0; } - typename compressed_vector<T>::index_array_type::iterator getIndexIterator () { - //return m_container->index_data().begin() + findPositionIndexData(); - return std::lower_bound(m_container->index_data().begin(), m_container->index_data().begin() + m_container->filled(), m_index); + return m_container->index_data().begin() + findPositionIndexData(); + //return std::lower_bound(m_container->index_data().begin(), m_container->index_data().begin() + m_container->filled(), m_index); } typename compressed_vector<T>::value_array_type::iterator getValueIterator () { @@ -405,7 +457,7 @@ return m_container->find(m_index); } - size_t getIndex () + size_t getIndex () const { return m_index; } @@ -433,18 +485,16 @@ void erase (typename mutant_vector<T>::iterator begin,typename mutant_vector<T>::iterator end) { - typename mutant_vector<T>::iterator it = begin; - typename mutant_vector<T>::iterator it2 = end; - for(;it != end; ++it) { - it.deleted(); + + if (end != this->end()) { + std::copy(end.getValueIterator(), this->end().getValueIterator(), begin.getValueIterator()); + typename compressed_vector<T>::index_array_type::iterator it = end.getIndexIterator(); + typename compressed_vector<T>::index_array_type::iterator index_end = end.getIndexIterator(); + for (; it != this->end().getIndexIterator(); ++it) { + *it -= (end - begin); + } + std::copy(index_end, this->end().getIndexIterator(), begin.getIndexIterator()); } - it = begin; - if (end != this->end()) - for(it2 = end; it2 != this->end(); ++it2, ++it) { - *it = *it2; - } - // compressed vector doesn't decrease the size when it is erased. - // we have to resize it. m_container.resize(m_container.size() - (end.getIndex() - begin.getIndex())); } @@ -487,12 +537,59 @@ inline void copy(mutant_vectora::iterator begin, mutant_vectora::iterator end, mutant_vectora::iterator it) { - mutant_vectora::iterator itt = begin; - for (;itt != end; ++itt, ++it) { - if (*it == 0u && *itt == 0u) - continue; - else - *it = *itt; + + size_t size = end - begin; + mutant_vectora::iterator it_end = it + size; + if (it_end.getIndex() <= it_end.getContainer()->size()) { + compressed_vector<Allele>::value_array_type::iterator src_value_begin = begin.getValueIterator(); + compressed_vector<Allele>::value_array_type::iterator src_value_end = end.getValueIterator(); + compressed_vector<Allele>::value_array_type::iterator dest_value_begin = it.getValueIterator(); + compressed_vector<Allele>::value_array_type::iterator dest_value_end = it_end.getValueIterator(); + compressed_vector<Allele>::index_array_type::iterator src_index_begin = begin.getIndexIterator(); + compressed_vector<Allele>::index_array_type::iterator dest_index_begin = it.getIndexIterator(); + size_t src_size = src_value_end - src_value_begin; + size_t dest_size = dest_value_end - dest_value_begin; + size_t src_idx_num_begin = begin.getIndex(); + size_t dest_idx_num_begin = it.getIndex(); + if (src_size > dest_size) { + size_t diff_size = src_size - dest_size; + size_t filled_size = it.getContainer()->filled(); + if (filled_size + diff_size >= it.getContainer()->nnz_capacity()) { + it.getContainer()->reserve(it.getContainer()->filled() + diff_size, true); + } + dest_index_begin = it.getIndexIterator(); + dest_value_begin = it.getValueIterator(); + std::copy_backward(dest_index_begin, it.getContainer()->index_data().begin() + filled_size, it.getContainer()->index_data().begin() + filled_size + diff_size); + for (size_t i = 0; i < src_size; i++) { + size_t range = *(src_index_begin + i) - src_idx_num_begin; + *(dest_index_begin+i) = dest_idx_num_begin + range; + } + std::copy_backward(dest_value_begin, it.getContainer()->value_data().begin() + filled_size, it.getContainer()->value_data().begin() + filled_size + diff_size); + std::copy(src_value_begin, src_value_end, dest_value_begin); + it.getContainer()->set_filled(filled_size + diff_size); + } else if (src_size < dest_size) { + size_t diff_size = dest_size - src_size; + size_t filled_size = it.getContainer()->filled(); + dest_index_begin = it.getIndexIterator(); + dest_value_begin = it.getValueIterator(); + std::copy(dest_index_begin + diff_size, it.getContainer()->index_data().begin() + filled_size, dest_index_begin); + for (size_t i = 0; i < src_size; i++) { + size_t range = *(src_index_begin + i) - src_idx_num_begin; + *(dest_index_begin + i) = dest_idx_num_begin + range; + } + std::copy(dest_value_begin + diff_size, it.getContainer()->value_data().begin() + filled_size, dest_value_begin); + std::copy(src_value_begin, src_value_end, dest_value_begin); + it.getContainer()->set_filled(filled_size - diff_size); + + } else { + dest_index_begin = it.getIndexIterator(); + dest_value_begin = it.getValueIterator(); + for (size_t i = 0; i < src_size; i++) { + size_t range = *(src_index_begin + i) - src_idx_num_begin; + *(dest_index_begin + i) = dest_idx_num_begin + range; + } + std::copy(src_value_begin, src_value_end, dest_value_begin); + } } } @@ -511,7 +608,7 @@ inline mutant_vectora::iterator find (mutant_vectora::iterator begin, mutant_vectora::iterator end, Allele value) { - mutant_vectora::iterator it = begin; + mutant_vectora::const_iterator it = begin; for(; it != end; ++it) { if(*it == value) Modified: trunk/src/sandbox.cpp =================================================================== --- trunk/src/sandbox.cpp 2012-01-31 18:12:21 UTC (rev 4365) +++ trunk/src/sandbox.cpp 2012-01-31 20:31:46 UTC (rev 4366) @@ -497,12 +497,6 @@ void MutSpaceRecombinator::transmitGenotype0(Population & pop, Population & offPop, const Individual & parent, size_t offIndex, int ploidy) const { -#ifdef BINARYALLELE - (void)offPop; // avoid warning about unused parameter - (void)parent; // avoid warning about unused parameter - (void)offIndex; // avoid warning about unused parameter - (void)ploidy; // avoid warning about unused parameter -#else size_t nCh = parent.numChrom(); // count duplicates... @@ -580,19 +574,12 @@ // fill the rest with 0. std::fill(it, it_end, 0); } -#endif } void MutSpaceRecombinator::transmitGenotype1(Population & pop, Population & offPop, const Individual & parent, size_t offIndex, int ploidy) const { -#ifdef BINARYALLELE - (void)offPop; // avoid warning about unused parameter - (void)parent; // avoid warning about unused parameter - (void)offIndex; // avoid warning about unused parameter - (void)ploidy; // avoid warning about unused parameter -#else const matrixi & ranges = m_ranges.elems(); for (size_t ch = 0; ch < parent.numChrom(); ++ch) { @@ -693,7 +680,6 @@ // fill the rest with 0. std::fill(it, it_end, 0); } -#endif } @@ -772,14 +758,8 @@ std::fill(new_alleles.begin(), new_alleles.end(), Allele(0)); set_difference(old_alleles.begin(), old_alleles.end(), commonAlleles.begin(), commonAlleles.end(), new_alleles.begin()); -#ifdef MUTANTALLELE - GenoIterator ptr = it->genoBegin(p); - for (vectora::iterator new_it = new_alleles.begin(); new_it != new_alleles.end(); ++new_it, ++ptr) - *ptr = *new_it; -#else std::copy(new_alleles.begin(), new_alleles.end(), it->genoBegin(p)); -#endif } } return true; @@ -1050,9 +1030,9 @@ bool MutSpaceMutator::apply(Population & pop) const { -#ifdef BINARYALLELE + #ifdef BINARYALLELE (void)pop; // avoid warning about unused parameter -#else + #else const matrixi & ranges = m_ranges.elems(); vectoru width(ranges.size()); @@ -1185,7 +1165,7 @@ } // each subpopulation if (out) closeOstream(); -#endif + #endif return true; } @@ -1193,12 +1173,12 @@ void MutSpaceRecombinator::transmitGenotype0(Population & pop, Population & offPop, const Individual & parent, size_t offIndex, int ploidy) const { -#ifdef BINARYALLELE + #ifdef BINARYALLELE (void)offPop; // avoid warning about unused parameter (void)parent; // avoid warning about unused parameter (void)offIndex; // avoid warning about unused parameter (void)ploidy; // avoid warning about unused parameter -#else + #else size_t nCh = parent.numChrom(); // count duplicates... @@ -1277,19 +1257,19 @@ // fill the rest with 0. std::fill(it, it_end, 0); } -#endif + #endif } void MutSpaceRecombinator::transmitGenotype1(Population & pop, Population & offPop, const Individual & parent, size_t offIndex, int ploidy) const { -#ifdef BINARYALLELE + #ifdef BINARYALLELE (void)offPop; // avoid warning about unused parameter (void)parent; // avoid warning about unused parameter (void)offIndex; // avoid warning about unused parameter (void)ploidy; // avoid warning about unused parameter -#else + #else const matrixi & ranges = m_ranges.elems(); for (size_t ch = 0; ch < parent.numChrom(); ++ch) { @@ -1391,7 +1371,7 @@ // fill the rest with 0. std::fill(it, it_end, 0); } -#endif + #endif } Modified: trunk/src/stator.cpp =================================================================== --- trunk/src/stator.cpp 2012-01-31 18:12:21 UTC (rev 4365) +++ trunk/src/stator.cpp 2012-01-31 20:31:46 UTC (rev 4366) @@ -707,15 +707,43 @@ pop.activateVirtualSubPop(*sp); // go through all loci +#ifdef MUTANTALLELE + IndIterator ind = pop.indIterator(sp->subPop()); + for (; ind.valid(); ++ind) { + GenoIterator it = ind->genoBegin(); + GenoIterator it_end = ind->genoEnd(); + compressed_vector<Allele>::index_array_type::iterator index_it = it.getIndexIterator(); + compressed_vector<Allele>::index_array_type::iterator index_it_end = it_end.getIndexIterator(); + compressed_vector<Allele>::value_array_type::iterator value_it = it.getValueIterator(); + size_t indIndex = it.getIndex(); + for (;index_it != index_it_end; ++index_it, ++value_it) { + if (m_loci.allAvail()) { + if (*value_it != 0) { + segSites.insert(*index_it - indIndex); + } + } else { + for (size_t idx = 0; idx < loci.size(); ++idx) { + if (*index_it == indIndex + loci[idx] && *value_it != 0) { + segSites.insert(loci[idx]); + break; + } + } + } + } + + } + +#else for (ssize_t idx = 0; idx < static_cast<ssize_t>(loci.size()); ++idx) { size_t loc = loci[idx]; IndAlleleIterator a = pop.alleleIterator(loc, sp->subPop()); for (; a.valid(); ++a) - if (*a != 0u) { - segSites.insert(loc); + if (*a != 0) { + segSites.insert((ULONG)loc); break; } } +#endif pop.deactivateVirtualSubPop(sp->subPop()); if (m_vars.contains(numOfSegSites_sp_String)) @@ -766,33 +794,44 @@ subPopList subPops = m_subPops.expandFrom(pop); subPopList::const_iterator sp = subPops.begin(); subPopList::const_iterator spEnd = subPops.end(); - for ( ; sp != spEnd; ++sp) { size_t mutantCount = 0; pop.activateVirtualSubPop(*sp); IndIterator ind = pop.indIterator(sp->subPop()); for (; ind.valid(); ++ind) { GenoIterator it = ind->genoBegin(); + GenoIterator it_end = ind->genoEnd(); #ifdef MUTANTALLELE - GenoIterator it_end = ind->genoEnd(); compressed_vector<Allele>::index_array_type::iterator index_it = it.getIndexIterator(); compressed_vector<Allele>::index_array_type::iterator index_it_end = it_end.getIndexIterator(); compressed_vector<Allele>::value_array_type::iterator value_it = it.getValueIterator(); size_t indIndex = it.getIndex(); for (;index_it != index_it_end; ++index_it, ++value_it) { - for (size_t idx = 0; idx < loci.size(); ++idx) { - size_t loc = indIndex + loci[idx]; - if (*index_it == loc && *value_it != 0) { + if (m_loci.allAvail()) { + if (*value_it != 0) mutantCount++; - break; + } else { + for (size_t idx = 0; idx < loci.size(); ++idx) { + size_t loc = indIndex + loci[idx]; + if (*index_it == loc && *value_it != 0) { + mutantCount++; + break; + } } } } #else - for (size_t idx = 0; idx < loci.size(); ++idx) { - size_t loc = loci[idx]; - if (*(it + loc) != 0) - mutantCount++; + if (m_loci.allAvail()) { + for (;it != it_end; ++it) { + if (*it != 0) + mutantCount++; + } + } else { + for (size_t idx = 0; idx < loci.size(); ++idx) { + size_t loc = loci[idx]; + if (*(it + loc) != 0) + mutantCount++; + } } #endif } Added: trunk/test/sample_32_mu.pop =================================================================== (Binary files differ) Property changes on: trunk/test/sample_32_mu.pop ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/test/sample_64_mu.pop =================================================================== (Binary files differ) Property changes on: trunk/test/sample_64_mu.pop ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ti...@us...> - 2012-02-10 21:02:51
|
Revision: 4372 http://simupop.svn.sourceforge.net/simupop/?rev=4372&view=rev Author: tiwcpe8 Date: 2012-02-10 21:02:45 +0000 (Fri, 10 Feb 2012) Log Message: ----------- Fixed performance problem in load and save Population function Modified Paths: -------------- trunk/src/individual.cpp trunk/src/individual.h trunk/src/initializer.cpp trunk/src/population.cpp trunk/test/sample_32_mu.pop trunk/test/sample_64_mu.pop Modified: trunk/src/individual.cpp =================================================================== --- trunk/src/individual.cpp 2012-02-07 22:17:08 UTC (rev 4371) +++ trunk/src/individual.cpp 2012-02-10 21:02:45 UTC (rev 4372) @@ -238,7 +238,7 @@ } - +// Fix me: This one has to optimize PyObject * Individual::genoAtLoci(const lociList & lociList) { ssize_t ply = ploidy(); Modified: trunk/src/individual.h =================================================================== --- trunk/src/individual.h 2012-02-07 22:17:08 UTC (rev 4371) +++ trunk/src/individual.h 2012-02-10 21:02:45 UTC (rev 4372) @@ -346,7 +346,13 @@ /// CPPONLY start of alleles GenoIterator genoBegin() const { +#ifdef MUTANTALLELE + // Call + operator in order to find the correct m_com_index; + // more information see operator+ function in mutant_vector.h + return m_genoPtr + 0; +#else return m_genoPtr; +#endif } Modified: trunk/src/initializer.cpp =================================================================== --- trunk/src/initializer.cpp 2012-02-07 22:17:08 UTC (rev 4371) +++ trunk/src/initializer.cpp 2012-02-10 21:02:45 UTC (rev 4372) @@ -241,10 +241,12 @@ #else IndIterator it = pop.indIterator(sp->subPop()); #endif - for (; it.valid(); ++it) + std::cout << "Start init!!!!!!!\n"; + for (size_t ii=0; it.valid(); ++it,++ii ) for (vectoru::iterator p = ploidy.begin(); p != ploidy.end(); ++p) for (vectoru::const_iterator loc = loci.begin(); loc != loci.end(); ++loc, ++idx) it->setAllele(ToAllele(m_genotype[idx % sz]), *loc, static_cast<int>(*p)); + std::cout << "End init!!!!!!!\n"; } #ifdef _OPENMP Modified: trunk/src/population.cpp =================================================================== --- trunk/src/population.cpp 2012-02-07 22:17:08 UTC (rev 4371) +++ trunk/src/population.cpp 2012-02-10 21:02:45 UTC (rev 4372) @@ -104,7 +104,6 @@ decGenoStruRef(); } - Population::Population(const Population & rhs) : GenoStruTrait(rhs), m_popSize(rhs.m_popSize), @@ -2918,15 +2917,6 @@ data = 0; } } -#elif defined MUTANTALLELE - size_t size = m_genotype.size(); - ar & size; - ConstGenoIterator ptr = m_genotype.begin(); - unsigned int data = 0; - for (size_t i = 0; i < size; ++i, ++ptr) { - data = *ptr; - ar & data; - } #else ar & m_genotype; #endif @@ -2958,15 +2948,6 @@ data = 0; } } -#elif defined MUTANTALLELE - size_t size = m_genotype.size(); - ar & size; - ConstGenoIterator ptr = m_genotype.begin(); - unsigned int data = 0; - for (size_t i = 0; i < size; ++i, ++ptr) { - data = *ptr; - ar & data; - } #else ar & m_genotype; #endif @@ -3015,15 +2996,12 @@ } // binary from mutant } else if (ma == 256) { - DBG_DO(DBG_POPULATION, cerr << "Load bin from mutant. " << endl); - size_t size; - ar & size; - m_genotype.resize(size); - GenoIterator ptr = m_genotype.begin(); - unsigned int data = 0; - for (size_t i = 0; i < size; ++i, ++ptr) { - ar & data; - *ptr = ToAllele(data); + mutant_vector<unsigned int> tmpgeno; + ar & tmpgeno; + m_genotype.resize(tmpgeno.size()); + for (size_t i = 0; i < tmpgeno.size(); ++i) { + unsigned int data = tmpgeno[i]; + m_genotype[i] = ToAllele(data); } // binary from others (long types) } else { @@ -3054,15 +3032,7 @@ // mutant from mutant if (ma == 256) { DBG_DO(DBG_POPULATION, cerr << "Load mutant from mutant. " << endl); - size_t size; - ar & size; - m_genotype.resize(size); - GenoIterator ptr = m_genotype.begin(); - unsigned int data = 0; - for (size_t i = 0; i < size; ++i, ++ptr) { - ar & data; - *ptr = data; - } + ar & m_genotype; } // mutant from long else { @@ -3071,22 +3041,19 @@ ar & data; m_genotype.resize(data.size()); for (size_t i = 0; i < data.size(); ++i) { - m_genotype[i] = data[i]; + if (data[i] != 0) + m_genotype[i] = data[i]; } } # else // long from mutant if (ma == 256) { DBG_DO(DBG_POPULATION, cerr << "Load long from mutant. " << endl); - size_t size; - ar & size; - m_genotype.resize(size); - GenoIterator ptr = m_genotype.begin(); - unsigned int data = 0; - for (size_t i = 0; i < size; ++i, ++ptr) { - ar & data; - *ptr = data; - } + mutant_vector<unsigned int> tmpgeno; + ar & tmpgeno; + m_genotype.resize(tmpgeno.size()); + for (size_t i = 0; i < tmpgeno.size(); ++i) + m_genotype[i] = tmpgeno[i]; // long from long } else { DBG_DO(DBG_POPULATION, cerr << "Load long from long. " << endl); @@ -3160,15 +3127,12 @@ } // binary from mutant } else if (ma == 256) { - DBG_DO(DBG_POPULATION, cerr << "Load bin from mutant. " << endl); - size_t size; - ar & size; - pd.m_genotype.resize(size); - GenoIterator ptr = pd.m_genotype.begin(); - unsigned int data = 0; - for (size_t i = 0; i < size; ++i, ++ptr) { - ar & data; - *ptr = ToAllele(data); + mutant_vector<unsigned int> tmpgeno; + ar & tmpgeno; + pd.m_genotype.resize(tmpgeno.size()); + for (size_t i = 0; i < tmpgeno.size(); ++i) { + unsigned int data = tmpgeno[i]; + pd.m_genotype[i] = ToAllele(data); } // binary from others (long types) } else { @@ -3197,16 +3161,7 @@ # ifdef MUTANTALLELE // mutant from mutant if (ma == 256) { - DBG_DO(DBG_POPULATION, cerr << "Load mutant from mutant. " << endl); - size_t size; - ar & size; - pd.m_genotype.resize(size); - GenoIterator ptr = pd.m_genotype.begin(); - unsigned int data = 0; - for (size_t i = 0; i < size; ++i, ++ptr) { - ar & data; - *ptr = data; - } + ar & pd.m_genotype; } // mutant from long else { @@ -3215,22 +3170,19 @@ ar & data; pd.m_genotype.resize(data.size()); for (size_t i = 0; i < data.size(); ++i) { - pd.m_genotype[i] = data[i]; + if (data[i] != 0) + pd.m_genotype[i] = data[i]; } } # else // long from mutant if (ma == 256) { DBG_DO(DBG_POPULATION, cerr << "Load long from mutant. " << endl); - size_t size; - ar & size; - pd.m_genotype.resize(size); - GenoIterator ptr = pd.m_genotype.begin(); - unsigned int data = 0; - for (size_t i = 0; i < size; ++i, ++ptr) { - ar & data; - *ptr = data; - } + mutant_vector<unsigned int> tmpgeno; + ar & tmpgeno; + pd.m_genotype.resize(tmpgeno.size()); + for (size_t i = 0; i < tmpgeno.size(); ++i) + pd.m_genotype[i] = tmpgeno[i]; // long from long } else { DBG_DO(DBG_POPULATION, cerr << "Load long from long. " << endl); Modified: trunk/test/sample_32_mu.pop =================================================================== (Binary files differ) Modified: trunk/test/sample_64_mu.pop =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2012-02-22 22:24:14
|
Revision: 4378 http://simupop.svn.sourceforge.net/simupop/?rev=4378&view=rev Author: simupop Date: 2012-02-22 22:24:07 +0000 (Wed, 22 Feb 2012) Log Message: ----------- Preliminary support for a dedicated Mitochondrial chromosome type Modified Paths: -------------- trunk/ChangeLog trunk/src/genoStru.cpp trunk/src/genoStru.h trunk/src/individual.cpp trunk/src/individual.h trunk/src/outputer.cpp trunk/src/penetrance.cpp trunk/src/selector.cpp trunk/src/simuPOP_cfg.h trunk/src/simuPOP_doc.i trunk/src/stator.cpp trunk/src/transmitter.cpp trunk/src/transmitter.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2012-02-22 19:03:33 UTC (rev 4377) +++ trunk/ChangeLog 2012-02-22 22:24:07 UTC (rev 4378) @@ -9,6 +9,8 @@ New features: - New option numOfSegSites to operator Stat to calculate the number of segragating sites. + - Add MITOCHONDRIAL as a natural chromosome type so that operators such as + Stat can handle them correctly. BUG: - Fix a bug that prevents the correct handling of population structure when evolving Modified: trunk/src/genoStru.cpp =================================================================== --- trunk/src/genoStru.cpp 2012-02-22 19:03:33 UTC (rev 4377) +++ trunk/src/genoStru.cpp 2012-02-22 22:24:07 UTC (rev 4378) @@ -230,7 +230,7 @@ #ifndef OPTIMIZED for (size_t i = 0; i < m_chromTypes.size(); ++i) { size_t type = m_chromTypes[i]; - DBG_ASSERT(type == AUTOSOME || type == CHROMOSOME_X || type == CHROMOSOME_Y || type == CUSTOMIZED, + DBG_ASSERT(type == AUTOSOME || type == CHROMOSOME_X || type == CHROMOSOME_Y || type == CUSTOMIZED || type == MITOCHONDRIAL, ValueError, "Chromsome type can only be one of AUTOSOME, CHROMOSOME_X, CHROMOSOME_Y and CUSTOMIZED."); } #endif @@ -256,6 +256,16 @@ DBG_WARNIF(m_chromX * m_chromY < 0, "Chromosome X and Y should be both present for sexual transmission to work."); // + m_mitochondrial.clear(); + for (size_t i = 0; i < m_chromTypes.size(); ++i) { + if (m_chromTypes[i] == MITOCHONDRIAL) { + DBG_FAILIF(!m_mitochondrial.empty() && m_mitochondrial.back() != i - 1, + ValueError, + "There can be several mitochondrial chromosmes, but they need to be adjacent to each other."); + m_mitochondrial.push_back(static_cast<ULONG>(i)); + } + } + // m_customized.clear(); for (size_t i = 0; i < m_chromTypes.size(); ++i) { if (m_chromTypes[i] == CUSTOMIZED) { Modified: trunk/src/genoStru.h =================================================================== --- trunk/src/genoStru.h 2012-02-22 19:03:33 UTC (rev 4377) +++ trunk/src/genoStru.h 2012-02-22 22:24:07 UTC (rev 4378) @@ -73,7 +73,7 @@ public: /// CPPONLY serialization library requires a default constructor GenoStructure() : m_ploidy(2), m_totNumLoci(0), - m_numLoci(0), m_chromTypes(), m_chromX(-1), m_chromY(-1), m_customized(), + m_numLoci(0), m_chromTypes(), m_chromX(-1), m_chromY(-1), m_mitochondrial(), m_customized(), m_haplodiploid(false), m_lociPos(0), m_chromIndex(0), m_chromNames(), m_alleleNames(), m_lociNames(), m_lociNameMap(), m_infoFields(0), m_refCount(0) @@ -207,6 +207,9 @@ /// index of chromosome Y, -1 if not exist int m_chromY; + /// indexes of mitochondrial chromosomes + vectoru m_mitochondrial; + /// indexes of customized chromosomes vectoru m_customized; @@ -475,7 +478,20 @@ return s_genoStruRepository[m_genoStruIdx].m_customized; } + /** CPPONLY + * Return the indexes of mitochondrial chromosomes. + * <group>2-chromosome</group> + */ + vectoru mitochondrialChroms() const + { + DBG_FAILIF(m_genoStruIdx == MaxTraitIndex, SystemError, + "totNumLoci: You have not set genoStructure. Please use setGenoStrucutre to set such info."); + return s_genoStruRepository[m_genoStruIdx].m_mitochondrial; + } + + + /// HIDDEN bool sexChrom() const { @@ -636,7 +652,7 @@ /** return the type of a chromosome \e chrom (\c CUSTOMIZED, \c AUTOSOME, - * \c CHROMOSOME_X, or \c CHROMOSOME_Y). + * \c CHROMOSOME_X, \c CHROMOSOME_Y or \c MITOCHONDRIAL. * <group>2-chromosome</group> */ size_t chromType(const size_t chrom) const @@ -650,7 +666,7 @@ /** return the type of all chromosomes (\c CUSTOMIZED, \c AUTOSOME, - * \c CHROMOSOME_X or \c CHROMOSOME_Y). + * \c CHROMOSOME_X, \c CHROMOSOME_Y, or \c MITOCHONDRIAL). * <group>2-chromosome</group> */ vectoru chromTypes() const Modified: trunk/src/individual.cpp =================================================================== --- trunk/src/individual.cpp 2012-02-22 19:03:33 UTC (rev 4377) +++ trunk/src/individual.cpp 2012-02-22 22:24:07 UTC (rev 4378) @@ -125,7 +125,8 @@ size_t t = chromType(ch); if ((s == FEMALE && t == CHROMOSOME_Y) || // female chromsome Y (s == MALE && // second copy of chromosome X and first copy of chromosome Y - ((p == 1 && t == CHROMOSOME_X) || (p == 0 && t == CHROMOSOME_Y)))) + ((p == 1 && t == CHROMOSOME_X) || (p == 0 && t == CHROMOSOME_Y))) || + (p > 0 && t == MITOCHONDRIAL)) // mitochondiral DNA only uses the first homologous copy return false; return true; @@ -261,6 +262,8 @@ if (((chType == CHROMOSOME_X && p == 1) || (chType == CHROMOSOME_Y && p == 0)) && sex() == MALE) continue; + if (chType == MITOCHONDRIAL && p > 0) + continue; alleles.push_back(allele(idx, p, ch)); } } @@ -282,6 +285,8 @@ if (((chromTypes[idx] == CHROMOSOME_X && p == 1) || (chromTypes[idx] == CHROMOSOME_Y && p == 0)) && sex() == MALE) continue; + if (chromTypes[idx] == MITOCHONDRIAL && p > 0) + continue; alleles.push_back(allele(loci[idx], p)); } } Modified: trunk/src/individual.h =================================================================== --- trunk/src/individual.h 2012-02-22 19:03:33 UTC (rev 4377) +++ trunk/src/individual.h 2012-02-22 22:24:07 UTC (rev 4378) @@ -1019,6 +1019,11 @@ break; p = 1; valid = it.valid(); + } else if (m_chromType == MITOCHONDRIAL) { + // only the first homologous copy is valid + DBG_ASSERT(p == 0, SystemError, "Only the first homologous copy of mitochondrial DNA can be iterated."); + ++ it; + valid = it.valid(); } } Modified: trunk/src/outputer.cpp =================================================================== --- trunk/src/outputer.cpp 2012-02-22 19:03:33 UTC (rev 4377) +++ trunk/src/outputer.cpp 2012-02-22 22:24:07 UTC (rev 4378) @@ -64,6 +64,9 @@ case CUSTOMIZED: out << " (CUSTOMIZED, "; break; + case MITOCHONDRIAL: + out << " (MITOCHONDRIAL, "; + break; default: throw ValueError("Wrong chromosome type"); } Modified: trunk/src/penetrance.cpp =================================================================== --- trunk/src/penetrance.cpp 2012-02-22 19:03:33 UTC (rev 4377) +++ trunk/src/penetrance.cpp 2012-02-22 22:24:07 UTC (rev 4378) @@ -153,6 +153,8 @@ if (((chromTypes[idx] == CHROMOSOME_X && p == 1) || (chromTypes[idx] == CHROMOSOME_Y && p == 0)) && ind->sex() == MALE) continue; + if (chromTypes[idx] == MITOCHONDRIAL && p > 0) + continue; alleles.push_back(ind->allele(loci[idx], p)); } } @@ -179,6 +181,8 @@ ++end_idx; } else if (chromTypes[i] == CHROMOSOME_X && ind->sex() == MALE) ++end_idx; + else if (chromTypes[i] == MITOCHONDRIAL) + ++end_idx; else end_idx += ply; if (key.size() != end_idx - begin_idx) { Modified: trunk/src/selector.cpp =================================================================== --- trunk/src/selector.cpp 2012-02-22 19:03:33 UTC (rev 4377) +++ trunk/src/selector.cpp 2012-02-22 22:24:07 UTC (rev 4378) @@ -87,6 +87,8 @@ if (((chromTypes[idx] == CHROMOSOME_X && p == 1) || (chromTypes[idx] == CHROMOSOME_Y && p == 0)) && ind->sex() == MALE) continue; + if (chromTypes[idx] == MITOCHONDRIAL && p > 0) + continue; alleles.push_back(ind->allele(loci[idx], p)); } } @@ -113,6 +115,8 @@ ++end_idx; } else if (chromTypes[i] == CHROMOSOME_X && ind->sex() == MALE) ++end_idx; + else if (chromTypes[i] == MITOCHONDRIAL) + ++end_idx; else end_idx += ply; if (key.size() != end_idx - begin_idx) { Modified: trunk/src/simuPOP_cfg.h =================================================================== --- trunk/src/simuPOP_cfg.h 2012-02-22 19:03:33 UTC (rev 4377) +++ trunk/src/simuPOP_cfg.h 2012-02-22 22:24:07 UTC (rev 4378) @@ -146,8 +146,8 @@ // according to MSVC manual, unsigned int is 32 bit, regardless of // platform. Because uint32_t is not handled correctly by swig under // windows, I am using unsigned int here. -typedef unsigned int Allele; -typedef unsigned int & AlleleRef; +typedef unsigned long Allele; +typedef unsigned long & AlleleRef; //# else // under a unix platform, uint32_t seems to work fine. //typedef uint32_t Allele; @@ -219,7 +219,8 @@ CUSTOMIZED = 11, AUTOSOME = 12, CHROMOSOME_X = 13, - CHROMOSOME_Y = 14 + CHROMOSOME_Y = 14, + MITOCHONDRIAL = 15, }; // For numOffspring and gene conversion Modified: trunk/src/simuPOP_doc.i =================================================================== --- trunk/src/simuPOP_doc.i 2012-02-22 19:03:33 UTC (rev 4377) +++ trunk/src/simuPOP_doc.i 2012-02-22 22:24:07 UTC (rev 4378) @@ -1665,6 +1665,8 @@ %ignore simuPOP::GenoStruTrait::setGenoStruIdx(size_t idx); +%ignore simuPOP::GenoStruTrait::swapGenoStru(GenoStruTrait &rhs); + %feature("docstring") simuPOP::GenoStruTrait::lociDist " Usage: @@ -3406,7 +3408,7 @@ Usage: - iterator(c) + iterator(iter) "; @@ -3450,6 +3452,14 @@ "; +%feature("docstring") simuPOP::mutantvector::iterator::getComIndex " + +Usage: + + x.getComIndex() + +"; + %feature("docstring") simuPOP::mutantvector::iterator::getContainer " Usage: @@ -9016,12 +9026,12 @@ Usage: Stat(popSize=False, numOfMales=False, numOfAffected=False, - numOfSegSites=[], alleleFreq=[], heteroFreq=[], homoFreq=[], - genoFreq=[], haploFreq=[], haploHeteroFreq=[], haploHomoFreq=[], - sumOfInfo=[], meanOfInfo=[], varOfInfo=[], maxOfInfo=[], - minOfInfo=[], LD=[], association=[], neutrality=[], - structure=[], HWE=[], vars=ALL_AVAIL, suffix=\"\", output=\"\", - begin=0, end=-1, step=1, at=[], reps=ALL_AVAIL, + numOfSegSites=[], numOfMutants=[], alleleFreq=[], heteroFreq=[], + homoFreq=[], genoFreq=[], haploFreq=[], haploHeteroFreq=[], + haploHomoFreq=[], sumOfInfo=[], meanOfInfo=[], varOfInfo=[], + maxOfInfo=[], minOfInfo=[], LD=[], association=[], + neutrality=[], structure=[], HWE=[], vars=ALL_AVAIL, suffix=\"\", + output=\"\", begin=0, end=-1, step=1, at=[], reps=ALL_AVAIL, subPops=ALL_AVAIL, infoFields=[]) Details: @@ -9737,6 +9747,32 @@ "; +%ignore simuPOP::statNumOfMutants; + +%feature("docstring") simuPOP::statNumOfMutants::statNumOfMutants " + +Usage: + + statNumOfMutants(loci, subPops, vars, suffix) + +"; + +%feature("docstring") simuPOP::statNumOfMutants::describe " + +Usage: + + x.describe(format=True) + +"; + +%feature("docstring") simuPOP::statNumOfMutants::apply " + +Usage: + + x.apply(pop) + +"; + %ignore simuPOP::statNumOfSegSites; %feature("docstring") simuPOP::statNumOfSegSites::statNumOfSegSites " Modified: trunk/src/stator.cpp =================================================================== --- trunk/src/stator.cpp 2012-02-22 19:03:33 UTC (rev 4377) +++ trunk/src/stator.cpp 2012-02-22 22:24:07 UTC (rev 4378) @@ -1071,8 +1071,8 @@ #ifndef OPTIMIZED size_t chromType = pop.chromType(pop.chromLocusPair(loc).first); - DBG_FAILIF(chromType == CHROMOSOME_X || chromType == CHROMOSOME_Y, - ValueError, "Heterozygosity count for sex chromosomes is not supported."); + DBG_FAILIF(chromType == CHROMOSOME_X || chromType == CHROMOSOME_Y || chromType == MITOCHONDRIAL, + ValueError, "Heterozygosity count for sex and mitochondrial chromosomes is not supported."); #endif size_t hetero = 0; size_t homo = 0; @@ -1229,6 +1229,8 @@ if (((chromTypes[idx] == CHROMOSOME_X && p == 1) || (chromTypes[idx] == CHROMOSOME_Y && p == 0)) && ind->sex() == MALE) continue; + if (chromTypes[idx] == MITOCHONDRIAL && p > 0) + continue; genotype.push_back(ind->allele(loc, p)); } genotypes[genotype]++; @@ -1382,6 +1384,8 @@ if (((chromType == CHROMOSOME_X && p == 1) || (chromType == CHROMOSOME_Y && p == 0)) && ind->sex() == MALE) continue; + if (chromType == MITOCHONDRIAL && p > 0) + continue; for (size_t idx = 0; idx < nLoci; ++idx) haplotype[idx] = ind->allele(loci[idx], p); haplotypes[haplotype]++; @@ -2202,6 +2206,8 @@ if (ply == 2 && ((chromTypes[idx] == CHROMOSOME_X && p == 1) || (chromTypes[idx] == CHROMOSOME_Y && p == 0)) && ind->sex() == MALE) continue; + if (chromTypes[idx] == MITOCHONDRIAL && p > 0) + continue; alleleCnt[idx][*(geno + loci[idx])]++; } // haplotype frequency @@ -2212,6 +2218,8 @@ if (((chromType == CHROMOSOME_X && p == 1) || (chromType == CHROMOSOME_Y && p == 0)) && ind->sex() == MALE) continue; + if (chromType == MITOCHONDRIAL && p > 0) + continue; haploCnt[idx][HAPLOCNT::key_type(*(geno + m_LD[idx][0]), *(geno + m_LD[idx][1]))]++; } } @@ -2515,6 +2523,8 @@ if (ply == 2 && ((chromTypes[idx] == CHROMOSOME_X && p == 1) || (chromTypes[idx] == CHROMOSOME_Y && p == 0)) && ind->sex() == MALE) continue; + if (chromTypes[idx] == MITOCHONDRIAL && p > 0) + continue; if (ind->affected()) caseAlleleCnt[idx][*(geno + loci[idx])]++; else @@ -2527,7 +2537,7 @@ GenoIterator geno1 = ind->genoBegin(0); GenoIterator geno2 = ind->genoBegin(1); for (size_t idx = 0; idx < nLoci; ++idx) { - if (chromTypes[idx] == CHROMOSOME_X || chromTypes[idx] == CHROMOSOME_Y) + if (chromTypes[idx] == CHROMOSOME_X || chromTypes[idx] == CHROMOSOME_Y || chromTypes[idx] == MITOCHONDRIAL) continue; Allele a1 = *(geno1 + loci[idx]); Allele a2 = *(geno2 + loci[idx]); @@ -2735,6 +2745,8 @@ if (((chromType == CHROMOSOME_X && p == 1) || (chromType == CHROMOSOME_Y && p == 0)) && ind->sex() == MALE) continue; + if (chromType == MITOCHONDRIAL && p > 0) + continue; for (size_t idx = 0; idx < nLoci; ++idx) haplotype[idx] = ToAllele(ind->allele(loci[idx], p)); allHaplotypes.push_back(haplotype); @@ -2926,7 +2938,7 @@ #ifndef OPTIMIZED for (size_t idx = 0; idx < loci.size(); ++idx) { size_t chromType = pop.chromType(pop.chromLocusPair(loci[idx]).first); - DBG_FAILIF(chromType == CHROMOSOME_X || chromType == CHROMOSOME_Y, ValueError, + DBG_FAILIF(chromType == CHROMOSOME_X || chromType == CHROMOSOME_Y || chromType == MITOCHONDRIAL, ValueError, "Fst can not be esimated from markers on sex chromosomes"); } #endif @@ -3079,8 +3091,8 @@ #ifndef OPTIMIZED for (size_t i = 0; i < loci.size(); ++i) { size_t chromType = pop.chromType(pop.chromLocusPair(loci[i]).first); - DBG_FAILIF(chromType == CHROMOSOME_X || chromType == CHROMOSOME_Y, ValueError, - "Can not run HWE test on loci on sex chromosomes."); + DBG_FAILIF(chromType == CHROMOSOME_X || chromType == CHROMOSOME_Y || chromType == MITOCHONDRIAL, ValueError, + "Can not run HWE test on loci on sex and mitochondrial chromosomes."); } #endif // count for all specified subpopulations Modified: trunk/src/transmitter.cpp =================================================================== --- trunk/src/transmitter.cpp 2012-02-22 19:03:33 UTC (rev 4377) +++ trunk/src/transmitter.cpp 2012-02-22 22:24:07 UTC (rev 4378) @@ -387,8 +387,12 @@ GenoTransmitter::initialize(ind); if (m_chroms.allAvail()) { for (size_t ch = 0; ch < ind.numChrom(); ++ch) - if (ind.chromType(ch) == CUSTOMIZED) + if (ind.chromType(ch) == MITOCHONDRIAL) m_mitoChroms.push_back(ch); + if (m_mitoChroms.empty()) + for (size_t ch = 0; ch < ind.numChrom(); ++ch) + if (ind.chromType(ch) == CUSTOMIZED) + m_mitoChroms.push_back(ch); } else m_mitoChroms = m_chroms.elems(); DBG_DO(DBG_TRANSMITTER, cerr << "Mitochondrial chromosomes " << m_mitoChroms << endl); Modified: trunk/src/transmitter.h =================================================================== --- trunk/src/transmitter.h 2012-02-22 19:03:33 UTC (rev 4377) +++ trunk/src/transmitter.h 2012-02-22 22:24:07 UTC (rev 4378) @@ -367,8 +367,10 @@ }; -/** This geno transmitter assumes that the first homologous copy of several (or - * all) \c Customized chromosomes are copies of mitochondrial chromosomes. It +/** This geno transmitter transmits the first homologous copy of \c Mitochondrial + * chromosomes. For backward-compatibility, it assumes that the first homologous + * copy of several (or all) \c Customized chromosomes are copies of mitochondrial + * chromosomes if no chromosome of type \c Mitochondrial is specified. This operator * transmits these chromosomes randomly from the female parent to offspring. * If this transmitter is applied to populations with more than one homologous * copies of chromosomes, it transmits the first homologous copy of @@ -377,8 +379,9 @@ class MitochondrialGenoTransmitter : public GenoTransmitter { public: - /** Createa a mitochondrial genotype transmitter that treats all Customized - * chromosomes, or a list of chromosomes specified by \e chroms, as human + /** Createa a mitochondrial genotype transmitter that treats all Mitochondiral + * chromosomes, Customized chromosomes if no Mitochondrial chromosomes are + * specified, or a list of chromosomes specified by \e chroms, as human * mitochondrial chromosomes. These chromosomes should have the same * length and the same number of loci. This operator transmits these * chromosomes randomly from the female parent to offspring of both sexes. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2012-02-23 03:27:05
|
Revision: 4381 http://simupop.svn.sourceforge.net/simupop/?rev=4381&view=rev Author: simupop Date: 2012-02-23 03:26:59 +0000 (Thu, 23 Feb 2012) Log Message: ----------- Force all mitochondrial DNAs to have the same length Modified Paths: -------------- trunk/src/__init__.py trunk/src/genoStru.cpp trunk/test/test_00_genoStru.py Modified: trunk/src/__init__.py =================================================================== --- trunk/src/__init__.py 2012-02-22 22:54:23 UTC (rev 4380) +++ trunk/src/__init__.py 2012-02-23 03:26:59 UTC (rev 4381) @@ -39,6 +39,7 @@ 'AUTOSOME', 'CHROMOSOME_X', 'CHROMOSOME_Y', + 'MITOCHONDRIAL', # 'CONSTANT', 'BINOMIAL_DISTRIBUTION', Modified: trunk/src/genoStru.cpp =================================================================== --- trunk/src/genoStru.cpp 2012-02-22 22:54:23 UTC (rev 4380) +++ trunk/src/genoStru.cpp 2012-02-23 03:26:59 UTC (rev 4381) @@ -257,12 +257,17 @@ "Chromosome X and Y should be both present for sexual transmission to work."); // m_mitochondrial.clear(); + size_t mt_len = 0; for (size_t i = 0; i < m_chromTypes.size(); ++i) { if (m_chromTypes[i] == MITOCHONDRIAL) { DBG_FAILIF(!m_mitochondrial.empty() && m_mitochondrial.back() != i - 1, ValueError, "There can be several mitochondrial chromosmes, but they need to be adjacent to each other."); m_mitochondrial.push_back(static_cast<ULONG>(i)); + if (mt_len == 0) + mt_len = m_numLoci[i]; + else if (m_numLoci[i] != mt_len) + throw ValueError("All mitochondrial DNAs should have the same length"); } } // Modified: trunk/test/test_00_genoStru.py =================================================================== --- trunk/test/test_00_genoStru.py 2012-02-22 22:54:23 UTC (rev 4380) +++ trunk/test/test_00_genoStru.py 2012-02-23 03:26:59 UTC (rev 4381) @@ -183,14 +183,18 @@ def testChromType(self): 'Testing genoStruTrait::chromType(chron), chromTypes()' - pop = Population(size=100, ploidy=2, loci=[2, 3, 2, 4], - chromTypes=[AUTOSOME, CHROMOSOME_X, CHROMOSOME_Y, CUSTOMIZED]) + pop = Population(size=100, ploidy=2, loci=[2, 3, 2, 4, 4], + chromTypes=[AUTOSOME, CHROMOSOME_X, CHROMOSOME_Y, MITOCHONDRIAL, CUSTOMIZED]) self.assertEqual(pop.chromType(0), AUTOSOME) self.assertEqual(pop.chromType(1), CHROMOSOME_X) self.assertEqual(pop.chromType(2), CHROMOSOME_Y) - self.assertEqual(pop.chromType(3), CUSTOMIZED) + self.assertEqual(pop.chromType(3), MITOCHONDRIAL) + self.assertEqual(pop.chromType(4), CUSTOMIZED) self.assertRaises(ValueError, Population, ploidy=4, chromTypes=[AUTOSOME, CHROMOSOME_X, CHROMOSOME_Y, CUSTOMIZED]) + # + self.assertRaises(ValueError, Population, loci=[3, 4], + chromTypes=[MITOCHONDRIAL]*2) def testNumChrom(self): 'Testing genoStruTrait::numChrom()' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2012-02-23 05:01:32
|
Revision: 4382 http://simupop.svn.sourceforge.net/simupop/?rev=4382&view=rev Author: simupop Date: 2012-02-23 05:01:25 +0000 (Thu, 23 Feb 2012) Log Message: ----------- Add a test for selection over mitochondrial DNAs Modified Paths: -------------- trunk/src/selector.h trunk/test/test_09_selection.py Modified: trunk/src/selector.h =================================================================== --- trunk/src/selector.h 2012-02-23 03:26:59 UTC (rev 4381) +++ trunk/src/selector.h 2012-02-23 05:01:25 UTC (rev 4382) @@ -182,7 +182,8 @@ * \c ALL_AVAIL. For each individual (parents if this operator is applied * before mating, and offspring if this operator is applied during * mating), genotypes at \e loci are collected one by one (e.g. - * p0_loc0, p1_loc0, p0_loc1, p1_loc1... for a diploid individual) and + * p0_loc0, p1_loc0, p0_loc1, p1_loc1... for a diploid individual, with + * number of alleles varying for sex and mitochondrial DNAs) and * are looked up in the dictionary. If a genotype cannot be found, it * will be looked up again without phase information (e.g. * <tt>(1,0)</tt> will match key <tt>(0,1)</tt>). If the genotype Modified: trunk/test/test_09_selection.py =================================================================== --- trunk/test/test_09_selection.py 2012-02-23 03:26:59 UTC (rev 4381) +++ trunk/test/test_09_selection.py 2012-02-23 05:01:25 UTC (rev 4382) @@ -115,6 +115,26 @@ self.assertEqual(ind.fitness, 0.9) elif ind.allele(2,1) == 2 and ind.sex() == MALE: self.assertEqual(ind.fitness, 0.8) + # mitochondrial DNA + pop = Population(size=1000, loci=[1, 2, 2], infoFields=['a', 'fitness', 'b'], + chromTypes=[AUTOSOME, MITOCHONDRIAL, MITOCHONDRIAL]) + initSex(pop) + initGenotype(pop, freq=[.2, 0, .8]) + MapSelector(loci=[2], fitness={(0,):0.9, (1,):0.8}).apply(pop) + for ind in pop.individuals(): + if ind.allele(2,0) == 0: + self.assertEqual(ind.fitness, 0.9) + elif ind.allele(2,0) == 1: + self.assertEqual(ind.fitness, 0.8) + # + MapSelector(loci=[2], fitness={(0,):0.9, (1,):0.8, ():1}).apply(pop) + for ind in pop.individuals(): + if ind.sex() == FEMALE: + self.assertEqual(ind.fitness, 1.0) + elif ind.allele(2,1) == 0 and ind.sex() == MALE: + self.assertEqual(ind.fitness, 0.9) + elif ind.allele(2,1) == 2 and ind.sex() == MALE: + self.assertEqual(ind.fitness, 0.8) # multiple loci pop = Population(size=1000, loci=[1, 2], infoFields=['a', 'fitness', 'b'], chromTypes=[CHROMOSOME_X, CHROMOSOME_Y]) @@ -211,6 +231,19 @@ self.assertEqual(ind.fitness, 0.9) elif ind.allele(2,1) == 2 and ind.sex() == MALE: self.assertEqual(ind.fitness, 0.8) + # mitochondrial DNA + pop = Population(size=1000, loci=[1, 2, 2], infoFields=['a', 'fitness', 'b'], + chromTypes=[AUTOSOME, MITOCHONDRIAL, MITOCHONDRIAL]) + initSex(pop) + initGenotype(pop, freq=[.2, 0, .8]) + MapSelector(loci=[2], fitness={(0,):0.9, (1,):0.8, (2,):0.4}).apply(pop) + for ind in pop.individuals(): + if ind.allele(2,0) == 0: + self.assertEqual(ind.fitness, 0.9) + elif ind.allele(2,0) == 1: + self.assertEqual(ind.fitness, 0.8) + elif ind.allele(2,0) == 2: + self.assertEqual(ind.fitness, 0.4) # multiple loci pop = Population(size=1000, loci=[1, 2], infoFields=['a', 'fitness', 'b'], chromTypes=[CHROMOSOME_X, CHROMOSOME_Y]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2012-02-23 17:21:03
|
Revision: 4383 http://simupop.svn.sourceforge.net/simupop/?rev=4383&view=rev Author: simupop Date: 2012-02-23 17:20:52 +0000 (Thu, 23 Feb 2012) Log Message: ----------- Allow only one mitochondrial chromosome, add a section in the user's guide to discuss how to simulate one or multiple copies of mtDNAs Modified Paths: -------------- trunk/doc/userGuide.lyx trunk/doc/userGuide.py trunk/src/genoStru.cpp trunk/src/genoStru.h trunk/src/transmitter.cpp trunk/src/transmitter.h Modified: trunk/doc/userGuide.lyx =================================================================== --- trunk/doc/userGuide.lyx 2012-02-23 05:01:25 UTC (rev 4382) +++ trunk/doc/userGuide.lyx 2012-02-23 17:20:52 UTC (rev 4383) @@ -3425,7 +3425,8 @@ \end_layout \begin_layout Subsection -Autosomes, sex chromosomes, and other types of chromosomes * +Autosomes, sex chromosomes, mitochondrial, and other types of chromosomes + * \end_layout \begin_layout Standard @@ -3434,13 +3435,13 @@ normal \emph default chromosomes in diploid, and in haploid populations. - simuPOP supports three other types of chromosomes, namely + simuPOP supports four other types of chromosomes, namely \emph on chromosome X \emph default , \emph on -chromosome Y +chromosome Y, mitochondrial, \emph default and \emph on @@ -3449,6 +3450,8 @@ chromosome types. Sex chromosomes are only valid in haploid populations where chromosomes X and Y are used to determine the sex of an offspring. + Mitochondrial DNAs can exists in haploid or diploid populations, and are + inherited maternally. Customized chromosomes rely on user defined functions and operators to be passed from parents to offspring. \end_layout @@ -3504,9 +3507,31 @@ \end_layout \begin_layout Standard -As an advanced feature of simuPOP, chromosomes that do not follow the inheritanc -e patterns of autosomes or sex chromosomes can be handled separately (see - section +The evolution of mitochonrial DNAs follow the following rules +\end_layout + +\begin_layout Itemize +There can be only one copy of mitochondrial DNA, exists for both males and + females. +\end_layout + +\begin_layout Itemize +In a non-haploid population where all chromosomes have multiple homologous + copies, only the first copy is used for mitochondrial DNA. +\end_layout + +\begin_layout Itemize +mtDNAs are inherited maternally +\end_layout + +\begin_layout Standard +Customized chromosomes are used to model more complex types of chromosomes. + They rely on customized operators for inheritence. + For example, if you would like to model multiple copies of mitochondrial + DNAs (cytohets with multiple organellar chromosomes) in a cell, and the + process of genetic drift of somatic cytoplasmic segregation of mtDNAs, + you can use multiple customized chromosomes to model multiple cytohets + (see section \begin_inset CommandInset ref LatexCommand ref reference "sub:Pre-defined-genotype-transmitters" @@ -11444,9 +11469,9 @@ \family typewriter MitochondrialGenoTransmitter \family default -: Treat all customized chromosomes or specified chromosomes as mitochondrial - chromosomes and transmit maternal mitochondrial chromosomes randomly to - an offspring. +: Treat a single mitochondrial chromosome, or all customized chromosomes, + or specified chromosomes as mitochondrial chromosomes and transmit maternal + mitochondrial chromosomes randomly to an offspring. This genotype transmitter can be applied to populations of \series bold any ploidy @@ -25019,6 +25044,167 @@ \end_layout \begin_layout Section +Simulation of mitochondrial DNAs (mtDNAs) +\end_layout + +\begin_layout Standard +Mitochondrial DNAs resides in human mitochondrion. + A zygote inherits its organelles from the cytoplasm of the egg, and thus + organelle inheritance is generally maternal. + Whereas there is only one copy of a nuclear chromosome per gamete, there + are man copies of an organellar chromosome, forming a population of identical + organelle chromosomes that is transmitted to the offspring through the + egg. + Because these organellar chromosomes are identical, they are modelled in + simuPOP as a single chromosome with type +\family typewriter +MITOCHONDRIAL +\family default +. + In order to simulate mitochondrial DNAs, it is important to remember: +\end_layout + +\begin_layout Itemize + +\family typewriter +MendelianGenoTransmitter +\family default + and +\family typewriter +Recombinator +\family default + do not handle mitochondrial DNAs so you will have to explicitly use +\family typewriter +MitochondrialGenoTransmitter +\family default + to transmit the mitochondrial DNAs from mother to offspring. + Note that +\family typewriter +CloneGenoTransmitter +\family default + is a special transmitter that will copy everything including sex, information + fields to offspring. +\end_layout + +\begin_layout Itemize +The +\family typewriter +Stat +\family default + operator recognizes this chromosome type and will report allele, haplotype, + and genotype counts, and other statistics correctly, although some diploid-spec +ific statistics are not applicable. +\end_layout + +\begin_layout Itemize +Natural selections on mtDNAs is usually performed using operator +\family typewriter +MapSelector +\family default + where single alleles are assigned a fitness value. + Operator +\family typewriter +MaSelector +\family default + assumes two alleles and is not applicable. +\end_layout + +\begin_layout Standard +Example +\begin_inset CommandInset ref +LatexCommand ref +reference "mitochondrial" + +\end_inset + + demonstrates the use of a +\family typewriter +Recombinator +\family default + to recombine an autosome and two sex chromosomes, and a +\family typewriter +MitochondrialGenoTransmitter +\family default + to transmit mitochondrial chromosomes. + Natural selection is applied to allele 3 at the 3rd locus on the mitochondrial + DNA, whose frequency in the population decreases as a result. +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand lstinputlisting +filename "log/mitochondrial.log" +lstparams "caption={Transmission of mitochondrial chromosomes},label={mitochondrial}" + +\end_inset + + +\end_layout + +\begin_layout Standard +You might wonder how a mutation can change the allele of all organelles + in the mitochondrion. + This is generally believed to be done through natural drift during cytoplasmic + segreagation, which is not a mitotic process because it takes place in + dividing asexual cells. + Because only one mitochondrial chromosome is allowed in simuPOP, you will + have to use customized chromosome types if you would like to simulate this + process. + Fortunately, operator +\family typewriter +MitochondrialGenoTransmitter +\family default + can select random organelles from multiple customized chromosomes, if no + chromosome of type +\family typewriter +MITOCHONDRIAL +\family default + is present. + +\end_layout + +\begin_layout Standard +Example +\begin_inset CommandInset ref +LatexCommand ref +reference "mtDNA_evolve" + +\end_inset + + demonstrates the fixation of mutant in cells with multiple organelles. + Althogh mutations are introduced to only one of the organelles, after a + number of cell divisions, the majority of the cells now have only one type + of allele. + This example uses a +\family typewriter +RandomSelection +\family default + mating scheme to select cells randomly from the parental population. + Because no sexual reproduction is involved, +\family typewriter +MitochondrialGenoTransmitter +\family default + passes the parental genotype to offspring regardless of sex of parent. + This example also demonstrates a disadvantage of using customized chromosomes + in that you will have to calculate statistics by yourself because only + you know the meaning of these chromosomes. + In this example, a function is written to count the number of mutants in + each cell (individual), and summarize the number of cells with 0, 1, 2, + 3, 4, and 5 copies of the mutant. +\end_layout + +\begin_layout Standard +\begin_inset CommandInset include +LatexCommand lstinputlisting +filename "log/mtDNA_evolve.log" +lstparams "caption={Evolution of multiple organelles in mitochondrion},label={mtDNA_evolve}" + +\end_inset + + +\end_layout + +\begin_layout Section Import and export dataset in other formats \end_layout @@ -25633,7 +25819,7 @@ \end_layout \begin_layout Subsection -Pre-defined genotype transmitters * +Genotype transmitters * \begin_inset CommandInset label LatexCommand label name "sub:Pre-defined-genotype-transmitters" @@ -25661,80 +25847,6 @@ \end_layout \begin_layout Standard -All genotype transmitters only handle known chromosome types such as -\family typewriter -AUTOSOME -\family default -, -\family typewriter -CHROMOSOME_X -\family default - and -\family typewriter -CHROMOSOME_Y -\family default -. - Customized chromosomes are left untouched because simuPOP does not know - how they should be transmitted from parents to offspring. - In case that Customized chromosomes are treated as mitochondrial chromosomes, - a -\family typewriter -MitochondrialGenoTransmitter -\family default - can be used to transmit customized chromosomes randomly from mother to - offspring. - Example -\begin_inset CommandInset ref -LatexCommand ref -reference "mitochondrial.log" - -\end_inset - - demonstrates the use of a -\family typewriter -Recombinator -\family default - to recombine an autosome and two sex chromosomes, and a -\family typewriter -MitochondrialGenoTransmitter -\family default - to transmit mitochondrial chromosomes. - Note that the default -\family typewriter -MendelianGenoTransmitter -\family default - is replaced by these two operators. - It will be (wastefully) applied if the new during-mating operators are - used in the -\family typewriter -Simulator.evolve -\family default - function. -\end_layout - -\begin_layout Standard -\begin_inset CommandInset include -LatexCommand lstinputlisting -filename "log/mitochondrial.log" -lstparams "caption={Transmission of mitochondrial chromosomes},label={mitochondrial.log}" - -\end_inset - - -\end_layout - -\begin_layout Subsection -Customized genotype transmitter ** -\begin_inset CommandInset label -LatexCommand label -name "sub:Customized-genotype-transmitter" - -\end_inset - - -\end_layout - -\begin_layout Standard Although simuPOP provides a number of genotype transmitters, they may still be cases where customized genotype transmitter is needed. For example, a Recombinator can be used to recombine parental chromosomes Modified: trunk/doc/userGuide.py =================================================================== --- trunk/doc/userGuide.py 2012-02-23 05:01:25 UTC (rev 4382) +++ trunk/doc/userGuide.py 2012-02-23 17:20:52 UTC (rev 4383) @@ -219,8 +219,9 @@ #begin_ignore sim.setRNG(seed=12345) #end_ignore -pop = sim.Population(size=6, ploidy=2, loci=[3, 3, 6, 4, 4, 4], - chromTypes=[sim.AUTOSOME]*2 + [sim.CHROMOSOME_X, sim.CHROMOSOME_Y] + [sim.CUSTOMIZED]*2) +pop = sim.Population(size=6, ploidy=2, loci=[3, 3, 3, 2, 2, 4, 4], + chromTypes=[sim.AUTOSOME]*2 + [sim.CHROMOSOME_X, sim.CHROMOSOME_Y, sim.MITOCHONDRIAL] + + [sim.CUSTOMIZED]*2) sim.initGenotype(pop, freq=[0.3, 0.7]) sim.dump(pop, structure=False) # does not display genotypic structure information #end_file @@ -3488,7 +3489,7 @@ sim.setRNG(seed=12345) #end_ignore pop = sim.Population(1000, loci=[5]*4, - chromTypes=[sim.AUTOSOME, sim.CHROMOSOME_X, sim.CHROMOSOME_Y, sim.CUSTOMIZED]) + chromTypes=[sim.AUTOSOME, sim.CHROMOSOME_X, sim.CHROMOSOME_Y, sim.MITOCHONDRIAL]) pop.setVirtualSplitter(sim.SexSplitter()) pop.evolve( initOps=[ @@ -3504,7 +3505,7 @@ sim.Stat(neutrality=range(5)), sim.Stat(neutrality=range(5, 10), suffix='_X'), sim.Stat(neutrality=range(10, 15), suffix='_Y'), - sim.Stat(neutrality=range(15, 20), subPops=[(0, 'Female')], suffix='_mt'), + sim.Stat(neutrality=range(15, 20), suffix='_mt'), sim.PyEval(r'"%.3f %.3f %.3f %.3f\n" % (Pi, Pi_X, Pi_Y, Pi_mt)'), ], gen = 2 @@ -5394,7 +5395,73 @@ #end_file +#begin_file log/mitochondrial.py +#begin_ignore +import simuOpt +simuOpt.setOptions(quiet=True) +#end_ignore +import simuPOP as sim +#begin_ignore +sim.setRNG(seed=12345) +#end_ignore +pop = sim.Population(1000, loci=[5]*4, + # one autosome, two sex chromosomes, and one mitochondrial chromosomes + chromTypes=[sim.AUTOSOME, sim.CHROMOSOME_X, sim.CHROMOSOME_Y, sim.MITOCHONDRIAL], + infoFields=['fitness']) +pop.evolve( + initOps=[ + sim.InitSex(), + sim.InitGenotype(freq=[0.25]*4) + ], + preOps=[ + sim.MapSelector(loci=17, fitness={(0,): 1, (1,): 1, (2,): 1, (3,): 0.4}) + ], + matingScheme=sim.RandomMating(ops= [ + sim.Recombinator(rates=0.1), + sim.MitochondrialGenoTransmitter(), + ]), + postOps=[ + sim.Stat(alleleFreq=17, step=10), + sim.PyEval(r'"%.2f %.2f %.2f %.2f\n" % (alleleNum[17][0],' + 'alleleNum[17][1], alleleNum[17][2], alleleNum[17][3])', step=10), + ], + gen = 100 +) +#end_file +#begin_file log/mtDNA_evolve.py +#begin_ignore +import simuOpt +simuOpt.setOptions(quiet=True) +#end_ignore +import simuPOP as sim +#begin_ignore +sim.setRNG(seed=12345) +#end_ignore + +def alleleCount(pop): + summary = [0]* 6 + for ind in pop.individuals(): + geno = ind.genotype(ploidy=0) + summary[geno[0] + geno[2] + geno[4] + geno[6] + geno[8]] += 1 + print('%d %s' % (pop.dvars().gen, summary)) + return True + +pop = sim.Population(1000, loci=[2]*5, chromTypes=[sim.CUSTOMIZED]*5) +pop.evolve( + # every one has miDNAs 10, 00, 00, 00, 00 + initOps=[ + sim.InitGenotype(haplotypes=[[1]+[0]*9]), + ], + # random select cells for cytoplasmic segregation + matingScheme=sim.RandomSelection(ops= [ + sim.MitochondrialGenoTransmitter(), + ]), + postOps=sim.PyOperator(func=alleleCount, step=10), + gen = 51 +) +#end_file + #begin_file log/importData.py #begin_ignore import simuOpt @@ -5577,34 +5644,6 @@ ) #end_file -#begin_file log/mitochondrial.py -#begin_ignore -import simuOpt -simuOpt.setOptions(quiet=True) -#end_ignore -import simuPOP as sim -#begin_ignore -sim.setRNG(seed=12345) -#end_ignore -pop = sim.Population(10, loci=[5]*5, - # one autosome, two sex chromosomes, and two mitochondrial chromosomes - chromTypes=[sim.AUTOSOME, sim.CHROMOSOME_X, sim.CHROMOSOME_Y] + [sim.CUSTOMIZED]*2, - infoFields=['father_idx', 'mother_idx']) -pop.evolve( - initOps=[ - sim.InitSex(), - sim.InitGenotype(freq=[0.4] + [0.2]*3) - ], - matingScheme=sim.RandomMating(ops= [ - sim.Recombinator(rates=0.1), - sim.MitochondrialGenoTransmitter(), - sim.ParentsTagger() - ]), - postOps=sim.Dumper(structure=False), - gen = 2 -) -#end_file - #begin_file log/sexSpecificRec.py #begin_ignore import simuOpt Modified: trunk/src/genoStru.cpp =================================================================== --- trunk/src/genoStru.cpp 2012-02-23 05:01:25 UTC (rev 4382) +++ trunk/src/genoStru.cpp 2012-02-23 17:20:52 UTC (rev 4383) @@ -256,14 +256,13 @@ DBG_WARNIF(m_chromX * m_chromY < 0, "Chromosome X and Y should be both present for sexual transmission to work."); // - m_mitochondrial.clear(); + m_mitochondrial = -1; size_t mt_len = 0; for (size_t i = 0; i < m_chromTypes.size(); ++i) { if (m_chromTypes[i] == MITOCHONDRIAL) { - DBG_FAILIF(!m_mitochondrial.empty() && m_mitochondrial.back() != i - 1, - ValueError, - "There can be several mitochondrial chromosmes, but they need to be adjacent to each other."); - m_mitochondrial.push_back(static_cast<ULONG>(i)); + DBG_ASSERT(m_mitochondrial == -1, ValueError, + "Only one mitochondrial chromosome can be specified"); + m_mitochondrial = i; if (mt_len == 0) mt_len = m_numLoci[i]; else if (m_numLoci[i] != mt_len) Modified: trunk/src/genoStru.h =================================================================== --- trunk/src/genoStru.h 2012-02-23 05:01:25 UTC (rev 4382) +++ trunk/src/genoStru.h 2012-02-23 17:20:52 UTC (rev 4383) @@ -73,7 +73,7 @@ public: /// CPPONLY serialization library requires a default constructor GenoStructure() : m_ploidy(2), m_totNumLoci(0), - m_numLoci(0), m_chromTypes(), m_chromX(-1), m_chromY(-1), m_mitochondrial(), m_customized(), + m_numLoci(0), m_chromTypes(), m_chromX(-1), m_chromY(-1), m_mitochondrial(-1), m_customized(), m_haplodiploid(false), m_lociPos(0), m_chromIndex(0), m_chromNames(), m_alleleNames(), m_lociNames(), m_lociNameMap(), m_infoFields(0), m_refCount(0) @@ -208,7 +208,7 @@ int m_chromY; /// indexes of mitochondrial chromosomes - vectoru m_mitochondrial; + int m_mitochondrial; /// indexes of customized chromosomes vectoru m_customized; @@ -482,7 +482,7 @@ * Return the indexes of mitochondrial chromosomes. * <group>2-chromosome</group> */ - vectoru mitochondrialChroms() const + int mitochondrial() const { DBG_FAILIF(m_genoStruIdx == MaxTraitIndex, SystemError, "totNumLoci: You have not set genoStructure. Please use setGenoStrucutre to set such info."); Modified: trunk/src/transmitter.cpp =================================================================== --- trunk/src/transmitter.cpp 2012-02-23 05:01:25 UTC (rev 4382) +++ trunk/src/transmitter.cpp 2012-02-23 17:20:52 UTC (rev 4383) @@ -411,16 +411,23 @@ bool MitochondrialGenoTransmitter::applyDuringMating(Population & pop, Population & offPop, RawIndIterator offspring, - Individual * /* dad */, Individual * mom) const + Individual * dad, Individual * mom) const { // if offspring does not belong to subPops, do nothing, but does not fail. if (!applicableToAllOffspring() && !applicableToOffspring(offPop, offspring)) return true; initializeIfNeeded(*offspring); - (void)mom; // avoid a warning message of unused varible in optimized modules - DBG_FAILIF(mom == NULL, ValueError, - "MitochondrialGenoTransmitter requires valid female parent."); + Individual * parent = NULL; + if (dad != NULL && mom == NULL) + // the case of single parent inheritance. Does not care about sex. + parent = dad; + else if (dad != NULL && mom != NULL) + parent = mom; + else { + DBG_FAILIF(true, ValueError, + "MitochondrialGenoTransmitter requires single parent, or valid female parent."); + } if (m_numLoci == 0) return true; @@ -431,12 +438,12 @@ vectoru::iterator it_end = m_mitoChroms.end(); for (; it != it_end; ++it) { size_t src = getRNG().randInt(static_cast<ULONG>(m_mitoChroms.size())); - GenoIterator par = mom->genoBegin(0, m_mitoChroms[src]); + GenoIterator par = parent->genoBegin(0, m_mitoChroms[src]); GenoIterator off = offspring->genoBegin(0, *it); #ifdef BINARYALLELE copyGenotype(par, off, m_numLoci); #else - GenoIterator par_end = mom->genoEnd(0, m_mitoChroms[src]); + GenoIterator par_end = parent->genoEnd(0, m_mitoChroms[src]); # ifdef MUTANTALLELE simuPOP::copy(par, par_end, off); # else Modified: trunk/src/transmitter.h =================================================================== --- trunk/src/transmitter.h 2012-02-23 05:01:25 UTC (rev 4382) +++ trunk/src/transmitter.h 2012-02-23 17:20:52 UTC (rev 4383) @@ -367,20 +367,22 @@ }; -/** This geno transmitter transmits the first homologous copy of \c Mitochondrial - * chromosomes. For backward-compatibility, it assumes that the first homologous - * copy of several (or all) \c Customized chromosomes are copies of mitochondrial - * chromosomes if no chromosome of type \c Mitochondrial is specified. This operator - * transmits these chromosomes randomly from the female parent to offspring. - * If this transmitter is applied to populations with more than one homologous - * copies of chromosomes, it transmits the first homologous copy of - * chromosomes and clears alleles (set to zero) on other homologous copies. +/** This geno transmitter transmits the first homologous copy of a \c Mitochondrial + * chromosome. If no mitochondrial chromosome is present, it assumes that the first + * homologous copy of several (or all) \c Customized chromosomes are copies of + * mitochondrial chromosomes. This operator transmits the mitochondrial chromosome + * from the female parent to offspring for sexsual reproduction, and any parent to + * offspring for asexual reproduction. If there are multiple chromosomes, the + * organelles are selected randomly. If this transmitter is applied to populations + * with more than one homologous copies of chromosomes, it transmits the first + * homologous copy of chromosomes and clears alleles (set to zero) on other + * homologous copies. */ class MitochondrialGenoTransmitter : public GenoTransmitter { public: - /** Createa a mitochondrial genotype transmitter that treats all Mitochondiral - * chromosomes, Customized chromosomes if no Mitochondrial chromosomes are + /** Createa a mitochondrial genotype transmitter that treats the Mitochondiral + * chromosome, or Customized chromosomes if no Mitochondrial chromosome is * specified, or a list of chromosomes specified by \e chroms, as human * mitochondrial chromosomes. These chromosomes should have the same * length and the same number of loci. This operator transmits these This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2012-02-23 21:43:04
|
Revision: 4386 http://simupop.svn.sourceforge.net/simupop/?rev=4386&view=rev Author: simupop Date: 2012-02-23 21:42:57 +0000 (Thu, 23 Feb 2012) Log Message: ----------- Extend the calculation of Fst/Gst to non-diploid population, sex chromosomes, and mitochondrial chromosomes Modified Paths: -------------- trunk/ChangeLog trunk/doc/userGuide.lyx trunk/src/stator.cpp trunk/src/stator.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2012-02-23 20:51:46 UTC (rev 4385) +++ trunk/ChangeLog 2012-02-23 21:42:57 UTC (rev 4386) @@ -11,6 +11,7 @@ sites. - Add MITOCHONDRIAL as a natural chromosome type so that operators such as Stat can handle them correctly. + - Extend Stat(structure) to handle haploid population and non-autosomal chromosomes. BUG: - Fix a bug that prevents the correct handling of population structure when evolving Modified: trunk/doc/userGuide.lyx =================================================================== --- trunk/doc/userGuide.lyx 2012-02-23 20:51:46 UTC (rev 4385) +++ trunk/doc/userGuide.lyx 2012-02-23 21:42:57 UTC (rev 4386) @@ -18516,6 +18516,9 @@ F_it \family default ) . + When hetergozygote count is unavailable (non-diploid population, loci on + sex chromosomes and mitochondrial chromosomes), simuPOP uses expected heterozyg +osity to estimate this quantity. \end_layout \begin_layout Standard Modified: trunk/src/stator.cpp =================================================================== --- trunk/src/stator.cpp 2012-02-23 20:51:46 UTC (rev 4385) +++ trunk/src/stator.cpp 2012-02-23 21:42:57 UTC (rev 4386) @@ -2932,16 +2932,14 @@ const vectoru & loci = m_loci.elems(&pop); - DBG_ASSERT(pop.ploidy() == 2, ValueError, - "Fst statistics is available only for diploid populations."); - -#ifndef OPTIMIZED + bool use_observed_het; for (size_t idx = 0; idx < loci.size(); ++idx) { size_t chromType = pop.chromType(pop.chromLocusPair(loci[idx]).first); - DBG_FAILIF(chromType == CHROMOSOME_X || chromType == CHROMOSOME_Y || chromType == MITOCHONDRIAL, ValueError, - "Fst can not be esimated from markers on sex chromosomes"); + if (idx == 0) + use_observed_het = pop.ploidy() == 2 and (chromType == AUTOSOME || chromType == CUSTOMIZED); + else if ((pop.ploidy() == 2 and (chromType == AUTOSOME || chromType == CUSTOMIZED)) != use_observed_het) + throw ValueError("Structure statistics can only be estimated from loci on chromosomes of the same type, because other wise the observed number of alleles will be different."); } -#endif // selected (virtual) subpopulatons. subPopList subPops = m_subPops.expandFrom(pop); @@ -2968,32 +2966,54 @@ ALLELES & alleles = allAlleles[idx]; size_t cnt = 0; - // go through all alleles - IndAlleleIterator a = pop.alleleIterator(loc, it->subPop()); - for (; a.valid(); ++cnt) { - Allele a1 = *a++; - Allele a2 = *a++; - ++af[a1]; - ++af[a2]; - hf[a1] += a1 != a2; - hf[a2] += a1 != a2; - alleles[a1] = true; - alleles[a2] = true; - } - // heterozygote frequency - map<size_t, float>::iterator it = af.begin(); - map<size_t, float>::iterator itEnd = af.end(); - for (; it != itEnd; ++it) - it->second /= 2 * cnt; - // heterozygote frequency - it = hf.begin(); - itEnd = hf.end(); - for (; it != itEnd; ++it) - it->second /= cnt; - // - DBG_FAILIF(spSize != 0 && spSize != cnt, SystemError, - "Subpopulation size counts are inconsistent. (locus not on autosome?)"); - spSize = cnt; + if (use_observed_het) { + // go through all alleles + IndAlleleIterator a = pop.alleleIterator(loc, it->subPop()); + for (; a.valid(); ++cnt) { + Allele a1 = *a++; + Allele a2 = *a++; + ++af[a1]; + ++af[a2]; + hf[a1] += a1 != a2; + hf[a2] += a1 != a2; + alleles[a1] = true; + alleles[a2] = true; + } + // allele frequency + map<size_t, float>::iterator it = af.begin(); + map<size_t, float>::iterator itEnd = af.end(); + for (; it != itEnd; ++it) + it->second /= 2 * cnt; + // heterozygote frequency + it = hf.begin(); + itEnd = hf.end(); + for (; it != itEnd; ++it) + it->second /= cnt; + // + spSize = cnt; + } else { + // go through all alleles + IndAlleleIterator a = pop.alleleIterator(loc, it->subPop()); + for (; a.valid(); ++cnt) { + Allele c = *a++; + ++af[c]; + ++hf[c]; + alleles[c] = true; + } + // allele frequency + map<size_t, float>::iterator it = af.begin(); + map<size_t, float>::iterator itEnd = af.end(); + for (; it != itEnd; ++it) + // h_a = 2 * f_a * (1 - f_a) + it->second /= cnt; + // heterozygote frequency calculate from allele frequency + it = hf.begin(); + itEnd = hf.end(); + for (; it != itEnd; ++it) + it->second = 2 * (it->second / cnt) * (1 - it->second / cnt); + // + spSize = cnt; + } } // (virtual) subpopulation size n_i.push_back(spSize); Modified: trunk/src/stator.h =================================================================== --- trunk/src/stator.h 2012-02-23 20:51:46 UTC (rev 4385) +++ trunk/src/stator.h 2012-02-23 21:42:57 UTC (rev 4386) @@ -1239,6 +1239,14 @@ * than two alleles) and multi-loci cases. This statistics should * be used if you would like to obtain a \e true Fst value of a large * Population. + * Nei's Gst uses only allele frequency information so it is available + * for all population type (haploid, diploid etc). Weir and Cockerham's + * Fst uses heterozygosity frequency so it is best for autosome of + * diploid populations. For non-diploid population, sex, and mitochondrial + * DNAs, simuPOP uses expected heterozygosity (1 - sum p_i^2) when + * heterozygosity is needed. These statistics output the following + * variables: + * * \li \c F_st (default) The WC84 \e Fst statistic estimated for all * specified loci. * \li \c F_is The WC84 \e Fis statistic estimated for all specified loci. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2012-02-24 04:19:40
|
Revision: 4388 http://simupop.svn.sourceforge.net/simupop/?rev=4388&view=rev Author: simupop Date: 2012-02-24 04:19:33 +0000 (Fri, 24 Feb 2012) Log Message: ----------- Fix tests Modified Paths: -------------- trunk/ChangeLog trunk/src/selector.h trunk/test/test_08_stat.py trunk/test/test_09_selection.py Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2012-02-24 01:54:04 UTC (rev 4387) +++ trunk/ChangeLog 2012-02-24 04:19:33 UTC (rev 4388) @@ -16,6 +16,7 @@ BUG: - Fix a bug that prevents the correct handling of population structure when evolving populations with changing population structure. + - Ensure 2^64 maximum allele states for the long module under 64 bit system version 1.0.6 - Rev 4260 (July 11, 2011) Major new feature: Modified: trunk/src/selector.h =================================================================== --- trunk/src/selector.h 2012-02-24 01:54:04 UTC (rev 4387) +++ trunk/src/selector.h 2012-02-24 04:19:33 UTC (rev 4388) @@ -268,8 +268,8 @@ * \li and in general 2**n for diploid and 3**n for haploid cases if there * are \c n loci. * - * This operator does not support haplodiploid populations and sex - * chromosomes. + * This operator does not support haplodiploid populations, sex and + * mitochondrial chromosomes. */ MaSelector(const lociList & loci, const vectorf & fitness, const uintList & wildtype = vectoru(1, 0), int begin = 0, int end = -1, int step = 1, Modified: trunk/test/test_08_stat.py =================================================================== --- trunk/test/test_08_stat.py 2012-02-24 01:54:04 UTC (rev 4387) +++ trunk/test/test_08_stat.py 2012-02-24 04:19:33 UTC (rev 4388) @@ -426,7 +426,7 @@ for hap in [(0,1,4), (2,5)]: homo = sum([[ind.allele(x, 0) for x in hap] == [ind.allele(x, 1) for x in hap] for ind in pop.individuals()]) self.assertEqual(pop.dvars().haploHeteroNum[hap], 6000 - homo) - self.assertEqual(pop.dvars().haploHeteroFreq[hap], 1 - homo / 6000.) + self.assertAlmostEqual(pop.dvars().haploHeteroFreq[hap], 1 - homo / 6000., 6) pop.setVirtualSplitter(SexSplitter()) stat(pop, haploHomoFreq=[(0,1,4), (2,5)], subPops=[(0,0)]) for hap in [(0,1,4), (2,5)]: Modified: trunk/test/test_09_selection.py =================================================================== --- trunk/test/test_09_selection.py 2012-02-24 01:54:04 UTC (rev 4387) +++ trunk/test/test_09_selection.py 2012-02-24 04:19:33 UTC (rev 4388) @@ -116,8 +116,8 @@ elif ind.allele(2,1) == 2 and ind.sex() == MALE: self.assertEqual(ind.fitness, 0.8) # mitochondrial DNA - pop = Population(size=1000, loci=[1, 2, 2], infoFields=['a', 'fitness', 'b'], - chromTypes=[AUTOSOME, MITOCHONDRIAL, MITOCHONDRIAL]) + pop = Population(size=1000, loci=[1, 2], infoFields=['a', 'fitness', 'b'], + chromTypes=[AUTOSOME, MITOCHONDRIAL]) initSex(pop) initGenotype(pop, freq=[.2, 0, .8]) MapSelector(loci=[2], fitness={(0,):0.9, (1,):0.8}).apply(pop) @@ -232,8 +232,8 @@ elif ind.allele(2,1) == 2 and ind.sex() == MALE: self.assertEqual(ind.fitness, 0.8) # mitochondrial DNA - pop = Population(size=1000, loci=[1, 2, 2], infoFields=['a', 'fitness', 'b'], - chromTypes=[AUTOSOME, MITOCHONDRIAL, MITOCHONDRIAL]) + pop = Population(size=1000, loci=[1, 2], infoFields=['a', 'fitness', 'b'], + chromTypes=[AUTOSOME, MITOCHONDRIAL]) initSex(pop) initGenotype(pop, freq=[.2, 0, .8]) MapSelector(loci=[2], fitness={(0,):0.9, (1,):0.8, (2,):0.4}).apply(pop) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2012-02-24 14:24:41
|
Revision: 4390 http://simupop.svn.sourceforge.net/simupop/?rev=4390&view=rev Author: simupop Date: 2012-02-24 14:24:30 +0000 (Fri, 24 Feb 2012) Log Message: ----------- Fix a bug that prevents MlPenetrance from being used in the evolve function. Modified Paths: -------------- trunk/ChangeLog trunk/src/penetrance.h trunk/test/test_15_penetrance.py Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2012-02-24 05:39:58 UTC (rev 4389) +++ trunk/ChangeLog 2012-02-24 14:24:30 UTC (rev 4390) @@ -16,6 +16,7 @@ BUG: - Fix a bug that prevents the correct handling of population structure when evolving populations with changing population structure. + - Fix a bug that prevents MlPenetrance from being used in the evolve function. - Ensure 2^64 maximum allele states for the long module under 64 bit system version 1.0.6 - Rev 4260 (July 11, 2011) Modified: trunk/src/penetrance.h =================================================================== --- trunk/src/penetrance.h 2012-02-24 05:39:58 UTC (rev 4389) +++ trunk/src/penetrance.h 2012-02-24 14:24:30 UTC (rev 4390) @@ -330,7 +330,7 @@ /// HIDDEN Deep copy of a multi-loci penetrance operator virtual BaseOperator * clone() const { - throw ValueError("Multi-loci penetrance operator can not be nested."); + return new MlPenetrance(*this); } Modified: trunk/test/test_15_penetrance.py =================================================================== --- trunk/test/test_15_penetrance.py 2012-02-24 05:39:58 UTC (rev 4389) +++ trunk/test/test_15_penetrance.py 2012-02-24 14:24:30 UTC (rev 4390) @@ -116,7 +116,6 @@ maPenetrance(pop, loci=[3,5], wildtype=0, penetrance=[0, .3, .5, 0.3, 0.6, 0.8, 0.1, 1, 0.8]) - def testMlPenetrance(self): 'Testing multi-locus penetrance' pop = Population(1000, loci=[3,5], infoFields=['penetrance']) @@ -140,6 +139,42 @@ mode=MULTIPLICATIVE ) + def testEvolveMaPenetrance(self): + 'Testing using MaPenetrance in evolve function' + pop = Population(1000, loci=[3,5]) + pop.evolve( + initOps=[ + InitSex(), + InitGenotype(freq=[.3, .7]), + ], + # + preOps= MaPenetrance(loci = 0, wildtype=0, + penetrance=[0, .3, .5]), + matingScheme=RandomMating(), + gen=4 + ) + + def testEvolveMlPenetrance(self): + 'Testing using MlPenetrance in evolve function' + pop = Population(1000, loci=[3,5]) + pop.evolve( + initOps=[ + InitSex(), + InitGenotype(freq=[.3, .7]), + ], + # + preOps=MlPenetrance(ops=[ + MaPenetrance(loci = 0, wildtype=0, + penetrance=[0, .3, .5]), + MapPenetrance(loci = 1, + penetrance={(0,0):0, (0,1):1, (1,1):1}) + ], + mode=ADDITIVE + ), + matingScheme=RandomMating(), + gen=4 + ) + def testPyPenetrance(self): 'Testing python penetrance operator' def pen(geno): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2012-02-27 22:45:27
|
Revision: 4397 http://simupop.svn.sourceforge.net/simupop/?rev=4397&view=rev Author: simupop Date: 2012-02-27 22:45:20 +0000 (Mon, 27 Feb 2012) Log Message: ----------- Re-enable openMP for macOSX with llvm-gcc 4.2 after adjusting the code to avoid a compiler failure Modified Paths: -------------- trunk/setup.py trunk/src/operator.cpp Modified: trunk/setup.py =================================================================== --- trunk/setup.py 2012-02-27 04:52:06 UTC (rev 4396) +++ trunk/setup.py 2012-02-27 22:45:20 UTC (rev 4397) @@ -73,9 +73,6 @@ if int(version[0]) < 4 or int(version[1]) < 2: print('Support for openMP is turned off because version %s.%s.%s of gcc does not support this feature' % version) USE_OPENMP = False - if int(version[0]) == 4 and int(version[1]) == 2 and int(version[2]) == 1 and 'LLVM' in output: - print('Support for openMP is turned off because of a bug in LLVM-gcc version 4.2.1.') - USE_OPENMP = False except: print('Can not obtain version of gcc, and openMP is disable') USE_OPENMP = False Modified: trunk/src/operator.cpp =================================================================== --- trunk/src/operator.cpp 2012-02-27 04:52:06 UTC (rev 4396) +++ trunk/src/operator.cpp 2012-02-27 22:45:20 UTC (rev 4397) @@ -1058,12 +1058,14 @@ BaseOperator * opPtr = op.clone(); opPtr->initializeIfNeeded(*pop->rawIndBegin()); + // NOTE: putting d and m in the applyDuringMating function will cause + // compiling error gor gcc/llvm under mac. + Individual * d = dad < 0 ? NULL : &pop->individual(static_cast<size_t>(dad)); + Individual * m = mom < 0 ? NULL : &pop->individual(static_cast<size_t>(mom)); #pragma omp parallel for // i needs to be int since some openMP implementation does not handle unsigned index for (int i = static_cast<int>(off.first); i < static_cast<int>(off.second); ++i) - opPtr->applyDuringMating(*pop, *offPop, pop->rawIndBegin() + i, - dad < 0 ? NULL : &pop->individual(static_cast<size_t>(dad)), - mom < 0 ? NULL : &pop->individual(static_cast<size_t>(mom))); + opPtr->applyDuringMating(*pop, *offPop, pop->rawIndBegin() + i, d, m); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ti...@us...> - 2012-03-01 17:15:39
|
Revision: 4403 http://simupop.svn.sourceforge.net/simupop/?rev=4403&view=rev Author: tiwcpe8 Date: 2012-03-01 17:15:33 +0000 (Thu, 01 Mar 2012) Log Message: ----------- Add more test case in testMutants and fixed bug in mutants function Modified Paths: -------------- trunk/src/individual.cpp trunk/test/test_01_individual.py Modified: trunk/src/individual.cpp =================================================================== --- trunk/src/individual.cpp 2012-02-28 23:17:30 UTC (rev 4402) +++ trunk/src/individual.cpp 2012-03-01 17:15:33 UTC (rev 4403) @@ -289,17 +289,21 @@ // has to be all chromosomes DBG_FAILIF(beginCh != 0 || endCh != numChrom(), ValueError, "If multiple ploidy are chosen, all chromosomes has to be chosen."); - compressed_vector<Allele>::index_array_type::iterator idx_beginP = (m_genoPtr + beginP * totNumLoci()).getIndexIterator(); - compressed_vector<Allele>::index_array_type::iterator idx_endP = (m_genoPtr + endP * totNumLoci()).getIndexIterator(); - compressed_vector<Allele>::value_array_type::iterator value_beginP = (m_genoPtr + beginP * totNumLoci()).getValueIterator(); + size_t begin = beginP * totNumLoci(); + size_t end = endP * totNumLoci(); + compressed_vector<Allele>::index_array_type::iterator idx_beginP = (m_genoPtr + begin).getIndexIterator(); + compressed_vector<Allele>::index_array_type::iterator idx_endP = (m_genoPtr + end).getIndexIterator(); + compressed_vector<Allele>::value_array_type::iterator value_beginP = (m_genoPtr + begin).getValueIterator(); mutantAllele.reserve(idx_endP - idx_beginP); for(;idx_beginP != idx_endP; ++idx_beginP, ++value_beginP) mutantAllele.push_back(std::pair<size_t, size_t>(*idx_beginP, *value_beginP)); return mutantAllele; } else { - compressed_vector<Allele>::index_array_type::iterator idx_beginP = (m_genoPtr + beginP * totNumLoci() + chromBegin(beginCh)).getIndexIterator(); - compressed_vector<Allele>::index_array_type::iterator idx_endP = (m_genoPtr + endP * totNumLoci() + chromEnd(endCh -1)).getIndexIterator(); - compressed_vector<Allele>::value_array_type::iterator value_beginP = (m_genoPtr + beginP * totNumLoci() + chromBegin(beginCh)).getValueIterator(); + size_t begin = beginP * totNumLoci() + chromBegin(beginCh); + size_t end = beginP * totNumLoci() + chromEnd(endCh -1); + compressed_vector<Allele>::index_array_type::iterator idx_beginP = (m_genoPtr + begin).getIndexIterator(); + compressed_vector<Allele>::index_array_type::iterator idx_endP = (m_genoPtr + end).getIndexIterator(); + compressed_vector<Allele>::value_array_type::iterator value_beginP = (m_genoPtr + begin).getValueIterator(); mutantAllele.reserve(idx_endP - idx_beginP); for(;idx_beginP != idx_endP; ++idx_beginP, ++value_beginP) mutantAllele.push_back(std::pair<size_t, size_t>(*idx_beginP, *value_beginP)); @@ -435,8 +439,20 @@ for (size_t j = 0; j < chroms.size(); ++j) { size_t chrom = chroms[j]; GenoIterator ptr = m_genoPtr + p * totNumLoci() + chromBegin(chrom); +#ifdef MUTANTALLELE + mutant_vectora ctmp; + ctmp.resize(numLoci(chrom)); + for (size_t i = 0; i < numLoci(chrom); i++, ++idx) { + Allele atmp = ToAllele(geno[idx % sz]); + if (atmp != 0) + ctmp.push_back(i, atmp); + } + simuPOP::copy(ctmp.begin(), ctmp.end(), ptr); +#else for (size_t i = 0; i < numLoci(chrom); i++, ++idx) *(ptr + i) = ToAllele(geno[idx % sz]); +#endif + } } } Modified: trunk/test/test_01_individual.py =================================================================== --- trunk/test/test_01_individual.py 2012-02-28 23:17:30 UTC (rev 4402) +++ trunk/test/test_01_individual.py 2012-03-01 17:15:33 UTC (rev 4403) @@ -14,9 +14,11 @@ from simuOpt import setOptions setOptions(quiet=True) new_argv = [] +alleleType = 'short' for arg in sys.argv: if arg in ['short', 'long', 'binary', 'mutant']: setOptions(alleleType = arg) + alleleType = arg elif arg.startswith('-j'): setOptions(numThreads = int(arg[2:])) else: @@ -153,27 +155,37 @@ def testMutants(self): 'Testing individual::genotype(), genotype(p), genotype(p, chrom)' - pop = self.getPop() - ind = pop.individual(0) - ind.setGenotype([2, 3, 4]) - gt = ind.mutants() - self.assertEqual(gt, ((0,2),(1,3),(2,4),(3,2),(4,3),(5,4),(6,2),(7,3),(8,4),(9,2),(10,3),(11,4),(12,2),(13,3),(14,4),(15,2),(16,3),(17,4),(18,2),(19,3),(20,4),(21,2),(22,3),(23,4))) - # ploidy 1 - gt = ind.mutants(1) - self.assertEqual(gt, ((12,2),(13,3),(14,4),(15,2),(16,3),(17,4),(18,2),(19,3),(20,4),(21,2),(22,3),(23,4))) - # ploidy 1, ch 1 - gt = ind.mutants(1, 1) - self.assertEqual(gt, ((17,4),(18,2),(19,3),(20,4),(21,2),(22,3),(23,4))) - # - self.assertRaises(IndexError, ind.mutants, 2) - self.assertRaises(IndexError, ind.mutants, 0, 2) - # accept single form - pop.setGenotype(1) - self.assertEqual(pop.individual(0).allele(0), 1) - pop.individual(0).setGenotype(0) - self.assertEqual(pop.individual(0).allele(0), 0) + if alleleType == 'mutant': + pop = self.getPop() + ind = pop.individual(0) + ind.setGenotype([2, 3, 4]) + gt = ind.mutants() + self.assertEqual(gt, ((0,2),(1,3),(2,4),(3,2),(4,3),(5,4),(6,2),(7,3),(8,4),(9,2),(10,3),(11,4),(12,2),(13,3),(14,4),(15,2),(16,3),(17,4),(18,2),(19,3),(20,4),(21,2),(22,3),(23,4))) + # ploidy 1 + gt = ind.mutants(1) + self.assertEqual(gt, ((12,2),(13,3),(14,4),(15,2),(16,3),(17,4),(18,2),(19,3),(20,4),(21,2),(22,3),(23,4))) + # ploidy 1, ch 1 + gt = ind.mutants(1, 1) + self.assertEqual(gt, ((17,4),(18,2),(19,3),(20,4),(21,2),(22,3),(23,4))) + # + self.assertRaises(IndexError, ind.mutants, 2) + self.assertRaises(IndexError, ind.mutants, 0, 2) + # accept single form + pop.setGenotype(1) + self.assertEqual(pop.individual(0).allele(0), 1) + pop.individual(0).setGenotype(0) + self.assertEqual(pop.individual(0).allele(0), 0) + # case: Genotype has zero value + ind.setGenotype([2, 0, 4, 0, 6]) + gt = ind.mutants() + self.assertEqual(gt,((0, 2), (2, 4), (4, 6), (5, 2), (7, 4), (9, 6), (10, 2), (12, 4), (14, 6), (15, 2), (17, 4), (19, 6), (20, 2), (22, 4))) + gt = ind.mutants(1) + self.assertEqual(gt,((12, 4), (14, 6), (15, 2), (17, 4), (19, 6), (20, 2), (22, 4))) + gt = ind.mutants(1, 1) + self.assertEqual(gt,((17, 4), (19, 6), (20, 2), (22, 4))) + def testSetGenotype(self): 'Testing individual::setGenotype(geno), setgenotype(geno, p), ' 'setGenotype(geno, p, chrom)' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2012-03-02 05:53:01
|
Revision: 4405 http://simupop.svn.sourceforge.net/simupop/?rev=4405&view=rev Author: simupop Date: 2012-03-02 05:52:54 +0000 (Fri, 02 Mar 2012) Log Message: ----------- Move RevertFixedSites from sandbox to the core Modified Paths: -------------- trunk/src/__init__.py trunk/src/mutator.cpp trunk/src/mutator.h trunk/src/sandbox.cpp trunk/src/sandbox.h trunk/src/sandbox.py trunk/test/test_03_operator.py Modified: trunk/src/__init__.py =================================================================== --- trunk/src/__init__.py 2012-03-01 21:17:49 UTC (rev 4404) +++ trunk/src/__init__.py 2012-03-02 05:52:54 UTC (rev 4405) @@ -174,6 +174,7 @@ 'AminoAcidMutator', 'ContextMutator', 'KAlleleMutator', + 'RevertFixedSites', # 'MapSelector', 'MaSelector', @@ -237,6 +238,7 @@ 'stepwiseMutate', 'snpMutate', 'acgtMutate', + 'revertFixedSites', # 'stat', # @@ -1106,6 +1108,10 @@ 'Function form of operator ``PointMutator``' PointMutator(*args, **kwargs).apply(pop) +def revertFixedSites(pop, *args, **kwargs): + 'Function form of operator ``RevertFixedSites``' + RevertFixedSites(*args, **kwargs).apply(pop) + def stat(pop, *args, **kwargs): '''Apply operator ``Stat`` with specified parameters to population *pop*. Resulting statistics could be accessed from the local namespace of ``pop`` Modified: trunk/src/mutator.cpp =================================================================== --- trunk/src/mutator.cpp 2012-03-01 21:17:49 UTC (rev 4404) +++ trunk/src/mutator.cpp 2012-03-02 05:52:54 UTC (rev 4405) @@ -459,4 +459,44 @@ } +bool RevertFixedSites::apply(Population & pop) const +{ + if (pop.popSize() == 0 || pop.totNumLoci() == 0) + return true; + + const vectoru & loci = m_loci.elems(&pop); + + const subPopList subPops = applicableSubPops(pop); + subPopList::const_iterator sp = subPops.begin(); + subPopList::const_iterator spEnd = subPops.end(); + + for (; sp != spEnd; ++sp) { + if (sp->isVirtual()) + pop.activateVirtualSubPop(*sp); + + for (size_t idx = 0; idx < loci.size(); ++idx) { + size_t loc = loci[idx]; + bool fixed = true; + IndAlleleIterator a = pop.alleleIterator(loc, sp->subPop()); + for (; a.valid(); ++a) { + if (! (*a)) { + fixed = false; + break; + } + } + // revert fixed allele + if (fixed) { + IndAlleleIterator a = pop.alleleIterator(loc, sp->subPop()); + for (; a.valid(); ++a) + *a = 0; + } + } + + if (sp->isVirtual()) + pop.deactivateVirtualSubPop(sp->subPop()); + } + return true; } + + +} Modified: trunk/src/mutator.h =================================================================== --- trunk/src/mutator.h 2012-03-01 21:17:49 UTC (rev 4404) +++ trunk/src/mutator.h 2012-03-02 05:52:54 UTC (rev 4405) @@ -644,5 +644,59 @@ vectoru m_inds; }; + +/** This operator checks all loci of a population and revert a mutant to + * wildtype allele if it is fixed in the population. If a list of (virtual) + * subpopulations are specified, alleles are reverted in each subpopulation, + * regardless if the allele is fixed in other subpopulations. + */ +class RevertFixedSites : public BaseOperator +{ +public: + /** Create an operator to revert alleles at fixed loci from value non-zero to zero. + * If parameter \e subPops are specified, only individuals in these subpopulations + * are considered. + */ + RevertFixedSites(const lociList & loci = lociList(), + const stringFunc & output = "", int begin = 0, int end = -1, int step = 1, + const intList & at = vectori(), + const intList & reps = intList(), const subPopList & subPops = subPopList(), + const stringList & infoFields = vectorstr()) + : BaseOperator("", begin, end, step, at, reps, subPops, infoFields), + m_loci(loci) + { + } + + + /// destructor + virtual ~RevertFixedSites() + { + } + + + /// HIDDEN Deep copy of a Migrator + virtual BaseOperator * clone() const + { + return new RevertFixedSites(*this); + } + + + /// HIDDEN apply the Migrator to populaiton \e pop. + virtual bool apply(Population & pop) const; + + /// HIDDEN + string describe(bool format = true) const + { + (void)format; // avoid warning about unused parameter + return "Revert fixed alleles to wildtype allele if it is fixed in the population."; + } + +private: + lociList m_loci; + +}; + + + } #endif Modified: trunk/src/sandbox.cpp =================================================================== --- trunk/src/sandbox.cpp 2012-03-01 21:17:49 UTC (rev 4404) +++ trunk/src/sandbox.cpp 2012-03-02 05:52:54 UTC (rev 4405) @@ -30,7 +30,7 @@ #ifdef MUTANTALLELE -bool RevertFixedSites::apply(Population & pop) const +bool SB_RevertFixedSites::apply(Population & pop) const { if (pop.popSize() == 0 || pop.totNumLoci() == 0) return true; @@ -712,7 +712,7 @@ // ########################### THE OLD VERSION FOR LONG ALLELE TYPE #### #else -bool RevertFixedSites::apply(Population & pop) const +bool SB_RevertFixedSites::apply(Population & pop) const { if (pop.popSize() == 0 || pop.totNumLoci() == 0) return true; Modified: trunk/src/sandbox.h =================================================================== --- trunk/src/sandbox.h 2012-03-01 21:17:49 UTC (rev 4404) +++ trunk/src/sandbox.h 2012-03-02 05:52:54 UTC (rev 4405) @@ -51,13 +51,13 @@ * to wildtype allele if it is fixed in the population. If a valid output is * specifieid, fixed alleles will be outputed with a leading generation number. */ -class RevertFixedSites : public BaseOperator +class SB_RevertFixedSites : public BaseOperator { public: /** Create an operator to revert alleles at fixed loci from value 1 to 0. * Parameter \e subPops is ignored. */ - RevertFixedSites(const stringFunc & output = "", int begin = 0, int end = -1, int step = 1, + SB_RevertFixedSites(const stringFunc & output = "", int begin = 0, int end = -1, int step = 1, const intList & at = vectori(), const intList & reps = intList(), const subPopList & subPops = subPopList(), const stringList & infoFields = vectorstr()) @@ -67,7 +67,7 @@ /// destructor - virtual ~RevertFixedSites() + virtual ~SB_RevertFixedSites() { } @@ -75,7 +75,7 @@ /// HIDDEN Deep copy of a Migrator virtual BaseOperator * clone() const { - return new RevertFixedSites(*this); + return new SB_RevertFixedSites(*this); } @@ -394,13 +394,13 @@ * to wildtype allele if it is fixed in the population. If a valid output is * specifieid, fixed alleles will be outputed with a leading generation number. */ -class RevertFixedSites : public BaseOperator +class SB_RevertFixedSites : public BaseOperator { public: /** Create an operator to revert alleles at fixed loci from value 1 to 0. * Parameter \e subPops is ignored. */ - RevertFixedSites(const stringFunc & output = "", int begin = 0, int end = -1, int step = 1, + SB_RevertFixedSites(const stringFunc & output = "", int begin = 0, int end = -1, int step = 1, const intList & at = vectori(), const intList & reps = intList(), const subPopList & subPops = subPopList(), const stringList & infoFields = vectorstr()) @@ -410,7 +410,7 @@ /// destructor - virtual ~RevertFixedSites() + virtual ~SB_RevertFixedSites() { } @@ -418,7 +418,7 @@ /// HIDDEN Deep copy of a Migrator virtual BaseOperator * clone() const { - return new RevertFixedSites(*this); + return new SB_RevertFixedSites(*this); } Modified: trunk/src/sandbox.py =================================================================== --- trunk/src/sandbox.py 2012-03-01 21:17:49 UTC (rev 4404) +++ trunk/src/sandbox.py 2012-03-02 05:52:54 UTC (rev 4405) @@ -35,8 +35,8 @@ """ __all__ = [ - 'revertFixedSites', - 'RevertFixedSites', + 'sb_revertFixedSites', + 'SB_RevertFixedSites', 'MutSpaceMutator', 'MutSpaceSelector', 'MutSpaceRecombinator', @@ -73,6 +73,6 @@ else: from simuPOP_std import * -def revertFixedSites(pop): +def sb_revertFixedSites(pop): '''Apply operator ``RevertFixedSites`` to ``pop``''' - RevertFixedSites().apply(pop) + SB_RevertFixedSites().apply(pop) Modified: trunk/test/test_03_operator.py =================================================================== --- trunk/test/test_03_operator.py 2012-03-01 21:17:49 UTC (rev 4404) +++ trunk/test/test_03_operator.py 2012-03-02 05:52:54 UTC (rev 4405) @@ -533,6 +533,163 @@ else: self.assertEqual(ind.a, 2.0) + def testRevertFixedSites(self): + 'Testing operator TestRevertFixedSites' + # + # for diploid + pop = Population([1000]*2, loci=10) + initGenotype(pop, freq=[0.4, 0.6]) + initGenotype(pop, loci=[2, 4], freq=[0, 0.5, 0.5]) + revertFixedSites(pop) + stat(pop, alleleFreq=ALL_AVAIL) + for loc in range(10): + if loc in [2, 4]: + self.assertEqual(pop.dvars().alleleFreq[loc][0], 1) + else: + self.assertNotEqual(pop.dvars().alleleFreq[loc][0], 0) + # for one subpopulation + pop = Population([1000]*2, loci=10) + initGenotype(pop, freq=[0.4, 0.6]) + initGenotype(pop, loci=[2, 4], freq=[0, 0.5, 0.5]) + revertFixedSites(pop, subPops=[1]) + stat(pop, alleleFreq=ALL_AVAIL) + for loc in range(10): + if loc in [2, 4]: + self.assertEqual(pop.dvars().alleleFreq[loc][0], 0.5) + else: + self.assertNotEqual(pop.dvars().alleleFreq[loc][0], 1) + # parameter loci + pop = Population([1000]*2, loci=10) + initGenotype(pop, freq=[0.4, 0.6]) + initGenotype(pop, loci=[2, 4], freq=[0, 0.5, 0.5]) + revertFixedSites(pop, loci=range(4)) + stat(pop, alleleFreq=ALL_AVAIL) + for loc in range(10): + if loc == 2: + self.assertEqual(pop.dvars().alleleFreq[loc][0], 1) + else: + self.assertNotEqual(pop.dvars().alleleFreq[loc][0], 1) + # for one virtual subpopulation + # + pop = Population([1000]*2, loci=10) + initSex(pop, sex=[MALE, FEMALE]) + pop.setVirtualSplitter(SexSplitter()) + initGenotype(pop, freq=[0.4, 0.6]) + initGenotype(pop, loci=[2, 4], freq=[0, 0.5, 0.5]) + revertFixedSites(pop, subPops=[(0,0), (1,1)]) + stat(pop, alleleFreq=ALL_AVAIL, vars='alleleFreq_sp') + for loc in range(10): + if loc == 2: + self.assertEqual(pop.dvars(0).alleleFreq[loc][0], 0.5) + self.assertEqual(pop.dvars(1).alleleFreq[loc][0], 0.5) + else: + self.assertNotEqual(pop.dvars(0).alleleFreq[loc][0], 0) + self.assertNotEqual(pop.dvars(1).alleleFreq[loc][0], 0) + # + # haploid, sex chromosome etc + # + pop = Population([1000]*2, ploidy=1, loci=10) + initGenotype(pop, freq=[0.4, 0.6]) + initGenotype(pop, loci=[2, 4], freq=[0, 0.5, 0.5]) + revertFixedSites(pop) + stat(pop, alleleFreq=ALL_AVAIL) + for loc in range(10): + if loc in [2, 4]: + self.assertEqual(pop.dvars().alleleFreq[loc][0], 1) + else: + self.assertNotEqual(pop.dvars().alleleFreq[loc][0], 0) + # for one subpopulation + pop = Population([1000]*2,ploidy=1, loci=10) + initGenotype(pop, freq=[0.4, 0.6]) + initGenotype(pop, loci=[2, 4], freq=[0, 0.5, 0.5]) + revertFixedSites(pop, subPops=[1]) + stat(pop, alleleFreq=ALL_AVAIL) + for loc in range(10): + if loc in [2, 4]: + self.assertEqual(pop.dvars().alleleFreq[loc][0], 0.5) + else: + self.assertNotEqual(pop.dvars().alleleFreq[loc][0], 1) + # parameter loci + pop = Population([1000]*2, ploidy=1, loci=10) + initGenotype(pop, freq=[0.4, 0.6]) + initGenotype(pop, loci=[2, 4], freq=[0, 0.5, 0.5]) + revertFixedSites(pop, loci=range(4)) + stat(pop, alleleFreq=ALL_AVAIL) + for loc in range(10): + if loc == 2: + self.assertEqual(pop.dvars().alleleFreq[loc][0], 1) + else: + self.assertNotEqual(pop.dvars().alleleFreq[loc][0], 1) + # for one virtual subpopulation + # + pop = Population([1000]*2, ploidy=1, loci=10) + initSex(pop, sex=[MALE, FEMALE]) + pop.setVirtualSplitter(SexSplitter()) + initGenotype(pop, freq=[0.4, 0.6]) + initGenotype(pop, loci=[2, 4], freq=[0, 0.5, 0.5]) + revertFixedSites(pop, subPops=[(0,0), (1,1)]) + stat(pop, alleleFreq=ALL_AVAIL, vars='alleleFreq_sp') + for loc in range(10): + if loc == 2: + self.assertEqual(pop.dvars(0).alleleFreq[loc][0], 0.5) + self.assertEqual(pop.dvars(1).alleleFreq[loc][0], 0.5) + else: + self.assertNotEqual(pop.dvars(0).alleleFreq[loc][0], 0) + self.assertNotEqual(pop.dvars(1).alleleFreq[loc][0], 0) + # + # sex chromosome + # + pop = Population([1000]*2, loci=[3, 7], chromTypes=[CHROMOSOME_X, CHROMOSOME_Y]) + initGenotype(pop, freq=[0.4, 0.6]) + initGenotype(pop, loci=[2, 4], freq=[0, 0.5, 0.5]) + revertFixedSites(pop) + stat(pop, alleleFreq=ALL_AVAIL) + for loc in range(10): + if loc in [2, 4]: + self.assertEqual(pop.dvars().alleleFreq[loc][0], 1) + else: + self.assertNotEqual(pop.dvars().alleleFreq[loc][0], 0) + # for one subpopulation + pop = Population([1000]*2, loci=[3, 7], chromTypes=[CHROMOSOME_X, CHROMOSOME_Y]) + initGenotype(pop, freq=[0.4, 0.6]) + initGenotype(pop, loci=[2, 4], freq=[0, 0.5, 0.5]) + revertFixedSites(pop, subPops=[1]) + stat(pop, alleleFreq=ALL_AVAIL) + for loc in range(10): + if loc in [2, 4]: + self.assertEqual(pop.dvars().alleleFreq[loc][0], 0.5) + else: + self.assertNotEqual(pop.dvars().alleleFreq[loc][0], 1) + # parameter loci + pop = Population([1000]*2, loci=[3, 7], chromTypes=[CHROMOSOME_X, CHROMOSOME_Y]) + initGenotype(pop, freq=[0.4, 0.6]) + initGenotype(pop, loci=[2, 4], freq=[0, 0.5, 0.5]) + revertFixedSites(pop, loci=range(4)) + stat(pop, alleleFreq=ALL_AVAIL) + for loc in range(10): + if loc == 2: + self.assertEqual(pop.dvars().alleleFreq[loc][0], 1) + else: + self.assertNotEqual(pop.dvars().alleleFreq[loc][0], 1) + # for one virtual subpopulation + # + pop = Population([1000]*2, loci=[3, 7], chromTypes=[CHROMOSOME_X, CHROMOSOME_Y]) + initSex(pop, sex=[MALE, FEMALE]) + pop.setVirtualSplitter(SexSplitter()) + initGenotype(pop, freq=[0.4, 0.6]) + initGenotype(pop, loci=[2, 4], freq=[0, 0.5, 0.5]) + revertFixedSites(pop, subPops=[(0,0), (1,0)]) + stat(pop, alleleFreq=ALL_AVAIL, subPops=[(0,0), (1,0)], vars='alleleFreq_sp') + for loc in range(10): + if loc in [2, 4]: + self.assertEqual(pop.dvars((0,0)).alleleFreq[loc][0], 1) + self.assertEqual(pop.dvars((1,0)).alleleFreq[loc][0], 1) + else: + self.assertNotEqual(pop.dvars((0,0)).alleleFreq[loc][0], 0) + self.assertNotEqual(pop.dvars((1,0)).alleleFreq[loc][0], 0) + + + if __name__ == '__main__': unittest.main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2012-03-02 18:28:42
|
Revision: 4416 http://simupop.svn.sourceforge.net/simupop/?rev=4416&view=rev Author: simupop Date: 2012-03-02 18:28:36 +0000 (Fri, 02 Mar 2012) Log Message: ----------- Add test and change interface again Modified Paths: -------------- trunk/src/stator.h trunk/test/test_08_stat.py Modified: trunk/src/stator.h =================================================================== --- trunk/src/stator.h 2012-03-02 18:13:27 UTC (rev 4415) +++ trunk/src/stator.h 2012-03-02 18:28:36 UTC (rev 4416) @@ -986,18 +986,17 @@ * * <b>numOfSegSites</b>: Parameter \e numOfSegSites accepts a list of loci * (loci indexes, names, or \c ALL_AVAIL) and count the number of loci with - * at least two different alleles (segregating sites) or loci with at least - * one non-zero allele (non-zero sites, which includes all segregating sites, - * and sites with fixed non-zero alleles) for individuals in all or - * specified (virtual) subpopulations. This parameter sets variables + * at least two different alleles (segregating sites) or loci with only one + * non-zero allele (no zero allele, not segragating) for individuals in all + * or specified (virtual) subpopulations. This parameter sets variables * \li \c numOfSegSites (default): Number of segregating sites in all or * specified (virtual) subpopulations. * \li \c numOfSegSites_sp: Number of segregating sites in each (virtual) * subpopulation. - * \li \c numOfNonZeroSites: Number of sites with at least one non-zero - * allele, in all or specified (virtual) subpopulations. - * \li \c numOfNonZeroSites_sp: Number of sites with at least one non-zero - * allele in each (virtual) subpopulations. + * \li \c numOfFixedSites: Number of sites with one non-zero allele in all + * or specified (virtual) subpopulations. + * \li \c numOfFixedSites_sp: Number of sites with one non-zero allele in + * in each (virtual) subpopulations. * * <b>alleleFreq</b>: This parameter accepts a list of loci (loci indexes, * names, or \c ALL_AVAIL), at which allele frequencies will be calculated. Modified: trunk/test/test_08_stat.py =================================================================== --- trunk/test/test_08_stat.py 2012-03-02 18:13:27 UTC (rev 4415) +++ trunk/test/test_08_stat.py 2012-03-02 18:28:36 UTC (rev 4416) @@ -153,10 +153,26 @@ # selected loci stat(pop, numOfSegSites=range(100, 1000)) self.assertEqual(pop.dvars().numOfSegSites, 0) + # + # number of non-zero sites + pop = Population(size=1000, loci=[10]*10) + # 20 segreagating sites with 0 + initGenotype(pop, loci= range(20), freq=[0.5, 0.5]) + # 10 segragating sites without 0, fixed for binary module + initGenotype(pop, loci= range(30, 40), freq=[0, 0.5, 0.5]) + # 10 fixed sites + initGenotype(pop, loci= range(50, 60), freq=[0, 1]) + stat(pop, numOfSegSites=ALL_AVAIL, vars=['numOfSegSites', 'numOfFixedSites']) + if moduleInfo()['alleleType'] == 'binary': + self.assertEqual(pop.dvars().numOfSegSites, 20) + self.assertEqual(pop.dvars().numOfFixedSites, 20) + else: + self.assertEqual(pop.dvars().numOfSegSites, 30) + self.assertEqual(pop.dvars().numOfFixedSites, 10) def testNumOfMutants(self): - 'Testing the number of segregating sites' + 'Testing the number of mutants' pop = Population(size=1000, loci=[100]*100) # 100 mutations for i in range(100): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <si...@us...> - 2012-03-03 22:48:29
|
Revision: 4420 http://simupop.svn.sourceforge.net/simupop/?rev=4420&view=rev Author: simupop Date: 2012-03-03 22:48:21 +0000 (Sat, 03 Mar 2012) Log Message: ----------- Lineage patch 2: structural changes to add modules lin and linop Modified Paths: -------------- trunk/MANIFEST.in trunk/SConstruct trunk/setup.py trunk/simuOpt.py trunk/src/__init__.py Added Paths: ----------- trunk/src/simuPOP_lin.i trunk/src/simuPOP_linop.i Modified: trunk/MANIFEST.in =================================================================== --- trunk/MANIFEST.in 2012-03-03 22:45:52 UTC (rev 4419) +++ trunk/MANIFEST.in 2012-03-03 22:48:21 UTC (rev 4420) @@ -42,6 +42,8 @@ # source files include src/customizedTypes.c +include src/customizedLineageTypes.c +include src/customizedTemplates.cpp include src/utility.cpp include src/genoStru.cpp include src/individual.cpp @@ -78,6 +80,8 @@ include src/simuPOP_laop.py include src/simuPOP_ba.py include src/simuPOP_baop.py +include src/simuPOP_lin.py +include src/simuPOP_linop.py include src/gsl_wrap.c # source wrap files @@ -89,6 +93,8 @@ include src/simuPOP_laop.i include src/simuPOP_ba.i include src/simuPOP_baop.i +include src/simuPOP_lin.i +include src/simuPOP_linop.i include src/gsl.i # source python files (modules) Modified: trunk/SConstruct =================================================================== --- trunk/SConstruct 2012-03-03 22:45:52 UTC (rev 4419) +++ trunk/SConstruct 2012-03-03 22:48:21 UTC (rev 4420) @@ -212,7 +212,7 @@ # targets = [] exe_targets = [] -all_modu = ['std', 'op', 'la', 'laop', 'ba', 'baop', 'mu', 'muop'] +all_modu = ['std', 'op', 'la', 'laop', 'ba', 'baop', 'mu', 'muop', 'lin', 'linop'] all_exe = [x + '_exe' for x in all_modu] for key in all_modu: if key in BUILD_TARGETS: Modified: trunk/setup.py =================================================================== --- trunk/setup.py 2012-03-03 22:45:52 UTC (rev 4419) +++ trunk/setup.py 2012-03-03 22:48:21 UTC (rev 4420) @@ -424,6 +424,10 @@ ('_SECURE_SCL', 1), ('_HAS_ITERATOR_DEBUGGING', 0)], 'muop': [('SIMUPOP_MODULE', 'simuPOP_muop'), ('MUTANTALLELE', None), ('OPTIMIZED', None), ('_SECURE_SCL', 0), ('_HAS_ITERATOR_DEBUGGING', 0)], + 'lin': [('SIMUPOP_MODULE', 'simuPOP_lin'), ('LINEAGE', None), + ('_SECURE_SCL', 1), ('_HAS_ITERATOR_DEBUGGING', 0)], + 'linop': [('SIMUPOP_MODULE', 'simuPOP_linop'), ('LINEAGE', None), ('OPTIMIZED', None), + ('_SECURE_SCL', 0), ('_HAS_ITERATOR_DEBUGGING', 0)], } @@ -436,6 +440,8 @@ 'baop': ['src/simuPOP_baop_wrap.cpp', 'src/simuPOP_baop.i', '-DBINARYALLELE -DOPTIMIZED'], 'mu': ['src/simuPOP_mu_wrap.cpp', 'src/simuPOP_mu.i', '-DMUTANTALLELE'], 'muop': ['src/simuPOP_muop_wrap.cpp', 'src/simuPOP_muop.i', '-DMUTANTALLELE -DOPTIMIZED'], + 'lin': ['src/simuPOP_lin_wrap.cpp', 'src/simuPOP_lin.i', '-DLINEAGE'], + 'linop': ['src/simuPOP_linop_wrap.cpp', 'src/simuPOP_linop.i', '-DLINEAGE -DOPTIMIZED'], } if os.name == 'nt': @@ -553,7 +559,7 @@ if __name__ == '__main__': SIMUPOP_VER, SIMUPOP_REV = simuPOP_version() # create source file for each module - MODULES = ['std', 'op', 'la', 'laop', 'ba', 'baop', 'mu', 'muop'] + MODULES = ['std', 'op', 'la', 'laop', 'ba', 'baop', 'mu', 'muop', 'lin', 'linop'] # # Generate Wrapping files # Modified: trunk/simuOpt.py =================================================================== --- trunk/simuOpt.py 2012-03-03 22:45:52 UTC (rev 4419) +++ trunk/simuOpt.py 2012-03-03 22:48:21 UTC (rev 4420) @@ -119,10 +119,10 @@ simuOptions['Optimized'] = True # AlleleType: from environmental variable SIMUALLELETYPE -if os.getenv('SIMUALLELETYPE') in ['short', 'long', 'binary','mutant']: +if os.getenv('SIMUALLELETYPE') in ['short', 'long', 'binary', 'mutant', 'lineage']: simuOptions['AlleleType'] = os.getenv('SIMUALLELETYPE') elif os.getenv('SIMUALLELETYPE') is not None: - print 'Environmental variable SIMUALLELETYPE can only be short, long, binary, or mutant' + print 'Environmental variable SIMUALLELETYPE can only be short, long, binary, mutant, or lineage.' # Debug: from environmental variable SIMUDEBUG if os.getenv('SIMUDEBUG') is not None: @@ -162,11 +162,12 @@ load, and how the module should be loaded. alleleType - Use the standard, binary,long or mutant allele version of the simuPOP module - if ``alleleType`` is set to 'short', 'binary', 'long', or 'mutant respectively. - If this parameter is not set, this function will try to get its value - from environmental variable ``SIMUALLELETYPE``. The standard (short) - module will be used if the environmental variable is not defined. + Use the standard, binary,long or mutant allele version of the simuPOP + module if ``alleleType`` is set to 'short', 'binary', 'long', 'mutant', + or 'lineage' respectively. If this parameter is not set, this function + will try to get its value from environmental variable ``SIMUALLELETYPE``. + The standard (short) module will be used if the environmental variable + is not defined. optimized Load the optimized version of a module if this parameter is set to @@ -226,10 +227,10 @@ elif optimized is not None: raise TypeError('Parameter optimized can be either True or False.') # Allele type - if alleleType in ['long', 'binary', 'short', 'mutant']: + if alleleType in ['long', 'binary', 'short', 'mutant', 'lineage']: simuOptions['AlleleType'] = alleleType elif alleleType is not None: - raise TypeError('Parameter alleleType can be either short, long, binary, or mutant.') + raise TypeError('Parameter alleleType can be either short, long, binary, mutant or lineage.') # Graphical toolkit if gui in [True, False, 'wxPython', 'Tkinter', 'batch']: simuOptions['GUI'] = gui Modified: trunk/src/__init__.py =================================================================== --- trunk/src/__init__.py 2012-03-03 22:45:52 UTC (rev 4419) +++ trunk/src/__init__.py 2012-03-03 22:48:21 UTC (rev 4420) @@ -294,6 +294,8 @@ from simuPOP.simuPOP_baop import * elif simuOptions['AlleleType'] == 'mutant': from simuPOP.simuPOP_muop import * + elif simuOptions['AlleleType'] == 'lineage': + from simuPOP.simuPOP_linop import * else: from simuPOP.simuPOP_op import * else: @@ -305,6 +307,8 @@ from simuPOP.simuPOP_ba import * elif simuOptions['AlleleType'] == 'mutant': from simuPOP.simuPOP_mu import * + elif simuOptions['AlleleType'] == 'lineage': + from simuPOP.simuPOP_lin import * else: from simuPOP.simuPOP_std import * Added: trunk/src/simuPOP_lin.i =================================================================== --- trunk/src/simuPOP_lin.i (rev 0) +++ trunk/src/simuPOP_lin.i 2012-03-03 22:48:21 UTC (rev 4420) @@ -0,0 +1,30 @@ +// +// $File: simuPOP_lin.i $ +// $LastChangedDate$ +// $Rev$ +// +// This file is part of simuPOP, a forward-time population genetics +// simulation environment. Please visit http://simupop.sourceforge.net +// for details. +// +// Copyright (C) 2004 - 2009 Bo Peng (bp...@md...) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// + +%module simuPOP_lin + +#define LINEAGE +%include "simuPOP_common.i" + Added: trunk/src/simuPOP_linop.i =================================================================== --- trunk/src/simuPOP_linop.i (rev 0) +++ trunk/src/simuPOP_linop.i 2012-03-03 22:48:21 UTC (rev 4420) @@ -0,0 +1,30 @@ +// +// $File: simuPOP_linop.i $ +// $LastChangedDate$ +// $Rev$ +// +// This file is part of simuPOP, a forward-time population genetics +// simulation environment. Please visit http://simupop.sourceforge.net +// for details. +// +// Copyright (C) 2004 - 2009 Bo Peng (bp...@md...) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// + +%module simuPOP_linop + +#define OPTIMIZED +#define LINEAGE +%include "simuPOP_common.i" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |