INNER CODE UNIT · Python
does_each_sequence_have_a_name_and_genomic_data
nickjcroucher/gubbins · python/gubbins/ValidateFastaAlignment.py:33
def does_each_sequence_have_a_name_and_genomic_data(self):
with open(self.input_filename, "r") as input_handle:
alignments = AlignIO.parse(input_handle, "fasta")
number_of_sequences = 0
for alignment in alignments:
for record in alignment:
number_of_sequences +=1
if record.name is None or record.name == "":
sys.stderr.write("Error with the input FASTA file: " + record.name + " is blank\n")
return False
if record.seq is None or record.seq == "":
sys.stderr.write("Error with the input FASTA file: " + record.name + " is empty\n")
return False
if re.search('[^ACGTNacgtn-]', str(record.seq)) != None:
sys.stderr.write("Error with the input FASTA file: " + record.name + " contains disallowed characters, only ACGTNacgtn- are permitted\n")
return False
return True