infile = "C:\\Users\\Dave\\Desktop\\b122803.txt"
outfile = "C:\\Users\\Dave\\Desktop\\b122803.png"
seqname = "b122803"

x = read.table(infile)
  
# Remove infinite values
lgl = is.finite(x[,2])
x = cbind(x[,1][lgl], x[,2][lgl])

png(file=outfile, width=600, height=800)
par(mar=c(5,5,2,2)+0.1, mfcol=c(2,1))

k = min(200, nrow(x))
xsub = x[1:k,]
plot (xsub, 
  ylim = c(min(0, min(xsub[,2])), max(xsub[,2])),
  xlab = "n",
  ylab=paste(seqname, "(n)", sep=""),
  bty="l",
  type="n",
  main = paste("Pin plot of", seqname))
segments(xsub[,1], rep(0, k), xsub[,1], xsub[,2])

# Log the data for the scatterplot?

logplot = T
tval = 100.
if (nrow(x) > 10) {
  fv = fivenum(abs(x[,2]))
  if (all(is.finite(fv))) {
    if (((fv[5]-fv[4]) / (fv[2]-fv[1]+1)) < tval) {
      logplot = F
    }
  }
}

ln10 = log(10)
if (logplot) {
  v = x[,2]
  plot(x[,1], asinh((v/2)/ln10), pch="+", cex=.5,
    xlab = "n",
    ylab=paste("qlog(", seqname, "(n))", sep=""),
    main=paste("Scatterplot of qlog(", seqname, "(n))", sep=""),
    bty="l")
} else {
  plot(x, pch="+", cex=.5,
    xlab = "n", 
    ylab = paste(seqname, "(n)", sep=""),
    main = paste("Scatterplot of ", seqname, "(n)", sep=""),
    bty="l")
}

dev.off()