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