alphaVbeta3 / alphaVbeta3.py
thewall's picture
Upload alphaVbeta3.py
3d38773
import os
import json
from collections import OrderedDict
import datasets
logger = datasets.logging.get_logger(__name__)
_CITATION = """\
@article{10.1093/nar/gkaa484,
author = {Ishida, Ryoga and Adachi, Tatsuo and Yokota, Aya and Yoshihara, Hidehito and Aoki, Kazuteru and Nakamura, \
Yoshikazu and Hamada, Michiaki},
title = "{RaptRanker: in silico RNA aptamer selection from HT-SELEX experiment based on local sequence and \
structure information}",
journal = {Nucleic Acids Research},
volume = {48},
number = {14},
pages = {e82-e82},
year = {2020},
month = {06},
abstract = "{Aptamers are short single-stranded RNA/DNA molecules that bind to specific target molecules. \
Aptamers with high binding-affinity and target specificity are identified using an in vitro procedure called \
high throughput systematic evolution of ligands by exponential enrichment (HT-SELEX). However, the development \
of aptamer affinity reagents takes a considerable amount of time and is costly because HT-SELEX produces a large \
dataset of candidate sequences, some of which have insufficient binding-affinity. Here, we present RNA aptamer \
Ranker (RaptRanker), a novel in silico method for identifying high binding-affinity aptamers from HT-SELEX data by \
scoring and ranking. RaptRanker analyzes HT-SELEX data by evaluating the nucleotide sequence and secondary \
structure simultaneously, and by ranking according to scores reflecting local structure and sequence frequencies. \
To evaluate the performance of RaptRanker, we performed two new HT-SELEX experiments, and evaluated \
binding affinities of a part of sequences that include aptamers with low binding-affinity. In both datasets, \
the performance of RaptRanker was superior to Frequency, Enrichment and MPBind. We also confirmed that \
the consideration of secondary structures is effective in HT-SELEX data analysis, and that RaptRanker \
successfully predicted the essential subsequence motifs in each identified sequence.}",
issn = {0305-1048},
doi = {10.1093/nar/gkaa484},
url = {https://doi.org/10.1093/nar/gkaa484},
eprint = {https://academic.oup.com/nar/article-pdf/48/14/e82/34130937/gkaa484.pdf},
}
"""
_DESCRIPTION = """\
PRJDB9111
https://www.ebi.ac.uk/ena/browser/view/PRJDB9111
To generate RNA aptamers against human integrin alphaV beta3, we have performed the high-throughput systematic evolution \
of ligands by exponential enrichment (HT-SELEX). Of the six performed rounds, the rounds 3 to 6 have been sequenced.
"""
_URL = "https://ftp.sra.ebi.ac.uk/vol1/fastq/DRR201"
_URLS = {
"round_3": "/".join([_URL, "DRR201870/DRR201870.fastq.gz"]),
"round_4": "/".join([_URL, "DRR201871/DRR201871.fastq.gz"]),
"round_5": "/".join([_URL, "DRR201872/DRR201872.fastq.gz"]),
"round_6": "/".join([_URL, "DRR201873/DRR201873.fastq.gz"]),
}
_FORWARD_PRIMER = "CGGAATTCTAATACGACTCACTATAGGGAGAACTTCGACCAGAA"
_FORWARD_PRIMER = "TAATACGACTCACTATAGGGAGAACTTCGACCAGAAG"
_REVERSE_PRIMER = "TATGTGCGCATACATGGATCCTC"
_DESIGN_LENGTH = 40
"""
"forward_primer":"TAATACGACTCACTATAGGGAGAACTTCGACCAGAAG",
"reverse_primer": "TATGTGCGCATACATGGATCCTC",
"add_forward_primer": "GGGAGAACTTCGACCAGAAG",
"add_reverse_primer": "TATGTGCGCATACATGGATCCTC",
"""
class AlphaVBeta3Config(datasets.BuilderConfig):
"""BuilderConfig for SQUAD."""
def __init__(self, url, adapter_match=True, length_match=True, remove_primer=True, **kwargs):
"""BuilderConfig for SQUAD.
Args:
**kwargs: keyword arguments forwarded to super.
"""
super(AlphaVBeta3Config, self).__init__(**kwargs)
self.url = url
self.adapter_match = adapter_match
self.length_match = length_match
self.remove_primer = remove_primer
class AlphaVBeta3(datasets.GeneratorBasedBuilder):
"""SQUAD: The Stanford Question Answering Dataset. Version 1.1."""
BUILDER_CONFIGS = [
AlphaVBeta3Config(name=key, url=_URLS[key]) for key in _URLS
]
DEFAULT_CONFIG_NAME = "round_4"
def _info(self):
return datasets.DatasetInfo(
description=_DESCRIPTION,
features=datasets.Features(
{
"id": datasets.Value("int32"),
"identifier": datasets.Value("string"),
"seq": datasets.Value("string"),
"count": datasets.Value("int32"),
}
),
homepage="https://www.ebi.ac.uk/ena/browser/view/PRJDB9111",
citation=_CITATION,
)
def _split_generators(self, dl_manager):
downloaded_files = dl_manager.download_and_extract(self.config.url)
return [
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files}),
]
def _generate_examples(self, filepath):
"""This function returns the examples in the raw (text) form."""
logger.info("generating examples from = %s", filepath)
key = 0
data = OrderedDict()
with open(filepath, encoding="utf-8") as f:
ans = {"id": key, "count": 1}
for i, line in enumerate(f):
if line.startswith("@") and i%4==0:
ans["identifier"] = line[1:].split()[0].strip()
elif i%4==1:
ans["seq"] = line.strip()
if self.filter_fn(ans):
if ans['seq'] in data:
data[ans['seq']]['count'] += 1
else:
data[ans['seq']] = ans
key += 1
ans = {"id": key, "count": 1}
for item in data.values():
yield item['id'], item
def filter_fn(self, example):
seq = example["seq"]
if self.config.adapter_match:
if not seq.startswith(_FORWARD_PRIMER) or not seq.endswith(_REVERSE_PRIMER):
return False
if self.config.length_match:
if len(seq)!=_DESIGN_LENGTH+len(_FORWARD_PRIMER)+len(_REVERSE_PRIMER):
return False
if self.config.remove_primer:
example["seq"] = seq[len(_FORWARD_PRIMER):len(seq)-len(_REVERSE_PRIMER)]
return True
if __name__=="__main__":
from datasets import load_dataset
dataset = load_dataset("alphaVbeta3.py", split="all")