Why do I receive the "File format must be GTF" error message when using the "GTFAnnotation" function in MATLAB?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 29 Oct 2024
Modifié(e) : MathWorks Support Team
le 31 Oct 2024
In MATLAB, I am trying to load a GTF file using the "GTFAnnotation" function, but I received an error message that says:
Error using GTFAnnotation (line 111)
File format must be GTF.
How do I resolve this issue?
Réponse acceptée
MathWorks Support Team
le 31 Oct 2024
Please note that you may encounter this issue if the GTF files you are working with have some entries that have missing "transcript_id" or "gene_id" attributes, or if there are invalid values in these attributes.
As a workaround, you can reformat your GTF files to work with the "GTFAnnotation" function by adding an empty string as the "transcript_id" attribute to the invalid entries or an empty string as the "gene_id" attribute to the invalid entries.
To perform this workaround, please consider the following code snippet that demonstrates how to replace the "transcript_id" attribute with an empty string:
% GTF file names
originalFile = "myfile.gtf";
fixedEmptyTranscriptIdEntriesFile = "myfile_fixed.gtf";
% Read in GTF file (skip last empty line)
gtfLines = readlines(originalFile, EmptyLineRule="skip");
% Find entries that do not contain "transcript_id" attribute (exclude header)
invalidEntryIdx = ~contains(gtfLines, ("transcript_id" | textBoundary + "#"));
% Add empty "transcript_id" attribute to the invalid entries
gtfLines(invalidEntryIdx) = gtfLines(invalidEntryIdx) + ' transcript_id "";';
% Write to a new GTF file that has the invalid entries fixed
writelines(gtfLines, fixedEmptyTranscriptIdEntriesFile);
GTFAnnotationObject = GTFAnnotation(fixedEmptyTranscriptIdEntriesFile);
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!