thewall commited on
Commit
3d38773
·
1 Parent(s): 84ccf15

Upload alphaVbeta3.py

Browse files
Files changed (1) hide show
  1. alphaVbeta3.py +155 -0
alphaVbeta3.py ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ from collections import OrderedDict
4
+ import datasets
5
+
6
+
7
+ logger = datasets.logging.get_logger(__name__)
8
+
9
+
10
+ _CITATION = """\
11
+ @article{10.1093/nar/gkaa484,
12
+ author = {Ishida, Ryoga and Adachi, Tatsuo and Yokota, Aya and Yoshihara, Hidehito and Aoki, Kazuteru and Nakamura, \
13
+ Yoshikazu and Hamada, Michiaki},
14
+ title = "{RaptRanker: in silico RNA aptamer selection from HT-SELEX experiment based on local sequence and \
15
+ structure information}",
16
+ journal = {Nucleic Acids Research},
17
+ volume = {48},
18
+ number = {14},
19
+ pages = {e82-e82},
20
+ year = {2020},
21
+ month = {06},
22
+ abstract = "{Aptamers are short single-stranded RNA/DNA molecules that bind to specific target molecules. \
23
+ Aptamers with high binding-affinity and target specificity are identified using an in vitro procedure called \
24
+ high throughput systematic evolution of ligands by exponential enrichment (HT-SELEX). However, the development \
25
+ of aptamer affinity reagents takes a considerable amount of time and is costly because HT-SELEX produces a large \
26
+ dataset of candidate sequences, some of which have insufficient binding-affinity. Here, we present RNA aptamer \
27
+ Ranker (RaptRanker), a novel in silico method for identifying high binding-affinity aptamers from HT-SELEX data by \
28
+ scoring and ranking. RaptRanker analyzes HT-SELEX data by evaluating the nucleotide sequence and secondary \
29
+ structure simultaneously, and by ranking according to scores reflecting local structure and sequence frequencies. \
30
+ To evaluate the performance of RaptRanker, we performed two new HT-SELEX experiments, and evaluated \
31
+ binding affinities of a part of sequences that include aptamers with low binding-affinity. In both datasets, \
32
+ the performance of RaptRanker was superior to Frequency, Enrichment and MPBind. We also confirmed that \
33
+ the consideration of secondary structures is effective in HT-SELEX data analysis, and that RaptRanker \
34
+ successfully predicted the essential subsequence motifs in each identified sequence.}",
35
+ issn = {0305-1048},
36
+ doi = {10.1093/nar/gkaa484},
37
+ url = {https://doi.org/10.1093/nar/gkaa484},
38
+ eprint = {https://academic.oup.com/nar/article-pdf/48/14/e82/34130937/gkaa484.pdf},
39
+ }
40
+ """
41
+
42
+ _DESCRIPTION = """\
43
+ PRJDB9111
44
+ https://www.ebi.ac.uk/ena/browser/view/PRJDB9111
45
+ To generate RNA aptamers against human integrin alphaV beta3, we have performed the high-throughput systematic evolution \
46
+ of ligands by exponential enrichment (HT-SELEX). Of the six performed rounds, the rounds 3 to 6 have been sequenced.
47
+ """
48
+
49
+ _URL = "https://ftp.sra.ebi.ac.uk/vol1/fastq/DRR201"
50
+ _URLS = {
51
+ "round_3": "/".join([_URL, "DRR201870/DRR201870.fastq.gz"]),
52
+ "round_4": "/".join([_URL, "DRR201871/DRR201871.fastq.gz"]),
53
+ "round_5": "/".join([_URL, "DRR201872/DRR201872.fastq.gz"]),
54
+ "round_6": "/".join([_URL, "DRR201873/DRR201873.fastq.gz"]),
55
+ }
56
+
57
+ _FORWARD_PRIMER = "CGGAATTCTAATACGACTCACTATAGGGAGAACTTCGACCAGAA"
58
+ _FORWARD_PRIMER = "TAATACGACTCACTATAGGGAGAACTTCGACCAGAAG"
59
+
60
+ _REVERSE_PRIMER = "TATGTGCGCATACATGGATCCTC"
61
+ _DESIGN_LENGTH = 40
62
+
63
+ """
64
+ "forward_primer":"TAATACGACTCACTATAGGGAGAACTTCGACCAGAAG",
65
+ "reverse_primer": "TATGTGCGCATACATGGATCCTC",
66
+ "add_forward_primer": "GGGAGAACTTCGACCAGAAG",
67
+ "add_reverse_primer": "TATGTGCGCATACATGGATCCTC",
68
+ """
69
+
70
+ class AlphaVBeta3Config(datasets.BuilderConfig):
71
+ """BuilderConfig for SQUAD."""
72
+
73
+ def __init__(self, url, adapter_match=True, length_match=True, remove_primer=True, **kwargs):
74
+ """BuilderConfig for SQUAD.
75
+ Args:
76
+ **kwargs: keyword arguments forwarded to super.
77
+ """
78
+ super(AlphaVBeta3Config, self).__init__(**kwargs)
79
+ self.url = url
80
+ self.adapter_match = adapter_match
81
+ self.length_match = length_match
82
+ self.remove_primer = remove_primer
83
+
84
+
85
+ class AlphaVBeta3(datasets.GeneratorBasedBuilder):
86
+ """SQUAD: The Stanford Question Answering Dataset. Version 1.1."""
87
+
88
+ BUILDER_CONFIGS = [
89
+ AlphaVBeta3Config(name=key, url=_URLS[key]) for key in _URLS
90
+ ]
91
+
92
+ DEFAULT_CONFIG_NAME = "round_4"
93
+
94
+ def _info(self):
95
+ return datasets.DatasetInfo(
96
+ description=_DESCRIPTION,
97
+ features=datasets.Features(
98
+ {
99
+ "id": datasets.Value("int32"),
100
+ "identifier": datasets.Value("string"),
101
+ "seq": datasets.Value("string"),
102
+ "count": datasets.Value("int32"),
103
+ }
104
+ ),
105
+ homepage="https://www.ebi.ac.uk/ena/browser/view/PRJDB9111",
106
+ citation=_CITATION,
107
+ )
108
+
109
+ def _split_generators(self, dl_manager):
110
+ downloaded_files = dl_manager.download_and_extract(self.config.url)
111
+
112
+ return [
113
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files}),
114
+ ]
115
+
116
+ def _generate_examples(self, filepath):
117
+ """This function returns the examples in the raw (text) form."""
118
+ logger.info("generating examples from = %s", filepath)
119
+ key = 0
120
+ data = OrderedDict()
121
+ with open(filepath, encoding="utf-8") as f:
122
+ ans = {"id": key, "count": 1}
123
+ for i, line in enumerate(f):
124
+ if line.startswith("@") and i%4==0:
125
+ ans["identifier"] = line[1:].split()[0].strip()
126
+ elif i%4==1:
127
+ ans["seq"] = line.strip()
128
+ if self.filter_fn(ans):
129
+ if ans['seq'] in data:
130
+ data[ans['seq']]['count'] += 1
131
+ else:
132
+ data[ans['seq']] = ans
133
+ key += 1
134
+ ans = {"id": key, "count": 1}
135
+ for item in data.values():
136
+ yield item['id'], item
137
+
138
+
139
+ def filter_fn(self, example):
140
+ seq = example["seq"]
141
+ if self.config.adapter_match:
142
+ if not seq.startswith(_FORWARD_PRIMER) or not seq.endswith(_REVERSE_PRIMER):
143
+ return False
144
+ if self.config.length_match:
145
+ if len(seq)!=_DESIGN_LENGTH+len(_FORWARD_PRIMER)+len(_REVERSE_PRIMER):
146
+ return False
147
+ if self.config.remove_primer:
148
+ example["seq"] = seq[len(_FORWARD_PRIMER):len(seq)-len(_REVERSE_PRIMER)]
149
+ return True
150
+
151
+
152
+ if __name__=="__main__":
153
+ from datasets import load_dataset
154
+ dataset = load_dataset("alphaVbeta3.py", split="all")
155
+