Skip to content

Commit

Permalink
Merge pull request #3 from refgenie/dev
Browse files Browse the repository at this point in the history
Release 0.2.0
  • Loading branch information
nsheff authored Feb 14, 2024
2 parents 3a362e8 + 9f4fc0d commit e0cac24
Show file tree
Hide file tree
Showing 48 changed files with 1,559 additions and 964 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Lint

on: [pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: psf/black@stable
15 changes: 8 additions & 7 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@ jobs:
deploy:

runs-on: ubuntu-latest

name: upload release to PyPI
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

21 changes: 21 additions & 0 deletions .github/workflows/run-codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Run codecov

on:
pull_request:
branches: [master]

jobs:
pytest:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.9]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v2
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
file: ./coverage.xml
name: py-${{ matrix.python-version }}-${{ matrix.os }}
30 changes: 30 additions & 0 deletions .github/workflows/run-pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Run pytests

on:
pull_request:
branches: [master, dev]

jobs:
pytest:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8", "3.11"]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install test dependencies
run: if [ -f requirements/requirements-test.txt ]; then pip install -r requirements/requirements-test.txt; fi

- name: Install package
run: python -m pip install .

- name: Run pytest tests
run: pytest tests -x -vv --cov=./ --cov-report=xml
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,12 @@ open_pipelines/
*RESERVE*

# Build-related stuff
build
dist/
refget.egg-info/

#ipynm checkpoints
*ipynb_checkpoints*
*.egg-info*


17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2017 Nathan Sheffield
Copyright 2024 Nathan Sheffield

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

[![Build Status](https://travis-ci.com/refgenie/refget.svg?branch=master)](https://travis-ci.com/refgenie/refget)

The refget package provides a Python interface to both remote and local use of the refget protocol.
The refget package provides a Python interface to both remote and local use of the refget protocol.

Documentation is hosted at [refget.databio.org](http://refget.databio.org).
This package provides clients and functions for both refget sequences and refget sequence collections (seqcol).

Documentation is hosted at [refgenie.org/refget](https://refgenie.org/refget/).
55 changes: 55 additions & 0 deletions array_overlap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# from itertools import compress
# from collections import Counter
# overlap = sum((Counter(A) & Counter(B)).values())
# A=example1
# B=example4
# overlap
# all = list(A) + list(set(B) - set(list(A)))
# A_compressed = list(compress(A, B))
# B_compressed = list(compress(B, A))
# A_filtered = list(filter(lambda x: x in B, A))
# B_filtered = list(filter(lambda x: x in A, B))
# len(A_compressed) == len(B_compressed)
# C_compressed = list(compress(C, A))

# from itertools import filter


def array_overlap(A, B):
A_filtered = list(filter(lambda x: x in B, A))
B_filtered = list(filter(lambda x: x in A, B))
A_count = len(A_filtered)
B_count = len(B_filtered)
overlap = min(len(A_filtered), len(B_filtered))
if A_count + B_count < 1:
# order match requires at least 2 matching elements
order = None
elif not (A_count == B_count):
# duplicated matches means order match is undefined
order = None
else:
order = A_filtered == B_filtered
return {"overlap": overlap, "order-match": order}


example1 = ["A", "B", "C", "D"]
example2 = ["A", "B", "C"]
example3 = ["A", "B", "C", "B"]
example4 = ["B", "B", "B", "B"]
example5 = ["X", "A", "B", "Y", "C", "D", "E"]
example6 = ["A", "B", "C", "D", "B"]
example7 = ["A", "B", "C", "D", "A"]
example8 = ["A", "B", "C", "D", "B", "A"]


compatoverlap(example1, example2)
compatoverlap(example1, example3)
compatoverlap(example2, example3)
compatoverlap(example1, example4)
compatoverlap(example1, example5)
compatoverlap(example3, example5)
compatoverlap(example5, example3)
compatoverlap(example3, example6)
compatoverlap(example6, example7)
compatoverlap(example7, example8)
compatoverlap(example8, example8)
38 changes: 38 additions & 0 deletions demo_fasta/compare-0vs1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"array_elements":{
"a":{
"lengths":3,
"names":3,
"sequences":3,
"sorted_name_length_pairs":3
},
"a_and_b":{
"lengths":2,
"names":2,
"sequences":0,
"sorted_name_length_pairs":2
},
"a_and_b_same_order":{
"lengths":true,
"names":true,
"sequences":null,
"sorted_name_length_pairs":true
},
"b":{
"lengths":2,
"names":2,
"sequences":2,
"sorted_name_length_pairs":2
}
},
"attributes":{
"a_and_b":[
"lengths",
"names",
"sequences",
"sorted_name_length_pairs"
],
"a_only":[],
"b_only":[]
}
}
38 changes: 38 additions & 0 deletions demo_fasta/compare-1vs1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"array_elements":{
"a":{
"lengths":2,
"names":2,
"sequences":2,
"sorted_name_length_pairs":2
},
"a_and_b":{
"lengths":2,
"names":2,
"sequences":2,
"sorted_name_length_pairs":2
},
"a_and_b_same_order":{
"lengths":true,
"names":true,
"sequences":true,
"sorted_name_length_pairs":true
},
"b":{
"lengths":2,
"names":2,
"sequences":2,
"sorted_name_length_pairs":2
}
},
"attributes":{
"a_and_b":[
"lengths",
"names",
"sequences",
"sorted_name_length_pairs"
],
"a_only":[],
"b_only":[]
}
}
38 changes: 38 additions & 0 deletions demo_fasta/compare-5vs6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"array_elements":{
"a":{
"lengths":3,
"names":3,
"sequences":3,
"sorted_name_length_pairs":3
},
"a_and_b":{
"lengths":3,
"names":3,
"sequences":3,
"sorted_name_length_pairs":3
},
"a_and_b_same_order":{
"lengths":false,
"names":false,
"sequences":false,
"sorted_name_length_pairs":true
},
"b":{
"lengths":3,
"names":3,
"sequences":3,
"sorted_name_length_pairs":3
}
},
"attributes":{
"a_and_b":[
"lengths",
"names",
"sequences",
"sorted_name_length_pairs"
],
"a_only":[],
"b_only":[]
}
}
6 changes: 6 additions & 0 deletions demo_fasta/demo0.fa
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
>chrX
TTGGGGAA
>chr1
GGAA
>chr2
GCGC
3 changes: 3 additions & 0 deletions demo_fasta/demo0.fa.fai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
chrX 8 6 8 9
chr1 4 21 4 5
chr2 4 32 4 5
2 changes: 2 additions & 0 deletions demo_fasta/demo1.fa.fai
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
chr1 4 6 4 5
chr2 4 17 4 5
Binary file added demo_fasta/demo1.fa.gz
Binary file not shown.
Binary file added demo_fasta/demo5.fa.gz
Binary file not shown.
6 changes: 6 additions & 0 deletions demo_fasta/demo6.fa
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
>chrX
TTGGGGAA
>chr1
GGAA
>chr2
GCGC
3 changes: 3 additions & 0 deletions demo_fasta/demo6.fa.fai
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
chrX 8 6 8 9
chr1 4 21 4 5
chr2 4 32 4 5
Loading

0 comments on commit e0cac24

Please sign in to comment.