Bio Restriction Mapping
Create restriction maps showing enzyme cut positions on DNA sequences using Biopython Bio.Restriction. Visualize cut sites, calculate distances between sites, and generate text or graphical maps. Use when creating or analyzing restriction maps.
Unsigned, install at your own risk
UnverifiedThis skill has no cryptographic signature attached. We can't verify the contents match what the publisher intended.
Install this skill
No account required. Pick your tool, or use the command that detects it for you.
Run in your terminal. It detects your AI tool.
npx @skills-hub-ai/cli install openclaw-medical-bio-restriction-mappingManual setup by platform
Claude Code
~/.claude/skills/openclaw-medical-bio-restriction-mapping/SKILL.md
Instructions
Restriction Mapping
Create Basic Restriction Map
from Bio import SeqIO
from Bio.Restriction import EcoRI, BamHI, HindIII, RestrictionBatch, Analysis
record = SeqIO.read('sequence.fasta', 'fasta')
seq = record.seq
batch = RestrictionBatch([EcoRI, BamHI, HindIII])
analysis = Analysis(batch, seq)
# Print formatted map
analysis.print_as('map')
Output Formats
# Map format (visual)
analysis.print_as('map')
# Linear format (list)
analysis.print_as('linear')
# Tabular format
analysis.print_as('tabulate')
# Get as string instead of printing
map_str = analysis.format_as('map')
linear_str = analysis.format_as('linear')
Calculate Distances Between Sites
from Bio.Restriction import EcoRI, BamHI
ecori_sites = EcoRI.search(seq)
bamhi_sites = BamHI.search(seq)
# All cut positions sorted
all_sites = sorted(ecori_sites + bamhi_sites)
# Calculate distances between consecutive sites
distances = []
for i in range(len(all_sites) - 1):
dist = all_sites[i + 1] - all_sites[i]
distances.append((all_sites[i], all_sites[i + 1], dist))
print(f'{all_sites[i]} -> {all_sites[i + 1]}: {dist} bp')
Create Detailed Restriction Map
from Bio import SeqIO
from Bio.Restriction import RestrictionBatch, Analysis
from Bio.Restriction import EcoRI, BamHI, HindIII, XhoI, NotI
record = SeqIO.read('plasmid.fasta', 'fasta')
seq = record.seq
seq_len = len(seq)
enzymes = RestrictionBatch([EcoRI, BamHI, HindIII, XhoI, NotI])
analysis = Analysis(enzymes, seq, linear=False)
print(f'Restriction Map: {record.id}')
print(f'Length: {seq_len} bp (circular)')
print('=' * 50)
results = analysis.full()
all_cuts = []
for enzyme, sites in results.items():
for site in sites:
all_cuts.append((site, str(enzyme)))
all_cuts.sort(key=lambda x: x[0])
print('\nCut sites (5\' -> 3\'):')
for pos, enz in all_cuts:
pct = (pos / seq_len) * 100
print(f' {pos:6d} bp ({pct:5.1f}%) - {enz}')
Text-Based Map Visualization
def draw_restriction_map(seq, results, width=80):
'''Draw a simple text restriction map'''
seq_len = len(seq)
scale = width / seq_len
# Header
print(f'0{" " * (width - 6)}{seq_len}')
print('|' + '-' * (width - 2) + '|')
# Plot each enzyme
for enzyme, sites in results.items():
if not sites:
continue
line = [' '] * width
for site in sites:
pos = int(site * scale)
if pos >= width:
pos = width - 1
line[pos] = '|'
print(''.join(line) + f' {enzyme}')
print('|' + '-' * (width - 2) + '|')
# Usage
batch = RestrictionBatch([EcoRI, BamHI, HindIII])
analysis = Analysis(batch, seq)
results = analysis.full()
draw_restriction_map(seq, results)
Map with GenBank Features
from Bio import SeqIO
from Bio.Restriction import RestrictionBatch, Analysis, EcoRI, BamHI
record = SeqIO.read('plasmid.gb', 'genbank')
seq = record.seq
enzymes = RestrictionBatch([EcoRI, BamHI])
analysis = Analysis(enzymes, seq, linear=False)
results = analysis.full()
print('Restriction Sites and Overlapping Features:')
print('=' * 60)
for enzyme, sites in results.items():
for site in sites:
print(f'\n{enzyme} at position {site}:')
for feature in record.features:
start = int(feature.location.start)
end = int(feature.location.end)
if start <= site <= end:
feat_type = feature.type
label = feature.qualifiers.get('label', feature.qualifiers.get('gene', ['unknown']))[0]
print(f' Within {feat_type}: {label} ({start}-{end})')
Export Map to File
def export_restriction_map(seq, results, output_file, seq_name='sequence'):
'''Export restriction map to text file'''
with open(output_file, 'w') as f:
f.write(f'Restriction Map: {seq_name}\n')
f.write(f'Length: {len(seq)} bp\n')
f.write('=' * 50 + '\n\n')
all_cuts = []
for enzyme, sites in results.items():
for site in sites:
all_cuts.append((site, str(enzyme)))
all_cuts.sort()
f.write('Site\tPosition\tFrom_Start\n')
for pos, enz in all_cuts:
f.write(f'{enz}\t{pos}\t{pos}\n')
f.write('\n\nFragment sizes between sites:\n')
if all_cuts:
positions = sorted([c[0] for c in all_cuts])
for i in range(len(positions) - 1):
size = positions[i + 1] - positions[i]
f.write(f'{positions[i]} -> {positions[i + 1]}: {size} bp\n')
# Usage
export_restriction_map(seq, results, 'restriction_map.txt', record.id)
Circular Map Coordinates
def circular_distances(sites, seq_len):
'''Calculate fragment sizes for circular DNA'''
if not sites:
return []
sites = sorted(sites)
fragments = []
# Between consecutive sites
for i in range(len(sites) - 1):
fragments.append(sites[i + 1] - sites[i])
# Wrap-around fragment
wrap = (seq_len - sites[-1]) + sites[0]
fragments.append(wrap)
return fragments
# Usage
ecori_sites = EcoRI.search(seq, linear=False)
fragments = circular_distances(ecori_sites, len(seq))
print(f'EcoRI fragments (circular): {fragments}')
Related Skills
- restriction-sites - Find where enzymes cut
- enzyme-selection - Choose enzymes for mapping
- fragment-analysis - Analyze fragment sizes
Security
Reviews (0)
Related skills
Browse all →More from OpenClaw Medical
View source →More Build skills
Browse category →Frequently asked questions about bio-restriction-mapping
What does the bio-restriction-mapping skill do?
Create restriction maps showing enzyme cut positions on DNA sequences using Biopython Bio.Restriction. Visualize cut sites, calculate distances between sites, and generate text or graphical maps. Use when creating or analyzing restriction maps. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.
How do I install the bio-restriction-mapping skill?
Run `npx @skills-hub-ai/cli install openclaw-medical-bio-restriction-mapping` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/openclaw-medical-bio-restriction-mapping/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.
Which AI tools does bio-restriction-mapping work with?
bio-restriction-mapping runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.
Is the bio-restriction-mapping skill free?
Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.
How do I use bio-restriction-mapping after installing it?
In Claude Code, type `/openclaw-medical-bio-restriction-mapping` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.
Can I share the bio-restriction-mapping skill with my team?
Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.