Skip to content

Commit 07301d2

Browse files
committed
Add script to perform initial validation
1 parent ba491ab commit 07301d2

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import csv
2+
3+
4+
def find_string(line, keywords):
5+
"""
6+
Check if any of the keywords are present in the line.
7+
8+
Args:
9+
line (iterable): An iterable containing items to be checked.
10+
keywords (list of str): A list of keywords to search for in the line.
11+
12+
Returns:
13+
bool: True if any keyword from the list is found in the line, False otherwise.
14+
"""
15+
return any(keyword in str(item).lower() for keyword in keywords for item in line)
16+
17+
18+
def main():
19+
"""
20+
Main function to process a CSV file and check for specific keywords in each line.
21+
We need RNA-related and non-RNA-related articles that mention "mrna" or "rna-seq".
22+
"""
23+
try:
24+
with open("check_abstracts.csv", mode="r", encoding="utf-8") as file:
25+
read_csv = csv.reader(file)
26+
keyword = [
27+
"non-coding", "noncoding", "ncrna", "rrna", "lncrna", "sncrna", "mirna", "trna", "rbp", "snrna", "pirna",
28+
"lincrna", "scrna", "pre-mirna", "riboswitch"
29+
]
30+
31+
for line_number, line in enumerate(read_csv, start=1):
32+
if line_number == 1:
33+
continue
34+
elif 2 <= line_number <= 101:
35+
if not find_string(line, ["mrna"]):
36+
print(f"Line {line_number} does not contain 'mrna': {line}")
37+
elif 102 <= line_number <= 201:
38+
if not find_string(line, ["mrna"]) or find_string(line, keyword):
39+
print(f"Please check line {line_number}: {line}")
40+
elif 202 <= line_number <= 301:
41+
if not find_string(line, ["rna-seq"]):
42+
print(f"Line {line_number} does not contain 'rna-seq': {line}")
43+
else:
44+
if not find_string(line, ["rna-seq"]) or find_string(line, keyword):
45+
print(f"Please check line {line_number}: {line}")
46+
47+
except Exception as e:
48+
print(f"Oops! We've had a problem: {e}")
49+
50+
51+
if __name__ == "__main__":
52+
main()

0 commit comments

Comments
 (0)