Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# To use CMAKE, create a new subdirectory in your source directory, e.g., build, then run
# the following commands:
# cd build
# cmake ..
# make
# For subsequent builds, just run make in the build subdirectory, or make -C build in SLiM

cmake_minimum_required (VERSION 2.6)

# Use the flags below for all builds and report the build type
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# using Clang
set(CMAKE_C_FLAGS "-g -std=c11 -O3 -Wno-deprecated-register -Wno-attributes")
set(CMAKE_CXX_FLAGS "-g -std=c++11 -O3 -Wno-deprecated-register -Wno-attributes")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# using GCC
set(CMAKE_C_FLAGS "-g -std=c11 -fopenmp -O3 -Wno-deprecated-register -Wno-attributes")
set(CMAKE_CXX_FLAGS "-g -std=c++11 -fopenmp -O3 -Wno-deprecated-register -Wno-attributes")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
# using Intel compilers
set(CMAKE_C_FLAGS "-g -std=c11 -openmp -O3 -Wno-deprecated-register -Wno-attributes")
set(CMAKE_CXX_FLAGS "-g -std=c++11 -openmp -O3 -Wno-deprecated-register -Wno-attributes")
endif()
message("CMAKE_BUILD_TYPE is ${CMAKE_BUILD_TYPE}")

# Place slim and eidos in the bin subdirectory of the source directory
set( EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin )


# GSL
set(TARGET_NAME gsl)
file(GLOB_RECURSE GSL_SOURCES ${PROJECT_SOURCE_DIR}/gsl/*.c ${PROJECT_SOURCE_DIR}/gsl/*/*.c)
set(GSL_INCLUDES ${PROJECT_SOURCE_DIR}/gsl ${PROJECT_SOURCE_DIR}/gsl/specfunc ${PROJECT_SOURCE_DIR}/gsl/blas ${PROJECT_SOURCE_DIR}/gsl/rng ${PROJECT_SOURCE_DIR}/gsl/cdf ${PROJECT_SOURCE_DIR}/gsl/vector ${PROJECT_SOURCE_DIR}/gsl/err ${PROJECT_SOURCE_DIR}/gsl/sys ${PROJECT_SOURCE_DIR}/gsl/randist ${PROJECT_SOURCE_DIR}/gsl/matrix ${PROJECT_SOURCE_DIR}/gsl/cblas ${PROJECT_SOURCE_DIR}/gsl/complex ${PROJECT_SOURCE_DIR}/gsl/block ${PROJECT_SOURCE_DIR}/gsl/linalg)
add_library(${TARGET_NAME} STATIC ${GSL_SOURCES})
target_include_directories(${TARGET_NAME} PUBLIC ${GSL_INCLUDES})


set(TARGET_NAME slim)
file(GLOB_RECURSE SLIM_SOURCES ${PROJECT_SOURCE_DIR}/core/*.cpp ${PROJECT_SOURCE_DIR}/eidos/*.cpp)
add_executable(${TARGET_NAME} ${SLIM_SOURCES})
target_include_directories(${TARGET_NAME} PRIVATE ${GSL_INCLUDES} "${PROJECT_SOURCE_DIR}/core" "${PROJECT_SOURCE_DIR}/eidos")
target_link_libraries(${TARGET_NAME} PUBLIC gsl)

set(TARGET_NAME eidos)
file(GLOB_RECURSE EIDOS_SOURCES ${PROJECT_SOURCE_DIR}/eidos/*.cpp ${PROJECT_SOURCE_DIR}/eidostool/*.cpp)
add_executable(${TARGET_NAME} ${EIDOS_SOURCES})
target_include_directories(${TARGET_NAME} PRIVATE ${GSL_INCLUDES} "${PROJECT_SOURCE_DIR}/eidos")
target_link_libraries(${TARGET_NAME} PUBLIC gsl)

81 changes: 71 additions & 10 deletions core/slim_sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3424,6 +3424,11 @@ void SLiMSim::StartTreeRecording(void)
// again on this SLiMSim instance – but note that in SLiMgui multiple SLiMSim instances may exist, and may all be recording their
// own trees, so your code needs to be capable of handling that. Store your state inside SLiMSim, not in globals. SLiMgui is
// single-threaded, though, so you don't need to worry about re-entrancy or multithreading issues.

// TODO initialize ARGrecorder instance.



}

void SLiMSim::RecordNewIndividual(Individual *p_individual)
Expand All @@ -3437,11 +3442,20 @@ void SLiMSim::RecordNewIndividual(Individual *p_individual)
// think). The first parent is always the female in sexual models, guaranteed. At present, when this code is called the individual may
// not be completely initialized yet; it may not know its sex, and its genomes may not know their types, and so forth. If that needs to
// be fixed, it should be reasonably straightforward to do so. For now, the only information guaranteed valid is the pedigree IDs.
slim_pedigreeid_t ind_pid = p_individual->PedigreeID();
slim_pedigreeid_t p1_pid = p_individual->Parent1PedigreeID();
slim_mutationid_t p2_pid = p_individual->Parent2PedigreeID();

//slim_pedigreeid_t ind_pid = p_individual->PedigreeID();
//slim_pedigreeid_t p1_pid = p_individual->Parent1PedigreeID();
//slim_mutationid_t p2_pid = p_individual->Parent2PedigreeID();

std::cout << Generation() << ": New individual created, pedigree id " << ind_pid << " (parents: " << p1_pid << ", " << p2_pid << ")" << std::endl;
//std::cout << Generation() << ": New individual created, pedigree id " << ind_pid << " (parents: " << p1_pid << ", " << p2_pid << ")" << std::endl;

//THOUGHT: Because all this method does is set Ivars, we could probably speed things up by setting the ivars instead of calling this method

//Set ivar to current individual, this way the calls to RecordRecombination have reference.
CurrentTreeSequenceIndividual = p_individual;
//Set ivar to indicate the first recombination has not been called, (this lets us know which parent each recombination is referring to)
FirstRecombinationCalled = false;

}

void SLiMSim::RecordRecombination(std::vector<slim_position_t> *p_breakpoints, bool p_start_strand_2)
Expand All @@ -3451,28 +3465,75 @@ void SLiMSim::RecordRecombination(std::vector<slim_position_t> *p_breakpoints, b
// Note that the breakpoints vector provided may (or may not) contain a breakpoint, as the final breakpoint in the vector, that is beyond
// the end of the chromosome. This is for bookkeeping in the crossover-mutation code and should be ignored, as the code below does.
// The breakpoints vector may be nullptr (indicating no recombination), but if it exists it will be sorted in ascending order.

//-Jared Start

slim_pedigreeid_t parentID;
slim_pedigreeid_t genomeID;
slim_pedigreeid_t parentalGenome1ID;
slim_pedigreeid_t parentalGenome2ID;
//if the first recombination has not been called this is a reference to parent 1

//std::cout << Generation() << ": Reference to individual: " << CurrentTreeSequenceIndividual->PedigreeID() << std::endl;

if(!FirstRecombinationCalled){
genomeID = 2 * CurrentTreeSequenceIndividual->PedigreeID();
parentID = CurrentTreeSequenceIndividual->Parent1PedigreeID();
FirstRecombinationCalled = true;
}else{
genomeID = (2 * CurrentTreeSequenceIndividual->PedigreeID()) + 1;
parentID = CurrentTreeSequenceIndividual->Parent2PedigreeID();
}

parentalGenome1ID = 2 * parentID;
parentalGenome2ID = 2 * parentID + 1;

std::cout << Generation() << ": Call to RecordRecombination for Ind: " << CurrentTreeSequenceIndividual->PedigreeID() << std::endl;
std::cout << Generation() << ": ARGrecorder.AddGenomeNode(inputID = " << genomeID << ",time = " << Generation() << ");" << std::endl;



size_t breakpoint_count = (p_breakpoints ? p_breakpoints->size() : 0);

if (breakpoint_count && (p_breakpoints->back() == chromosome_.last_position_mutrun_ + 1))
breakpoint_count--;

if (breakpoint_count)
{
std::cout << Generation() << ": Recombination at positions:";
std::cout << Generation() << ": Recombination at positions:";

for (size_t breakpoint_index = 0; breakpoint_index < breakpoint_count; ++breakpoint_index)
for (size_t breakpoint_index = 0; breakpoint_index < breakpoint_count; ++breakpoint_index){
std::cout << " " << (*p_breakpoints)[breakpoint_index];

std::cout << " (start with parental strand " << (p_start_strand_2 ? 2 : 1) << ")" << std::endl;
}
std::cout << std::endl;

p_breakpoints->insert(p_breakpoints->begin(),0);
p_breakpoints->pop_back();
p_breakpoints->push_back(chromosome_.last_position_);
breakpoint_count++;

for (size_t breakpoint_index = 0; breakpoint_index < breakpoint_count; ++breakpoint_index){
std::cout << Generation() << ": ARGrecorder.AddEdge(left = " << (*p_breakpoints)[breakpoint_index] << ",right = " << (*p_breakpoints)[breakpoint_index + 1];
std::cout << ",parent = " << (p_start_strand_2 ? parentalGenome2ID : parentalGenome1ID) << ",child = " << genomeID << ");" << std::endl;

p_start_strand_2 = !p_start_strand_2;
}

//std::cout << " (start with parental genome " << (p_start_strand_2 ? 2 : 1) << ")" << std::endl;
}
else if (p_breakpoints)
{
std::cout << Generation() << ": No recombination (use parental strand " << (p_start_strand_2 ? 2 : 1) << ")" << std::endl;
std::cout << Generation() << ": No recombination (use parental strand " << (p_start_strand_2 ? 2 : 1) << ")" << std::endl;
std::cout << Generation() << ": ARGrecorder.AddEdge(left = " << 0 << ",right = " << chromosome_.last_position_;
std::cout << ",parent = " << (p_start_strand_2 ? parentalGenome2ID : parentalGenome1ID) << ",child = " << genomeID << ");" << std::endl;
}
else
{
std::cout << Generation() << ": No parental genome" << std::endl;
std::cout << Generation() << ": No parental genome" << std::endl;
}
std::cout << std::endl;

//-Jared End
}

void SLiMSim::WriteTreeSequence(void)
Expand Down
2 changes: 2 additions & 0 deletions core/slim_sim.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ class SLiMSim : public SLiMEidosDictionary
// TREE SEQUENCE RECORDING
bool recording_tree_ = false; // true if we are doing tree sequence recording
std::string recording_tree_path_; // the path to write the final tree file to; given to initializeSLiMOptions(treeRecordingPath)
Individual *CurrentTreeSequenceIndividual;
bool FirstRecombinationCalled = false;
// add further ivars you need for tree sequence recording here; don't forget to add cleanup for them to SLiMSim::~SLiMSim() if necessary

public:
Expand Down