Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Provide a specific argument to a specific function from a series of functions from command line

$
0
0

@flalom wrote:

Hello everybody.

I would like to ask you: how to enter the argument(s) for only one specific function of the many ones I have in my script file from command line?

In more details: I am working on a training file, where I am writing many different functions, just to train myself…
In one of the function (which translates dna into proteins) I would like to provide from the command line the dna sequence as function argument directly or even provide the file text directly (but I haven’t worked with files yet.

here my function:

function translator_from_rna(rna_seq :: AbstractString)
    traslation = []
    table = Dict(
        "AUA"::"I", "AUC"::"I", "AUU"::"I", "AUG"::"M", 
        "ACA"::"U", "ACC"::"T", "ACG"::"T", "ACU"::"T", 
        "AAC"::"N", "AAU"::"N", "AAA"::"K", "AAG"::"K", 
        "AGC"::"S", "AGU"::"S", "AGA"::"R", "AGG"::"R",                  
        "CUA"::"L", "CUC"::"L", "CUG"::"L", "CUU"::"L", 
        "CCA"::"P", "CCC"::"P", "CCG"::"P", "CCU"::"P", 
        "CAC"::"H", "CAU"::"H", "CAA"::"Q", "CAG"::"Q", 
        "CGA"::"R", "CGC"::"R", "CGG"::"R", "CGU"::"R", 
        "GUA"::"V", "GUC"::"V", "GUG"::"V", "GUU"::"V", 
        "GCA"::"A", "GCC"::"A", "GCG"::"A", "GCU"::"A", 
        "GAC"::"D", "GAU"::"D", "GAA"::"E", "GAG"::"E", 
        "GGA"::"G", "GGC"::"G", "GGG"::"G", "GGU"::"G", 
        "UCA"::"S", "UCC"::"S", "UCG"::"S", "UCU"::"S", 
        "UUC"::"F", "UUU"::"F", "UUA"::"L", "UUG"::"L", 
        "UAC"::"Y", "UAU"::"Y", "UAA"::"_", "UAG"::"_", 
        "UGC"::"C", "UGU"::"C", "UGA"::"_", "UGG"::"W" )
    
    start_translation = findfirst("AUG", uppercase(rna_seq))[2]
    triplets = 2
    for (num, sequence) in enumerate(start_translation:length(rna_seq))
        if num % 3 == 0 && num < length(rna_seq)
            triplents = rna_seq[sequence:sequence + triplets]
            println(triplents)
            append!(traslation, table[triplents])
        end
    end
    return join(traslation, "")
end

translator_from_rna("UUUAUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGAUUCACAUGUAAA")

Thank you!

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles