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
[Real
,Real
]) – (min, max) tuple of the mass spectrum rangevol (
Real
) – the “volume” of the atom used during reconstructioncolor (
Tuple
[Real
,Real
,Real
]) – the color as RGB fractions
- property color: Tuple[numbers.Real, numbers.Real, numbers.Real]¶
Get the color of the range as (R, G, B) tuple. Values range from 0-1
- Return type
Tuple
[Real
,Real
,Real
]
- contains_mass(mass)[source]¶
Test if the given mass/charge ratio is contained within range’s bounds :type mass:
Real
: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[numbers.Real, numbers.Real]¶
Get the (min, max) interval defined the mass spectrum range
- Return type
Tuple
[Real
,Real
]
- property ion: apav.core.isotopic.Ion¶
Get a tuple of the elements that compose this range
- Return type
Ion
- property lower: numbers.Real¶
Get the lower (closed) boundary of the range
- Return type
Real
- property upper: numbers.Real¶
Get the upper (open) boundary of the range
- Return type
Real
- property vol: numbers.Real¶
Get the volume of the range
- Return type
Real
RangeCollection
¶
- class apav.RangeCollection(ranges=())[source]¶
Operations on multiple ranges
Maintain and operate on a collection of ranges the 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 create 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¶
Get a copy of the ranges in the RangeCollection. This returns a copy so as 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()