Skip to content

Commit 1ebc6ea

Browse files
committed
first commit
0 parents  commit 1ebc6ea

10 files changed

Lines changed: 225 additions & 0 deletions

.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Byte-compiled / optimized files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# Distribution / packaging
7+
dist/
8+
build/
9+
*.egg-info/
10+
11+
# Environment and virtualenv files
12+
.env
13+
.env.*
14+
venv/
15+
virtualenv/
16+
*.venv
17+
18+
# Testing and coverage files
19+
.coverage
20+
.tox/
21+
htmlcov/
22+
23+
# IDE-specific files and directories
24+
.idea/
25+
.vscode/
26+
*.pydevproject
27+
*.pydevworkspace
28+
29+
# Editor-specific files
30+
*~
31+
*.swp
32+
33+
# OS-specific files
34+
.DS_Store
35+
Thumbs.db
36+
37+
38+
setup.py
39+
dist/*
40+
build/*
41+
42+
dist/
43+
build/
44+
*.egg-info/
45+
__pycache__/
46+
*.pyc

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Md. Ismiel Hossen Abir
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

QCBio/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from .fasta_reader import read_fasta
2+
from .seq_reverser import reverse_complement
3+
from .simple_translator import translate_dna
4+
from .gc_calculator import gc_content
5+
from .motif_finder import find_motif
6+
from .random_dna_gen import generate_random_dna

QCBio/fasta_reader.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def read_fasta(file_path):
2+
sequences = {}
3+
with open(file_path, 'r') as f:
4+
header = None
5+
seq = ''
6+
for line in f:
7+
line = line.strip()
8+
if line.startswith('>'):
9+
if header:
10+
sequences[header] = seq
11+
header = line[1:]
12+
seq = ''
13+
else:
14+
seq += line
15+
if header:
16+
sequences[header] = seq
17+
return sequences

QCBio/gc_calculator.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def gc_content(seq):
2+
gc_count = sum(1 for base in seq.upper() if base in "GC")
3+
return (gc_count / len(seq)) * 100 if seq else 0

QCBio/motif_finder.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
def find_motif(seq, motif):
2+
positions = []
3+
seq = seq.upper()
4+
motif = motif.upper()
5+
for i in range(len(seq) - len(motif) + 1):
6+
if seq[i:i+len(motif)] == motif:
7+
positions.append(i + 1)
8+
return positions

QCBio/random_dna_gen.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import random
2+
3+
def generate_random_dna(length):
4+
return ''.join(random.choices('ATCG', k=length))

QCBio/seq_reverser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def reverse_complement(seq):
2+
complement = str.maketrans('ATCGatcg', 'TAGCtagc')
3+
return seq.translate(complement)[::-1]

QCBio/simple_translator.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
codon_table = {
2+
'ATA':'I', 'ATC':'I', 'ATT':'I', 'ATG':'M',
3+
'ACA':'T', 'ACC':'T', 'ACG':'T', 'ACT':'T',
4+
'AAC':'N', 'AAT':'N', 'AAA':'K', 'AAG':'K',
5+
'AGC':'S', 'AGT':'S', 'AGA':'R', 'AGG':'R',
6+
'CTA':'L', 'CTC':'L', 'CTG':'L', 'CTT':'L',
7+
'CCA':'P', 'CCC':'P', 'CCG':'P', 'CCT':'P',
8+
'CAC':'H', 'CAT':'H', 'CAA':'Q', 'CAG':'Q',
9+
'CGA':'R', 'CGC':'R', 'CGG':'R', 'CGT':'R',
10+
'GTA':'V', 'GTC':'V', 'GTG':'V', 'GTT':'V',
11+
'GCA':'A', 'GCC':'A', 'GCG':'A', 'GCT':'A',
12+
'GAC':'D', 'GAT':'D', 'GAA':'E', 'GAG':'E',
13+
'GGA':'G', 'GGC':'G', 'GGG':'G', 'GGT':'G',
14+
'TCA':'S', 'TCC':'S', 'TCG':'S', 'TCT':'S',
15+
'TTC':'F', 'TTT':'F', 'TTA':'L', 'TTG':'L',
16+
'TAC':'Y', 'TAT':'Y', 'TAA':'_', 'TAG':'_',
17+
'TGC':'C', 'TGT':'C', 'TGA':'_', 'TGG':'W',
18+
}
19+
20+
def translate_dna(seq):
21+
protein = ''
22+
for i in range(0, len(seq)-2, 3):
23+
codon = seq[i:i+3].upper()
24+
protein += codon_table.get(codon, 'X')
25+
return protein

README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# QCBio
2+
3+
**QCBio** is a lightweight Python package offering 6 essential bioinformatics utilities.
4+
It is designed for quick sequence operations, small analyses, and everyday bioinformatics tasks.
5+
6+
---
7+
8+
## Features
9+
10+
- **FASTA Reader**: Parse FASTA files into Python dictionaries.
11+
- **Reverse Complement**: Get the reverse complement of DNA or RNA sequences.
12+
- **DNA Translator**: Translate DNA sequences into protein.
13+
- **GC Content Calculator**: Calculate GC percentage of a sequence.
14+
- **Motif Finder**: Find positions of motifs (subsequences) inside sequences.
15+
- **Random DNA Generator**: Create random DNA sequences of desired length.
16+
17+
---
18+
19+
## Installation
20+
21+
You can install QCBio via pip once it's uploaded:
22+
23+
```bash
24+
pip install QCBio
25+
```
26+
27+
28+
# Usage
29+
## 1. FASTA Reader
30+
```bash
31+
from QCBio import read_fasta
32+
33+
sequences = read_fasta("example.fasta")
34+
print(sequences)
35+
```
36+
37+
## 2. Reverse Complement
38+
39+
```bash
40+
from QCBio import reverse_complement
41+
42+
seq = "ATCG"
43+
rc = reverse_complement(seq)
44+
print(rc)
45+
```
46+
47+
## 3. DNA Translator
48+
49+
```bash
50+
from QCBio import translate_dna
51+
52+
dna_seq = "ATGGCCATTGTAATGGGCCGCTGAAAGGGTGCCCGATAG"
53+
protein = translate_dna(dna_seq)
54+
print(protein)
55+
```
56+
57+
58+
## 4. GC Content Calculator
59+
60+
```bash
61+
from QCBio import gc_content
62+
63+
seq = "ATGCGC"
64+
gc_percentage = gc_content(seq)
65+
print(f"GC Content: {gc_percentage:.2f}%")
66+
67+
```
68+
69+
70+
71+
## 5. Motif Finder
72+
73+
```bash
74+
from QCBio import find_motif
75+
76+
seq = "ATGCGCGTAGCGC"
77+
motif = "GCG"
78+
positions = find_motif(seq, motif)
79+
print(positions)
80+
```
81+
82+
83+
## 6. Random DNA Generator
84+
85+
```bash
86+
from QCBio import generate_random_dna
87+
88+
random_seq = generate_random_dna(50)
89+
print(random_seq)
90+
91+
92+
```

0 commit comments

Comments
 (0)