[docs]classRelevantSequenceExporter(EncodingReport):""" Exports the sequences that are extracted as label-associated when using the :py:obj:`~immuneML.encodings.abundance_encoding.SequenceAbundanceEncoder.SequenceAbundanceEncoder` or :py:obj:`~immuneML.encodings.abundance_encoding.CompAIRRSequenceAbundanceEncoder.CompAIRRSequenceAbundanceEncoder` in AIRR-compliant format. **YAML specification:** .. indent with spaces .. code-block:: yaml definitions: reports: my_relevant_sequences: RelevantSequenceExporter """def__init__(self,dataset:RepertoireDataset=None,result_path:Path=None,name:str=None,number_of_processes:int=1):super().__init__(dataset=dataset,result_path=result_path,name=name,number_of_processes=number_of_processes)
def_generate(self)->ReportResult:df=pd.read_csv(self.dataset.encoded_data.info["relevant_sequence_path"])PathBuilder.build(self.result_path)filename=self.result_path/"relevant_sequences.csv"df.to_csv(filename,index=False)returnReportResult(self.name,info=f"Exports the sequences that are extracted as label-associated using the {self.dataset.encoded_data.encoding} in AIRR-compliant format.",output_tables=[ReportOutput(filename,"relevant sequences")])
[docs]defcheck_prerequisites(self):valid_encodings=[SequenceAbundanceEncoder.__name__,CompAIRRSequenceAbundanceEncoder.__name__]ifself.dataset.encoded_dataisNoneorself.dataset.encoded_data.infoisNone:logging.warning("RelevantSequenceExporter: the dataset is not encoded, skipping this report...")returnFalseelifself.dataset.encoded_data.encodingnotinvalid_encodings:logging.warning(f"RelevantSequenceExporter: the dataset encoding ({self.dataset.encoded_data.encoding}) was not in the list of valid "f"encodings ({valid_encodings}), skipping this report...")returnFalseelif"relevant_sequence_path"notinself.dataset.encoded_data.infoornotos.path.isfile(self.dataset.encoded_data.info['relevant_sequence_path']):logging.warning(f"RelevantSequenceExporter: the relevant sequences were not set for this encoded data, skipping this report...")returnFalseelse:returnTrue