API reference
agp
Functions for reading and writing AGP files.
AgpFormatError
Bases: Exception
Invalidly formatted AGP
Source code in agp/__init__.py
5 6 7 8 9 10 11 12 |
|
AgpRow
A single non-comment row of an AGP
A single non-comment row of an AGP file. Because AGP is a weird kind of TSV where fields can have different meanings depending on the value of the component_type field, I'm representing this as a class with instance variables rather than an OrderedDict or something along those lines. See the NCBI documentation for more information:
https://www.ncbi.nlm.nih.gov/assembly/agp/AGP_Specification/
Source code in agp/__init__.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 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 61 62 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 |
|
__init__(line)
Creates a new instance of AgpRow
Creates a new instance of AgpRow by parsing the given line of text.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
line |
str
|
a line of text in AGP format |
required |
Source code in agp/__init__.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
__str__()
Returns the string representation of the AGP row as a line of text containing all the fields separated by tabs.
Source code in agp/__init__.py
60 61 62 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 |
|
contains(position)
Check whether a row contains a position
Determine whether this row contains a given coordinate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
position |
int
|
a genomic position in base pairs |
required |
Returns:
Type | Description |
---|---|
bool
|
true if position is within the bounds of this entry, false otherwise |
Source code in agp/__init__.py
129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
is_string(var)
Determine whether var is a string
Determine whether var
is a string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
var |
variable to check for stringiness |
required |
Returns:
Type | Description |
---|---|
bool
|
true if |
Source code in agp/__init__.py
164 165 166 167 168 169 170 171 172 173 174 175 |
|
open_agp(filename)
Open and read an AGP file
Open an AGP file from a path, and then parse it
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
path to an AGP file to read |
required |
Returns:
Type | Description |
---|---|
Iterator[Union[str, AgpRow]]
|
an Iterator over the rows of the file |
Source code in agp/__init__.py
198 199 200 201 202 203 204 205 206 207 208 209 |
|
read(infile)
Read an AGP file
Read an AGP file, yielding rows as AgpRow instances and comment lines as plain strings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
infile |
TextIO
|
input file in AGP format |
required |
Yields:
Type | Description |
---|---|
Union[str, AgpRow]
|
each row as either a string containing the entire line for |
Union[str, AgpRow]
|
comments, or an AgpRow for non-comment lines |
Source code in agp/__init__.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
|
agp.assemble
Functions for assembling scaffolds from contigs based on an agp file
print_fasta(name, sequence, outfile, wrap=60)
Given a sequence name and the sequence itself, print a fasta- formatted string of it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
the sequence id |
required |
sequence |
str
|
the sequence itself |
required |
outfile |
IO
|
where to write the sequence to |
required |
wrap |
int
|
the number of bases per line of sequence |
60
|
Examples:
>>> import sys
>>> print_fasta(
... 'chr1', 'ATCGACTGATCGACTGACTGACTACTG', outfile=sys.stdout, wrap=10
... )
>chr1
ATCGACTGAT
CGACTGACTG
ACTACTG
Source code in agp/assemble.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|
run(contigs_fasta, outfile, agp_rows)
Given contigs in fasta format and their order and orientation into scaffolds in AGP format, outputs the assembled scaffolds in fasta format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
contigs_fasta |
screed.openscreed.Open
|
fasta iterator in screed format containing contigs |
required |
outfile |
IO
|
file where scaffolds fasta should be written |
required |
agp_rows |
Iterable[agp.AgpRow]
|
iterable returning agp.AgpRow objects, each containing a single row of the agp file |
required |
Source code in agp/assemble.py
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 |
|
agp.bed
Functions for parsing bed files
BadRangeError
Bases: Exception
Error raised when range starts in middle of component
Source code in agp/bed.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
BedRange
dataclass
Single entry (i.e., line) of a bed file.
Source code in agp/bed.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
chrom: str
class-attribute
Name of the chromosome or sequence of the bed range
end: Optional[int] = None
class-attribute
End position of the bed range
extra_fields: Optional[List[str]] = None
class-attribute
Additional columns containing miscellaneous data
start: Optional[int] = None
class-attribute
Start position of the bed range
strand: Optional[str] = None
class-attribute
Strand of the bed range (either '+' or '-')
EmptyRangeError
Bases: Exception
Error raised when bed range contains no contigs
Source code in agp/bed.py
9 10 11 12 13 14 15 16 17 18 |
|
ParsingError
Bases: Exception
Error parsing bed file
Source code in agp/bed.py
38 39 40 41 |
|
open_bed(filename)
Open and parse a bed file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
path to a bed file |
required |
Source code in agp/bed.py
73 74 75 76 77 78 79 |
|
read(bedfile)
Read and parse a bed file
Read a bed file line by line. If a line contains start and end positions, yield the sequence name and start and end positions as a BedRange; if the line contains only a sequence name, yield a BedRange with {start,end}=None.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bedfile |
TextIO
|
a bed-formatted file |
required |
Returns:
Type | Description |
---|---|
Iterator[BedRange]
|
an iterator that yields single lines of the file at a time |
Source code in agp/bed.py
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 |
|
agp.compose
Functions for composing two AGPs together.
contains(outer_row, inner_row)
Determines whether outer_row fully contains inner_row. For example, if outer_row specifies that the current object contains the range 500-1000 of a component1, and inner_row specifies how to assemble the range 600-800 of this component, then outer_row contains inner_row. Because breaking components is not supported, right now, this function raises a BrokenComponentError if the outer row partially contains the inner row.
Source code in agp/compose.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
run(outer_agp, inner_agp, outfile, print_unused=False)
runs the compose module of agptools
Source code in agp/compose.py
61 62 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 |
|
agp.flip
Given an AGP file describing an assembly and a list of chromosomes to flip, output a new AGP file with those chromosomes reoriented in reverse-complement.
flip(agp_rows, ranges_to_flip)
Reverse-complements all rows of an AGP file that fall within a list of ranges.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agp_rows |
Sequence[AgpRow]
|
all rows in an AGP file |
required |
ranges_to_flip |
Iterable[BedRange]
|
a list of ranges in the AGP file to reverse-complement. Takes genomic (bed) coordinates, not array coordinates. |
required |
Returns:
Name | Type | Description |
---|---|---|
agp_rows |
List[AgpRow]
|
the same rows that were input, except the rows in the specified range are now reverse-complemented |
Source code in agp/flip.py
54 55 56 57 58 59 60 61 62 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 |
|
reverse_rows(rows)
Given a list of AGP rows, return a new set of rows assembling the reverse complement of the input rows.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rows |
List[AgpRow]
|
an ordered list of AgpRow objects to reverse |
required |
Returns:
Type | Description |
---|---|
List[AgpRow]
|
the input, except in reverse order, with the rows modified to be |
List[AgpRow]
|
reverse-complements |
Source code in agp/flip.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
agp.join
Functions for joining scaffolds
BadSequenceNameError
Bases: Exception
Sequence name is not allowed
Source code in agp/join.py
32 33 34 35 36 37 38 39 |
|
JoinGroup
dataclass
Bases: Sequence
A group of scaffolds to be joined together
This class represents a group of scaffolds that should be joined
together as specified in a joins file. Optionally, a group can be given
a name to use for the new superscaffold instead of using
make_superscaffold_name()
to make one up based on the names of the
components. If accessed as a Sequence
, it provides direct access to
the underlying list of scaffolds, e.g.,
from agp.join import JoinGroup join_group = JoinGroup(["scaffold_1", "-scaffold_2", "+scaffold_3"]) len(join_group) 3 join_group[1] '-scaffold_2'
Attributes:
Name | Type | Description |
---|---|---|
scaffolds |
List[str]
|
a list of scaffolds to join together, in the correct order. A scaffold name can be preceded by "+" or "-" to indicate orientation; if none is specified, "+" is assumed. |
name |
Optional[str]
|
a name to use for the new superscaffold in the output agp |
Source code in agp/join.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
ScaffoldNotFoundError
Bases: Exception
Scaffold in joins list not found in agp
Source code in agp/join.py
20 21 22 23 |
|
ScaffoldUsedTwiceError
Bases: Exception
Scaffold(s) used more than once in joins file
Source code in agp/join.py
26 27 28 29 |
|
join_scaffolds(superscaffold_rows, gap_size=500, gap_type='scaffold', gap_evidence='na', name=None)
Transforms agp rows from multiple scaffolds into agp rows for a single superscaffold containing all the given scaffolds in the specified order. Scaffolds should be oriented properly before using this function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
superscaffold_rows |
List[List[AgpRow]]
|
a list of lists of agp rows. Each sub-list is a list of all rows in a single scaffold. These scaffolds will be joined in the order given |
required |
gap_size |
int
|
length of the new gaps created by joining scaffolds together |
500
|
gap_type |
str
|
what to call the new gaps in the agp file |
'scaffold'
|
gap_evidence |
str
|
evidence type for linkage across gap |
'na'
|
name |
str
|
name of new superscaffold. If None, this function will come up with a name based on the names of subscaffolds contained by this superscaffold |
None
|
Returns:
Type | Description |
---|---|
List[AgpRow]
|
a list of AgpRow instances containing the new scaffold specification |
Source code in agp/join.py
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 |
|
joins_type(filename)
argparse type function for file listing scaffold joins
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
filename giving path to a file listing scaffolds to join. Each line should contain a comma- separated list of scaffolds to be joined into a single scaffold. Optionally, the file can contain a second column after a tab that gives each group a name. |
required |
Returns:
Type | Description |
---|---|
List[JoinGroup]
|
list of join groups. Scaffold names may have "+" or "-" before their name; that is the job of downstream code to handle. |
Raises:
Type | Description |
---|---|
ScaffoldUsedTwiceError
|
if a scaffold is used multiple times |
Source code in agp/join.py
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 |
|
make_superscaffold_name(subscaffold_names)
Comes up with a nice superscaffold name based on the given subscaffold names. If the subscaffold names are all in the format '[prefix][suffix]', where prefix is the same for all subscaffolds, then the superscaffold name is '[prefix][suffix1]p[suffix2]p[etc.]' Otherwise, it's the names of all scaffolds concatenated with 'p'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
subscaffold_names |
list(str
|
list of names of subscaffolds being combined into a superscaffold |
required |
Returns:
Name | Type | Description |
---|---|---|
superscaffold_name |
str
|
a name for the new scaffolds based on the subscaffold names |
Source code in agp/join.py
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 |
|
run(joins_list, outfile, agp_infile, gap_size=500, gap_type='scaffold', gap_evidence='na')
Runs the 'join' module of agptools.
Source code in agp/join.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 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 263 264 265 266 267 268 269 |
|
agp.remove
scaffolds_list_type(filename)
Parse a list of scaffolds
Given a filename pointing to a list of scaffolds, one per line, parse it and return a list of scaffold strings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
path to a file containing a list of scaffolds |
required |
Returns:
Type | Description |
---|---|
Set[str]
|
the set of scaffold names in the file |
Source code in agp/remove.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
agp.rename
rename_rows(rows_to_rename, new_name, orientation)
Rename a bunch of agp rows
Rename a bunch of agp rows, and possibly reverse them too.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rows_to_rename |
Iterable[AgpRow]
|
all of the rows of a scaffold that is being renamed |
required |
new_name |
str
|
the new name for this scaffold |
required |
orientation |
str
|
either "+" or "-", the latter if reverse orienting the scaffold is desired |
required |
Returns:
Type | Description |
---|---|
list[AgpRow]
|
the renamed and perhaps reverse oriented rows |
Source code in agp/rename.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
renaming_file_type(filename)
Parse a renaming file
A renaming file has 2-3 columns: 1. current scaffold name 2. desired new scaffold name 3. orientation (+/-)
Parse one of these files and return it in dictionary format
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
path to renaming file |
required |
Returns:
Type | Description |
---|---|
dict[str, tuple[str, str]]
|
the file in dict format: d[old_name] = (new_name, orientation) |
Source code in agp/rename.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
run(renaming_map, outfile, agp_rows)
Run the rename module
Parameters:
Name | Type | Description | Default |
---|---|---|---|
renaming_map |
Mapping[str, tuple[str, str]]
|
maps the name of a contig to be renamed to a tuple containing the new name and orientation |
required |
outfile |
TextIO
|
file where agp output should be sent |
required |
agp_rows |
Sequence[AgpRow]
|
all input AGP rows |
required |
Source code in agp/rename.py
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 |
|
agp.split
Functions for splitting a scaffold into subscaffolds at gaps.
ParsingError
Bases: Exception
Raised when breakpoints file is misformatted.
Source code in agp/split.py
12 13 14 15 |
|
breakpoints_type(filename)
Argparse type function for breakpoints file: first column is the scaffold name; second column is a comma-separated list of locations within gaps where scaffold should be broken.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
path to the breakpoints file |
required |
Returns:
Name | Type | Description |
---|---|---|
breakpoints |
Dict[str, List[int]]
|
a dict mapping scaffold name to a list of breakpoints (int) on that scaffold |
Raises:
Type | Description |
---|---|
FileNotFoundError
|
if |
ParsingError
|
if there is an error in the input file's format or content |
Source code in agp/split.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
convert_rows(rows, subscaffold_counter)
Converts rows that are part of a scaffold into their own standalone scaffold. Changes the positions and part numbers so that the new scaffold starts at 1, and names the new scaffold after the old scaffold, but with '.{subscaffold_counter}' at the end.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rows |
List[AgpRow]
|
rows to turn into their own scaffold. |
required |
subscaffold_counter |
int
|
suffix to add to the old scaffold name in order to turn it into the new scaffold name. |
required |
Returns:
Type | Description |
---|---|
List[AgpRow]
|
the input rows, but with object names, positions, and part |
List[AgpRow]
|
numbers changed so that they now function as a standalone |
List[AgpRow]
|
scaffold |
Source code in agp/split.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
split_contig(contig_row, breakpoints)
Splits a single row containing a contig into multiple rows, each containing a piece of the contig.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
contig_row |
AgpRow
|
a single row to be split |
required |
breakpoints |
List[int]
|
positions where contig should be split, in object coordinates, not component coordinates. The left part of the split includes the breakpoint: e.g., splitting a contig of length 100 at 43 will make two new contigs: one from 1-43 and the other from 44-100. |
required |
Returns:
Type | Description |
---|---|
List[AgpRow]
|
a list of rows of length len(breakpoints) + 1, where each row is |
List[AgpRow]
|
a piece of the contig after splitting. Note that while the new |
List[AgpRow]
|
coordinates are correct in the coordinates of the original |
List[AgpRow]
|
scaffold they came from, the object coordinates still need to be |
List[AgpRow]
|
offset to match the new scaffold they will end up in. |
Examples:
>>> import agp
>>> r = agp.AgpRow('\t'.join(map(str, ['scaf', 501, 1000, 5, 'W',
... 'ctg', 1, 500, '+'])))
>>> [str(x).split('\t') for x in split_contig(r, [750, 867])]
[['scaf', '501', '750', '5', 'W', 'ctg', '1', '250', '+'],
['scaf', '751', '867', '6', 'W', 'ctg', '251', '367', '+'],
['scaf', '868', '1000', '7', 'W', 'ctg', '368', '500', '+']]
Source code in agp/split.py
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 |
|
split_scaffold(scaffold_rows, breakpoints)
Splits a scaffold at specified breakpoints.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scaffold_rows |
Iterable[AgpRow]
|
all the rows for a given scaffold in an AGP file |
required |
breakpoints |
List[int]
|
a list of locations where scaffold should be broken. All locations are specified in genomic coordinates and must be within the boundaries of a gap. |
required |
Returns:
Name | Type | Description |
---|---|---|
broken_rows |
List[AgpRow]
|
rows of the input scaffold broken into len(breakpoints)+1 sub-scaffolds, with the gaps containing the breakpoints removed |
Source code in agp/split.py
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 |
|
unoffset_rows(new_scaffold_name, rows)
Modifies some AGP rows so that they can be their own standalone scaffold. This requires changing their object names to a new scaffold name, and changing the part numbers and coordinates such that the first row starts with 1 and the rest follow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_scaffold_name |
str
|
name for the new scaffold which will replace all 'object' fields |
required |
rows |
List[AgpRow]
|
rows to modify so that they function as a standalone scaffold together. The first row will be used to calculate offsets. |
required |
Returns:
Name | Type | Description |
---|---|---|
out_rows |
List[AgpRow]
|
input rows, but with all 'object' fields replaced with new_scaffold_name, and all positions and part numbers modified so that the first row is the beginning of a new scaffold. |
Source code in agp/split.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
agp.transform
Functions for transforming genomic coordinates from contig-based to scaffold-based.
BadOrientationError
Bases: Exception
Error for bad orientation (not +/-)
Source code in agp/transform.py
34 35 36 37 |
|
CoordinateNotFoundError
Bases: Exception
Error for bad coordinates specified
Source code in agp/transform.py
28 29 30 31 |
|
UnsupportedOperationError
Bases: Exception
Error for trying to transform an unsupported style of bed row
Source code in agp/transform.py
22 23 24 25 |
|
create_contig_dict(agp_in)
Load the agp file into a dictionary mapping contig name to a list of rows in which that contig is the component_id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agp_in |
Iterator[Union[str, AgpRow]]
|
an agp file to read into a dictionary |
required |
Returns:
Type | Description |
---|---|
ContigDict
|
a dict mapping contig name to a list of rows in which that |
ContigDict
|
contig is the component_id |
Source code in agp/transform.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
find_agp_row(contig_name, coordinate_on_contig, contig_dict)
Find the agp row containing a coordinate.
Given a dictionary mapping contig name to a list of agp rows containing that contig, and a single position in contig coordinates, find and return the AGP row containing that position.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
contig_name |
str
|
the contig containing the coordinate |
required |
coordinate_on_contig |
int
|
the position to look for, in contig coordinates |
required |
contig_dict |
ContigDict
|
a dictionary mapping contig name to a list of agp rows containing that contig |
required |
Returns:
Type | Description |
---|---|
AgpRow
|
a single AGP row containing the requested position |
Source code in agp/transform.py
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 |
|
transform_bed_row(bed_row, contig_dict)
Transform a bed row to scaffold coordinates
Transform a single row of a bed file from contig coordinates to scaffold coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bed_row |
BedRange
|
the row to transform |
required |
contig_dict |
ContigDict
|
a dictionary mapping contig name to the agp row(s) containing that contig |
required |
Returns:
Type | Description |
---|---|
BedRange
|
the same bed row, but in scaffold coordinates now |
Source code in agp/transform.py
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 |
|
transform_single_position(position, agp_row)
Transform a position from component to object coordinates
Given a position in component coordinates (e.g., a position on a contig), and the agp row containing that position, transform the position to object coordinates (e.g., the same position, but on a scaffold of which that contig is a part).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
position |
int
|
a position in component/contig coordinates |
required |
agp_row |
AgpRow
|
the row containing that position |
required |
Returns:
Type | Description |
---|---|
int
|
the same position, but in object/scaffold coordinates |
Source code in agp/transform.py
61 62 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 |
|