With file path#
A simple example on how find files task works for a file path.
[1] -
from os import getcwd
from os.path import dirname
from openvariant import findfiles
dataset_file = f'{dirname(getcwd())}/datasets/sample1/5a3a743.wxs.maf.gz'
As it occurs on the directory path examples, it will get the file and its corresponding Annotation object.
find_files function parameters:
base_path- Base path of input file.annotation_path- Path of annotation file.skip_files- Skip unreadable files and directories.
It will only get one file as an output, the file that is passed as a parameter. In case that there’s any annotation file that matches with the file’s pattern, it won’t generate any output.
[2] -
for file_path, annotation in findfiles(base_path=dataset_file):
print(f'File path: {file_path}')
print(f'Annotation object: {annotation}')
print("-------------------------------------")
File path: /home/dmartinez/openvariant/examples/datasets/sample1/5a3a743.wxs.maf.gz
Annotation object: <openvariant.annotation.annotation.Annotation object at 0x7f46043b9580>
-------------------------------------
It is possible to pass the annotation file as a parameter of the function.
It will generate the same output as it did before, and if the annotation file doesn’t match with the input file it will not generate any output.
[3] -
annotation_file = f'{dirname(getcwd())}/datasets/sample1/annotation_maf.yaml'
for file_path, annotation in findfiles(dataset_file, annotation_file):
print(f'File path: {file_path}')
print(f'Annotation object: {annotation}')
print("-------------------------------------")
File path: /home/dmartinez/openvariant/examples/datasets/sample1/5a3a743.wxs.maf.gz
Annotation object: <openvariant.annotation.annotation.Annotation object at 0x7f46040c7940>
-------------------------------------
As it occurs on the directory path examples, it will get the file and its corresponding Annotation object.
It will only get one file as an output, the file that is passed as a parameter. In case that there’s any annotation file that matches with the file’s pattern, it won’t generate any output.
[4] -
for file_path, annotation in findfiles(dataset_file):
print(f'File path: {file_path}')
print(f'Annotation object: {annotation}')
print("-------------------------------------")
File path: /home/dmartinez/openvariant/examples/datasets/sample1/5a3a743.wxs.maf.gz
Annotation object: <openvariant.annotation.annotation.Annotation object at 0x7f46040c7c70>
-------------------------------------