GFA
- class gratools.Graph.GFA(gfa_path: ~pathlib.Path, logger: ~logging.Logger = <factory>, gfa_name: str | None = None, version: float | None = None, header_gfa: list = <factory>, sample_reference: str | None = None, bam_segments_file: ~pathlib.Path | None = None, dict_link_SA_SB: ~collections.defaultdict = <factory>, dict_samples_chrom: ~collections.defaultdict = <factory>, dict_segments_size: ~collections.defaultdict = <factory>, dict_segments_samples: ~collections.defaultdict = <factory>, dict_samples_bed: ~collections.defaultdict = <factory>, works_path: ~pathlib.Path | None = None, bed_path: ~pathlib.Path | None = None, bam_path: ~pathlib.Path | None = None)[source]
Bases:
object
A class to parse and process GFA files, including handling BAM files and extracting segments and links.
- gfa_path
The path to the GFA file.
- Type:
Path
- gfa_name
The name of the GFA file.
- Type:
str
- version
The version of the GFA file.
- Type:
float
- header_gfa
The header information from the GFA file.
- Type:
list
- sample_reference
The reference sample from the GFA file.
- Type:
str
- bam_segments_file
The path to the BAM segments file.
- Type:
Path
- dict_link_SA_SB
A dictionary of links between segments.
- Type:
defaultdict
- dict_samples_chrom
A dictionary of sample chromosomes.
- Type:
defaultdict
- dict_segments_size
A dictionary of segment sizes.
- Type:
defaultdict
- dict_segments_samples
A dictionary of segment samples.
- Type:
defaultdict
- works_path
The path to the working directory.
- Type:
Path
- bed_path
The path to the BED files directory.
- Type:
Path
- bam_path
The path to the BAM files directory.
- Type:
Path
Attributes Summary
Methods Summary
Parse the GFA file to extract specific information.
Save the header information in a text file.
Sauvegarde et trie les segments des échantillons dans un fichier BED.
Save the samples and their corresponding chromosomes in a text file.
tag_bam
()Tags the BAM file with the given dictionary of segment links and segment samples.
Attributes Documentation
- bam_path: Path = None
- bam_segments_file: Path = None
- bed_path: Path = None
- gfa_name: str = None
- sample_reference: str = None
- version: float = None
- works_path: Path = None
Methods Documentation
- parse_gfa()[source]
Parse the GFA file to extract specific information. Reads the GFA file, processes each line based on its type (Header, Segment, Link, Walk), and performs specific actions for each line type. The function updates the header information, writes to a BAM file, builds a dictionary, and processes the walk line.
- tag_bam()[source]
Tags the BAM file with the given dictionary of segment links and segment samples.
This function takes the self.bam_segments_file and uses the Bam class to tag it with the self.dict_link_SA_SB and self.dict_segments_samples dictionaries. The resulting tagged BAM file is then assigned to self.bam_segments_file.
- Parameters:
self (object) – The instance of the class.
- Returns:
None