Mercurial > repos > greg > plant_tribes_add_scaffold
comparison add_scaffold.py @ 6:7973201f23e7 draft
Uploaded
author | greg |
---|---|
date | Tue, 22 May 2018 10:10:15 -0400 |
parents | f2e91be20b43 |
children | 82822d1e5119 |
comparison
equal
deleted
inserted
replaced
5:f2e91be20b43 | 6:7973201f23e7 |
---|---|
62 except Exception as e: | 62 except Exception as e: |
63 msg = "Caught exception executing SQL:\n%s\nException:\n%s\n" % (sql.format(args), e) | 63 msg = "Caught exception executing SQL:\n%s\nException:\n%s\n" % (sql.format(args), e) |
64 self.stop_err(msg) | 64 self.stop_err(msg) |
65 return cur | 65 return cur |
66 | 66 |
67 def check_scaffold(self): | 67 @property |
68 def can_add_scaffold(self): | |
68 """ | 69 """ |
69 Make sure the scaffold has not already been added. | 70 Make sure the scaffold has not already been added. |
70 """ | 71 """ |
71 scaffold_id = os.path.basename(self.args.scaffold_path) | 72 scaffold_id = os.path.basename(self.args.scaffold_path) |
72 sql = "SELECT id FROM plant_tribes_scaffold WHERE scaffold_id = '%s';" % scaffold_id | 73 sql = "SELECT id FROM plant_tribes_scaffold WHERE scaffold_id = '%s';" % scaffold_id |
73 cur = self.conn.cursor() | 74 cur = self.conn.cursor() |
74 cur.execute(sql) | 75 cur.execute(sql) |
75 try: | 76 try: |
76 cur.fetchone()[0] | 77 cur.fetchone()[0] |
77 self.stop_err("The scaffold %s has already been added to the database." % scaffold_id) | 78 self.stop_err("The scaffold %s has already been added to the database." % scaffold_id) |
79 return False | |
78 except: | 80 except: |
79 # The scaffold has not yet been added. | 81 # The scaffold has not yet been added. |
80 pass | 82 return True |
81 | 83 |
82 def run(self): | 84 def run(self): |
83 self.check_scaffold() | 85 if self.can_add_scaffold: |
84 self.process_annot_dir() | 86 self.process_annot_dir() |
85 self.process_scaffold_config_files() | 87 self.process_scaffold_config_files() |
86 self.process_orthogroup_fasta_files() | 88 self.process_orthogroup_fasta_files() |
87 self.fh.flush() | 89 self.fh.flush() |
88 self.fh.close() | 90 self.fh.close() |
89 | 91 |
90 def process_annot_dir(self): | 92 def process_annot_dir(self): |
91 """ | 93 """ |
92 First, parse all of the *.min_evalue.summary files in the | 94 First, parse all of the *.min_evalue.summary files in the |
93 ~/<scaffold_id>/annot directory (e.g., ~/22Gv1.1/annot) to populate | 95 ~/<scaffold_id>/annot directory (e.g., ~/22Gv1.1/annot) to populate |