Re^4: Listing of files using glob
by tobyink (Canon) on Jan 05, 2012 at 09:27 UTC
|
I can't speak for AG87, but on Linux it's pretty easy to create a file with a pipe symbol in it.
touch 'foo|bar' && ls -l foo* && rm -i 'foo|bar'
If I recall correctly, the only character disallowed in Linux filenames is the slash. | [reply] |
|
|
| [reply] [d/l] [select] |
|
|
There are many characters, though, that you can use in file names, but you never should :-)
| [reply] |
Re^4: Listing of files using glob
by AG87 (Acolyte) on Jan 05, 2012 at 10:25 UTC
|
I am working on linux and it has no issues in creating a filename with "|" sign in it. I have figured out the problem. In actual the file created in sub createFoldersAndFiles automatically inserts a space before the extension .fasta due to which the complete file name is not being grabbed by glob. Can anyone suggest how to overcome this problem coz its very strange. Normally the FILEOUT handle does not add a space before extension. Any thoughts??? :(
| [reply] |
|
|
The handle does not create the filename. Your program does.
open(FILEOUT, ">$dir/$nameWithoutFastaSign/$nameWithoutFastaSign.fasta
+");
Remove the space from $nameWithoutFastaSign. | [reply] [d/l] |
Re^4: Listing of files using glob
by AG87 (Acolyte) on Jan 05, 2012 at 11:02 UTC
|
I cant see any space though
Even the code (part of the previous complete code) below does not print the complete filename. It only prints the extension
$nameWithoutFastaSign =~ tr/>//d;
print "$nameWithoutFastaSign.fasta\n";
Any more thoughts?? :( | [reply] [d/l] |
|
|
What is in $nameWithoutFastaSign before tr?
| [reply] [d/l] |
Re^4: Listing of files using glob
by AG87 (Acolyte) on Jan 05, 2012 at 11:14 UTC
|
| [reply] |
|
|
perl -e '$nameWithoutFastaSign = ">1elwA";
print "before: $nameWithoutFastaSign\n";
$nameWithoutFastaSign =~ tr/>//d;
print "after: $nameWithoutFastaSign\n";'
Output:before: >1elwA
after: 1elwA
| [reply] [d/l] [select] |
Re^4: Listing of files using glob
by AG87 (Acolyte) on Jan 05, 2012 at 11:46 UTC
|
A separate code does work for me as well. But in the full fledge code its not working. The file names ">1elwA" etc etc are stored in a hash as a key. In a loop it has to retrieve the key value, tr it, and then print the output with .fasta extension. In the embedded code it is not printing the complete file name. Maybe there is some problem in storing the file in hash. Is there some other way to capture the output of the regular expression into the key of the hash other than the way used in my code in the first sub with the name of "StoreInHash"????
| [reply] |
|
|
Are you chomping lines when storing names into the hash?
| [reply] |
|
|
open(FILE, "$path_to_fastaSeqs") or die("cannot open file");
{
while(<FILE>)
{
my $line = $_;
if ($line =~ />.*/)
{
#print "$&\n";
}
else
{
#print "$line\n";
}
$seqInfo{$&} = $line;
}
close(FILE);
}
Any errors or wrong approach?? | [reply] [d/l] |
|
|
|
|
|
|
|
|
|
Please, be careful to what post you are replying to.
| [reply] |
|
|
| [reply] |