# 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

Under Microsoft Windows, one only needs to unzip/copy the executable on hard disk. Both 32- and 64-bit versions of the executables are distributed. Under Linux/Mac OSX, extract all c++ sources from the distributed `sources.tar.gz` (or from the `src/` subdirectory of the R package sources, except `RcppExports.cpp`), and compile with a compiler that supports the C++11 standards. For Windows, one can use `g++` version 4.9.3 (distributed with recent versions of the R tools) with an ad hoc flag:

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

(`O` in `-O3` is the letter O, not zero). With more recent versions of `g++` (>=6.0) or `clang++`, no such flag is required:

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

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 packageor 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.↩︎