but fix your CRLF files before....
• 0 views
•
link
Dear all,
I have two files. File1.tsv:
CHROM POS REF ALT Allele Consequence IMPACT SYMBOL Gene
chrM 3338 G A A missense_variant MODERATE MT-ND1 ENSG00000198888
chrM 3395 T C C missense_variant MODERATE MT-ND1 ENSG00000198888
Files2.tsv:
CHROM POS REF ALT FILTER nHet nHomAlt nHomRef
chrM 3338 G A PASS 0 1 499
chrM 3395 T C PASS 1 2 497
My desired output is
chrM 3338 G A A missense_variant MODERATE MT-ND1 ENSG00000198888 chrM 3338 G A PASS 0 1 499
chrM 3395 T C C missense_variant MODERATE MT-ND1 ENSG00000198888 chrM 3395 T C PASS 1 2 497
I tired to do a simple paste, but when I do paste file1.txt files2.txt the columns of the second file start from the new line, when i do paste file2.txt file1.txt it works. I do not know the reason. Also I would like to take into considerazion the first 4 columns (CHROM, POS,REF,ALT), which should match.
create a composite key with awk , sort and use join. Something like (not tested)
join -t $'\t' -1 1 -2 1 \
<(awk '{printf("%s|%s|%s|%s\t%s\n",$1,$2,$3,$4,$0);}' in1.vcf | sort -t $'\t' -k1,1) \
<(awk '{printf("%s|%s|%s|%s\t%s\n",$1,$2,$3,$4,$0);}' in2.vcf | sort -t $'\t' -k1,1)
but fix your CRLF files before....
Log in to answer this question.
check your files are NOT windows files with CR/LF returns with
file your.vcfHow to fix this?
it's ok. there is no problem here.tr -d '\r' < bad.vcf > fixed.vcf
is it possible to integrate it directly in the command line without creating a new file? This does not work..
Try
dos2unixtool. It's present in most of distro repos.Note: tsv-join output looks like joined numbers at the end, but they are not. The numbers are tab separated.