---
name: bio-small-rna-seq-target-prediction
description: Predict miRNA target genes using sequence-based algorithms and database lookups. Use when identifying potential mRNA targets of differentially expressed or functionally important miRNAs.
tool_type: mixed
primary_tool: miRanda
measurable_outcome: Execute skill workflow successfully with valid output within 15 minutes.
allowed-tools:
  - read_file
  - run_shell_command
---

<!--
# COPYRIGHT NOTICE
# This file is part of the "Universal Biomedical Skills" project.
# Copyright (c) 2026 MD BABU MIA, PhD <md.babu.mia@mssm.edu>
# All Rights Reserved.
#
# This code is proprietary and confidential.
# Unauthorized copying of this file, via any medium is strictly prohibited.
#
# Provenance: Authenticated by MD BABU MIA

-->


# miRNA Target Prediction

## miRanda Algorithm

```bash
# Run miRanda for target prediction
miranda miRNA.fa UTRs.fa \
    -sc 140 \
    -en -20 \
    -out predictions.txt

# Options:
# -sc 140: Minimum alignment score (default 140)
# -en -20: Maximum free energy threshold (kcal/mol)
# Higher score and lower energy = stronger prediction
```

## Parse miRanda Output

```python
import pandas as pd

def parse_miranda(output_file):
    '''Parse miRanda output file'''
    results = []
    with open(output_file) as f:
        for line in f:
            if line.startswith('>'):
                parts = line.strip().split('\t')
                if len(parts) >= 5:
                    results.append({
                        'mirna': parts[0].lstrip('>'),
                        'target': parts[1],
                        'score': float(parts[2]),
                        'energy': float(parts[3]),
                        'position': parts[4]
                    })
    return pd.DataFrame(results)
```

## TargetScan Database Lookup

```python
import requests
import pandas as pd

def query_targetscan(mirna_family):
    '''Query TargetScan for predicted targets

    Note: TargetScan uses miRNA family names (e.g., miR-21-5p)
    '''
    # TargetScan provides downloadable files
    # For human: https://www.targetscan.org/vert_80/vert_80_data_download/
    targetscan_file = 'Predicted_Targets_Context_Scores.txt'

    df = pd.read_csv(targetscan_file, sep='\t')
    targets = df[df['miRNA family'] == mirna_family]
    return targets.sort_values('context++ score')
```

## miRDB Database Lookup

```python
def query_mirdb(mirna_id):
    '''Query miRDB for target predictions

    miRDB uses machine learning for target prediction
    Score > 80 indicates high confidence
    '''
    # Download from http://mirdb.org/download.html
    mirdb_file = 'miRDB_v6.0_prediction_result.txt'

    df = pd.read_csv(mirdb_file, sep='\t', header=None,
                     names=['mirna', 'target', 'score'])
    targets = df[df['mirna'] == mirna_id]
    return targets[targets['score'] >= 80].sort_values('score', ascending=False)
```

## Combine Multiple Databases

```python
def consensus_targets(mirna, min_databases=2):
    '''Find targets predicted by multiple databases

    More reliable targets are predicted by multiple algorithms
    '''
    miranda_targets = set(query_miranda_targets(mirna))
    targetscan_targets = set(query_targetscan_targets(mirna))
    mirdb_targets = set(query_mirdb_targets(mirna))

    # Count predictions per target
    all_targets = miranda_targets | targetscan_targets | mirdb_targets
    consensus = []

    for target in all_targets:
        count = sum([
            target in miranda_targets,
            target in targetscan_targets,
            target in mirdb_targets
        ])
        if count >= min_databases:
            consensus.append({
                'target': target,
                'n_databases': count,
                'miranda': target in miranda_targets,
                'targetscan': target in targetscan_targets,
                'mirdb': target in mirdb_targets
            })

    return pd.DataFrame(consensus).sort_values('n_databases', ascending=False)
```

## Python miRNA Target Prediction

```python
# Using mirtarbase package for validated targets
def get_validated_targets(mirna):
    '''Get experimentally validated targets from miRTarBase'''
    # Download from https://mirtarbase.cuhk.edu.cn/
    mirtarbase_file = 'miRTarBase_MTI.xlsx'

    df = pd.read_excel(mirtarbase_file)
    validated = df[df['miRNA'] == mirna]
    return validated[['Target Gene', 'Experiments', 'Support Type']]
```

## Seed Match Analysis

```python
from Bio.Seq import Seq

def find_seed_matches(mirna_seq, utr_seq):
    '''Find seed matches in UTR sequence

    Seed region: positions 2-8 of miRNA (7-mer)
    '''
    mirna = Seq(mirna_seq)
    utr = Seq(utr_seq)

    # Get seed (positions 2-8, 0-indexed: 1-7)
    seed = str(mirna[1:8])
    seed_rc = str(Seq(seed).reverse_complement())

    matches = []
    start = 0
    while True:
        pos = str(utr).find(seed_rc, start)
        if pos == -1:
            break
        matches.append(pos)
        start = pos + 1

    return matches
```

## Functional Enrichment of Targets

```python
def enrich_target_genes(targets, background=None):
    '''Run GO enrichment on predicted target genes'''
    import gseapy as gp

    enr = gp.enrichr(
        gene_list=targets,
        gene_sets=['GO_Biological_Process_2021', 'KEGG_2021_Human'],
        organism='Human'
    )
    return enr.results
```

## Related Skills

- differential-mirna - Get DE miRNAs for target prediction
- pathway-analysis/go-enrichment - Enrich target gene functions
- database-access/entrez-fetch - Query biological databases


<!-- AUTHOR_SIGNATURE: 9a7f3c2e-MD-BABU-MIA-2026-MSSM-SECURE -->

---
Source attribution: GPTomics
Original project: https://github.com/GPTomics/bioSkills
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 FridrichMethod

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

---

NOTE ON BUNDLED CONTENT

This repository aggregates skills from multiple upstream projects (see the
README for the source list). Each `skills/<name>/` directory may carry its
own license inherited from its upstream source. The MIT license above
applies to this repository's curation and the scripts/workflows in `/`,
`/scripts/`, and `/.github/` — not to the upstream skill content itself.
Consult the upstream repository linked in the README and any LICENSE
file inside a skill directory before reusing skill content commercially.



# Mega AI Hub resource metadata

Creator / publisher: GPTomics
Original project: https://github.com/GPTomics/bioSkills
Attribution basis: Exact package in biomedical source index and publisher source table

Fields of work: Data & Analytics, Education & Research
Roles: Business Intelligence Analyst, Data Scientist, Researcher
Specialties: Backend, Database, Excel, Frontend
Tools: Targetscan, Mirdb, Miranda
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: c001cebc4899e760a2e7c8d9229ec6f6b484f5bbdd1a27699b263e81a9c6dd2b
Metadata reviewed: 2026-10-27
This metadata supersedes earlier Mega AI Hub catalog attribution. Original instruction and supporting files are preserved.
