Dear Biostars,
my aim is to rename sample_name of g.vcf files (generated after gatk haplotype-caller containig varints for each individual for each g.vcffile)
but my script breaks with error Segmentation fault (core dumped)
Question: any suggestions how i could resolves this?
g.vcfs files are saved in directory /sc/hydra/projects/canan/colon_cancer10312019/joint_calling_colon/gvcfs/renamed_sm_gvcfs/
g.vcfs are saved as this CC_0001.hg38.g.vcf.gz CC_0002.hg38.g.vcf.gz CC_0003.hg38.g.vcf.gz ....... CC_nnnn.hg38.g.vcf.gz
gvcfs="/sc/hydra/projects/canan/colon_cancer10312019/joint_calling_colon/gvcfs/renamed_sm_gvcfs/*.hg38.g.vcf.gz"
gvcfsSampleNames="/sc/hydra/projects/canan/colon_cancer10312019/joint_calling_colon/gvcfs/renamed_sm_gvcfs/sampleNames_dir/*.txt"
for i in $gvcfs
do
sampleName=`basename -s .hg38.g.vcf.gz $i` ###grab basename of gvcf to use for replacement
echo "$sampleName" > sampleNames_dir/$sampleName.txt ###same basename/name in a file to set as input for bcftools reheader --samples
for j in $gvcfsSampleNames; do
bcftools reheader --samples $j -o renamed_gvcfs2/renamed_SM.$i $i
done
done
error logs
Segmentation fault (core dumped)
Segmentation fault (core dumped)
Segmentation fault (core dumped)
Segmentation fault (core dumped)
Segmentation fault (core dumped)
renamed_gvcfs2/renamed_SM./sc/hydra/projects/canan/colon_cancer10312019/joint_calling_colon/gvcfs/renamed_sm_gvcfs/NEW_samples_CC10008_Germline_edited.hg38.g.vcf.gz: No such file or directory
renamed_gvcfs2/renamed_SM./sc/hydra/projects/canan/colon_cancer10312019/joint_calling_colon/gvcfs/renamed_sm_gvcfs/NEW_samples_CC10008_Germline_edited.hg38.g.vcf.gz: No such file or directory
renamed_gvcfs2/renamed_SM./sc/hydra/projects/canan/colon_cancer10312019/joint_calling_colon/gvcfs/renamed_sm_gvcfs/NEW_samples_CC10008_Germline_edited.hg38.g.vcf.gz: No such file or directory
renamed_gvcfs2/renamed_SM./sc/hydra/projects/canan/colon_cancer10312019/joint_calling_colon/gvcfs/renamed_sm_gvcfs/NEW_samples_CC10008_Germline_edited.hg38.g.vcf.gz: No such file or directory
renamed_gvcfs2/renamed_SM./sc/hydra/projects/canan/colon_cancer10312019/joint_calling_colon/gvcfs/renamed_sm_gvcfs/NEW_samples_CC10008_Germline_edited.hg38.g.vcf.gz: No such file or directory
Segmentation fault (core dumped)
Segmentation fault (core dumped)
Segmentation fault (core dumped)
Segmentation fault (core dumped)
Segmentation fault (core dumped)
renamed_gvcfs2/renamed_SM./sc/hydra/projects/canan/colon_cancer10312019/joint_calling_colon/gvcfs/renamed_sm_gvcfs/NEW_SM3_CC10008_Germline_edited.hg38.g.vcf.gz: No such file or directory
renamed_gvcfs2/renamed_SM./sc/hydra/projects/canan/colon_cancer10312019/joint_calling_colon/gvcfs/renamed_sm_gvcfs/NEW_SM3_CC10008_Germline_edited.hg38.g.vcf.gz: No such file or directory
renamed_gvcfs2/renamed_SM./sc/hydra/projects/canan/colon_cancer10312019/joint_calling_colon/gvcfs/renamed_sm_gvcfs/NEW_SM3_CC10008_Germline_edited.hg38.g.vcf.gz: No such file or directory
renamed_gvcfs2/renamed_SM./sc/hydra/projects/canan/colon_cancer10312019/joint_calling_colon/gvcfs/renamed_sm_gvcfs/NEW_SM3_CC10008_Germline_edited.hg38.g.vcf.gz: No such file or directory
renamed_gvcfs2/renamed_SM./sc/hydra/projects/canan/colon_cancer10312019/joint_calling_colon/gvcfs/renamed_sm_gvcfs/NEW_SM3_CC10008_Germline_edited.hg38.g.vcf.gz: No such file or directory
Segmentation fault (core dumped)
Segmentation fault (core dumped)
Segmentation fault (core dumped)
Segmentation fault (core dumped)
Segmentation fault (core dumped)
1 answer
ouch! I forget to post my solution!
just in case someone else encounters similar solution.
bcftools reheader --samples requires a file with sample names so I specified correctly file in local directory by inserting quotes "${sampleName}.txt" to make it work.
thanks everyone for the support
S
####implement the real codes for entire 41 WES T/N samples; script written in Bourne Again Shell (bash)
gvcfs="/sc/hydra/projects/canan/colon_cancer10312019/joint_calling_colon/gvcfs/*.hg38.g.vcf.gz"
NamePrefix="CC_renamed_" ##addd this prefix to all newly created gvcf files
for i in $gvcfs
do
sampleName=`basename -s .hg38.g.vcf.gz $i` ###grab basename of gvcf to be use as sample_name (SM) in gvcf file
Outgvcf_file=`basename $i` ###prepare desired output gvcf file name
#newName=$sampleName.txt
echo "$sampleName" > ${sampleName}.txt ###save sample name as a txt file for use bcftools reheader command
bcftools reheader --samples "${sampleName}.txt" -o "$NamePrefix${Outgvcf_file}" $i ###this bcf rename command to execute
echo "completd $i" ###tell you are done
done
gvcfs_files_to_index="/sc/hydra/projects/canan/colon_cancer10312019/joint_calling_colon/gvcfs/renamed_SM_gvcfs_colon/*.hg38.g.vcf.gz"
for i in $gvcfs_files_to_index;
do
bcftools index -t $i
done
Log in to answer this question.
How many files do you have? You may be running out of file descriptors on your system (i.e. too many files opened)
@Jean-Karim Heriche, I have only 41 g.vf files
I tried this second approach but results are printed to the screen; I'm not really sure what I'm doing wrong?
What is this coded in? Bash? If you want the sample names to be in a file, you probably need to use the --samples-file option of bcftools, the --samples option takes a comma-separated list of names, in the later case, you could just do --samples $sampleName