1 """Code to interact with the primersearch program from EMBOSS.
2 """
3
4
26
27
29 """Represent the information from a primersearch job.
30
31 amplifiers is a dictionary where the keys are the primer names and
32 the values are a list of PrimerSearchAmplifier objects.
33 """
36
37
39 """Represent a single amplification from a primer.
40 """
42 self.hit_info = ""
43 self.length = 0
44
45
47 """Get output from primersearch into a PrimerSearchOutputRecord
48 """
49 record = OutputRecord()
50
51 for line in handle:
52 if not line.strip():
53 continue
54 elif line.startswith("Primer name"):
55 name = line.split()[-1]
56 record.amplifiers[name] = []
57 elif line.startswith("Amplimer"):
58 amplifier = Amplifier()
59 record.amplifiers[name].append(amplifier)
60 elif line.startswith("\tSequence: "):
61 amplifier.hit_info = line.replace("\tSequence: ", "")
62 elif line.startswith("\tAmplimer length: "):
63 length = line.split()[-2]
64 amplifier.length = int(length)
65 else:
66 amplifier.hit_info += line
67
68 for name in record.amplifiers:
69 for amplifier in record.amplifiers[name]:
70 amplifier.hit_info = amplifier.hit_info.rstrip()
71
72 return record
73