Hello Monks, I have some programs that check wether corresponding sites in different single line text files match or differ with respect to a 0 or N character. The program ultimately creates a single file of the same length where at any position in the text file a 0 denotes all searched files contain a 0 in that spot and an N denotes at least one file contained an N. The initial step involves the cp command and for two of my 6 programs I receive this message from my terminal screen.

usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_fi +le cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... targe +t_directory mv: rename /Users/logancurtis-whitchurch/Dropbox/thesis_folder/consens +us_files/files/mask.9_Afr_females_chr.23.output.txt to /Users/logancurtis-whitchurch/Dropbox/thesis_folder/consensus_files/fi +les/mask.9_Afr_females.chr.23.txt: No such file or directory .chr.23.txtmask.NA18505

I am at a loss because these directories do exist and when executing the cp command in an isolated manner with just terminal it works

#! /usr/bin/perl -w use strict; use warnings; use Term::ANSIColor; #--------------------------------------------------------------------- +---------- # What: This program will output the number of reference sites assayed + in all # individuals in a given file, for chromosome 23. # # This is for the subpopulation of 9 Afr females. #--------------------------------------------------------------------- +---------- my $usage = "get_ref_sites_9_Afr_females.pl [individual_name_list]\n"; die $usage unless @ARGV == 1; #--------------------------------------------------------------------- +---------- open (INDV, "<$ARGV[0]") or die "Cannot open $ARGV[0]:$!\n"; my @individuals = <INDV>; # Define array close(INDV); my $chr = 23; my $indv_count = 0; my ($indv, $individuals, $covered, $buf, $data, $n, $count); while ($indv_count < 9){ #This needs to be the count of the number of + individuals if ($indv_count == 0) { chomp($individuals[$indv_count]); $indv = $individuals[$indv_count]; $count = 0; my $file_name = "mask".".$indv".".chr.23.txt"; system("cp /Users/logancurtis-whitchurch/Dropbox/thesis_fo +lder/CompleteGenomics/all_individuals_called_sites/$file_name /Users/ +logancurtis-whitchurch/Dropbox/thesis_folder/consensus_files/files/ma +sk.9_Afr_females_chr.$chr.output.txt"); $indv_count++; } else{ system("mv /Users/logancurtis-whitchurch/Dropbox/thesis_fo +lder/consensus_files/files/mask.9_Afr_females_chr.$chr.output.txt /Us +ers/logancurtis-whitchurch/Dropbox/thesis_folder/consensus_files/file +s/mask.9_Afr_females.chr.$chr.txt"); chomp($individuals[$indv_count]); $indv = $individuals[$indv_count]; $count = 0; my $file_name = "mask".".$indv".".chr.23.txt"; open(INPUT, "/Users/logancurtis-whitchurch/Dropbox/thesis_ +folder/CompleteGenomics/all_individuals_called_sites/$file_name") or +die "can't open $file_name\n"; open(OUT, ">/Users/logancurtis-whitchurch/Dropbox/thesis_f +older/consensus_files/files/mask.9_Afr_females.chr.$chr.output.txt"); open(MASK, "/Users/logancurtis-whitchurch/Dropbox/thesis_f +older/consensus_files/files/mask.9_Afr_females.chr.$chr.txt") or die +"can't open masked file for chr $chr:$!\n"; my $mask=<MASK>; chomp($mask); close(MASK); while (($n = read INPUT, $data, 100000) != 0) { my @info = split(//, $data); foreach my $info (@info){ if($info =~ "N"){ substr($mask,($count),1,'N'); } $count++; } $buf .= $data; print "$count for $indv for chr $chr are read\n"; } print OUT "$mask\n"; close(INPUT); close(OUT); $count = 0; $indv_count++; $mask = ""; $data = ""; $n = ""; $buf = ""; } }

In reply to cp Program Error by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.