How to convert vcf file to ped file using plink? - bioinformatics

I am trying to convert a .vcf file to a .ped file using plink. I have read some manuals and posts online, but it seems that no one specifically mentions how to convert vcf to ped.
I am hoping that there may be some experts here who have experience with plink to convert vcf to ped. I would appreciate it if you could share the knowledge. Moreover, if there is another way (non-plink) of doing that, please do share it.
Thank you!

Plink provides its own functionality for converting vcf (and other format) files to plink-compatible ones. The command you're looking for is recode and the actual command would look like this:
plink --vcf myfile.vcf.gz --recode --out myfile

I convert my vcf files to PLINK formats (ped, fam, map) using VCFtools:
https://vcftools.github.io/man_latest.html
My commands look like this:
vcftools --vcf my_data.vcf --out my_data --plink

Related

Building useable program in Terminal/Applescript for extracting XLSX to CSV

I'm looking for a way to automate XLSX to CSV conversion. Ideally, I would also like to add column names that are not yet in the XLSX.
For now, I'm using CSVkit/In2CSV. This works, but I still have to enter the name of the file manually. In terminal, I now do this:
in2csv /Users/file.xslx -f xlsx -I > file.csv
I would like to be able to automate this, so that when I open the script, it asks me for the location of the file (or I just drag the file to the script), and then it automatically converts. I have looked into AppleScript, but can't really seem to figure it out, must probably be very easy. How can I automate this? I'm on a Mac.

Piping an image retrieved using curl to sips to change format without saving intermediate file

I have url links to image files I want to retrieve from the internet.
I can download the files using curl without issue using:
curl "https://...web address..." > myfileName;
The image files are of various types, some .bmp some .jpg etc. I have been using sip in Terminal on Mac osx to convert each to .png files using:
sips -s format png downloadFileName --out newFileName.png
This works well on files I've saved as downloadedFileName regardless of the starting file type.
As I have many files to process I wanted to pipe the output of the curl download directly into sips, without saving an intermediate file.
I tried the following (which combines my two working steps without the intermediate file name):
curl "https://...web address..." | sips -s format png --out fileName.png
And get a no file error: Error 4: no file was specified.
I've searched the sip man pages but cannot find a reference for piped input and have been unable to find a useful answer searching SO or google.
Is there a way to process an image downloaded using curl directly in sips without first saving the file?
I do not necessarily need the solution to use a pipe, or even be on one line. I have a script that will cycle through a few thousand urls and simply want to avoid saving lots of files that will be deleted a line later.
I should add, I do not necessarily need to use sips either. However, any solution must be able to handle image files of unknown type (which sips does admirably) as no file extension is present on the files.
Thanks
I don't have sips installed but its
manpage indicates that it cannot read
from stdin. However, if you use Bash or ZSH (MacOS default now) you
can use process substitution, in this example I use convert which is
a part of ImageMagick and can convert different image types too:
$ convert <(curl -s https://i.kym-cdn.com/entries/icons/mobile/000/018/012/this_is_fine.jpg) this_is_fine.png
$ file this_is_fine.png
this_is_fine.png: PNG image data, 800 x 450, 8-bit/color RGB, non-interlaced
After doing that this_is_fine.png will be the only file in the
directory with no temporary files
Apparently sips only reads regular files which makes it impossible to use /dev/stdin or named pipes.
However, it is possible using the mature and feature-rich convert command:
$ curl -sL https://picsum.photos/200.jpg | convert - newFilename.png
$ file newFilename.png
newFilename.png: PNG image data, 200 x 200, 8-bit/color RGB, non-interlaced
(First install ImageMagick via brewinstall imagemagick or sudoportinstall ImageMagick.)
ImageMagick permits image data to be read and written from the standard streams STDIN (standard in) and STDOUT (standard out), respectively, using a pseudo-filename of -.
source, section STDIN, STDOUT, and file descriptors

OSX terminal script - Try to open all files in directory

I have some video files in a directory which can't be opened. The problem is that some of them have been wrongly transcoded, so they can't be opened with QuickTime.
What I was wondering is if there is some kind of script I could write that would read through all the files in a directory and try to open them with QuickTime, and if they can't be opened, to move them or do something else.
My actual file directory would be something like this:
--Main folder
---Subfolder
-----video.mov
-----video.mov
------Sub-Subfolder
--------video.mov
--------video.mov
---Subfolder
-----video.mov
-----video.mov
------Sub-Subfolder
--------video.mov
(...) and so on
I hope I've explained it well so you can understand it... If someone could help me, I'd appreciate it so much.
Thanks!
The looping part is pretty easy, and should look like this :
for x in `find <folder> -name "*.mov"`; do <validate movie file command>; done
For the validate file command there's a suitable option in ffmpeg utility which is basically a video converter, but you can convert the input video to NULL and just read input file and report any errors that will appear.
ffmpeg -v error -i ${x} -f null - 2>error.log

Download file with different local name using wget

Hi i have a text file where download links are given like -
http://www.example.com/10.10.11/abc.jpg
http://www.example.com/10.10.12/abc.jpg
http://www.example.com/10.10.13/abc.jpg
Here 10.10.* is the date of the image.
I need to download all the images using wget where the image name will be the corresponding date (eg. 10.10.111.jpg).
PS. I tried using:
wget -i download.txt
So, any solution?
Thanks in advance
You can instruct Wget to create subdirectories based on the URL, and then do the renaming after the download has finished.
I'd suggest a batch script that downloads the files one by one using the -O option, and a bit of sed/awk magic to get the names right
But careful! given the -O option, you have to call wget on a per file basis
This should do the trick.
#!/bin/sh
while read url; do
urldir=${url%/*}
dir=${urldir##*/}
wget -O $dir.jpg $url
done < download.txt
This might work for you:
sed '\|/\([^/]*\)/[^/]*\1[^/.]*.jpg|!d' download.txt | wget -i -
Explanation:
Filter the download.txt file to contain only those files which you require and then pass them on to wget.
I have developed a script that does just this bulkGetter. Super easy to use, you just need an input file with all the links you want to download and use option "-rb" (refer to link).

PVRTexTool, is there a way to run it on multiple files at once?

I am using PVRTexTool to convert png files to pvr files but the tool seems to only be able to run on one file at a time(wont accept *.png as file name).
does anyone know how to run it on a group of files at once?
Its really a hassle to run it on all of my textures.
In a shell, run
for file in *.png ; do
PVRTexToll $file
done
(I don't know how to call PVRTeXTool from a command line, so please substitute the second line with a correct version)
This is a general way to feed each file to a command which only accepts one file at a time. See any introduction on shell scripting, e.g. this discussion of the for loop.

Resources