Skip to content

Instantly share code, notes, and snippets.

@nievergeltlab
Created November 29, 2018 21:45
Show Gist options
  • Select an option

  • Save nievergeltlab/743070c4ab37f59c824005e7333fd40b to your computer and use it in GitHub Desktop.

Select an option

Save nievergeltlab/743070c4ab37f59c824005e7333fd40b to your computer and use it in GitHub Desktop.
##Part 1: If final report is not split into 1 subject per file, this will split it up. Otherwise don't run this part!
#User: List name of final report file here
final_report=Akesogen_Cohen_FC_CNV_V.1_FinalReport.txt
#Creates a header
head -n10 $final_report > header.txt
#Column $1 is the default here, but the number should correspond to whatever number the subjects are named in
awk 'NR>10{print >$1}' $final_report
for file in $(ls | grep -v $final_report | grep -v header.txt | grep -v temp)
do
echo $file
cat header.txt $file > temp && mv temp $file
done
## Part 2:
#Get sample name from the final report text file
#Column $1 is the default here, but the number should correspond to whatever number the subjects are named in
for files in $(ls | grep -v $final_report | grep -v header.txt | grep -v temp)
do
samplename=$(awk 'NR==12{print $1}' $files)
echo $files $samplename >> sample_ids.txt
samplename=""
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment