Εδώ είμαι πάλι.
Εδώ με βοηθήσατε να αντεπεξέλθω σε κάποια προβλήματα.
ΜΕ την εντολή
system ()
λέω στην perl να εκτελέσει μια έντολή:
μια χαρά δουλεύει και μου βγάζει πολύ καλά αποτελέσματα στην οθόνη.Κώδικας:system ("intersectBed", "-wao", "-a", "$PeakDir/$peakfiles[$i]", "-b", "$RepeatDir/$repeatfiles[$j]");
πως μπορώ να αποθηκεύω τα αποτελέσματα σε ένα τεστ αρχείο; έχω δοκιμάσει τα παρακάτω χωρίς καμία ελπίδα:
όπως πάντα κάθε συμβουλή δεκτή. λόγω δουλειάς αργώ να τις ελένξω.Κώδικας:my $test = "$desktop_path/test"; mkpath($test); opendir (testDir, "$test") || die "can't opendir $RepeatDir: $!"; system ("intersectBed", "-wao", "-a", "$PeakDir/$peakfiles[$i]", "-b", "$RepeatDir/$repeatfiles[$j]") >$test; #$test = `intersectBed -wao -a $PeakDir/$peakfiles[$i] -b $RepeatDir/$repeatfiles[$j]`; #@test = `intersectBed -wao -a $PeakDir/$peakfiles[$i] -b $RepeatDir/$repeatfiles[$j]`;
Εμφάνιση 1-13 από 13
-
26-01-12, 20:52 perl once more "the print on file" problem. #1
-
28-01-12, 13:55 Απάντηση: perl once more "the print on file" problem. #2
Αφού την λύση την έχεις δώσει ήδη μόνος σου πιο κάτω στα σχόλια. Μόνο με τα backticks "`" μπορείς να πάρεις το αποτέλεσμα της εντολής στην perl και όχι με system. Αν έχεις scalar στο βάζει εκεί, αλλιώς σε array:
Κώδικας:$ perl -MData::Dumper -e 'my $listing=`ls /`; print Dumper($listing);' $VAR1 = '] bin boot cgroup Desktop dev etc home lib lib64 lost+found media mnt opt proc root run sbin selinux srv sys tftpboot tmp usr var '; $ perl -MData::Dumper -e 'my @listing=`ls /`; chomp(@listing); print Dumper(\@listing);' $VAR1 = [ ']', 'bin', 'boot', 'cgroup', 'Desktop', 'dev', 'etc', 'home', 'lib', 'lib64', 'lost+found', 'media', 'mnt', 'opt', 'proc', 'root', 'run', 'sbin', 'selinux', 'srv', 'sys', 'tftpboot', 'tmp', 'usr', 'var' ];
-
29-01-12, 13:05 Απάντηση: perl once more "the print on file" problem. #3
Επιπλέον, αν θέλεις να πάρεις και το stderr, μπορείς μέσα στα backticks να το ανακατευθύνεις στο stdout, δηλαδή να γράψεις κάτι τέτοιο:
Κώδικας:$output = `$cmd 2>&1`;
NetBSD Rocks!
http://www.netbsd.org
-
29-01-12, 14:18 Απάντηση: perl once more "the print on file" problem. #4
χμμ, αυτό το έκανα απλά δε μπορεί να μου γράψει το αρχείο σε συγκεκριμένη θέση από όπου μετά να μπορώ να το διαβάσω (στο υπόλοιπο μέρος του προγράμματος) για να το επεξεργαστώ.
Δηλαδή, ενώ δημιουργώ τον φάκελο
Κώδικας:my $test = "$desktop_path/test"; mkpath($test);
$test = `intersectBed -wao -a $PeakDir/$peakfiles[$i] -b $RepeatDir/$repeatfiles[$j]`;
δε μου γράφει τίποτα έκεί
το αναμενόμενο αποτέλεσμα είναι αυτό και χωρίζεται μόνο με tabs και \n:
Κώδικας:chr20 4901985 4902690 . 532 . 2.61349 7.52958 6.65339 475 . -1 -1 . 0 chr7 101823335 101824261 . 532 . 2.58479 7.52958 6.65343 415 . -1 -1 . 0 chr9 105895270 105897014 . 532 . 1.94527 7.52318 6.64706 958 chr9 105895459 105895612 SINE 153 chr9 105895270 105897014 . 532 . 1.94527 7.52318 6.64706 958 chr9 105896648 105896671 Low_complexity 23 chr9 105895270 105897014 . 532 . 1.94527 7.52318 6.64706 958 chr9 105896964 105897139 LINE 50 chr2 101235311 101236140 . 532 . 2.72318 7.52152 6.64543 503 chr2 101235205 101235343 SINE 32 chr2 101235311 101236140 . 532 . 2.72318 7.52152 6.64543 503 chr2 101235579 101235660 Simple_repeat 81 chr2 101235311 101236140 . 532 . 2.72318 7.52152 6.64543 503 chr2 101235991 101236035 Low_complexity 44 chr8 38774444 38774779 . 532 . 5.16409 7.52088 6.64483 165 . -1 -1 . 0 chr3 128981266 128981689 . 532 . 5.33268 7.52088 6.64487 269 chr3 128981288 128981325 SINE 37 chr2 231696385 231696733 . 532 . 5.37224 7.52088 6.6449 156 . -1 -1 . 0 chr19 19793186 19793692 . 532 . 4.9497 7.52088 6.64493 253 . -1 -1 . 0 chr8 142471103 142471733 . 532 . 5.16409 7.52088 6.64497 185 chr8 142471178 142471216 Low_complexity 38 chr8 142471103 142471733 . 532 . 5.16409 7.52088 6.64497 185 chr8 142471377 142471409 Low_complexity 32 chr8 142471103 142471733 . 532 . 5.16409 7.52088 6.64497 185 chr8 142471424 142471501 Low_complexity 77 chr7 43653136 43653467 . 532 . 5.21809 7.52088 6.645 164 . -1 -1 . 0 chr18 54506158 54506566 . 532 . 3.46667 7.51759 6.64174 216 chr18 54506511 54506539 Simple_repeat 28 chr6 52466422 52466806 . 532 . 3.44185 7.51759 6.64177 193 chr6 52466236 52466423 SINE 1 chr5 131822311 131823025 . 532 . 3.49556 7.51759 6.64181 105 chr5 131821684 131822480 LINE 169 chr5 131822311 131823025 . 532 . 3.49556 7.51759 6.64181 105 chr5 131822480 131822547 Class_DNA 67 chr21 45175307 45176049 . 532 . 3.44632 7.51759 6.64184 399 chr21 45175309 45175369 LINE 60
το "2>&1" τι ακριβώς κάνει;;;Τελευταία επεξεργασία από το μέλος trotos : 29-01-12 στις 14:18. Αιτία: auto merged post
-
29-01-12, 14:38 Απάντηση: perl once more "the print on file" problem. #5
Σου είπα τι κάνει. Ανακατευθύνει το stderr (το "2") στο stdout (το "1").
NetBSD Rocks!
http://www.netbsd.org
-
30-01-12, 09:45 Απάντηση: perl once more "the print on file" problem. #6
Δες βρε αν η $test σου έχει αποτέλεσμα. Προσπάθησε να καταλάβεις που είναι το πρόβλημα. Αν η $test έχει όντως αποτέλεσμα και δεν είναι κενή, τότε το πρόβλημα μήπως είναι επειδή δεν κάνεις close το αρχείο και δεν το σώζεις;
Με γενικότητες "δε μου γράφει τίποτα"/"δεν κάνει τίποτα" δεν μπορούμε να σε βοηθήσουμε. Θέλουμε κώδικα να δούμε.
-
30-01-12, 11:27 Απάντηση: perl once more "the print on file" problem. #7
Αυτό που δε μπορώ να καταλάβω είναι ότι ενώ βλέπω το output της εντολής intersectBed στην οθόνη, δε μπορώ να βρω που και αν το γράφει πουθενά.
αυτός είναι ο κώδικας.
Κώδικας:#!/usr/bin/perl use File::Path; use warnings; use strict; my $path = $ENV{HOME}; my $desktop_path = "$path/Desktop"; my $PeakDir = "$desktop_path/BioProject"; my $RepeatDir = "$desktop_path/repeatfiles"; mkpath($PeakDir); my $test = "$desktop_path/test"; mkpath($test); #open peak file downloaded and saved to PeakDir folder, and read contents opendir (peakDir, "$PeakDir") || die "can't opendir $PeakDir: $!"; my @peakfiles = grep { ! /^\.{1,2}$/ } readdir (peakDir);#= readdir (peakDir); #open peak file downloaded and saved to PeakDir folder, and read contents opendir (repeatDir, "$RepeatDir") || die "can't opendir $RepeatDir: $!"; my @repeatfiles = grep { ! /^\.{1,2}$/ } readdir (repeatDir); opendir (testDir, "$test") || die "can't opendir $testDir: $!"; #only for mac os x my @deletefile = ("$PeakDir/\.DS_Store","$RepeatDir/\.DS_Store"); foreach my $filetodelete ( @deletefile ) { unlink $filetodelete or warn "Could not unlink $filetodelete: $!"; } #test of directories print "@peakfiles $!\n"; print "@repeatfiles $!\n"; #main program for (my $i = 0; $i <= scalar(@peakfiles)-1; $i++) { print "$i file in array is: $peakfiles[$i]\n"; for (my $j=0; $j<=scalar(@repeatfiles)-1;$j++) { print "$j file in array is: $repeatfiles[$j]\n"; #εδώ δε γράφει στο τεστ $test = `intersectBed -wao -a $PeakDir/$peakfiles[$i] -b $RepeatDir/$repeatfiles[$j]`; my @testfiles = grep { ! /^\.{1,2}$/ } readdir (testDir); open IN, ("$test");#"intersectBed -wao -a $PeakDir/$peakfiles[$i] -b $RepeatDir/$repeatfiles[$j] |"); my %mean_overlap=(); my %no=(); while (<IN>) { if (/(.+)\t(.+)\t(.+)\t(.+)\t(.+)\t(.+)\t(.+)\t(.+)\t(.+)\t(.+)\t(.+)\t(.+)\t(.+)\t(.+)\t(.+)/) { #a3iologish ba8mou epikalhpshs $overlap = (2*$15)/(($3-$2)+($13-$12)); $mean_overlap{$14} += $overlap; $no{$14}++; } } } } close OUT; close IN; closedir (peakDir);
-
30-01-12, 16:16 Απάντηση: perl once more "the print on file" problem. #8
όταν πάει να διαβάσει τα
[CODE]open IN, ("$test");
λέει ότι:
Unsuccessful open on filename containing newline at /Users/sunta3iouxos/Desktop/script line 43.
readline() on closed filehandle IN at /Users/sunta3iouxos/Desktop/script line 46.
-
31-01-12, 14:42 Απάντηση: perl once more "the print on file" problem. #9
Ναι, καλά στα λέει, γιατί χρησιμοποιείς με τελείως λάθος τρόπο τον filehandler. Κάτι σε τέτοιο θα σου έπαιζε καλύτερα:
Κώδικας:if (open(FH,">myoutfile")) { print FH $test; close FH; }
-
31-01-12, 15:38 Απάντηση: perl once more "the print on file" problem. #10
Ωχ... το if (open (....>...)) ή με >> πρέπει να το είχα ψηλιαστεί.
Το πρόβλημα είναι ότι ακόμα δε μπορώ να το κάνω να μου ΕΞΑΓΕΙ και τα αποτελέσματα του:
Κώδικας:$test = `intersectBed -wao -a $PeakDir/$peakfiles[$i] -b $RepeatDir/$repeatfiles[$j]`;
-
02-02-12, 18:54 Απάντηση: perl once more "the print on file" problem. #11
όταν δίνω με τον παραπάνω κώδικα να μου εξάγει τα αποτελέσματα (τα οποία είναι της μορφής που φαίνονται παραπάνω) μου δίνει το εξής μήνυμα:
Κώδικας:Argument "chr18^I58975469^I58981096^I.^I1000^I.^I8.10918^I225.9060..." isn't numeric in right bitshift (>>) at /Users/sunta3iouxos/Desktop/script line 43.
%test
@test
$test
είναι κάτι που δεν έχω καταλάβει;
πρέπει να ορίσω τον τύπο του output όπως στην C και αυτό πως το κάνω;
-
07-02-12, 17:52 Απάντηση: perl once more "the print on file" problem. #12
παίδες υπάρχει κάποια βοήθεια στο πως να μπορέσω να εξάγω σωστά το αποτέλεσμα (όπως φαίνεται στα προηγούμενα posts) σε αρχείο σε συγκεκριμένη θέση;
-
10-02-12, 01:25 Απάντηση: perl once more "the print on file" problem. #13
Αν δεν δώσεις το συγκεκριμένο κομμάτι που έχει το πρόβλημα δεν μπορούμε να κάνουμε και πολλά. Αυτό που καταλαβαίνω είναι ότι κάνεις binary shifting σε scalar που έχει κείμενο και όχι αριθμό όπως πολύ σωστά σου λέει.
Κανένα περίεργο redirect μήπως; Δεν παίζει το >> redirect στην perl για output. Αυτό είναι για shell.
Bookmarks