BedContainer Class¶
Represents a Bed Storage for BedEntry objects.
BedContainer Class (BedEntry 3 Col)¶
-
class
bedContainer.BedContainer.BedContainer(addExtras: bool = False)¶ Represents a Python Container for BedEntry objects (bed file format rows with 3 columns, plus possibly Extra Fields).
-
__init__(addExtras: bool = False) → None¶ Creates an instance of BedEntry object.
Parameters: addExtras (bool) – True if the Bed Entries have extra fields, False otherwise.
-
empty() → None¶ Remove all BedEntries in the BedContainer. Also, reset all Counters. Final result similar to a new BedContainer instance.
-
select_Chromosomes() → List[str]¶ Returns all chromosome names present in the BedContainer
Return List: Return a List of strings representing chromosome names.
-
select_EntriesInChr(chrom: str) → List[bedEntry.BedEntry.BedEntry]¶ Returns all BedEntry objects inside the BedContainer, in the specified chromosome.
If none, an empty list is returned.
Parameters: chrom (str) – Chromosome name (chr) of BedEntry objects to return Return List: A List of all BedEntry located in chrom
-
number_EntriesInChr(chrom: str) → int¶ Number of BedEntry with input chromosome name.
If none, 0 (zero) ir returned.
Parameters: chrom (str) – Chromosome name (chr) of BedEntry objects to count Returns: Number of BedEntry with input chromosome name.
-
addFrom_List(listBedEntry: List[Union[str, List[T]]]) → None¶ - Add one BedEntry object based in input list (listBedEntry), composed by strings / List, following the rules below:[“chr”, “sCoord”, “eCoord”, [extraField1, extraField2, …]] (extraFields List is optional)
This function is also responsible for adding a unite to entryCounts Counter and to reset the sort property of BedContainer to False, since the new added BedEntry is added at the end of the correspondent chromosome list. Besides that, it also ensured that the chromosome key of the new BedEntry is added to the BedContainer if not already there.
Parameters: listBedEntry (List) – A list of strings with the required properties to be initialized by BedEntry constructor.
-
addFrom_BedEntryObj(obj: bedEntry.BedEntry.BedEntry) → None¶ Add BedEntry object directly in the container.
This function is also responsible for adding a unite to entryCounts Counter and to reset the sort property of BedContainer to False, since the new added BedEntry is added at the end of the correspondent chromosome list. Besides that, it also ensured that the chromosome key is added to the BedContainer if not already there.
Parameters: obj (BedEntry) – BedEntry object to add.
-
removeEntryBed(entryBedObj: bedEntry.BedEntry.BedEntry) → None¶ Remove BedEntry object from BedContainer.
This function is also responsible for decrease one unite to entryCounts Counter and ensured that the chromosome key is removed from BedContainer if not there is no BedEntry in that chromosome.
Parameters: entryBedObj (BedEntry) – BedEntry object to remove
-
static
merge(other1: object, other2: object) → object¶ Returns a their BedContainer object, with the content of the both merged input BedContainer*s. Having as great advantage the preservation of *BedEntry objects inside the input BedContainer objects.
If at least one input BedContainer has flagged having extraField (addExtras), it ensures that the final BedContainer output also has that flag as True.
Parameters: - other1 (BedContainer) – BedContainer to merge, 1!
- other2 (BedContainer) – BedContainer to merge, 2!
Returns: Returns a their BedContainer object, with the content of both input ones.
-
sort() → None¶ Sort the list of each chromosome in the bedContainer recursively and the Chromosome List (chrList). Ensures that set the sorted flag to True
-
readFromBedFile(BedFilePath: str) → None¶ Read a Bed File with 3 Columns (is possible to add more in extraFields) and store in the BedContainer object.
Parameters: BedFilePath (str) – Path to Bed File Format
-
writeToBedFile(BedFilePath: str) → None¶ Writes in a Bed File Format all BedEntry objects inside BedContainer. If the BedContainer has defined having the flag addExtras as True, the extra fields will also be write in the Bed File, in the same order as they are registered in BedContainer object.
Parameters: BedFilePath (str) – The path where the bed file will be writen.
-
Build-in Functions¶
-
BedContainer.__getitem__(item: int) → bedEntry.BedEntry.BedEntry¶ Getter item function for BedContainer class. Design to return a single BedEntry per time. Slices are not accepted, by now.
Parameters: item (int) – Index of BedEntry to retrieve Return BedEntry: A BedEntry Object(s)
-
BedContainer.__iter__() → Generator[bedEntry.BedEntry.BedEntry, None, None]¶ Iterator function for BedContainer class.
Return BedEntry: A BedEntry Object
-
BedContainer.__len__()¶ Returns the number of BedEntry objects in the BedContainer
Returns: Number BedEntry objects
-
BedContainer.__eq__()¶ Return self==value.
-
BedContainer.__str__()¶ A meta representation of the BedContainer
The following parameters are being returned:
- Number of Entries
- Number Chromosomes
- isSorted (Flag)
- Add Extra Fields (Flag)
Returns: String with the BedContainer meta representation.
BedContainer Class (6 Col)¶
-
class
bedContainer.BedContainer6.BedContainer6(addExtras: bool = False)¶ Bases:
bedContainer.BedContainer.BedContainerRepresents a Python Container for BedEntry6 objects (bed file format rows with 6 columns, plus possibly Extra Fields).
-
__init__(addExtras: bool = False)¶ Creates an instance of BedEntry object.
Parameters: addExtras (bool) – True if the Bed Entries have extra fields, False otherwise.
-
addFrom_List(listBedEntry: List[Union[str, List[T], int]]) → None¶ - Add one BedEntry object based in input list (listBedEntry), composed by strings / List, following the rules below:[“chr”, “sCoord”, “eCoord”, “name”, “score”,”strand”, [extraField1, extraField2, …]] (extraFields List is optional)
This function is also responsible for adding a unite to entryCounts Counter and to reset the sort property of BedContainer to False, since the new added BedEntry is added at the end of the correspondent chromosome list. Besides that, it also ensured that the chromosome key of the new BedEntry is added to the BedContainer if not already there.
Parameters: listBedEntry (List) – A list of strings with the required properties to be initialized by BedEntry constructor.
-
addFrom_BedEntryObj(obj: bedEntry.BedEntry.BedEntry) → None¶ Add BedEntry object directly in the container.
This function is also responsible for adding a unite to entryCounts Counter and to reset the sort property of BedContainer to False, since the new added BedEntry is added at the end of the correspondent chromosome list. Besides that, it also ensured that the chromosome key is added to the BedContainer if not already there.
Parameters: obj (BedEntry) – BedEntry object to add.
-
empty() → None¶ Remove all BedEntries in the BedContainer. Also, reset all Counters. Final result similar to a new BedContainer instance.
-
static
merge(other1: object, other2: object) → object¶ Returns a their BedContainer object, with the content of the both merged input BedContainer*s. Having as great advantage the preservation of *BedEntry objects inside the input BedContainer objects.
If at least one input BedContainer has flagged having extraField (addExtras), it ensures that the final BedContainer output also has that flag as True.
Parameters: - other1 (BedContainer) – BedContainer to merge, 1!
- other2 (BedContainer) – BedContainer to merge, 2!
Returns: Returns a their BedContainer object, with the content of both input ones.
-
number_EntriesInChr(chrom: str) → int¶ Number of BedEntry with input chromosome name.
If none, 0 (zero) ir returned.
Parameters: chrom (str) – Chromosome name (chr) of BedEntry objects to count Returns: Number of BedEntry with input chromosome name.
-
readFromBedFile(BedFilePath: str) → None¶ Read a Bed File with 3 Columns (is possible to add more in extraFields) and store in the BedContainer object.
Parameters: BedFilePath (str) – Path to Bed File Format
-
removeEntryBed(entryBedObj: bedEntry.BedEntry.BedEntry) → None¶ Remove BedEntry object from BedContainer.
This function is also responsible for decrease one unite to entryCounts Counter and ensured that the chromosome key is removed from BedContainer if not there is no BedEntry in that chromosome.
Parameters: entryBedObj (BedEntry) – BedEntry object to remove
-
select_Chromosomes() → List[str]¶ Returns all chromosome names present in the BedContainer
Return List: Return a List of strings representing chromosome names.
-
select_EntriesInChr(chrom: str) → List[bedEntry.BedEntry.BedEntry]¶ Returns all BedEntry objects inside the BedContainer, in the specified chromosome.
If none, an empty list is returned.
Parameters: chrom (str) – Chromosome name (chr) of BedEntry objects to return Return List: A List of all BedEntry located in chrom
-
sort() → None¶ Sort the list of each chromosome in the bedContainer recursively and the Chromosome List (chrList). Ensures that set the sorted flag to True
-
writeToBedFile(BedFilePath: str) → None¶ Writes in a Bed File Format all BedEntry objects inside BedContainer. If the BedContainer has defined having the flag addExtras as True, the extra fields will also be write in the Bed File, in the same order as they are registered in BedContainer object.
Parameters: BedFilePath (str) – The path where the bed file will be writen.
-
Build-in Functions¶
-
BedContainer6.__getitem__(item: int) → bedEntry.BedEntry6.BedEntry6¶ Getter item function for BedContainer class. Design to return a single BedEntry per time. Slices are not accepted, by now.
Parameters: item (int) – Index of BedEntry to retrieve Return BedEntry: A BedEntry Object
-
BedContainer6.__iter__() → Generator[bedEntry.BedEntry6.BedEntry6, bedEntry.BedEntry6.BedEntry6, None]¶ Iterator function for BedContainer class.
Return BedEntry: A BedEntry Object
-
BedContainer6.__len__()¶ Returns the number of BedEntry objects in the BedContainer
Returns: Number BedEntry objects
-
BedContainer6.__eq__()¶ Return self==value.
-
BedContainer6.__str__()¶ A meta representation of the BedContainer
The following parameters are being returned:
- Number of Entries
- Number Chromosomes
- isSorted (Flag)
- Add Extra Fields (Flag)
Returns: String with the BedContainer meta representation.