compare
ensembl.io.genomio.fasta.compare
¶
Compares the INSDC and core fasta files based on md5sum and ids.
CompareFasta
¶
Read and compare the FASTA sequences.
Source code in src/python/ensembl/io/genomio/fasta/compare.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
|
comp = []
instance-attribute
¶
fasta_core = Path(fasta_core)
instance-attribute
¶
fasta_ext = Path(fasta_ext)
instance-attribute
¶
output_dir = Path(output_dir)
instance-attribute
¶
build_seq_dict(seqs)
¶
Builds a dictionary of unique sequences and their associated IDs, accounting for duplicates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seqs
|
dict[str, str]
|
A dictionary where keys are sequence IDs and values are sequences. |
required |
Returns:
Type | Description |
---|---|
dict[str, SeqGroup]
|
A dictionary where keys are unique sequences and values are |
Source code in src/python/ensembl/io/genomio/fasta/compare.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
compare_seq_for_Ns(only1, only2)
¶
Compare sequences in only1
and only2
for differences in N
content and length.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
only1
|
dict[str, SeqGroup]
|
Sequences unique to the first dataset, mapping sequence to group/identifier. |
required |
only2
|
dict[str, SeqGroup]
|
Sequences unique to the second dataset, mapping sequence to group/identifier. |
required |
Source code in src/python/ensembl/io/genomio/fasta/compare.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
|
compare_seqs()
¶
Compare two FASTA files for common, unique, and differing sequences.
Use write_results()
to generate a report.
Source code in src/python/ensembl/io/genomio/fasta/compare.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
find_common_groups(seq_ext_dict, seq_core_dict)
¶
Find common sequences between two dictionaries and group them.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seq_ext_dict
|
dict[str, SeqGroup]
|
Dictionary of sequences from the first dataset. |
required |
seq_core_dict
|
dict[str, SeqGroup]
|
Dictionary of sequences from the second dataset. |
required |
Returns:
Type | Description |
---|---|
dict[str, str]
|
A dictionary of common sequence mappings and a list of comparison results. |
Source code in src/python/ensembl/io/genomio/fasta/compare.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
read_fasta(fasta_path)
¶
Reads a FASTA file and returns a dictionary mapping sequence IDs to sequences.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fasta_path
|
Path
|
Path to the FASTA file. Supports gzipped files. |
required |
Returns:
Type | Description |
---|---|
dict[str, str]
|
A dictionary where keys are sequence IDs and values are sequences with all non-CGTA characters replaced by "N". |
Source code in src/python/ensembl/io/genomio/fasta/compare.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
write_results()
¶
Write the comparison results to a file in the output directory.
Source code in src/python/ensembl/io/genomio/fasta/compare.py
194 195 196 197 198 199 200 201 202 203 204 |
|
SeqGroup
¶
Represents a group of sequence identifiers and maintains a count of them.
Source code in src/python/ensembl/io/genomio/fasta/compare.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
count = 1
instance-attribute
¶
ids = [str(identifier)]
instance-attribute
¶
add_id(identifier=None)
¶
Add a new identifier to the group and updates the count.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier
|
str | None
|
The identifier to add. If |
None
|
Source code in src/python/ensembl/io/genomio/fasta/compare.py
52 53 54 55 56 57 58 59 60 |
|
main(arg_list=None)
¶
Main script entry-point.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arg_list
|
list[str] | None
|
Parsed arguments as an |
None
|
Source code in src/python/ensembl/io/genomio/fasta/compare.py
265 266 267 268 269 270 271 272 273 274 275 276 |
|
parse_args(arg_list)
¶
Return a populated namespace with the arguments parsed from a list or from the command line.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arg_list
|
list[str] | None
|
List of arguments to parse. If |
required |
Source code in src/python/ensembl/io/genomio/fasta/compare.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
|