Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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 = ""; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: cp Program Error
by choroba (Cardinal) on Aug 01, 2013 at 10:32 UTC | |
by Anonymous Monk on Aug 01, 2013 at 12:38 UTC | |
Re: cp Program Error
by RichardK (Parson) on Aug 01, 2013 at 10:54 UTC | |
by Anonymous Monk on Aug 01, 2013 at 12:45 UTC | |
by RichardK (Parson) on Aug 01, 2013 at 13:25 UTC |
Back to
Seekers of Perl Wisdom