Advertisement
Guest User

Imperative way of splitting paired-end FASTA in Scala

a guest
Jun 5th, 2012
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.50 KB | None | 0 0
  1. import java.io.PrintWriter
  2. import java.io.File
  3.  
  4. val fileName = args(0)
  5. val p1 = new PrintWriter(new File(fileName + ".1"))
  6. val p2 = new PrintWriter(new File(fileName + ".2"))
  7. var count = 0
  8.  
  9. for (l <- io.Source.fromFile(fileName).getLines) {
  10.     if (l startsWith ">") count = count + 1
  11.     count % 2 match {
  12.         case 1 => p1 print (l + "\n")
  13.         case 0 => p2 print (l + "\n")
  14.     }
  15. }; p1.close; p2.close
  16. println("Done bro!")
  17. println("Seems to work fine, but concise imperative code is still imperative code :(")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement