Range
Range
- class apav.Range(ion, minmax, vol=1, color=(0, 0, 0))[source]
A single mass spectrum range
Define a singular mass spectrum range composed of a composition, interval, volume, and color. i.e. Created as:
>>> cu = Range("Cu", (62, 66), color=(0.5, 1, 0.25))
- Parameters
ion (
Union
[Ion
,str
]) – the range compositionminmax (
Tuple
[Number
,Number
]) – (min, max) tuple of the mass spectrum rangevol (
Number
) – the “volume” of the atom used during reconstructioncolor (
Tuple
[Number
,Number
,Number
]) – the color as RGB fractions
- property color: Tuple[Number, Number, Number]
Get the color of the range as (R, G, B) tuple. Values range from 0-1
- Return type
Tuple
[Number
,Number
,Number
]
- contains_mass(mass)[source]
Test if the given mass/charge ratio is contained within range’s bounds :type mass:
Number
:param mass: mass/charge ratio- Return type
bool
- property formula: str
Get the range composition as a string
- Return type
str
- property hill_formula: str
Get the range composition as a string
- Return type
str
- property interval: Tuple[Number, Number]
Get the (min, max) interval defined the mass spectrum range
- Return type
Tuple
[Number
,Number
]
- property ion: Ion
Get a tuple of the elements that compose this range
- Return type
Ion
- property lower: Number
Get the lower (closed) boundary of the range
- Return type
Number
- property upper: Number
Get the upper (open) boundary of the range
- Return type
Number
- property vol: Number
Get the volume of the range
- Return type
Number
RangeCollection
- class apav.RangeCollection(ranges=())[source]
Operations on multiple ranges
Maintain and operate on a collection of ranges that describe the peaks in a mass spectrum. This is the principle class used for mass spectrum range definitions. A collection may be created by manually supplying the Range objects through the constructor, or 1 by 1 through
RangeCollection.add()
. ARangeCollection
may also be created using the alternate constructorsRangeCollection.from_rng()
andRangeCollection.from_rrng()
to import the ranges from the two common range file types.A
RangeCollection
can be created as:>>> rng_lst = [Range("Cu", (62.5, 63.5)), Range("Cu", (63.5, 66))] >>> rngs = RangeCollection(rng_list)
Or 1 by 1 as:
>>> rngs = RangeCollection() >>> rngs.add(Range("Cu", (62.5, 63.5))) >>> rngs.add(Range("Cu", (63.5, 66)))
- Parameters
ranges (
Sequence
[Range
]) – sequence of Range objects
- add(new)[source]
Add a new
Range
to theRangeCollection
:type new:Range
:param new: the newRange
:return:
- check_overlap()[source]
Check if any ranges in the RangeCollection overlap. This returns the first overlap found, not all overlaps. This is provided if Ranges are being directly accessed and modified
- Return type
Union
[Tuple
,Tuple
[float
,float
]]
- property filepath: str
Get the file path the
RangeCollection
was created from, if it was imported from a file- Return type
str
- classmethod from_rng(filepath)[source]
Build RangeCollection from a .rng file :type filepath:
str
:param filepath: filepath
- classmethod from_rrng(fpath)[source]
Build RangeCollection from *.rrng files :type fpath:
str
:param fpath: filepath
- property ranges: List[Range]
Get a copy of the ranges in the RangeCollection. This returns a copy to prevent accidental modification of the underlying ranges possibly resulting in overlapping ranges.
Instead, remove the old range with RangeCollection.remove_by_mass() and add the new one, or use RangeCollection.replace()
- Return type
List
[Range
]