Skip to content

Commit

Permalink
docs: handle whitespace in blocks2hap example (#237)
Browse files Browse the repository at this point in the history
  • Loading branch information
aryarm authored Jan 14, 2024
1 parent 1ed9139 commit bbdacf8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions docs/api/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ examples

Converting a ``.blocks.det`` file into a ``.hap`` file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can use the :ref:`data API <api-data>` to easily convert `a PLINK 1.9 .blocks.det file <https://www.cog-genomics.org/plink/1.9/formats#blocks>`_ into a ``.hap`` file.
You can use the :ref:`data API <api-data>` to convert `a PLINK 1.9 .blocks.det file <https://www.cog-genomics.org/plink/1.9/formats#blocks>`_ into a ``.hap`` file.

As an example, let's say we would like to convert `the following .blocks.det file <https://github.com/cast-genomics/haptools/blob/main/tests/data/simple.blocks.det>`_.
As an example, let's say we would like to convert `the following simple.blocks.det file <https://github.com/cast-genomics/haptools/blob/main/tests/data/simple.blocks.det>`_.

.. include:: ../../tests/data/simple.blocks.det
:literal:
Expand All @@ -31,7 +31,7 @@ As an example, let's say we would like to convert `the following .blocks.det fil
for idx, line in enumerate(blocks_file.read().splitlines()[1:]):
# initialize variables and parse line from the blocks file
hap_id = f"H{idx}"
chrom, bp1, bp2, kb, nsnps, snps = line.split("\t")
chrom, bp1, bp2, kb, nsnps, snps = line.strip().split()
# create a haplotype line in the .hap file
hp.data[hap_id] = data.Haplotype(
Expand Down Expand Up @@ -72,7 +72,7 @@ Then your ``.hap`` file might look something like this.
.. include:: ../../tests/data/apoe.hap
:literal:

You can easily use the :ref:`data API <api-data>` and the :ref:`simphenotype API <api-haptools-sim_phenotype>` to create such a file.
You can use the :ref:`data API <api-data>` and the :ref:`simphenotype API <api-haptools-sim_phenotype>` to create such a file.

.. code-block:: python
Expand Down
2 changes: 1 addition & 1 deletion docs/commands/transform.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ transform

Transform a set of genotypes via a list of haplotypes. Create a new VCF containing haplotypes instead of variants.

The ``transform`` command takes as input a set of genotypes and a list of haplotypes and outputs a set of haplotype *pseudo-genotypes*, where each haplotype is encoded as a bi-allelic variant record in the output. In other words, each sample will have a genotype of ``0|0``, ``1|0``, ``0|1``, or ``1|1`` indicating whether each of their two chromosome copies contains the alleles of a haplotype.
The ``transform`` command takes as input a set of **phased** genotypes and a list of haplotypes and outputs a set of haplotype *pseudo-genotypes*, where each haplotype is encoded as a bi-allelic variant record in the output. In other words, each sample will have a genotype of ``0|0``, ``1|0``, ``0|1``, or ``1|1`` indicating whether each of their two chromosome copies contains the alleles of a haplotype.

.. figure:: https://drive.google.com/uc?id=1GyluoQ3IeGXo9FjWsCC3XwaRuflr68pn
:figwidth: 600
Expand Down
8 changes: 4 additions & 4 deletions tests/data/simple.blocks.det
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CHR BP1 BP2 KB NSNPS SNPS
1 10114 10117 2.001 2 1:10114:T:C|1:10116:A:G
1 10114 10119 2.007 2 1:10114:T:C|1:10117:C:A
1 10116 10119 2.011 2 1:10116:A:G|1:10117:C:A
CHR BP1 BP2 KB NSNPS SNPS
1 10114 10117 2.001 2 1:10114:T:C|1:10116:A:G
1 10114 10119 2.007 2 1:10114:T:C|1:10117:C:A
1 10116 10119 2.011 2 1:10116:A:G|1:10117:C:A
2 changes: 1 addition & 1 deletion tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2129,7 +2129,7 @@ def test_blocks2hap(self):
for idx, line in enumerate(blocks_file.read().splitlines()[1:]):
# initialize variables and parse line from the blocks file
hap_id = f"H{idx}"
chrom, bp1, bp2, kb, nsnps, snps = line.split("\t")
chrom, bp1, bp2, kb, nsnps, snps = line.strip().split()

# create a haplotype line in the .hap file
hp.data[hap_id] = Haplotype(
Expand Down

0 comments on commit bbdacf8

Please sign in to comment.