Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Opio
    Member
    • Oct 2017
    • 10

    [Annovar] - "cannot write to outfile"

    Hi,

    I'm pretty new to bioinformatics.
    I'm training on a set of 2 WES (whole exomes sequencing) to get introduced to all those steps.
    I followed the GATK good practices, and I'm with a joint VCF file, and then I want to filter and annotate it with annovar.
    Before working on annovar, I chose to convert vcf to avinput.

    For that I tried the following :

    convert2annovar.pl -format vcf4 -allsample input.vcf -outfile STDOUT
    And i have the following error (ubuntu 14.04 or 16.04) :
    NOTICE: output files will be written to STDOUT.<samplename>.avinput
    cannot write to outfile
    It's not about rights, my colleage bioinformatician looked it up with me, it's all about how convert2annovar deals with the argument -allsamples to get a outfile per sample.
    Otherwise convert2annovar works fine to me.

    The only workaround I found is to use the parameter "-withfreq" which makes it work like a charm..

    I can't find anything on google, have you any ideas about where that error could come from?

    Best,
    Last edited by Opio; 10-25-2017, 05:50 AM.
  • GenoMax
    Senior Member
    • Feb 2008
    • 7142

    #2
    STDOUT is a reserved output channel. Generally that refers to the screen you are using to enter commands/get output. Try using a different name in your command:
    Code:
    convert2annovar.pl -format vcf4 -allsample input.vcf -outfile MyFile

    Comment

    • Markiyan
      Senior Member
      • Sep 2010
      • 126

      #3
      Do not use stdin or stdout words for regular filenames.

      The stdout and stdin are reserved filenames in the unix/perl world...

      So avoid using them in regular file names.

      Better do:

      convert2annovar.pl -format vcf4 -allsample input.vcf -outfile output

      and see what it tells you.

      PS: have a look at:
      I'm not asking about general syntactic rules for file names. I mean gotchas that jump out of nowhere and bite you. For example, trying to name a file "COM&lt;n&gt;" on Windows?


      and:
      The file systems supported by Windows use the concept of files and directories to access data stored on a disk or device.


      (if any part of your integrated systems runs on windows)

      Comment

      • Opio
        Member
        • Oct 2017
        • 10

        #4
        Thank for your answers !

        Actually I put that name for the forum only, the one on my command was different
        /genetics/ongoing_work/test_avinput$ /genetics/apps/annovar/convert2annovar.pl -format vcf4 -allsample 78_14_TR_p_BWA_mem_PIC_conv_ord_mdup_group_recal_rawvariants_Joint_INDEL_recalibrated_extracted_filter_appl_flqg.vcf -outfile 78_14_TR_p_BWA_mem_PIC_conv_ord_mdup_group_recal_rawvariants_Joint_INDEL_recalibrated_extracted_filter_appl_flqg_avinput
        And the result :

        NOTICE: output files will be written to 78_14_TR_p_BWA_mem_PIC_conv_ord_mdup_group_recal_rawvariants_Joint_INDEL_recalibrated_extracted_filter_appl_flqg_avinput.<samplename>.avinput
        1 cannot write to outfile
        And the same as well with myfile

        By the way my OS is Linux Ubuntu14.04

        Code:
        if ($chr =~ m/^#CHR/i) {		#format specification line
        			$found_headerline and next;	#sometimes people concatenate multiple VCF files together without removing header lines in the combined file; we need to address this
        			$found_headerline++;
        			if ($allsample and @sample and not $withfreq) {
        				
        				if (not @sample and $withfreq) {
        					die "Error: -withfreq argument is set, but the VCF file does not contain any sample\n";
        				}
        				
        				for my $i (0 .. @sample-1) {
        					open ($fhout[$i], ">$outfile.$sample[$i].avinput") or die "1 cannot write to outfile\n";
        					#open ($fhout[$i], ">$outfile.$sample[$i].avinput");
        					my $fhout = $fhout[$i];		#must use a temp variable for this to work
        					$comment and @comment and print $fhout join ("\n", @comment), "\n", join ("\t", $chr, $start, $ID, $ref, $alt, $quality_score, $filter, $info, $format, $sample[$i]), "\n";
        				}
        			} else {
        				my $fhout;
        				if ($outfile) {
        					open ($fhout, ">$outfile") or die "Error: cannot write to output file $outfile: $!\n";
        					$fhout[0] = $fhout;
        				} else {
        					$fhout[0] = *STDOUT;
        					$fhout = $fhout[0];
        				}
        				$comment and @comment and print $fhout join ("\n", @comment), "\n", join ("\t", $chr, $start, $ID, $ref, $alt, $quality_score, $filter, $info, $format, $sample[0]), "\n";
        				if (@sample > 1) {
        					if (not $allsample or not $withfreq) {
        						print STDERR "WARNING to old ANNOVAR users: this program no longer does line-to-line conversion for multi-sample VCF files. If you want to include all variants in output, use '-format vcf4old' or use '-format vcf4 -allsample -withfreq' instead.\n";
        					}
        				}
        			}
        			$countsample = scalar (@sample);
        			next;
        As a complement, I focused on the part of the code of convert2annovar.pl which raised the error. But as a not PERList, I don't exactly know what $fhout does
        Last edited by Opio; 10-25-2017, 06:20 AM.

        Comment

        • GenoMax
          Senior Member
          • Feb 2008
          • 7142

          #5
          You may not have write permission to this directory (/genetics/ongoing_work/test_avinput) based on that error. What if you try to save the output files somewhere else?

          $fhout is designating a file handle (name) to write the output to.
          Last edited by GenoMax; 10-25-2017, 06:40 AM.

          Comment

          • Opio
            Member
            • Oct 2017
            • 10

            #6
            Apprently it seems that I have it !

            drwxr-xr-x 2 username group 4096 Oct 25 15:24 test_avinput
            I just remplaced username and group in that line, but that's the good one.

            Weirdly enough, I have another machine with ubuntu which is administrated by my (I'm root on it) and I have the same issue.

            I then think that it may not be the issue :/

            Is my file can cause that? That would be weird because it goes well with -allsample -withfreq but not without the -withfreq

            .. i'm lost !

            Comment

            • GenoMax
              Senior Member
              • Feb 2008
              • 7142

              #7
              Sounds like this is an issue of some combination of those command options for Annovar. You may want to search GATK forums to see if someone has seen this before.

              Comment

              • Opio
                Member
                • Oct 2017
                • 10

                #8
                I tried with no success so far, but I'll keep look at it.

                But my question can be obvious though : how do you do from a joint vcf to put it in annovar ? You have to have that step in your pipeline I guess?

                Comment

                • Markiyan
                  Senior Member
                  • Sep 2010
                  • 126

                  #9
                  Include the file name in the error message in convert2annovar.pl

                  We need to improve our exception handling a bit.
                  We should always include the name on the file which our program tries to open for writing in the error message. Also differentiate between file open and file writing errors and include os error output ($! in perl) in the die message.

                  To do that replace in convert2annovar.pl :

                  for my $i (0 .. @sample-1) {
                  open ($fhout[$i], ">$outfile.$sample[$i].avinput") or die "1 cannot write to outfile\n";


                  with:

                  for my $i (0 .. @sample-1) {
                  open ($fhout[$i], ">$outfile.$sample[$i].avinput") or die "Cannot open output file for writing: $outfile.$sample[$i].avinput\n$!\n";


                  Than, please make sure that ALL sample names are defined for that vcf file(s), and that each sample name is unique, and has NO SPACES, SLASHES, and other file name unfriendly characters!
                  Last edited by Markiyan; 10-25-2017, 09:24 AM. Reason: Clarification.

                  Comment

                  • Opio
                    Member
                    • Oct 2017
                    • 10

                    #10
                    Hi,
                    thank you very much for helping me.
                    So I tried your part of code and I have with the command :
                    convert2annovar.pl -format vcf4 -allsample 78_14_TR_p_BWA_mem_PIC_conv_ord_mdup_group_recal_rawvariants_Joint_INDEL_recalibrated_extracted_filter_appl_flqg.vcf -outfile example
                    the following result :
                    NOTICE: output files will be written to example.<samplename>.avinput
                    Cannot open output file for writing: example./media/romain/MYBOOK/romain_work/78_81/78_14_TR_p_BWA_mem_PIC_conv_ord_mdup.bam.avinput
                    No such file or directory
                    which is indeed.. true. That files doesn't exist (even though /media/romain/MYBOOK/romain_work/78_81/78_14_TR_p_BWA_mem_PIC_conv_ord_mdup.bam exists)

                    So it's calling a file which is a compound of the output name and the source name?

                    By the way, side question : my vcf files calls for sample which are a path, even if the path is correct and the file exists, convert2annovar will work locally on the vcf file, not on the path of the sample right?


                    I guess the fact it has "/" makes it unhealthy for annovar
                    Last edited by Opio; 10-26-2017, 03:45 AM.

                    Comment

                    • Opio
                      Member
                      • Oct 2017
                      • 10

                      #11
                      removed the bad "sample" name in my vcf file

                      ... and it works fine now. Actually it was calling indeed a file made of a path, you pointed right.

                      Thank you so much.

                      Comment

                      Latest Articles

                      Collapse

                      • SEQadmin2
                        Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
                        by SEQadmin2


                        Proteomics platforms are evolving rapidly, with advances in mass spectrometry and affinity-based approaches expanding what researchers can detect and at what scale. As the field moves toward deeper proteome coverage and clinical applications, scientists face an increasingly complex landscape of tools. This article will explore how researchers are navigating these choices to find the right platform for their work.

                        The systematic characterization of the human proteome has
                        ...
                        07-20-2026, 11:48 AM
                      • SEQadmin2
                        Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                        by SEQadmin2



                        Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
                        ...
                        07-09-2026, 11:10 AM
                      • SEQadmin2
                        Cancer Drug Resistance: The Lingering Barrier to Rising Survival
                        by SEQadmin2



                        Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

                        There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
                        07-08-2026, 05:17 AM

                      ad_right_rmr

                      Collapse

                      News

                      Collapse

                      Topics Statistics Last Post
                      Started by SEQadmin2, 07-24-2026, 12:17 PM
                      0 responses
                      34 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, 07-23-2026, 11:41 AM
                      0 responses
                      25 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, 07-20-2026, 11:10 AM
                      0 responses
                      217 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, 07-13-2026, 10:26 AM
                      0 responses
                      79 views
                      0 reactions
                      Last Post SEQadmin2  
                      Working...