|
8 | 8 | from protein_quest.alphafold.fetch import downloadable_formats |
9 | 9 | from protein_quest.converter import converter |
10 | 10 | from protein_quest.ss import SecondaryStructureFilterQuery |
11 | | -from protein_quest.uniprot import Query |
12 | 11 | from rich import print as rprint |
13 | 12 | from rich.logging import RichHandler |
14 | 13 | from rich_argparse import RawDescriptionRichHelpFormatter, RichHelpFormatter |
|
19 | 18 | add_powerfit_parser, |
20 | 19 | handle_powerfit, |
21 | 20 | ) |
| 21 | +from protein_detective.search import UniprotQuery |
22 | 22 | from protein_detective.workflow import ( |
23 | 23 | filter_structures, |
24 | 24 | retrieve_structures, |
@@ -50,6 +50,23 @@ def add_search_parser(subparsers): |
50 | 50 | action="append", |
51 | 51 | help="Molecular function (GO term, e.g. GO:0003677). Can be specified multiple times.", |
52 | 52 | ) |
| 53 | + parser.add_argument( |
| 54 | + "--interaction-partner-seed", |
| 55 | + type=str, |
| 56 | + action="append", |
| 57 | + help=dedent("""\ |
| 58 | + UniProt ID to use as interaction partner seed. |
| 59 | + The search will be expanded to include structures identifiers of the found interaction partners. |
| 60 | + Can be specified multiple times. |
| 61 | + """), |
| 62 | + ) |
| 63 | + parser.add_argument( |
| 64 | + "--interaction-partner-exclude", |
| 65 | + type=str, |
| 66 | + action="append", |
| 67 | + help="UniProt ID to exclude as found interaction partners. Can be specified multiple times.", |
| 68 | + ) |
| 69 | + |
53 | 70 | parser.add_argument("--limit", type=int, default=10_000, help="Limit number of results") |
54 | 71 |
|
55 | 72 |
|
@@ -131,20 +148,27 @@ def add_filter_parser(subparsers: argparse._SubParsersAction): |
131 | 148 |
|
132 | 149 |
|
133 | 150 | def handle_search(args): |
134 | | - query = Query( |
135 | | - taxon_id=args.taxon_id, |
136 | | - reviewed=args.reviewed, |
137 | | - subcellular_location_uniprot=args.subcellular_location_uniprot, |
138 | | - subcellular_location_go=args.subcellular_location_go, |
139 | | - molecular_function_go=args.molecular_function_go, |
| 151 | + query = converter.structure( |
| 152 | + { |
| 153 | + "taxon_id": args.taxon_id, |
| 154 | + "reviewed": args.reviewed, |
| 155 | + "subcellular_location_uniprot": args.subcellular_location_uniprot, |
| 156 | + "subcellular_location_go": args.subcellular_location_go, |
| 157 | + "molecular_function_go": args.molecular_function_go, |
| 158 | + "interaction_partner_seeds": args.interaction_partner_seed or [], |
| 159 | + "interaction_partner_excludes": args.interaction_partner_exclude or [], |
| 160 | + }, |
| 161 | + UniprotQuery, |
140 | 162 | ) |
141 | 163 | session_dir = Path(args.session_dir) |
142 | | - nr_uniprot, nr_pdbes, nr_prot2pdbes, nr_afs = search_structures_in_uniprot(query, session_dir, limit=args.limit) |
| 164 | + result = search_structures_in_uniprot(query, session_dir, limit=args.limit) |
143 | 165 | rprint( |
144 | | - f"Search completed: {nr_uniprot} UniProt entries found, " |
145 | | - f"{nr_pdbes} PDBe structures, {nr_prot2pdbes} UniProt to PDB mappings, " |
146 | | - f"{nr_afs} AlphaFold structures." |
| 166 | + f"Search completed: {result.nr_uniprot_accessions} UniProt entries found, " |
| 167 | + f"{result.nr_pdbs} PDBe structures, {result.nr_prot2pdb} UniProt to PDB mappings, " |
| 168 | + f"{result.nr_afs} AlphaFold structures." |
147 | 169 | ) |
| 170 | + if query.interaction_partner_seeds: |
| 171 | + rprint(f"Included {result.nr_interaction_partners} Uniprot entries found as interaction partners.") |
148 | 172 |
|
149 | 173 |
|
150 | 174 | def handle_retrieve(args): |
|
0 commit comments