0

I recently had to change from the Linux UI to Windows to run some of my analysis for my Science work.

I'm running a program called Blast on Linux and I use it to run multiple files at a time.

The command I use on Linux is this:

for f in *.log; do blastn -query $f -db dbname -out $f.out -outfmt 6 -evalue 0.000001 &done

Upon which, the program will take all the files with *.log, run the command, then create output files named *.out

However, I've 0 idea on how to convert that into a Powershell command.

I'm currently running it one by one but I have hundred of files.

This is the base command in Powershell.

blastn.exe -query .\filename_log -db ..\dbname -out filename.out -outfmt 6 -evalue 0.00001

I'm considering the following, but it's not working because I am still woefully not sure of how to make it do something. =____=

Get-ChildItem "C:\pathway\Genomes\" -Filter *.log | Foreach-Object { $content = Get-Content $_.FullName

$content | Where-Object {$_ -do blastn.exe -query .\filename_log -db ..\dbname -out filename.out -outfmt 6 -evalue 0.00001'} | Set-Content ($_.BaseName + '.out') }

If creating such a command is not possible, would it be possible to create a script for this?

3
  • Basically the same ls *.log | %{$_.Name} | %{blastn.exe -query $_ -db dbname -out $_.out -outfmt 6 -evalue 0.000001} Commented Jun 21, 2019 at 5:07
  • 1
    @LarrySong Using %_.out will look for a property in the object with the name out instead of appending it to the end of the $_ result Commented Jun 21, 2019 at 5:13
  • bruh u saved my life thank you so much <3 Commented Jun 21, 2019 at 5:23

1 Answer 1

0

Try this :

$FileList = Get-ChildItem "C:\\pathway\\Genomes\\"  -Filter "*.log" # GETTING THE LIST OF .LOG FILES

$FileList | %{ # FOR EACH LOOP ON ALL .LOG FILE

    blastn.exe -query .\filename_log -db ..\dbname -out filename.out -outfmt 6 -evalue 0.00001 | Set-Content $_.BaseName.out
    # YOUR COMMAND | SET-CONTENT FILENAME # TO SAVE COMMAND OUTPUT IN FILE
    # $_ IS FOR LOOP VARIABLE AND BASENAME IS FILENAME WITHOUT EXTENSION
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.