https://github.com/fjruizruano/ngs-protocols
Tip revision: 39a091d1fa569a7fc717ac73c4b3de07f0a1204d authored by fjruizruano on 03 August 2023, 11:48:27 UTC
adding gfa2fas.py and extract_gfa.py
adding gfa2fas.py and extract_gfa.py
Tip revision: 39a091d
split_illumina.py
#!/usr/bin/python
# usage message
usage = """Usage:
repeat_masker_run.py [FASTA FILE]"""
import sys
if len(sys.argv) != 2:
print usage
exit(1)
file = sys.argv[1]
try:
open(file, "r")
except IOError:
print "Error! " + file + "does not exist, or is not readable!"
exit(1)
file_r = open(file, "r").readlines()
len_file = len(file_r)
filename = file.split(".")
filename = filename[0]
number = 3000000
i = 0
j = 0
total_files = (len_file/number)+1
for f in range(0,total_files):
fc = str(f)
while len(fc) < len(str(total_files)):
fc = ["0"] + [fc]
fc = "".join(fc)
f_name = "%s_%s.fas" % (filename, fc)
out = open(f_name, "w")
text = file_r[number*f:number*(f+1)]
text = "".join(text)
out.write(text)
out.close()