Code Monkey home page Code Monkey logo

snprimer's Introduction

SNPrimer

Small python library to search snp in primer by position or by sequence.

Installation

pip install snprimer

Usage

🎯 By position 🎯

from snprimer import PositionRange

position = PositionRange("chr8",19818430, 19818440)
print(position)
# PositionRange(chr='chr8', start=19818430, end=19818440, strand=None, snp=[SNP(id='chr8:g.19818436C>G', rsid='rs316', vaf=0.15300000000000002), SNP(id='chr8:g.19818436C>T', rsid='rs316', vaf=0.15300000000000002)])
for snp in position.get_snp(max_vaf=0.05):
    print(snp)
#SNP(id='chr8:g.19818436C>G', rsid='rs316', vaf=0.15300000000000002)
#SNP(id='chr8:g.19818436C>T', rsid='rs316', vaf=0.15300000000000002)

🔤 By sequence 🔤

from snprimer import Primer

primer = Primer("CACACAGATCAGAGGGCCAAC")
print(primer)
#Primer(seq='CACACAGATCAGAGGGCCAAC', position_ranges=[PositionRange(chr='chr1', start=26774827, end=26774847, strand='+', snp=[SNP(id='chr1:g.26774827G>A', rsid='rs2075289787', vaf=0), SNP(id='chr1:g.26774830A>G', rsid='rs986550282', vaf=0.0), SNP(id='chr1:g.26774842T>C', rsid='rs1440652363', vaf=0.0)])])

🖥️In silico PCR🖥️

from pathlib import Path
from snprimer import Primer, PrimerPair

a = Primer("GGAGATGTACAGCGTGCCATAC", "hg19")
b = Primer("TACATCTTGCTGAGGGGAAGGC", "hg19")
pp = PrimerPair(a, b)
pcr = pp.make_pcr(Path('/path/to/hg19.fa'))
print(pcr)

Design

from snprimer import PrimerMaker, PositionRange
from pathlib import Path
seq_args = {
        }
global_args = {
        "PRIMER_EXPLAIN_FLAG": 1,
        "PRIMER_MAX_END_STABILITY": 9.0,
        "PRIMER_MAX_LIBRARY_MISPRIMING": 18.00,
        "PRIMER_PAIR_MAX_LIBRARY_MISPRIMING": 50.00,
        "PRIMER_MIN_SIZE": 17,
        "PRIMER_OPT_SIZE": 22,
        "PRIMER_MAX_SIZE": 27,
        "PRIMER_MIN_TM": 58,
        "PRIMER_OPT_TM": 61,
        "PRIMER_MAX_TM": 63,
        "PRIMER_MAX_DIFF_TM": 100,
        "PRIMER_MIN_GC": 20,
        "PRIMER_MAX_GC": 80,
        "PRIMER_SELF_END": 9.00,
        "PRIMER_MAX_POLY_X": 5,
        "PRIMER_GC_CLAMP": 0,
        "PRIMER_PRODUCT_SIZE_RANGE": [[70, 160]],
    }
position_range = PositionRange("chr1",27100919,27100919)
ref_fasta = Path("/path/to/fasta")
print(PrimerMaker(ref_fasta,
                  seq_args, global_args).get_primers(position_range)[0]
      .make_pcr(ref_fasta))
#[>chr1:27100876-27100999
#GGAGATGTACAGCGTGCCATACAGCACTGGGCAGGGGCAGCCTCAGCAGCAGCAGTTGCCCCCAGCCCAGCCCCAGCCTGCCAGCCAGCAACAAGCTGCCCAGCCTTCCCCTCAGCAAGATGTA]

CLI

You can also use SNPrimer in cli with two options :

  • check will check the presence of snp in a position range
  • pcr will make the insilico pcr

Installation

git clone [email protected]:Benoitdw/SNPrimer.git
cd SNPrimer
python -m venv venv # recommended work in a virtual environment
source venv/bin/activate # Recommended activate the virtual environment


poetry install
# OR pip install .

🎯 Check 🎯

Usage: main.py check [OPTIONS] POSITION_FILE [OUTPUT]

Options:
  --vaf FLOAT  minimum snp vaf to report

python main.py check --vaf 0.00 tests/files/position.tsv tests/files/output_position.tsv

will produce the output_position.tsv file you can see in tests/files directory

TODO

[] Remake cli [] Custom blast [] cross primer hybridization [] Better unit tests

snprimer's People

Contributors

benoitdw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.