From a19bee6fba091247470dd15466e013a8142c031a Mon Sep 17 00:00:00 2001 From: Louis-Philippe Lemieux Perreault Date: Fri, 24 Mar 2017 13:55:57 -0400 Subject: [PATCH 1/3] New script to build pyplink for conda --- conda_build.sh | 78 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 11 deletions(-) diff --git a/conda_build.sh b/conda_build.sh index 8f04ac9..bc1ba79 100755 --- a/conda_build.sh +++ b/conda_build.sh @@ -1,28 +1,84 @@ -#!/usr/bin/env bash +#!/bin/bash -x + +# Getting pyplink's version to build +pyplink_version=$1 +if [ -z $pyplink_version ]; then + (>&2 echo "usage: $0 VERSION PYTHON_VERSION") + exit 1 +fi + +# Getting the version of python we want to build for +python_version=$2 +if [ -z $python_version ]; then + (>&2 echo "usage: $0 VERSION PYTHON_VERSION") + exit 1 +fi + +# Creating a directory for the build module +mkdir -p conda_dist # Creating a directory for the skeleton mkdir -p skeleton pushd skeleton # Creating the skeleton -conda skeleton pypi pyplink +conda skeleton pypi pyplink --version $pyplink_version -# The different python versions and platforms -python_versions="2.7 3.3 3.4 3.5 3.6" +# Checking that fetching pyplink was successful +if [ $? -ne 0 ]; then + (>&2 echo "Error when creating skeleton for pyplink version $pyplink_version") + exit 1 +fi + +# The different python versions build +if [ "$python_version" == "2" ]; then + python_versions="2.7" +elif [ "$python_version" == "3" ]; then + python_versions="3.3 3.4 3.5 3.6" +else + (>&2 echo "$python_version: invalid Python version") + exit 1 +fi + +# The different build platforms platforms="all" # Building -for python_version in $python_versions -do +for python_build_version in $python_versions; do # Building - conda build --python $python_version pyplink &> log.txt - filename=$(egrep "^# [$] anaconda upload \S+$" log.txt | cut -d " " -f 5) + conda build --python $python_build_version pyplink &> log.txt + + # Checking the build was completed + if [ $? -ne 0 ]; then + cat log.txt + (>&2 echo "Error when building pyplink $pyplink_version (python $python_build_version)") + exit 1 + fi - # Converting - for platform in $platforms - do + # Fetching the file name of the build + filename=$(grep -oP "anaconda upload \K(\S+)$" log.txt) + + # Checking the file exists + if [ -z $filename ]||[ ! -e $filename ]; then + echo "Problem fetching file $filename" 1>&2 + exit 1 + fi + + # Converting to the different platforms + for platform in $platforms; do conda convert -p $platform $filename -o ../conda_dist + + # Checking the conversion was completed + if [ $? -ne 0 ]; then + (>&2 echo "Problem converting pyplink $pyplink_version (python $python_build_version) to $platform") + exit 1 + fi + done + + # Purging + conda build purge + done popd From 593f7ed242606873e8d2795057dcc3459ae99ad0 Mon Sep 17 00:00:00 2001 From: Louis-Philippe Lemieux Perreault Date: Fri, 24 Mar 2017 13:56:59 -0400 Subject: [PATCH 2/3] Now returns a dictionary of duplicated markers (original marker name -> list of marker names) instead of just a set --- pyplink/pyplink.py | 12 ++++++++++-- pyplink/tests/test_pyplink.py | 8 +++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pyplink/pyplink.py b/pyplink/pyplink.py index 932d6c5..b44af26 100644 --- a/pyplink/pyplink.py +++ b/pyplink/pyplink.py @@ -251,7 +251,12 @@ def _read_bim(self): duplicated = bim.snp.duplicated(keep=False) duplicated_markers = bim.loc[duplicated, "snp"] duplicated_marker_counts = duplicated_markers.value_counts() - self._dup_markers = set(duplicated_marker_counts.index) + + # The dictionary that will contain information about the duplicated + # markers + self._dup_markers = { + m: [] for m in duplicated_marker_counts.index + } # Logging a warning logger.warning("Duplicated markers found") @@ -267,6 +272,9 @@ def _read_bim(self): new_name = "{}:dup{}".format(marker, counter[marker]) bim.loc[i, "snp"] = new_name + # Updating the dictionary containing the duplicated markers + self._dup_markers[marker].append(new_name) + # Resetting the index bim = bim.set_index("snp", verify_integrity=True) @@ -320,7 +328,7 @@ def get_duplicated_markers(self): if self._has_duplicated: return self._dup_markers else: - return set() + return {} def _read_fam(self): """Reads the FAM file.""" diff --git a/pyplink/tests/test_pyplink.py b/pyplink/tests/test_pyplink.py index afee1d0..f5ccce5 100644 --- a/pyplink/tests/test_pyplink.py +++ b/pyplink/tests/test_pyplink.py @@ -1129,10 +1129,12 @@ def test_dup_markers(self, pyplink_logger): np.testing.assert_array_equal(geno, self.genotypes[i]) # Checking the list of duplicated markers - self.assertEqual( - set(m.split(":")[0] for m in markers if ":" in m), - pedfile.get_duplicated_markers(), + expected_dup = dict( + rs2949420=["rs2949420:dup1", "rs2949420:dup2"], + rs4030303=["rs4030303:dup1", "rs4030303:dup2", "rs4030303:dup3"], + rs940550=["rs940550:dup1", "rs940550:dup2"], ) + self.assertEqual(expected_dup, pedfile.get_duplicated_markers()) # Closing the file pedfile.close() From 949f093ce63e1fb1a6b7fe508d889a18168b6891 Mon Sep 17 00:00:00 2001 From: Louis-Philippe Lemieux Perreault Date: Fri, 24 Mar 2017 14:02:43 -0400 Subject: [PATCH 3/3] Preparing for next release --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 37b9edf..e09bd84 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ MAJOR = 1 MINOR = 3 -MICRO = 3 +MICRO = 4 VERSION = "{}.{}.{}".format(MAJOR, MINOR, MICRO)