Skip to content

Commit 67bb4ea

Browse files
Fix sorting with header row; Solution is to use a subshell to combine the
outputs of a head and tail | sort
1 parent a7a5400 commit 67bb4ea

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/FitHiC_SigInt.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,7 @@ if (0) {
17481748
}
17491749

17501750
# now sort the file contents and write that in the final specified output file
1751-
system(paste('sort -k1,1 -k2,2n -k5,5n', paste0('-k',opt$cccol,',',opt$cccol,'nr'), temp_outfile, '>', opt$OutFile))
1751+
system(paste('(head -n 1', temp_outfile, '&& tail -n +2', temp_outfile '| sort -k1,1 -k2,2n -k5,5n', paste0('-k',opt$cccol,',',opt$cccol,'nr'), ')>', opt$OutFile))
17521752

17531753
} # end dummy if
17541754

@@ -1772,7 +1772,7 @@ if (1) {
17721772
system(paste("rm", temp_outfile_2))
17731773

17741774
# now sort the file contents and write that in the final specified output file
1775-
system(paste('sort -k1,1 -k2,2n -k5,5n', paste0('-k',opt$cccol,',',opt$cccol,'nr'), temp_outfile, '>', opt$OutFile))
1775+
system(paste('(head -n 1', temp_outfile, '&& tail -n +2', temp_outfile '| sort -k1,1 -k2,2n -k5,5n', paste0('-k',opt$cccol,',',opt$cccol,'nr'), ')>', opt$OutFile))
17761776

17771777
} # end dummy if
17781778

0 commit comments

Comments
 (0)