Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
30
Task/FASTA-format/Kotlin/fasta-format.kotlin
Normal file
30
Task/FASTA-format/Kotlin/fasta-format.kotlin
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// version 1.1.2
|
||||
|
||||
import java.util.Scanner
|
||||
import java.io.File
|
||||
|
||||
fun checkNoSpaces(s: String) = ' ' !in s && '\t' !in s
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
var first = true
|
||||
val sc = Scanner(File("input.fasta"))
|
||||
while (sc.hasNextLine()) {
|
||||
val line = sc.nextLine()
|
||||
if (line[0] == '>') {
|
||||
if (!first) println()
|
||||
print("${line.substring(1)}: ")
|
||||
if (first) first = false
|
||||
}
|
||||
else if (first) {
|
||||
println("Error : File does not begin with '>'")
|
||||
break
|
||||
}
|
||||
else if (checkNoSpaces(line))
|
||||
print(line)
|
||||
else {
|
||||
println("\nError : Sequence contains space(s)")
|
||||
break
|
||||
}
|
||||
}
|
||||
sc.close()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue