2 Installing Genepop and session examples | Genepop version 4.8.5
Author: F. Rousset

# 2 Installing Genepop and session examples

## 2.1 Installation

### 2.1.1 R package

As any R package, it can be installed by `install.packages("genepop")` if on CRAN, and more generally by `install.packages(``,type="source",repos=NULL)`. See the R documentation for more information.

### 2.1.2 Stand-alone executable

For all supported operating systems, the sources can be recompiled as described in this section. Under Microsoft Windows, a simple alternative is to unzip/copy the 64-bit executable on hard disk (the 32-bit version is no longer supported).

The sources can be recompiled as follows. (1) Extract all c++ sources from the distributed `sources.tar.gz` (or from the `src/` subdirectory of the R package sources, except `RcppExports.cpp`). (2) the following compilation line should suffice:

`g++ -o Genepop *.cpp -O2`

(`O` in `-O2` is the letter O, not zero).

If this does not work then check the compiler version. The sources can be compiled with any compiler that supports at least the C++11 standard but have been updated to compile with `g++ -std=gnu++20`. This means that for any recent or even not so recent compiler, the above compilation line should suffice. One can even use a `g++` version as old as 4.9.3 with an ad hoc flag:

`g++ -std=c++11 -o Genepop *.cpp -O2`

but with versions of `g++` (>=6.0) or `clang++`, no version flag is required.

Past versions of this documentation specified `-03` instead of `-02`. `-03` may be fine for some compiler/system combinations, but not all.

### 2.1.3 Beyond the Genepop executable

The data files do not need to be in the same directory as the executable1; however, users might find that specifying path names under Windows is not as easy at it should.

Examples and documentation files are included in the R package and are available on the Genepop distribution page.

Linkdos, a program described by Garnier-Géré and Dillmann (1992), is distributed with (but is not part of) Genepop. It is originally a DOS program, but the source file distributed can be recompiled under Linux using the Free Pascal compiler (or at least ``could’’, since this is no longer maintained/checked).

## 2.2 Example sessions

To reproduce the examples of this session one should copy in a personal directory the examples files found in the `extdata/` subdirectory of the package or on the Genepop distribution page.

### 2.2.1 Example 1: basic session

Open a console window in the directory where Genepop has been installed and just execute

     Genepop

If Genepop has never been run before, it will ask for an input file. Otherwise, the main menu should appear, in which case you should use the `C` option to load this input file. For this sample session, the file name to be given is `sample.txt`. Genepop will display some information about the file read, then display the main menu:

    -------> Change Data ................... C

    Testing :
        Hardy-Weinberg exact tests (several options) ...................... 1
        Exact tests for genotypic disequilibrium (several options) ........ 2
        Exact tests for population differentiation (several options) ...... 3

    Estimating:
        Nm estimates (private allele method) .............................. 4
        Allele frequencies, various Fis and gene diversities .............. 5
        Fst & other correlations, isolation by distance (several options).. 6

    Ecumenicism and various utilities:
        Ecumenicism: file conversion (several options) .................... 7
        Null alleles and miscellaneous input file utilities ............... 8

    QUIT Genepop .......................................................... 9

    Your choice? :

Each option will be described later. Let us see some tests for heterozygote deficiency. Reply `1`, next `1`, next `y`(es). As indicated, the results of the analysis are stored in the file `sample.txt.D`.

The next example illustrates a slightly more elaborate use of Genepop.

### 2.2.2 Example 2: using the settings file

Execute

     Genepop settingsFile=SampleSettings.txt

Do not add spaces in the arguments. Capitalisation matters for file names (here `SampleSettings.txt`) if it matters for the operating system (i.e. for Linux).

You can see that the previous and additional analyses are performed, and that you just need to hit Return each time Genepop stops and waits for feedback. Finally, you are brought back to the main menu. Simple instructions for performing the analyses are contained in the `SampleSettings.txt` file, which you may edit. Section 4 will explain how to use this file. By default, Genepop seeks and eventually reads instructions in a `Genepop.txt` file. You can see that one such file is present and was thus read when performing Example 1.

### 2.2.3 Example 3: Batch processing

Execute the same command as in the previous example but with one more statement:

     Genepop settingsFile=SampleSettings.txt Mode=Batch

Genepop should perform the same computations as in the previous example but it will not stop and wait for feedback, and will exit after completion of the computations. Note again that spaces are not allowed within each of the arguments `settingsFile=SampleSettings.txt` and `Mode=Batch`, nor more generally in arguments specified on the command line. `Mode=Batch2File` is a variant of the batch mode that also removes some console outputs. It is suitable for use in running environments where the console output is redirected to a file.

The batch mode makes it easy to analyze multiple files. However, note that concurrent Genepop processes should be run in distinct directories. Otherwise, the temporary files of each process might conflict with each other.

1. …in contrast to earlier versions of Genepop.↩︎