How to use the pygtftk.utils.get_example_file function in pygtftk

To help you get started, we’ve selected a few pygtftk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dputhier / pygtftk / pygtftk / gtf_interface.py View on Github external
raise GTFtkError("Input_file should contain two columns.")
            if not token[0].isdigit():
                raise GTFtkError("Column 1 of intput file should be an int.")

        new_data = self._dll.add_attr_to_pos(self._data,
                                             native_str(input_file.name),
                                             native_str(new_key))

        return self._clone(new_data)


if __name__ == "__main__":

    from pygtftk.utils import get_example_file

    a = get_example_file()
    gtf = GTF(a[0])
    for i in gtf["feature", "transcript"]:
        i.write(sys.stdout)
github dputhier / pygtftk / pygtftk / plugins / get_example.py View on Github external
"data",
                                    dataset)

        file_dataset = os.listdir(path_dataset)

        for i in file_dataset:
            print("\t" + i)
    else:
        if format == "gtf":
            example_file = get_example_file(datasetname=dataset,
                                            ext=format)

            if example_file:
                example_file = example_file[0]
            else:
                example_file = get_example_file(datasetname=dataset,
                                                ext=format + ".gz")
                if example_file:
                    example_file = example_file[0]
                else:
                    message("No GTF file found for this dataset.",
                            type="ERROR")
            GTF(example_file, check_ensembl_format=False).write(outputfile, gc_off=True)

        elif format in ["fa", "join", "join_mat", "genome", "chromInfo", "genes", "geneList"]:
            try:
                infile = open(get_example_file(datasetname=dataset,
                                               ext=format)[0], "r")
            except:
                message("Unable to find example file.", type="ERROR")

            for line in infile:
github dputhier / pygtftk / pygtftk / plugins / get_example.py View on Github external
for i in dataset_list:
            print("\t- " + os.path.basename(i))

    elif list:

        path_dataset = os.path.join(pygtftk.__path__[0],
                                    "data",
                                    dataset)

        file_dataset = os.listdir(path_dataset)

        for i in file_dataset:
            print("\t" + i)
    else:
        if format == "gtf":
            example_file = get_example_file(datasetname=dataset,
                                            ext=format)

            if example_file:
                example_file = example_file[0]
            else:
                example_file = get_example_file(datasetname=dataset,
                                                ext=format + ".gz")
                if example_file:
                    example_file = example_file[0]
                else:
                    message("No GTF file found for this dataset.",
                            type="ERROR")
            GTF(example_file, check_ensembl_format=False).write(outputfile, gc_off=True)

        elif format in ["fa", "join", "join_mat", "genome", "chromInfo", "genes", "geneList"]:
            try:
github dputhier / pygtftk / pygtftk / plugins / get_example.py View on Github external
if example_file:
                example_file = example_file[0]
            else:
                example_file = get_example_file(datasetname=dataset,
                                                ext=format + ".gz")
                if example_file:
                    example_file = example_file[0]
                else:
                    message("No GTF file found for this dataset.",
                            type="ERROR")
            GTF(example_file, check_ensembl_format=False).write(outputfile, gc_off=True)

        elif format in ["fa", "join", "join_mat", "genome", "chromInfo", "genes", "geneList"]:
            try:
                infile = open(get_example_file(datasetname=dataset,
                                               ext=format)[0], "r")
            except:
                message("Unable to find example file.", type="ERROR")

            for line in infile:
                outputfile.write(line)

        elif format == "*":

            file_path = glob.glob(os.path.join(pygtftk.__path__[0],
                                               'data',
                                               dataset,
                                               "*"))
            file_path = [x for x in file_path if "__" not in x]
            target_path = os.path.join(pygtftk.__path__[0], 'data', dataset)
            if not quiet: