Mercurial > repos > peterjc > seq_filter_by_id
comparison tools/seq_filter_by_id/seq_filter_by_id.py @ 12:85ef5f5a0562 draft default tip
v0.2.9 - Fixed file open mode for Python 3.11 onwards.
author | peterjc |
---|---|
date | Thu, 21 Dec 2023 10:47:58 +0000 |
parents | 4a7d8ad2a983 |
children |
comparison
equal
deleted
inserted
replaced
11:83a19df00eab | 12:85ef5f5a0562 |
---|---|
19 | 19 |
20 Cock et al 2009. Biopython: freely available Python tools for computational | 20 Cock et al 2009. Biopython: freely available Python tools for computational |
21 molecular biology and bioinformatics. Bioinformatics 25(11) 1422-3. | 21 molecular biology and bioinformatics. Bioinformatics 25(11) 1422-3. |
22 https://doi.org/10.1093/bioinformatics/btp163 pmid:19304878. | 22 https://doi.org/10.1093/bioinformatics/btp163 pmid:19304878. |
23 | 23 |
24 This script is copyright 2010-2017 by Peter Cock, The James Hutton Institute | 24 This script is copyright 2010-2023 by Peter Cock, The James Hutton Institute |
25 (formerly the Scottish Crop Research Institute, SCRI), UK. All rights reserved. | 25 (formerly the Scottish Crop Research Institute, SCRI), UK. All rights reserved. |
26 See accompanying text file for licence details (MIT license). | 26 See accompanying text file for licence details (MIT license). |
27 | 27 |
28 Use -v or --version to get the version, -h or --help for help. | 28 Use -v or --version to get the version, -h or --help for help. |
29 """ | 29 """ |
111 ) | 111 ) |
112 | 112 |
113 options, args = parser.parse_args() | 113 options, args = parser.parse_args() |
114 | 114 |
115 if options.version: | 115 if options.version: |
116 print("v0.2.7") | 116 print("v0.2.9") |
117 sys.exit(0) | 117 sys.exit(0) |
118 | 118 |
119 in_file = options.input | 119 in_file = options.input |
120 seq_format = options.format | 120 seq_format = options.format |
121 out_positive_file = options.output_positive | 121 out_positive_file = options.output_positive |
245 for x in options.id_list.split(): | 245 for x in options.id_list.split(): |
246 ids.add(clean_name(x.strip())) | 246 ids.add(clean_name(x.strip())) |
247 print("Have %i unique identifiers from list" % len(ids)) | 247 print("Have %i unique identifiers from list" % len(ids)) |
248 for tabular_file, columns in identifiers: | 248 for tabular_file, columns in identifiers: |
249 file_ids = set() | 249 file_ids = set() |
250 handle = open(tabular_file, "rU") | 250 handle = open(tabular_file) |
251 if len(columns) > 1: | 251 if len(columns) > 1: |
252 # General case of many columns | 252 # General case of many columns |
253 for line in handle: | 253 for line in handle: |
254 if line.startswith("#"): | 254 if line.startswith("#"): |
255 # Ignore comments | 255 # Ignore comments |